During spdk_bs_init() data present on the device can be cleared
depending on the clear_method used.
Picking BS_CLEAR_WITH_UNMAP results in deallocate command sent
when NVMe device is used.
The size of logical blocks do not have to match the indirection unit
size (IU) of the device. The SSDs can only unmap full physical blocks.
Since the deallocate command is advisory, the controller can complete
the command without deallocating any blocks.
In practice this results in some controllers not deallocating any blocks
if number of logical blocks is not aligned to the IU size.
Make sure that spdk_bs_init() handles this case.
The size of the unmap is now chunked at UINT32_MAX - 127,
which is an even multiple of 512B blocks with a 64KiB IU.
This is already addressed with an API change in SPDK 21.10:
(f01146ae)blob: use uint64_t for unmap and write_zeroes lba count
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ie00bd5ae7cdaec4f1486f16fceb6cb18e30bf563
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9970
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>