Skip to contentSkip to conversation

lightnvm: base 2.0 implementation

PATCH Superseded Matias Bjørling 4 participants 13 messages Feb 5, 2018 – Mar 28, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover lightnvm: base 2.0 implementation

Hi,

A couple of patches for 2.0 support for the lightnvm subsystem. They form the basis for integrating 2.0 support.

For the rest of the support, Javier has code that implements report chunk and sets up the LBA format data structure. He also has a bunch of patches that brings pblk up to speed.

The first two patches is preparation for the 2.0 work. The third patch implements the 2.0 data structures, the geometry command, and exposes the sysfs attributes that comes with the 2.0 specification. Note that the attributes between 1.2 and 2.0 are different, and it is expected that user-space shall use the version sysfs attribute to know which attributes will be available.

The last patch implements support for using the nvme namespace logical block and metadata fields and sync it with the internal lightnvm identify structures.

-Matias

Matias Bjørling (4):
lightnvm: make 1.2 data structures explicit
lightnvm: flatten nvm_id_group into nvm_id
lightnvm: add 2.0 geometry identification
nvme: lightnvm: add late setup of block size and metadata

 drivers/lightnvm/core.c      |  27 ++-
 drivers/nvme/host/core.c     |   2 +
 drivers/nvme/host/lightnvm.c | 508 ++++++++++++++++++++++++++++++++-----------
 drivers/nvme/host/nvme.h     |   2 +
 include/linux/lightnvm.h     |  64 +++---
 5 files changed, 426 insertions(+), 177 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/4 lightnvm: make 1.2 data structures explicit

Make the 1.2 data structures explicit, so it will be easy to identify the 2.0 data structures. Also fix the order of which the nvme_nvm_* are declared, such that they follow the nvme_nvm_command order.

---
 drivers/nvme/host/lightnvm.c | 82 ++++++++++++++++++++++----------------------
 1 file changed, 41 insertions(+), 41 deletions(-)
drivers/nvme/host/lightnvm.c +41 -41
index dc0b1335c7c6..60db3f1b59da 100644
@@ -51,6 +51,21 @@ struct nvme_nvm_ph_rw {
 	__le64			resv;
 };
 
+struct nvme_nvm_erase_blk {
+	__u8			opcode;
+	__u8			flags;
+	__u16			command_id;
+	__le32			nsid;
+	__u64			rsvd[2];
+	__le64			prp1;
+	__le64			prp2;
+	__le64			spba;
+	__le16			length;
+	__le16			control;
+	__le32			dsmgmt;
+	__le64			resv;
+};
+
 struct nvme_nvm_identity {
 	__u8			opcode;
 	__u8			flags;
@@ -89,33 +104,18 @@ struct nvme_nvm_setbbtbl {
 	__u32			rsvd4[3];
 };
 
-struct nvme_nvm_erase_blk {
-	__u8			opcode;
-	__u8			flags;
-	__u16			command_id;
-	__le32			nsid;
-	__u64			rsvd[2];
-	__le64			prp1;
-	__le64			prp2;
-	__le64			spba;
-	__le16			length;
-	__le16			control;
-	__le32			dsmgmt;
-	__le64			resv;
-};
-
 struct nvme_nvm_command {
 	union {
 		struct nvme_common_command common;
-		struct nvme_nvm_identity identity;
 		struct nvme_nvm_ph_rw ph_rw;
+		struct nvme_nvm_erase_blk erase;
+		struct nvme_nvm_identity identity;
 		struct nvme_nvm_getbbtbl get_bb;
 		struct nvme_nvm_setbbtbl set_bb;
-		struct nvme_nvm_erase_blk erase;
 	};
 };
 
-struct nvme_nvm_id_group {
+struct nvme_nvm_id12_grp {
 	__u8			mtype;
 	__u8			fmtype;
 	__le16			res16;
@@ -141,7 +141,7 @@ struct nvme_nvm_id_group {
 	__u8			reserved[906];
 } __packed;
 
-struct nvme_nvm_addr_format {
+struct nvme_nvm_id12_addrf {
 	__u8			ch_offset;
 	__u8			ch_len;
 	__u8			lun_offset;
@@ -157,16 +157,16 @@ struct nvme_nvm_addr_format {
 	__u8			res[4];
 } __packed;
 
-struct nvme_nvm_id {
+struct nvme_nvm_id12 {
 	__u8			ver_id;
 	__u8			vmnt;
 	__u8			cgrps;
 	__u8			res;
 	__le32			cap;
 	__le32			dom;
-	struct nvme_nvm_addr_format ppaf;
+	struct nvme_nvm_id12_addrf ppaf;
 	__u8			resv[228];
-	struct nvme_nvm_id_group group;
+	struct nvme_nvm_id12_grp grp;
 	__u8			resv2[2880];
 } __packed;
 
@@ -191,25 +191,25 @@ static inline void _nvme_nvm_check_size(void)
 {
 	BUILD_BUG_ON(sizeof(struct nvme_nvm_identity) != 64);
 	BUILD_BUG_ON(sizeof(struct nvme_nvm_ph_rw) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_nvm_erase_blk) != 64);
 	BUILD_BUG_ON(sizeof(struct nvme_nvm_getbbtbl) != 64);
 	BUILD_BUG_ON(sizeof(struct nvme_nvm_setbbtbl) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_nvm_erase_blk) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_nvm_id_group) != 960);
-	BUILD_BUG_ON(sizeof(struct nvme_nvm_addr_format) != 16);
-	BUILD_BUG_ON(sizeof(struct nvme_nvm_id) != NVME_IDENTIFY_DATA_SIZE);
+	BUILD_BUG_ON(sizeof(struct nvme_nvm_id12_grp) != 960);
+	BUILD_BUG_ON(sizeof(struct nvme_nvm_id12_addrf) != 16);
+	BUILD_BUG_ON(sizeof(struct nvme_nvm_id12) != NVME_IDENTIFY_DATA_SIZE);
 	BUILD_BUG_ON(sizeof(struct nvme_nvm_bb_tbl) != 64);
 }
 
-static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id)
+static int init_grp(struct nvm_id *nvm_id, struct nvme_nvm_id12 *id12)
 {
-	struct nvme_nvm_id_group *src;
+	struct nvme_nvm_id12_grp *src;
 	struct nvm_id_group *grp;
 	int sec_per_pg, sec_per_pl, pg_per_blk;
 
-	if (nvme_nvm_id->cgrps != 1)
+	if (id12->cgrps != 1)
 		return -EINVAL;
 
-	src = &nvme_nvm_id->group;
+	src = &id12->grp;
 	grp = &nvm_id->grp;
 
 	grp->mtype = src->mtype;
@@ -261,34 +261,34 @@ static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id)
 static int nvme_nvm_identity(struct nvm_dev *nvmdev, struct nvm_id *nvm_id)
 {
 	struct nvme_ns *ns = nvmdev->q->queuedata;
-	struct nvme_nvm_id *nvme_nvm_id;
+	struct nvme_nvm_id12 *id;
 	struct nvme_nvm_command c = {};
 	int ret;
 
 	c.identity.opcode = nvme_nvm_admin_identity;
 	c.identity.nsid = cpu_to_le32(ns->head->ns_id);
 
-	nvme_nvm_id = kmalloc(sizeof(struct nvme_nvm_id), GFP_KERNEL);
-	if (!nvme_nvm_id)
+	id = kmalloc(sizeof(struct nvme_nvm_id12), GFP_KERNEL);
+	if (!id)
 		return -ENOMEM;
 
 	ret = nvme_submit_sync_cmd(ns->ctrl->admin_q, (struct nvme_command *)&c,
-				nvme_nvm_id, sizeof(struct nvme_nvm_id));
+				id, sizeof(struct nvme_nvm_id12));
 	if (ret) {
 		ret = -EIO;
 		goto out;
 	}
 
-	nvm_id->ver_id = nvme_nvm_id->ver_id;
-	nvm_id->vmnt = nvme_nvm_id->vmnt;
-	nvm_id->cap = le32_to_cpu(nvme_nvm_id->cap);
-	nvm_id->dom = le32_to_cpu(nvme_nvm_id->dom);
-	memcpy(&nvm_id->ppaf, &nvme_nvm_id->ppaf,
+	nvm_id->ver_id = id->ver_id;
+	nvm_id->vmnt = id->vmnt;
+	nvm_id->cap = le32_to_cpu(id->cap);
+	nvm_id->dom = le32_to_cpu(id->dom);
+	memcpy(&nvm_id->ppaf, &id->ppaf,
 					sizeof(struct nvm_addr_format));
 
-	ret = init_grps(nvm_id, nvme_nvm_id);
+	ret = init_grp(nvm_id, id);
 out:
-	kfree(nvme_nvm_id);
+	kfree(id);
 	return ret;
 }
 
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/4 lightnvm: flatten nvm_id_group into nvm_id

In reply to Matias Bjørling

There are no groups in the 2.0 specification, make sure that the nvm_id structure is flattened before 2.0 data structures are added.

---
 drivers/lightnvm/core.c      |  25 ++++++-----
 drivers/nvme/host/lightnvm.c | 100 +++++++++++++++++++++----------------------
 include/linux/lightnvm.h     |  53 +++++++++++------------
 3 files changed, 86 insertions(+), 92 deletions(-)
drivers/lightnvm/core.c +12 -13
index dcc9e621e651..c72863b36439 100644
@@ -851,33 +851,32 @@ EXPORT_SYMBOL(nvm_get_tgt_bb_tbl);
 static int nvm_core_init(struct nvm_dev *dev)
 {
 	struct nvm_id *id = &dev->identity;
-	struct nvm_id_group *grp = &id->grp;
 	struct nvm_geo *geo = &dev->geo;
 	int ret;
 
 	memcpy(&geo->ppaf, &id->ppaf, sizeof(struct nvm_addr_format));
 
-	if (grp->mtype != 0) {
+	if (id->mtype != 0) {
 		pr_err("nvm: memory type not supported\n");
 		return -EINVAL;
 	}
 
 	/* Whole device values */
-	geo->nr_chnls = grp->num_ch;
-	geo->nr_luns = grp->num_lun;
+	geo->nr_chnls = id->num_ch;
+	geo->nr_luns = id->num_lun;
 
 	/* Generic device geometry values */
-	geo->ws_min = grp->ws_min;
-	geo->ws_opt = grp->ws_opt;
-	geo->ws_seq = grp->ws_seq;
-	geo->ws_per_chk = grp->ws_per_chk;
-	geo->nr_chks = grp->num_chk;
-	geo->sec_size = grp->csecs;
-	geo->oob_size = grp->sos;
-	geo->mccap = grp->mccap;
+	geo->ws_min = id->ws_min;
+	geo->ws_opt = id->ws_opt;
+	geo->ws_seq = id->ws_seq;
+	geo->ws_per_chk = id->ws_per_chk;
+	geo->nr_chks = id->num_chk;
+	geo->sec_size = id->csecs;
+	geo->oob_size = id->sos;
+	geo->mccap = id->mccap;
 	geo->max_rq_size = dev->ops->max_phys_sect * geo->sec_size;
 
-	geo->sec_per_chk = grp->clba;
+	geo->sec_per_chk = id->clba;
 	geo->sec_per_lun = geo->sec_per_chk * geo->nr_chks;
 	geo->all_luns = geo->nr_luns * geo->nr_chnls;
 
drivers/nvme/host/lightnvm.c +48 -52

160 lines not on this page · raw message

include/linux/lightnvm.h +26 -27

68 lines not on this page · raw message

Signature · 1 line
2.11.0
#3 lore raw

PATCH 3/4 lightnvm: add 2.0 geometry identification

In reply to Matias Bjørling

Implement the geometry data structures for 2.0 and enable a drive to be identified as one, including exposing the appropriate 2.0 sysfs entries.

---
 drivers/lightnvm/core.c      |   2 +-
 drivers/nvme/host/lightnvm.c | 334 +++++++++++++++++++++++++++++++++++++------
 include/linux/lightnvm.h     |  11 +-
 3 files changed, 295 insertions(+), 52 deletions(-)
drivers/lightnvm/core.c +1 -1
index c72863b36439..250e74dfa120 100644
@@ -934,7 +934,7 @@ static int nvm_init(struct nvm_dev *dev)
 	pr_debug("nvm: ver:%x nvm_vendor:%x\n",
 			dev->identity.ver_id, dev->identity.vmnt);
 
-	if (dev->identity.ver_id != 1) {
+	if (dev->identity.ver_id != 1 && dev->identity.ver_id != 2) {
 		pr_err("nvm: device not supported by kernel.");
 		goto err;
 	}
drivers/nvme/host/lightnvm.c +287 -47

416 lines not on this page · raw message

include/linux/lightnvm.h +7 -4
index 94b704a8d83d..b717c000b712 100644
@@ -184,10 +184,9 @@ struct nvm_id {
 	u16	csecs;
 	u16	sos;
 
-	u16	ws_min;
-	u16	ws_opt;
-	u16	ws_seq;
-	u16	ws_per_chk;
+	u32	ws_min;
+	u32	ws_opt;
+	u32	mw_cunits;
 
 	u32	trdt;
 	u32	trdm;
@@ -199,6 +198,10 @@ struct nvm_id {
 	u32	mccap;
 	u16	cpar;
 
+	/* calculated values */
+	u16	ws_seq;
+	u16	ws_per_chk;
+
 	/* 1.2 compatibility */
 	u8	mtype;
 	u8	fmtype;
Signature · 1 line
2.11.0
#4 lore raw

Re: [PATCH 3/4] lightnvm: add 2.0 geometry identification

Quoted 16 lines · Matias Bjørling

Implement the geometry data structures for 2.0 and enable a drive to be identified as one, including exposing the appropriate 2.0 sysfs entries.

---
 drivers/lightnvm/core.c      |   2 +-
 drivers/nvme/host/lightnvm.c | 334 +++++++++++++++++++++++++++++++++++++------
 include/linux/lightnvm.h     |  11 +-
 3 files changed, 295 insertions(+), 52 deletions(-)
drivers/lightnvm/core.c +0 -0
index c72863b36439..250e74dfa120 100644

drivers/lightnvm/core.c static int nvm_init(struct nvm_dev *dev) · line 940

Quoted 8 lines
drivers/lightnvm/core.c +1 -1
@@ -934,7 +934,7 @@ static int nvm_init(struct nvm_dev *dev)
 	pr_debug("nvm: ver:%x nvm_vendor:%x\n",
 			dev->identity.ver_id, dev->identity.vmnt);
 
-	if (dev->identity.ver_id != 1) {
+	if (dev->identity.ver_id != 1 && dev->identity.ver_id != 2) {
 		pr_err("nvm: device not supported by kernel.");
 		goto err;
 	}

Hi,
The pr_err() above could be a bit more informative to the user. E.g.,

		pr_err("nvm: device ver_id %d not supported by kernel.",
			dev->identity.ver_id);

BTW, isn't that line missing a '\n'?

Signature · 1 line
~Randy
#5 lore raw

Re: [PATCH 3/4] lightnvm: add 2.0 geometry identification

Quoted 28 lines · Randy Dunlap
Quoted 16 lines · Matias Bjørling

Implement the geometry data structures for 2.0 and enable a drive to be identified as one, including exposing the appropriate 2.0 sysfs entries.

---
  drivers/lightnvm/core.c      |   2 +-
  drivers/nvme/host/lightnvm.c | 334 +++++++++++++++++++++++++++++++++++++------
  include/linux/lightnvm.h     |  11 +-
  3 files changed, 295 insertions(+), 52 deletions(-)
drivers/lightnvm/core.c +0 -0
index c72863b36439..250e74dfa120 100644

drivers/lightnvm/core.c static int nvm_init(struct nvm_dev *dev) · line 940

Quoted 8 lines
drivers/lightnvm/core.c +1 -1
@@ -934,7 +934,7 @@ static int nvm_init(struct nvm_dev *dev)
  	pr_debug("nvm: ver:%x nvm_vendor:%x\n",
  			dev->identity.ver_id, dev->identity.vmnt);
 
-	if (dev->identity.ver_id != 1) {
+	if (dev->identity.ver_id != 1 && dev->identity.ver_id != 2) {
  		pr_err("nvm: device not supported by kernel.");
  		goto err;
  	}

Hi,
The pr_err() above could be a bit more informative to the user. E.g.,

Quoted 5 lines
		pr_err("nvm: device ver_id %d not supported by kernel.",
			dev->identity.ver_id);

BTW, isn't that line missing a '\n'?

Good point! Thanks. I'll add it in.

#6 lore raw

Re: [PATCH 3/4] lightnvm: add 2.0 geometry identification

In reply to Matias Bjørling
Quoted 76 lines · Matias Bjørling

Implement the geometry data structures for 2.0 and enable a drive to be identified as one, including exposing the appropriate 2.0 sysfs entries.

---

drivers/lightnvm/core.c      |   2 +-
drivers/nvme/host/lightnvm.c | 334 +++++++++++++++++++++++++++++++++++++------
include/linux/lightnvm.h     |  11 +-
3 files changed, 295 insertions(+), 52 deletions(-)
drivers/lightnvm/core.c +1 -1
index c72863b36439..250e74dfa120 100644
@@ -934,7 +934,7 @@ static int nvm_init(struct nvm_dev *dev)
 	pr_debug("nvm: ver:%x nvm_vendor:%x\n",
 			dev->identity.ver_id, dev->identity.vmnt);
 
-	if (dev->identity.ver_id != 1) {
+	if (dev->identity.ver_id != 1 && dev->identity.ver_id != 2) {
 		pr_err("nvm: device not supported by kernel.");
 		goto err;
 	}
drivers/nvme/host/lightnvm.c +42 -0
index 6412551ecc65..a9c010655ccc 100644
@@ -184,6 +184,58 @@ struct nvme_nvm_bb_tbl {
 	__u8	blk[0];
 };
 
+struct nvme_nvm_id20_addrf {
+	__u8			grp_len;
+	__u8			pu_len;
+	__u8			chk_len;
+	__u8			lba_len;
+	__u8			resv[4];
+};
+
+struct nvme_nvm_id20 {
+	__u8			mjr;
+	__u8			mnr;
+	__u8			resv[6];
+
+	struct nvme_nvm_id20_addrf lbaf;
+
+	__u32			mccap;
+	__u8			resv2[12];
+
+	__u8			wit;
+	__u8			resv3[31];
+
+	/* Geometry */
+	__u16			num_grp;
+	__u16			num_pu;
+	__u32			num_chk;
+	__u32			clba;
+	__u8			resv4[52];
+
+	/* Write data requirements */
+	__u32			ws_min;
+	__u32			ws_opt;
+	__u32			mw_cunits;
+	__u32			maxoc;
+	__u32			maxocpu;
+	__u8			resv5[44];
+
+	/* Performance related metrics */
+	__u32			trdt;
+	__u32			trdm;
+	__u32			twrt;
+	__u32			twrm;
+	__u32			tcrst;

drivers/nvme/host/lightnvm.c struct nvme_nvm_bb_tbl { · line 238

Quoted 10 lines
drivers/nvme/host/lightnvm.c +9 -0
+	__u32			tcrsm;
+	__u8			resv6[40];
+
+	/* Reserved area */
+	__u8			resv7[2816];
+
+	/* Vendor specific */
+	__u8			vs[1024];
+};
 

All __u16, __u32 should be __le16, __le32

Javier

#7 lore raw

PATCH 4/4 nvme: lightnvm: add late setup of block size and metadata

In reply to Matias Bjørling

The nvme driver sets up the size of the nvme namespace in two steps. First it initializes the device with standard logical block and metadata sizes, and then sets the correct logical block and metadata size. Due to the OCSSD 2.0 specification relies on the namespace to expose these sizes for correct initialization, let it be updated appropriately on the LightNVM side as well.

---
 drivers/nvme/host/core.c     | 2 ++
 drivers/nvme/host/lightnvm.c | 8 ++++++++
 drivers/nvme/host/nvme.h     | 2 ++
 3 files changed, 12 insertions(+)
drivers/nvme/host/core.c +2 -0
index f837d666cbd4..740ceb28067c 100644
@@ -1379,6 +1379,8 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
 	if (ns->noiob)
 		nvme_set_chunk_size(ns);
 	nvme_update_disk_info(disk, ns, id);
+	if (ns->ndev)
+		nvme_nvm_update_nvm_info(ns);
 #ifdef CONFIG_NVME_MULTIPATH
 	if (ns->head->disk)
 		nvme_update_disk_info(ns->head->disk, ns, id);
drivers/nvme/host/lightnvm.c +8 -0
index a9c010655ccc..8d4301854811 100644
@@ -814,6 +814,14 @@ int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg)
 	}
 }
 
+void nvme_nvm_update_nvm_info(struct nvme_ns *ns)
+{
+	struct nvm_dev *ndev = ns->ndev;
+
+	ndev->identity.csecs = ndev->geo.sec_size = 1 << ns->lba_shift;
+	ndev->identity.sos = ndev->geo.oob_size = ns->ms;
+}
+
 int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node)
 {
 	struct request_queue *q = ns->queue;
drivers/nvme/host/nvme.h +2 -0
index ea1aa5283e8e..1ca08f4993ba 100644
@@ -451,12 +451,14 @@ static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
 #endif /* CONFIG_NVME_MULTIPATH */
 
 #ifdef CONFIG_NVM
+void nvme_nvm_update_nvm_info(struct nvme_ns *ns);
 int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node);
 void nvme_nvm_unregister(struct nvme_ns *ns);
 int nvme_nvm_register_sysfs(struct nvme_ns *ns);
 void nvme_nvm_unregister_sysfs(struct nvme_ns *ns);
 int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg);
 #else
+static inline void nvme_nvm_update_nvm_info(struct nvme_ns *ns) {};
 static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name,
 				    int node)
 {
Signature · 1 line
2.11.0
#8 lore raw

Re: [PATCH 4/4] nvme: lightnvm: add late setup of block size and metadata

Quoted 56 lines · Matias Bjørling

The nvme driver sets up the size of the nvme namespace in two steps. First it initializes the device with standard logical block and metadata sizes, and then sets the correct logical block and metadata size. Due to the OCSSD 2.0 specification relies on the namespace to expose these sizes for correct initialization, let it be updated appropriately on the LightNVM side as well.

---
  drivers/nvme/host/core.c     | 2 ++
  drivers/nvme/host/lightnvm.c | 8 ++++++++
  drivers/nvme/host/nvme.h     | 2 ++
  3 files changed, 12 insertions(+)
drivers/nvme/host/core.c +2 -0
index f837d666cbd4..740ceb28067c 100644
@@ -1379,6 +1379,8 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
  	if (ns->noiob)
  		nvme_set_chunk_size(ns);
  	nvme_update_disk_info(disk, ns, id);
+	if (ns->ndev)
+		nvme_nvm_update_nvm_info(ns);
  #ifdef CONFIG_NVME_MULTIPATH
  	if (ns->head->disk)
  		nvme_update_disk_info(ns->head->disk, ns, id);
drivers/nvme/host/lightnvm.c +8 -0
index a9c010655ccc..8d4301854811 100644
@@ -814,6 +814,14 @@ int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg)
  	}
  }
 
+void nvme_nvm_update_nvm_info(struct nvme_ns *ns)
+{
+	struct nvm_dev *ndev = ns->ndev;
+
+	ndev->identity.csecs = ndev->geo.sec_size = 1 << ns->lba_shift;
+	ndev->identity.sos = ndev->geo.oob_size = ns->ms;
+}
+
  int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node)
  {
  	struct request_queue *q = ns->queue;
drivers/nvme/host/nvme.h +1 -0
index ea1aa5283e8e..1ca08f4993ba 100644
@@ -451,12 +451,14 @@ static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
  #endif /* CONFIG_NVME_MULTIPATH */
 
  #ifdef CONFIG_NVM
+void nvme_nvm_update_nvm_info(struct nvme_ns *ns);

drivers/nvme/host/nvme.h static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns) · line 464

Quoted 10 lines
drivers/nvme/host/nvme.h +1 -0
  int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node);
  void nvme_nvm_unregister(struct nvme_ns *ns);
  int nvme_nvm_register_sysfs(struct nvme_ns *ns);
  void nvme_nvm_unregister_sysfs(struct nvme_ns *ns);
  int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg);
  #else
+static inline void nvme_nvm_update_nvm_info(struct nvme_ns *ns) {};
  static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name,
  				    int node)
  {

Hi Keith,

When going through the patches for 4.17, I forgot to run this patch by you. It is part of adding OCSSD2.0 support to the kernel, and slides in between a large refactoring, and the 2.0 part. May I add your reviewed by and let Jens pick it up after the nvme patches for 4.17 has gone up?

Thanks!

-Matias

#9 lore raw

Re: [PATCH 4/4] nvme: lightnvm: add late setup of block size and metadata

I really don't want more lightnvm cruft in the core. We'll need a proper abstraction.c

Quoted 73 lines · Matias Bj�rling
Quoted 54 lines · Matias Bj�rling

The nvme driver sets up the size of the nvme namespace in two steps. First it initializes the device with standard logical block and metadata sizes, and then sets the correct logical block and metadata size. Due to the OCSSD 2.0 specification relies on the namespace to expose these sizes for correct initialization, let it be updated appropriately on the LightNVM side as well.

---
  drivers/nvme/host/core.c     | 2 ++
  drivers/nvme/host/lightnvm.c | 8 ++++++++
  drivers/nvme/host/nvme.h     | 2 ++
  3 files changed, 12 insertions(+)
drivers/nvme/host/core.c +2 -0
index f837d666cbd4..740ceb28067c 100644
@@ -1379,6 +1379,8 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
  	if (ns->noiob)
  		nvme_set_chunk_size(ns);
  	nvme_update_disk_info(disk, ns, id);
+	if (ns->ndev)
+		nvme_nvm_update_nvm_info(ns);
  #ifdef CONFIG_NVME_MULTIPATH
  	if (ns->head->disk)
  		nvme_update_disk_info(ns->head->disk, ns, id);
drivers/nvme/host/lightnvm.c +8 -0
index a9c010655ccc..8d4301854811 100644
@@ -814,6 +814,14 @@ int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg)
  	}
  }
+void nvme_nvm_update_nvm_info(struct nvme_ns *ns)
+{
+	struct nvm_dev *ndev = ns->ndev;
+
+	ndev->identity.csecs = ndev->geo.sec_size = 1 << ns->lba_shift;
+	ndev->identity.sos = ndev->geo.oob_size = ns->ms;
+}
+
  int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node)
  {
  	struct request_queue *q = ns->queue;
drivers/nvme/host/nvme.h +1 -0
index ea1aa5283e8e..1ca08f4993ba 100644
@@ -451,12 +451,14 @@ static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
  #endif /* CONFIG_NVME_MULTIPATH */
  #ifdef CONFIG_NVM
+void nvme_nvm_update_nvm_info(struct nvme_ns *ns);
  int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node);

drivers/nvme/host/nvme.h static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns) · line 464

Quoted 10 lines
drivers/nvme/host/nvme.h +1 -0
  void nvme_nvm_unregister(struct nvme_ns *ns);
  int nvme_nvm_register_sysfs(struct nvme_ns *ns);
  void nvme_nvm_unregister_sysfs(struct nvme_ns *ns);
  int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg);
  #else
+static inline void nvme_nvm_update_nvm_info(struct nvme_ns *ns) {};
  static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name,
  				    int node)
  {
 

Hi Keith,

When going through the patches for 4.17, I forgot to run this patch by you. It is part of adding OCSSD2.0 support to the kernel, and slides in between a large refactoring, and the 2.0 part. May I add your reviewed by and let Jens pick it up after the nvme patches for 4.17 has gone up?

Quoted 8 lines

Thanks!

-Matias

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

---end quoted text---

#10 lore raw

Re: [PATCH 4/4] nvme: lightnvm: add late setup of block size and metadata

Quoted 3 lines · Christoph Hellwig

I really don't want more lightnvm cruft in the core. We'll need a proper abstraction.c

I agree, we should get that moving, and make a proper abstraction for it. Also with respect to how an SMR interface in general is integrated into NVMe.

The patch is necessary due to the revalidate event for retrieving the lba format from the nvme drive. It might not be available the first time around, and we have to hook in when the drive is revalidated the second time.

Quoted 84 lines · Matias Bjørling
Quoted 73 lines · Matias Bjørling
Quoted 54 lines

The nvme driver sets up the size of the nvme namespace in two steps. First it initializes the device with standard logical block and metadata sizes, and then sets the correct logical block and metadata size. Due to the OCSSD 2.0 specification relies on the namespace to expose these sizes for correct initialization, let it be updated appropriately on the LightNVM side as well.

---
   drivers/nvme/host/core.c     | 2 ++
   drivers/nvme/host/lightnvm.c | 8 ++++++++
   drivers/nvme/host/nvme.h     | 2 ++
   3 files changed, 12 insertions(+)
drivers/nvme/host/core.c +2 -0
index f837d666cbd4..740ceb28067c 100644
@@ -1379,6 +1379,8 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
   	if (ns->noiob)
   		nvme_set_chunk_size(ns);
   	nvme_update_disk_info(disk, ns, id);
+	if (ns->ndev)
+		nvme_nvm_update_nvm_info(ns);
   #ifdef CONFIG_NVME_MULTIPATH
   	if (ns->head->disk)
   		nvme_update_disk_info(ns->head->disk, ns, id);
drivers/nvme/host/lightnvm.c +8 -0
index a9c010655ccc..8d4301854811 100644
@@ -814,6 +814,14 @@ int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg)
   	}
   }
+void nvme_nvm_update_nvm_info(struct nvme_ns *ns)
+{
+	struct nvm_dev *ndev = ns->ndev;
+
+	ndev->identity.csecs = ndev->geo.sec_size = 1 << ns->lba_shift;
+	ndev->identity.sos = ndev->geo.oob_size = ns->ms;
+}
+
   int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node)
   {
   	struct request_queue *q = ns->queue;
drivers/nvme/host/nvme.h +1 -0
index ea1aa5283e8e..1ca08f4993ba 100644
@@ -451,12 +451,14 @@ static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
   #endif /* CONFIG_NVME_MULTIPATH */
   #ifdef CONFIG_NVM
+void nvme_nvm_update_nvm_info(struct nvme_ns *ns);
   int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node);

drivers/nvme/host/nvme.h static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns) · line 464

Quoted 10 lines
drivers/nvme/host/nvme.h +1 -0
   void nvme_nvm_unregister(struct nvme_ns *ns);
   int nvme_nvm_register_sysfs(struct nvme_ns *ns);
   void nvme_nvm_unregister_sysfs(struct nvme_ns *ns);
   int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg);
   #else
+static inline void nvme_nvm_update_nvm_info(struct nvme_ns *ns) {};
   static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name,
   				    int node)
   {
 

Hi Keith,

When going through the patches for 4.17, I forgot to run this patch by you. It is part of adding OCSSD2.0 support to the kernel, and slides in between a large refactoring, and the 2.0 part. May I add your reviewed by and let Jens pick it up after the nvme patches for 4.17 has gone up?

Quoted 8 lines

Thanks!

-Matias

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

---end quoted text---

#11 lore raw
In reply to Matias Bjørling
Quoted 37 lines · Matias Bjørling

Hi,

A couple of patches for 2.0 support for the lightnvm subsystem. They form the basis for integrating 2.0 support.

For the rest of the support, Javier has code that implements report chunk and sets up the LBA format data structure. He also has a bunch of patches that brings pblk up to speed.

The first two patches is preparation for the 2.0 work. The third patch implements the 2.0 data structures, the geometry command, and exposes the sysfs attributes that comes with the 2.0 specification. Note that the attributes between 1.2 and 2.0 are different, and it is expected that user-space shall use the version sysfs attribute to know which attributes will be available.

The last patch implements support for using the nvme namespace logical block and metadata fields and sync it with the internal lightnvm identify structures.

-Matias

Matias Bjørling (4):
lightnvm: make 1.2 data structures explicit
lightnvm: flatten nvm_id_group into nvm_id
lightnvm: add 2.0 geometry identification
nvme: lightnvm: add late setup of block size and metadata

drivers/lightnvm/core.c      |  27 ++-
drivers/nvme/host/core.c     |   2 +
drivers/nvme/host/lightnvm.c | 508 ++++++++++++++++++++++++++++++++-----------
drivers/nvme/host/nvme.h     |   2 +
include/linux/lightnvm.h     |  64 +++---
5 files changed, 426 insertions(+), 177 deletions(-)
Quoted 2 lines

--
2.11.0

Thanks for posting these. I have started rebasing my patches on top of the new geometry - it is a bit different of how I implemented it, but I'll take care of it.

I'll review as I go - some of the changes I have might make sense to squash in your patches to keep a clean history...

I'll add a couple of patches abstracting the geometry so that at core.c level we only work with a single geometry structure. This is they way it is done in the early patches I pointe you to before. Then it is patches building bottom-up support for the new features in 2.0.

Javier

#12 lore raw
Quoted 40 lines · Javier Gonzalez
Quoted 37 lines · Matias Bjørling

Hi,

A couple of patches for 2.0 support for the lightnvm subsystem. They form the basis for integrating 2.0 support.

For the rest of the support, Javier has code that implements report chunk and sets up the LBA format data structure. He also has a bunch of patches that brings pblk up to speed.

The first two patches is preparation for the 2.0 work. The third patch implements the 2.0 data structures, the geometry command, and exposes the sysfs attributes that comes with the 2.0 specification. Note that the attributes between 1.2 and 2.0 are different, and it is expected that user-space shall use the version sysfs attribute to know which attributes will be available.

The last patch implements support for using the nvme namespace logical block and metadata fields and sync it with the internal lightnvm identify structures.

-Matias

Matias Bjørling (4):
lightnvm: make 1.2 data structures explicit
lightnvm: flatten nvm_id_group into nvm_id
lightnvm: add 2.0 geometry identification
nvme: lightnvm: add late setup of block size and metadata

drivers/lightnvm/core.c      |  27 ++-
drivers/nvme/host/core.c     |   2 +
drivers/nvme/host/lightnvm.c | 508 ++++++++++++++++++++++++++++++++-----------
drivers/nvme/host/nvme.h     |   2 +
include/linux/lightnvm.h     |  64 +++---
5 files changed, 426 insertions(+), 177 deletions(-)
Quoted 2 lines

--
2.11.0

Quoted 7 lines

Thanks for posting these. I have started rebasing my patches on top of the new geometry - it is a bit different of how I implemented it, but I'll take care of it.

I'll review as I go - some of the changes I have might make sense to squash in your patches to keep a clean history...

Thanks.

Quoted 5 lines

I'll add a couple of patches abstracting the geometry so that at core.c level we only work with a single geometry structure. This is they way it is done in the early patches I pointe you to before. Then it is patches building bottom-up support for the new features in 2.0.

Yep, I was expecting that. I skipped that part since it went into pblk and you already had some patches for it.

Quoted 2 lines

Javier