bdev_nvme: add support for write_zeroes
In this iteration, we only support write_zeroes in the form of a deallocate call that returns all zeroes. Change-Id: Ica837ce70672174df63012719de60463fdb799cf Signed-off-by: Seth Howell <seth.howell@intel.com> Reviewed-on: https://review.gerrithub.io/372005 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
670dc20f63
commit
c9dc522ba9
@ -376,6 +376,13 @@ _bdev_nvme_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_
|
|||||||
bdev_io->u.write.len,
|
bdev_io->u.write.len,
|
||||||
bdev_io->u.write.offset);
|
bdev_io->u.write.offset);
|
||||||
|
|
||||||
|
case SPDK_BDEV_IO_TYPE_WRITE_ZEROES:
|
||||||
|
return bdev_nvme_unmap((struct nvme_bdev *)bdev_io->bdev->ctxt,
|
||||||
|
ch,
|
||||||
|
(struct nvme_bdev_io *)bdev_io->driver_ctx,
|
||||||
|
bdev_io->u.write.len,
|
||||||
|
bdev_io->u.write.offset);
|
||||||
|
|
||||||
case SPDK_BDEV_IO_TYPE_UNMAP:
|
case SPDK_BDEV_IO_TYPE_UNMAP:
|
||||||
return bdev_nvme_unmap((struct nvme_bdev *)bdev_io->bdev->ctxt,
|
return bdev_nvme_unmap((struct nvme_bdev *)bdev_io->bdev->ctxt,
|
||||||
ch,
|
ch,
|
||||||
@ -442,6 +449,23 @@ bdev_nvme_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
|||||||
cdata = spdk_nvme_ctrlr_get_data(nbdev->nvme_ctrlr->ctrlr);
|
cdata = spdk_nvme_ctrlr_get_data(nbdev->nvme_ctrlr->ctrlr);
|
||||||
return cdata->oncs.dsm;
|
return cdata->oncs.dsm;
|
||||||
|
|
||||||
|
case SPDK_BDEV_IO_TYPE_WRITE_ZEROES:
|
||||||
|
cdata = spdk_nvme_ctrlr_get_data(nbdev->nvme_ctrlr->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(nbdev->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.
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user