aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2015-02-19 15:39:03 -0500
committerKeith Busch <keith.busch@intel.com>2015-02-19 18:15:35 -0500
commite1e5e5641e6f271321aec257ed26a72715e4a8c2 (patch)
tree8dc9aecb4a660826ac8c8d223719c963ca283948 /include
parent89d3fa45b4add00cd0056361a2498e978cb1e119 (diff)
NVMe: Metadata format support
Adds support for NVMe metadata formats and exposes block devices for all namespaces regardless of their format. Namespace formats that are unusable will have disk capacity set to 0, but a handle to the block device is created to simplify device management. A namespace is not usable when the format requires host interleave block and metadata in single buffer, has no provisioned storage, or has better data but failed to register with blk integrity. The namespace has to be scanned in two phases to support separate metadata formats. The first establishes the sector size and capacity prior to invoking add_disk. If metadata is required, the capacity will be temporarilly set to 0 until it can be revalidated and registered with the integrity extenstions after add_disk completes. The driver relies on the integrity extensions to provide the metadata buffer. NVMe requires this be a single physically contiguous region, so only one integrity segment is allowed per command. If the metadata is used for T10 PI, the driver provides mappings to save and restore the reftag physical block translation. The driver provides no-op functions for generate and verify if metadata is not used for protection information. This way the setup is always provided by the block layer. If a request does not supply a required metadata buffer, the command is failed with bad address. This could only happen if a user manually disables verify/generate on such a disk. The only exception to where this is okay is if the controller is capable of stripping/generating the metadata, which is possible on some types of formats. The metadata scatter gather list now occupies the spot in the nvme_iod that used to be used to link retryable IOD's, but we don't do that anymore, so the field was unused. Signed-off-by: Keith Busch <keith.busch@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/nvme.h2
-rw-r--r--include/uapi/linux/nvme.h16
2 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 19a5d4b23209..cca264db2478 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -121,6 +121,7 @@ struct nvme_ns {
121 unsigned ns_id; 121 unsigned ns_id;
122 int lba_shift; 122 int lba_shift;
123 int ms; 123 int ms;
124 int pi_type;
124 u64 mode_select_num_blocks; 125 u64 mode_select_num_blocks;
125 u32 mode_select_block_len; 126 u32 mode_select_block_len;
126}; 127};
@@ -138,6 +139,7 @@ struct nvme_iod {
138 int nents; /* Used in scatterlist */ 139 int nents; /* Used in scatterlist */
139 int length; /* Of data, in bytes */ 140 int length; /* Of data, in bytes */
140 dma_addr_t first_dma; 141 dma_addr_t first_dma;
142 struct scatterlist meta_sg[1]; /* metadata requires single contiguous buffer */
141 struct scatterlist sg[0]; 143 struct scatterlist sg[0];
142}; 144};
143 145
diff --git a/include/uapi/linux/nvme.h b/include/uapi/linux/nvme.h
index 26386cf3db44..406bfc95652c 100644
--- a/include/uapi/linux/nvme.h
+++ b/include/uapi/linux/nvme.h
@@ -124,10 +124,22 @@ struct nvme_id_ns {
124 124
125enum { 125enum {
126 NVME_NS_FEAT_THIN = 1 << 0, 126 NVME_NS_FEAT_THIN = 1 << 0,
127 NVME_NS_FLBAS_LBA_MASK = 0xf,
128 NVME_NS_FLBAS_META_EXT = 0x10,
127 NVME_LBAF_RP_BEST = 0, 129 NVME_LBAF_RP_BEST = 0,
128 NVME_LBAF_RP_BETTER = 1, 130 NVME_LBAF_RP_BETTER = 1,
129 NVME_LBAF_RP_GOOD = 2, 131 NVME_LBAF_RP_GOOD = 2,
130 NVME_LBAF_RP_DEGRADED = 3, 132 NVME_LBAF_RP_DEGRADED = 3,
133 NVME_NS_DPC_PI_LAST = 1 << 4,
134 NVME_NS_DPC_PI_FIRST = 1 << 3,
135 NVME_NS_DPC_PI_TYPE3 = 1 << 2,
136 NVME_NS_DPC_PI_TYPE2 = 1 << 1,
137 NVME_NS_DPC_PI_TYPE1 = 1 << 0,
138 NVME_NS_DPS_PI_FIRST = 1 << 3,
139 NVME_NS_DPS_PI_MASK = 0x7,
140 NVME_NS_DPS_PI_TYPE1 = 1,
141 NVME_NS_DPS_PI_TYPE2 = 2,
142 NVME_NS_DPS_PI_TYPE3 = 3,
131}; 143};
132 144
133struct nvme_smart_log { 145struct nvme_smart_log {
@@ -261,6 +273,10 @@ enum {
261 NVME_RW_DSM_LATENCY_LOW = 3 << 4, 273 NVME_RW_DSM_LATENCY_LOW = 3 << 4,
262 NVME_RW_DSM_SEQ_REQ = 1 << 6, 274 NVME_RW_DSM_SEQ_REQ = 1 << 6,
263 NVME_RW_DSM_COMPRESSED = 1 << 7, 275 NVME_RW_DSM_COMPRESSED = 1 << 7,
276 NVME_RW_PRINFO_PRCHK_REF = 1 << 10,
277 NVME_RW_PRINFO_PRCHK_APP = 1 << 11,
278 NVME_RW_PRINFO_PRCHK_GUARD = 1 << 12,
279 NVME_RW_PRINFO_PRACT = 1 << 13,
264}; 280};
265 281
266struct nvme_dsm_cmd { 282struct nvme_dsm_cmd {