nvme: Implement NS Optimial IO Boundary from 1.3 Spec
PATCH 1/1 nvme: Implement NS Optimial IO Boundary from 1.3 Spec
The NVMe 1.3 spec introduces Namespace Optimal IO Boundaries (NOIOB). This feature standardizes the stripe mechanism we currently have quirks for. This patch implements the necessary logic to handle this new feature.
--- drivers/nvme/host/core.c | 7 +++++++ include/linux/nvme.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +7 -0
@@ -1000,6 +1000,7 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)u8 lbaf, pi_type;u16 old_ms;unsigned short bs; +unsigned int iob; old_ms = ns->ms; lbaf = id->flbas &NVME_NS_FLBAS_LBA_MASK ;
@@ -1027,6 +1028,12 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id) ns->pi_type = pi_type;blk_queue_logical_block_size (ns->queue, bs); +if (ns->ctrl->vs >=NVME_VS (1 ,3 ,0 ) &&le16_to_cpu (id->noiob)) { +/* Convert from controller logical blocks to 512 sectors. */ + iob = ((unsigned int )le16_to_cpu (id->noiob)) << (ns->lba_shift -9 ); +if (is_power_of_2 (iob)) +blk_queue_chunk_sectors (ns->queue, iob); + }if (ns->ms && !blk_get_integrity (disk) && !ns->ext)nvme_init_integrity (ns);
include/linux/nvme.h +1 -1
@@ -274,7 +274,7 @@ struct nvme_id_ns {__le16 nabsn;__le16 nabo;__le16 nabspf; -__u16 rsvd46; +__le16 noiob;__u8 nvmcap[16 ];__u8 rsvd64[40 ];__u8 nguid[16 ];
Signature · 1 line
2.7.4
PATCH 1/1 nvme: Implement NS Optimial IO Boundary from 1.3 Spec
Quoted 5 lines · Scott Bauer
The NVMe 1.3 spec introduces Namespace Optimal IO Boundaries (NOIOB). This feature standardizes the stripe mechanism we currently have quirks for. This patch implements the necessary logic to handle this new feature.
Signed-off-by Scott Bauer <scott.bauer at intel.com>
Thanks Scott, looks good to me.
drivers/nvme/host/core.c static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id) · line 1036
Quoted 6 lines
drivers/nvme/host/core.c +6
-0+if (ns->ctrl->vs >=NVME_VS (1 ,3 ,0 ) &&le16_to_cpu (id->noiob)) { +/* Convert from controller logical blocks to 512 sectors. */ + iob = ((unsigned int )le16_to_cpu (id->noiob)) << (ns->lba_shift -9 ); +if (is_power_of_2 (iob)) +blk_queue_chunk_sectors (ns->queue, iob); + }
Just want to point out that if a Namespace has this set, then magically doesn't after a rescan, we're stuck with the previous chunk size. Even if that does happen, the only harm is a command may be split into two smaller ones. Not a big deal, and that'll never happen in real life anyway.
Christoph Hellwig
maintainerPATCH 1/1 nvme: Implement NS Optimial IO Boundary from 1.3 Spec
In reply to Scott BauerLooks fine,
Can you also add support to nvme-cli?