[PATCH] Formatted LBA SIZE[FLBAS]

Sathyavathi M sathya.m at samsung.com
Mon Aug 2 22:29:12 PDT 2021


The NLBAF(number of LBA formats) support in older spec was 16, but the new spec says the LBA support can be extended to 64.
The namespace data structure FLBAS(Formated LBA size) field bits have been changed to support more LBAF.

Signed-off-by: Sathyavathi M <sathya.m at samsung.com>
Reviewed-by: Jaegyu Choi <jg123.choi at samsung.com>

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 11779be..49cca79 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1683,6 +1683,9 @@ static int nvme_setup_streams_ns(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
 {
 	struct nvme_ctrl *ctrl = ns->ctrl;
+	unsigned ls_lbaf = id->flbas & NVME_NS_FLBAS_LBA_LSMASK;
+	unsigned ms_lbaf = (id->flbas & NVME_NS_FLBAS_LBA_MSMASK) >> 1;
+	unsigned lbaf = ms_lbaf | ls_lbaf;
 
 	/*
 	 * The PI implementation requires the metadata size to be equal to the
@@ -1855,7 +1858,9 @@ static void nvme_set_chunk_sectors(struct nvme_ns *ns, struct nvme_id_ns *id)
 
 static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
 {
-	unsigned lbaf = id->flbas & NVME_NS_FLBAS_LBA_MASK;
+	unsigned ls_lbaf = id->flbas & NVME_NS_FLBAS_LBA_LSMASK;
+	unsigned ms_lbaf = (id->flbas & NVME_NS_FLBAS_LBA_MSMASK) >> 1;
+	unsigned lbaf = ms_lbaf | ls_lbaf;
 	int ret;
 
 	blk_mq_freeze_queue(ns->disk->queue);
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index b7c4c41..e64194a 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -376,7 +376,7 @@ struct nvme_id_ns {
 	__le16			endgid;
 	__u8			nguid[16];
 	__u8			eui64[8];
-	struct nvme_lbaf	lbaf[16];
+	struct nvme_lbaf	lbaf[64];
 	__u8			rsvd192[192];
 	__u8			vs[3712];
 };
@@ -395,7 +395,7 @@ struct nvme_id_ns_zns {
 	__le32			rrl;
 	__le32			frl;
 	__u8			rsvd20[2796];
-	struct nvme_zns_lbafe	lbafe[16];
+	struct nvme_zns_lbafe	lbafe[64];
 	__u8			rsvd3072[768];
 	__u8			vs[256];
 };
@@ -454,7 +454,8 @@ enum {
 	NVME_NS_FEAT_ATOMICS	= 1 << 1,
 	NVME_NS_FEAT_IO_OPT	= 1 << 4,
 	NVME_NS_ATTR_RO		= 1 << 0,
-	NVME_NS_FLBAS_LBA_MASK	= 0xf,
+	NVME_NS_FLBAS_LBA_LSMASK	= 0xf,
+	NVME_NS_FLBAS_LBA_MSMASK	= 0x60,
 	NVME_NS_FLBAS_META_EXT	= 0x10,
 	NVME_NS_NMIC_SHARED	= 1 << 0,
 	NVME_LBAF_RP_BEST	= 0,



More information about the Linux-nvme mailing list