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ZXJzL252bWUvaG9zdC9jb3JlLmMgICAgICAgICB8ICAgMiArCiBkcml2ZXJz L252bWUvaG9zdC9saWdodG52bS5jICAgICB8IDUxMyArKysrKysrKysrKysrKysrKysrKysrKysr KysrLS0tLS0tLS0tLS0KIGRyaXZlcnMvbnZtZS9ob3N0L252bWUuaCAgICAgICAgIHwgICAyICsK IGluY2x1ZGUvbGludXgvbGlnaHRudm0uaCAgICAgICAgIHwgIDcxICsrKy0tLQogNyBmaWxlcyBj aGFuZ2VkLCA0NDIgaW5zZXJ0aW9ucygrKSwgMjI0IGRlbGV0aW9ucygtKQoKLS0gCjIuMTEuMAoK Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCkxpbnV4LW52 bWUgbWFpbGluZyBsaXN0CkxpbnV4LW52bWVAbGlzdHMuaW5mcmFkZWFkLm9yZwpodHRwOi8vbGlz dHMuaW5mcmFkZWFkLm9yZy9tYWlsbWFuL2xpc3RpbmZvL2xpbnV4LW52bWUK
PATCH v2 1/6 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
@@ -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
PATCH v2 2/6 lightnvm: flatten nvm_id_group into nvm_id
In reply to Matias BjørlingThere 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
@@ -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
PATCH v2 3/6 lightnvm: add 2.0 geometry identification
In reply to Matias BjørlingImplement 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 | 8 +- drivers/nvme/host/lightnvm.c | 334 +++++++++++++++++++++++++++++++++++++------ include/linux/lightnvm.h | 11 +- 3 files changed, 297 insertions(+), 56 deletions(-)
drivers/lightnvm/core.c +3 -5
@@ -931,11 +931,9 @@ static int nvm_init(struct nvm_dev *dev) goto err; } -pr_debug ("nvm: ver:%x nvm_vendor:%x\n" , - dev->identity.ver_id, dev->identity.vmnt); - -if (dev->identity.ver_id !=1 ) { -pr_err ("nvm: device not supported by kernel." ); +if (dev->identity.ver_id !=1 && dev->identity.ver_id !=2 ) { +pr_err ("nvm: device ver_id %d not supported by kernel.\n" , + dev->identity.ver_id); goto err; }
drivers/nvme/host/lightnvm.c +287 -47
416 lines not on this page · raw message
include/linux/lightnvm.h +7 -4
@@ -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
PATCH v2 4/6 lightnvm: remove max_rq_size
In reply to Matias BjørlingThe field is no longer used.
--- drivers/lightnvm/core.c | 1 - include/linux/lightnvm.h | 2 -- 2 files changed, 3 deletions(-)
drivers/lightnvm/core.c +0 -1
@@ -874,7 +874,6 @@ static int nvm_core_init(struct nvm_dev *dev) 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 = id->clba; geo->sec_per_lun = geo->sec_per_chk * geo->nr_chks;
include/linux/lightnvm.h +0 -2
@@ -295,8 +295,6 @@ struct nvm_geo {int ws_seq;int ws_per_chk; -int max_rq_size; -int op;struct nvm_addr_format ppaf;
Signature · 1 line
2.11.0
PATCH v2 5/6 lightnvm: remove nvm_dev_ops->max_phys_sect
In reply to Matias BjørlingThe value of max_phys_sect is always static. Instead of defining it in the nvm_dev_ops structure, declare it as a global value.
--- drivers/lightnvm/core.c | 28 +++++++--------------------- drivers/lightnvm/pblk-init.c | 9 ++++----- drivers/lightnvm/pblk-recovery.c | 8 ++------ drivers/nvme/host/lightnvm.c | 5 +---- include/linux/lightnvm.h | 5 ++--- 5 files changed, 16 insertions(+), 39 deletions(-)
drivers/lightnvm/core.c +7 -21
@@ -407,7 +407,8 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) tdisk->private_data = targetdata; tqueue->queuedata = targetdata; -blk_queue_max_hw_sectors (tqueue,8 * dev->ops->max_phys_sect); +blk_queue_max_hw_sectors (tqueue, + (dev->geo.sec_size >>9 ) *NVM_MAX_VLBA );set_capacity (tdisk, tt->capacity (targetdata));add_disk (tdisk);
@@ -719,7 +720,7 @@ int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas,struct nvm_rq rqd;int ret; -if (nr_ppas > dev->ops->max_phys_sect) { +if (nr_ppas >NVM_MAX_VLBA ) {pr_err ("nvm: unable to update all blocks atomically\n" );return -EINVAL ; }
@@ -740,14 +741,6 @@ int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas, }EXPORT_SYMBOL (nvm_set_tgt_bb_tbl); -int nvm_max_phys_sects (struct nvm_tgt_dev *tgt_dev) -{ -struct nvm_dev *dev = tgt_dev->parent; - -return dev->ops->max_phys_sect; -} -EXPORT_SYMBOL (nvm_max_phys_sects); -int nvm_submit_io (struct nvm_tgt_dev *tgt_dev,struct nvm_rq *rqd) {struct nvm_dev *dev = tgt_dev->parent;
@@ -965,17 +958,10 @@ int nvm_register(struct nvm_dev *dev)if (!dev->q || !dev->ops)return -EINVAL ; -if (dev->ops->max_phys_sect >256 ) { -pr_info ("nvm: max sectors supported is 256.\n" ); -return -EINVAL ; - } - -if (dev->ops->max_phys_sect >1 ) { - dev->dma_pool = dev->ops->create_dma_pool (dev,"ppalist" ); -if (!dev->dma_pool) { -pr_err ("nvm: could not create dma pool\n" ); -return -ENOMEM ; - } + dev->dma_pool = dev->ops->create_dma_pool (dev,"ppalist" ); +if (!dev->dma_pool) { +pr_err ("nvm: could not create dma pool\n" ); +return -ENOMEM ; } ret =nvm_init (dev);
drivers/lightnvm/pblk-init.c +4 -5
@@ -260,8 +260,7 @@ static int pblk_core_init(struct pblk *pblk)return -ENOMEM ;/* Internal bios can be at most the sectors signaled by the device. */ - pblk->page_bio_pool =mempool_create_page_pool (nvm_max_phys_sects (dev), -0 ); + pblk->page_bio_pool =mempool_create_page_pool (NVM_MAX_VLBA ,0 );if (!pblk->page_bio_pool) goto free_global_caches;
@@ -716,12 +715,12 @@ static int pblk_lines_init(struct pblk *pblk) pblk->min_write_pgs = geo->sec_per_pl * (geo->sec_size /PAGE_SIZE ); max_write_ppas = pblk->min_write_pgs * geo->all_luns; - pblk->max_write_pgs = (max_write_ppas <nvm_max_phys_sects (dev)) ? - max_write_ppas :nvm_max_phys_sects (dev); + pblk->max_write_pgs =min_t (int, max_write_ppas,NVM_MAX_VLBA );pblk_set_sec_per_write (pblk, pblk->min_write_pgs);if (pblk->max_write_pgs >PBLK_MAX_REQ_ADDRS ) { -pr_err ("pblk: cannot support device max_phys_sect\n" ); +pr_err ("pblk: vector list too big(%u > %u)\n" , + pblk->max_write_pgs,PBLK_MAX_REQ_ADDRS );return -EINVAL ; }
drivers/lightnvm/pblk-recovery.c +2 -6
@@ -21,17 +21,15 @@ void pblk_submit_rec(struct work_struct *work)struct pblk_rec_ctx *recovery = container_of(work, struct pblk_rec_ctx, ws_rec);struct pblk *pblk = recovery->pblk; -struct nvm_tgt_dev *dev = pblk->dev;struct nvm_rq *rqd = recovery->rqd;struct pblk_c_ctx *c_ctx =nvm_rq_to_pdu (rqd); -int max_secs =nvm_max_phys_sects (dev);struct bio *bio;unsigned int nr_rec_secs;unsigned int pgs_read;int ret; nr_rec_secs =bitmap_weight ((unsigned long int *)&rqd->ppa_status, - max_secs); +NVM_MAX_VLBA ); bio =bio_alloc (GFP_KERNEL , nr_rec_secs);
@@ -74,8 +72,6 @@ int pblk_recov_setup_rq(struct pblk *pblk, struct pblk_c_ctx *c_ctx, struct pblk_rec_ctx *recovery, u64 *comp_bits, unsigned int comp) { - struct nvm_tgt_dev *dev = pblk->dev; -int max_secs =nvm_max_phys_sects (dev); struct nvm_rq *rec_rqd;struct pblk_c_ctx *rec_ctx;int nr_entries = c_ctx->nr_valid + c_ctx->nr_padded;
@@ -86,7 +82,7 @@ int pblk_recov_setup_rq(struct pblk *pblk, struct pblk_c_ctx *c_ctx,/* Copy completion bitmap, but exclude the first X completed entries */ bitmap_shift_right ((unsigned long int *)&rec_rqd->ppa_status, (unsigned long int *)comp_bits, - comp, max_secs); + comp,NVM_MAX_VLBA );/* Save the context for the entries that need to be re-written and * update current context with the completed entries.
drivers/nvme/host/lightnvm.c +1 -4
@@ -612,8 +612,6 @@ static struct nvm_dev_ops nvme_nvm_dev_ops = { .destroy_dma_pool = nvme_nvm_destroy_dma_pool, .dev_dma_alloc = nvme_nvm_dev_dma_alloc, .dev_dma_free = nvme_nvm_dev_dma_free, - - .max_phys_sect = 64, }; static int nvme_nvm_submit_user_cmd(struct request_queue *q,
@@ -932,8 +930,7 @@ static ssize_t nvm_dev_attr_show_12(struct device *dev, }else if (strcmp (attr->name,"media_capabilities" ) ==0 ) {return scnprintf (page,PAGE_SIZE ,"0x%08x\n" , id->mccap); }else if (strcmp (attr->name,"max_phys_secs" ) ==0 ) { -return scnprintf (page,PAGE_SIZE ,"%u\n" , - ndev->ops->max_phys_sect); +return scnprintf (page,PAGE_SIZE ,"%u\n" ,NVM_MAX_VLBA ); }else { return scnprintf(page, PAGE_SIZE,
include/linux/lightnvm.h +2 -3
@@ -73,8 +73,6 @@ struct nvm_dev_ops {nvm_destroy_dma_pool_fn *destroy_dma_pool;nvm_dev_dma_alloc_fn *dev_dma_alloc;nvm_dev_dma_free_fn *dev_dma_free; - -unsigned int max_phys_sect; };#ifdef CONFIG_NVM
@@ -228,6 +226,8 @@ struct nvm_target {#define NVM_VERSION_MINOR 0#define NVM_VERSION_PATCH 0 +#define NVM_MAX_VLBA (64)/* max logical blocks in a vector command */ +struct nvm_rq ;typedef void (nvm_end_io_fn )(struct nvm_rq *);
@@ -436,7 +436,6 @@ extern void nvm_unregister(struct nvm_dev *);extern int nvm_set_tgt_bb_tbl (struct nvm_tgt_dev *,struct ppa_addr *,int ,int ); -extern int nvm_max_phys_sects (struct nvm_tgt_dev *);extern int nvm_submit_io (struct nvm_tgt_dev *,struct nvm_rq *);extern int nvm_submit_io_sync (struct nvm_tgt_dev *,struct nvm_rq *);extern void nvm_end_io (struct nvm_rq *);
Signature · 1 line
2.11.0
Re: [PATCH v2 5/6] lightnvm: remove nvm_dev_ops->max_phys_sect
Quoted 7 lines · Matias Bj?rling
The value of
max_phys_sectis always static. Instead of defining it in thenvm_dev_opsstructure, declare it as a global value.
Quoted 9 lines
Signed-off-by Matias Bj?rling <mb at lightnvm.io>---
drivers/lightnvm/core.c | 28 +++++++--------------------- drivers/lightnvm/pblk-init.c | 9 ++++----- drivers/lightnvm/pblk-recovery.c | 8 ++------ drivers/nvme/host/lightnvm.c | 5 +---- include/linux/lightnvm.h | 5 ++--- 5 files changed, 16 insertions(+), 39 deletions(-)
The patch looks good, but I have a question. If a target implements the scalar interface, then it will not be limited to 64 lbas/ppas and it will not make sense to split the bio base don this value. In fact, it looks like in time, we will move to a scalar interface in the 2.0 path to align with the zoned interface, so this value will be dependent on whether the target is using the scalar or vector interface.
Javier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20180216/0af427e0/attachment.sig>
Re: [PATCH v2 5/6] lightnvm: remove nvm_dev_ops->max_phys_sect
Quoted 17 lines · Javier Gonzalez
Quoted 7 lines · Matias Bj?rling
The value of
max_phys_sectis always static. Instead of defining it in thenvm_dev_opsstructure, declare it as a global value.Quoted 9 lines
Signed-off-by Matias Bj?rling <mb at lightnvm.io>---
drivers/lightnvm/core.c | 28 +++++++--------------------- drivers/lightnvm/pblk-init.c | 9 ++++----- drivers/lightnvm/pblk-recovery.c | 8 ++------ drivers/nvme/host/lightnvm.c | 5 +---- include/linux/lightnvm.h | 5 ++--- 5 files changed, 16 insertions(+), 39 deletions(-)
Quoted 7 lines
The patch looks good, but I have a question. If a target implements the scalar interface, then it will not be limited to 64 lbas/ppas and it will not make sense to split the bio base don this value. In fact, it looks like in time, we will move to a scalar interface in the 2.0 path to align with the zoned interface, so this value will be dependent on whether the target is using the scalar or vector interface.
Both read/write and vector interface will coexist. I am only removing what is hardwired into the specification.
The read/write interface has always been able issue more than 64 LBAs, it is instead limited by what the hardware reports its max transfer size to be.
Javier Gonzalez
Reviewed-byRe: [PATCH v2 5/6] lightnvm: remove nvm_dev_ops->max_phys_sect
Quoted 24 lines · Matias Bj?rling
Quoted 14 lines · Javier Gonzalez
Quoted 6 lines · Matias Bj?rling
The value of
max_phys_sectis always static. Instead of defining it in thenvm_dev_opsstructure, declare it as a global value.Quoted 8 lines
Signed-off-by Matias Bj?rling <mb at lightnvm.io>---
drivers/lightnvm/core.c | 28 +++++++--------------------- drivers/lightnvm/pblk-init.c | 9 ++++----- drivers/lightnvm/pblk-recovery.c | 8 ++------ drivers/nvme/host/lightnvm.c | 5 +---- include/linux/lightnvm.h | 5 ++--- 5 files changed, 16 insertions(+), 39 deletions(-)Quoted 6 lines
The patch looks good, but I have a question. If a target implements the scalar interface, then it will not be limited to 64 lbas/ppas and it will not make sense to split the bio base don this value. In fact, it looks like in time, we will move to a scalar interface in the 2.0 path to align with the zoned interface, so this value will be dependent on whether the target is using the scalar or vector interface.
Quoted 7 lines
Both read/write and vector interface will coexist. I am only removing what is hardwired into the specification.
The read/write interface has always been able issue more than 64 LBAs, it is instead limited by what the hardware reports its max transfer size to be.
Exactly. I was thinking of a similar mechanism for the vector interface to simplify integration with the scalar interface and avoid having an if/else for what we now call max_phys_sect.
I guess we can wait and see what the code looks like when we adapt pblk.
Javier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20180219/3e1e46fe/attachment-0001.sig>
PATCH v2 6/6 nvme: lightnvm: add late setup of block size and metadata
In reply to Matias BjørlingThe 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/lightnvm/core.c | 3 --- drivers/nvme/host/core.c | 2 ++ drivers/nvme/host/lightnvm.c | 8 ++++++++ drivers/nvme/host/nvme.h | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-)
drivers/lightnvm/core.c +0 -3
@@ -864,8 +864,6 @@ static int nvm_core_init(struct nvm_dev *dev) 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->sec_per_chk = id->clba;
@@ -893,7 +891,6 @@ static int nvm_core_init(struct nvm_dev *dev)if (ret) goto err_fmtype; -blk_queue_logical_block_size (dev->q, geo->sec_size);return 0 ; err_fmtype:kfree (dev->lun_map);
drivers/nvme/host/core.c +2 -0
@@ -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
@@ -812,6 +812,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
@@ -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
Quoted 50 lines · Matias Bj?rling
A couple of patches for 2.0 support for the lightnvm subsystem. They form the foundation for the integration.
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 next two patches removes
max_phys_sectandmax_rq_size, as they not used.The last patch implements support for using the nvme namespace logical block and metadata fields and sync it with the internal lightnvm identify structures.
Changes since v2:
- Removed
blk_queue_block_size()setup innvm_initand made sure to only update csecs and sos in on the late setup path. No reason to set it twice. From discussion with Javier.
- Added two extra patches, that removesmax_phys_sectandmax_rq_size.Changes since v1:
-
pr_errfix from Randy.
- Address type fix from Javier.
- Also CC the nvme mailing list.Matias Bj?rling (6):
lightnvm: make 1.2 data structures explicit
lightnvm: flattennvm_id_groupintonvm_id
lightnvm: add 2.0 geometry identification
lightnvm: removemax_rq_size
lightnvm: removenvm_dev_ops->max_phys_sect
nvme: lightnvm: add late setup of block size and metadatadrivers/lightnvm/core.c | 61 ++--- drivers/lightnvm/pblk-init.c | 9 +- drivers/lightnvm/pblk-recovery.c | 8 +- drivers/nvme/host/core.c | 2 + drivers/nvme/host/lightnvm.c | 513 ++++++++++++++++++++++++++++----------- drivers/nvme/host/nvme.h | 2 + include/linux/lightnvm.h | 71 +++--- 7 files changed, 442 insertions(+), 224 deletions(-)
Quoted 3 lines
--
2.11.0
The patches look good. I tested them together with pblk's 2.0 support and all works as it should.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20180221/ab00a287/attachment-0001.sig>