lib/nvme: add a quirk for read zero after unmap

Unmapped blocks on some older nvme devices will read zero even if the
device does not explicitly define the unmap behavior.

Change-Id: Ia825a406cbd01f89192c300cfe35013fb4aed715
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/372006
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Seth Howell 2017-07-31 12:56:30 -07:00 committed by Daniel Verkamp
parent 610374cd49
commit 5e79d6b8c6
3 changed files with 16 additions and 2 deletions

View File

@ -84,6 +84,13 @@
*/
#define NVME_QUIRK_DELAY_AFTER_QUEUE_ALLOC 0x10
/*
* Earlier NVMe devices do not indicate whether unmapped blocks
* will read all zeroes or not. This define indicates that the
* device does in fact read all zeroes after an unmap event
*/
#define NVME_QUIRK_READ_ZERO_AFTER_DEALLOCATE 0x20
#define NVME_MAX_ASYNC_EVENTS (8)
#define NVME_MIN_TIMEOUT_PERIOD (5)

View File

@ -188,8 +188,14 @@ spdk_nvme_ns_get_data(struct spdk_nvme_ns *ns)
enum spdk_nvme_dealloc_logical_block_read_value spdk_nvme_ns_get_dealloc_logical_block_read_value(
struct spdk_nvme_ns *ns)
{
struct spdk_nvme_ctrlr *ctrlr = ns->ctrlr;
const struct spdk_nvme_ns_data *data = spdk_nvme_ns_get_data(ns);
return data->dlfeat.bits.read_value;
if (ctrlr->quirks & NVME_QUIRK_READ_ZERO_AFTER_DEALLOCATE) {
return SPDK_NVME_DEALLOC_READ_00;
} else {
return data->dlfeat.bits.read_value;
}
}
int nvme_ns_construct(struct spdk_nvme_ns *ns, uint16_t id,

View File

@ -42,7 +42,8 @@ static const struct nvme_quirk nvme_quirks[] = {
{ {SPDK_PCI_VID_INTEL, 0x0953, SPDK_PCI_ANY_ID, SPDK_PCI_ANY_ID},
NVME_INTEL_QUIRK_READ_LATENCY |
NVME_INTEL_QUIRK_WRITE_LATENCY |
NVME_INTEL_QUIRK_STRIPING
NVME_INTEL_QUIRK_STRIPING |
NVME_QUIRK_READ_ZERO_AFTER_DEALLOCATE
},
{ {SPDK_PCI_VID_INTEL, 0x0A53, SPDK_PCI_ANY_ID, SPDK_PCI_ANY_ID},
NVME_INTEL_QUIRK_STRIPING