Commit 73f18e89 authored by Yalong Wang's avatar Yalong Wang Committed by Konrad Sztyber
Browse files

lib/reduce: fix the magic number of empty mapping detection.



In debug mode, when the backing dev capacity is greater than 16TB, the value of io_unit_index is likely to be UINT32_MAX. Similarly, when the capacity is greater than 64TB, the value of chunk_map_index may be UINT32_MAX.
These above situations may cause coredump to be triggered incorrectly.

Change-Id: I9d89102531daebd779b3f0eb6386f478bfcaa80b
Signed-off-by: default avatarYalong Wang <yalong9@staff.sina.com.cn>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25427


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarGangCao <gang.cao@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
parent 02935561
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1389,7 +1389,7 @@ _reduce_vol_write_chunk(struct spdk_reduce_vol_request *req, reduce_request_fn n
	/* TODO: fail if no chunk map found - but really this should not happen if we
	 * size the number of requests similarly to number of extra chunk maps
	 */
	assert(req->chunk_map_index != UINT32_MAX);
	assert(req->chunk_map_index != REDUCE_EMPTY_MAP_ENTRY);
	spdk_bit_array_set(vol->allocated_chunk_maps, req->chunk_map_index);

	req->chunk = _reduce_vol_get_chunk_map(vol, req->chunk_map_index);
@@ -1439,7 +1439,7 @@ _reduce_vol_write_chunk(struct spdk_reduce_vol_request *req, reduce_request_fn n
		/* TODO: fail if no backing block found - but really this should also not
		 * happen (see comment above).
		 */
		assert(req->chunk->io_unit_index[i] != UINT32_MAX);
		assert(req->chunk->io_unit_index[i] != REDUCE_EMPTY_MAP_ENTRY);
		spdk_bit_array_set(vol->allocated_backing_io_units, req->chunk->io_unit_index[i]);
		vol->info.allocated_io_units++;
	}
@@ -1793,7 +1793,7 @@ _reduce_vol_read_chunk(struct spdk_reduce_vol_request *req, reduce_request_fn ne
	struct spdk_reduce_vol *vol = req->vol;

	req->chunk_map_index = vol->pm_logical_map[req->logical_map_index];
	assert(req->chunk_map_index != UINT32_MAX);
	assert(req->chunk_map_index != REDUCE_EMPTY_MAP_ENTRY);

	req->chunk = _reduce_vol_get_chunk_map(vol, req->chunk_map_index);
	req->num_io_units = spdk_divide_round_up(req->chunk->compressed_size,