bdev/nvme: do not use DSM to emulate write zeroes

We cannot rely on DSM/DEALLOCATE as a write zeroes
alternative, even if DLFEAT reports that deallocated
blocks will be read as all zeroes.  DEALLOCATE is
advisory, meaning that blocks may not actually be
deallocated.  In cases where they are not deallocated,
they will not be read back later as zeroes.

QEMU 6.0 started reporting DLFEAT as returning zeroes
for deallocated blocks but for some of our write
zeroes tests, blocks aren't actually deallocated.

We may be able to add quirks in the future if we know
that a controller reliably deallocates blocks, but
for now we need to revert this completely.

Note that since bdev/nvme module now does not support
write zeroes in any cases, we need to disable the
write zeroes call in the unit tests.

Fixes issue #1932.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7723 (master)

(cherry picked from 3faf457f568666aa19f2cec43904822bea603298
with minor modifications)

Change-Id: I79f0673774b621a9ffcc46891728cc7719e34cdb
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8879
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Jim Harris 2021-05-03 16:39:05 +00:00 committed by Tomasz Zawadzki
parent d28343f894
commit 9b420e8c00

View File

@ -727,13 +727,6 @@ _bdev_nvme_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_
bdev_io->u.bdev.offset_blocks,
bdev->dif_check_flags);
case SPDK_BDEV_IO_TYPE_WRITE_ZEROES:
return bdev_nvme_unmap(nvme_ns->ns,
qpair,
nbdev_io,
bdev_io->u.bdev.offset_blocks,
bdev_io->u.bdev.num_blocks);
case SPDK_BDEV_IO_TYPE_UNMAP:
return bdev_nvme_unmap(nvme_ns->ns,
qpair,
@ -837,20 +830,11 @@ bdev_nvme_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
return cdata->oncs.dsm;
case SPDK_BDEV_IO_TYPE_WRITE_ZEROES:
cdata = spdk_nvme_ctrlr_get_data(ctrlr);
/*
* If an NVMe controller guarantees reading unallocated blocks returns zero,
* we can implement WRITE_ZEROES as an NVMe deallocate command.
*/
if (cdata->oncs.dsm &&
spdk_nvme_ns_get_dealloc_logical_block_read_value(ns) ==
SPDK_NVME_DEALLOC_READ_00) {
return true;
}
/*
* The NVMe controller write_zeroes function is currently not used by our driver.
* If a user submits an arbitrarily large write_zeroes request to the controller, the request will fail.
* Until this is resolved, we only claim support for write_zeroes if deallocated blocks return 0's when read.
* NVMe write zeroes is limited to 16-bit block count, and the bdev layer currently
* has no mechanism for reporting a max write zeroes block count, nor ability to
* split a write zeroes request.
*/
return false;