LightNVM updates for next 4.5-rc
Subsystems (2)
v2 cover LightNVM updates for next 4.5-rc
Hi Jens,
(Sorry for double post. Missed Signed-off-by)
A couple of patches to fix a couple of bugs.
One patch from Javier that fixes intersection locking after multi page functionality was added and another that adds a warning if interrupts are disabled during address locking.
A patch from Wenwei that makes sure we return bio if mempool allocation fails.
Two patches from me. One that fixes calculation of MLC memory pairs for lower page table and another that allows the null_blk to have a media manager added without having a storage backend.
Please pick up when convenient.
Thanks,
Matias
Javier González (2):
lightnvm: warn if irqs are disabled in lock laddr
lightnvm: fix request intersection locking in rrpc
Matias Bjørling (2):
lightnvm: check overflow and correct mlc pairs
lightnvm: allow to force mm initialization
Wenwei Tao (1):
lightnvm: put bio before return
drivers/block/null_blk.c | 2 +- drivers/lightnvm/core.c | 25 ++++++++++++++++--------- drivers/lightnvm/rrpc.c | 4 +++- drivers/lightnvm/rrpc.h | 5 +++-- drivers/nvme/host/lightnvm.c | 12 +++++++++--- include/linux/lightnvm.h | 4 ++++ 6 files changed, 36 insertions(+), 16 deletions(-)
Signature · 1 line
2.1.4
PATCH v2 1/5 lightnvm: put bio before return
From: Wenwei Tao <[email protected]>
The bio is not returned if the data page cannot be allocated.
--- drivers/lightnvm/rrpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/lightnvm/rrpc.c +3 -1
@@ -300,8 +300,10 @@ static int rrpc_move_valid_pages(struct rrpc *rrpc, struct rrpc_block *rblk) } page =mempool_alloc (rrpc->page_pool,GFP_NOIO ); -if (!page) +if (!page) { +bio_put (bio);return -ENOMEM ; + }while ((slot =find_first_zero_bit (rblk->invalid_pages, nr_pgs_per_blk)) < nr_pgs_per_blk) {
Signature · 1 line
2.1.4
PATCH v2 2/5 lightnvm: warn if irqs are disabled in lock laddr
In reply to Matias BjørlingFrom: Javier González <[email protected]>
Add a warning if irqs are disabled when locking a new address in rrpc. The typical path to a new request does not disable irqs, but this is not guaranteed in the future.
--- drivers/lightnvm/rrpc.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/lightnvm/rrpc.h +2 -0
@@ -184,6 +184,8 @@ static int __rrpc_lock_laddr(struct rrpc *rrpc, sector_t laddr,sector_t laddr_end = laddr + pages -1 ;struct rrpc_inflight_rq *rtmp; +WARN_ON (irqs_disabled ()); +spin_lock_irq (&rrpc->inflights.lock);list_for_each_entry (rtmp, &rrpc->inflights.reqs, list) {if (unlikely (request_intersects (rtmp, laddr, laddr_end))) {
Signature · 1 line
2.1.4
PATCH v2 3/5 lightnvm: fix request intersection locking in rrpc
In reply to Matias BjørlingFrom: Javier González <[email protected]>
This patch fixes an error on the calculation of intersecting logical addresses; it contemplates the case where a new request including several addresses intersects with a single locked address. This case is typical when multiple pages are sent in a new request, while GC - which at the moment sends one address at the time - is running.
--- drivers/lightnvm/rrpc.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/lightnvm/rrpc.h +1 -2
@@ -174,8 +174,7 @@ static inline sector_t rrpc_get_sector(sector_t laddr)static inline int request_intersects (struct rrpc_inflight_rq *r,sector_t laddr_start,sector_t laddr_end) { -return (laddr_end >= r->l_start && laddr_end <= r->l_end) && - (laddr_start >= r->l_start && laddr_start <= r->l_end); +return (laddr_end >= r->l_start) && (laddr_start <= r->l_end); } static int __rrpc_lock_laddr(struct rrpc *rrpc, sector_t laddr,
Signature · 1 line
2.1.4
PATCH v2 4/5 lightnvm: check overflow and correct mlc pairs
In reply to Matias BjørlingThe specification currently limits the number of MLC pairs to 886. Make sure that a device is unable to be instantiate if more is configured.
Also, previously the patch had the wrong math for copying MLC pairs, as it only copied half of the actual entries.
--- drivers/nvme/host/lightnvm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/nvme/host/lightnvm.c +9 -3
@@ -146,9 +146,10 @@ struct nvme_nvm_command { }; }; +#define NVME_NVM_LP_MLC_PAIRS 886struct nvme_nvm_lp_mlc {__u16 num_pairs; -__u8 pairs[886 ]; +__u8 pairs[NVME_NVM_LP_MLC_PAIRS ]; };struct nvme_nvm_lp_tbl {
@@ -282,9 +283,14 @@ static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id)memcpy (dst->lptbl.id, src->lptbl.id,8 ); dst->lptbl.mlc.num_pairs =le16_to_cpu (src->lptbl.mlc.num_pairs); -/* 4 bits per pair */ + +if (dst->lptbl.mlc.num_pairs >NVME_NVM_LP_MLC_PAIRS ) { +pr_err ("nvm: number of MLC pairs not supported\n" ); +return -EINVAL ; + } +memcpy (dst->lptbl.mlc.pairs, src->lptbl.mlc.pairs, - dst->lptbl.mlc.num_pairs >>1 ); + dst->lptbl.mlc.num_pairs); } }
Signature · 1 line
2.1.4
PATCH v2 5/5 lightnvm: allow to force mm initialization
In reply to Matias BjørlingSystem block allows the device to initialize with its configured media manager. The system blocks is written to disk, and read again when media manager is determined. For this to work, the backend must store the data. Device drivers, such as null_blk, does not have any backend storage. This patch allows the media manager to be initialized without a storage backend.
It also fix incorrect configuration of capabilities in null_blk, as it does not support get/set bad block interface.
--- drivers/block/null_blk.c | 2 +- drivers/lightnvm/core.c | 25 ++++++++++++++++--------- include/linux/lightnvm.h | 4 ++++ 3 files changed, 21 insertions(+), 10 deletions(-)
drivers/block/null_blk.c +1 -1
@@ -478,7 +478,7 @@ static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id) id->ver_id =0x1 ; id->vmnt =0 ; id->cgrps =1 ; - id->cap =0x3 ; + id->cap =0x2 ; id->dom =0x1 ; id->ppaf.blk_offset =0 ;
drivers/lightnvm/core.c +16 -9
@@ -568,11 +568,13 @@ int nvm_register(struct request_queue *q, char *disk_name, } } - ret =nvm_get_sysblock (dev, &dev->sb); -if (!ret) -pr_err ("nvm: device not initialized.\n" ); -else if (ret <0 ) -pr_err ("nvm: err (%d) on device initialization\n" , ret); +if (dev->identity.cap &NVM_ID_DCAP_BBLKMGMT ) { + ret =nvm_get_sysblock (dev, &dev->sb); +if (!ret) +pr_err ("nvm: device not initialized.\n" ); +else if (ret <0 ) +pr_err ("nvm: err (%d) on device initialization\n" , ret); + }/* register device with a supported media manager */ down_write (&nvm_lock);
@@ -1051,9 +1053,11 @@ static long __nvm_ioctl_dev_init(struct nvm_ioctl_dev_init *init)strncpy (info.mmtype, init->mmtype,NVM_MMTYPE_LEN ); info.fs_ppa.ppa =-1 ; - ret =nvm_init_sysblock (dev, &info); -if (ret) -return ret; +if (dev->identity.cap &NVM_ID_DCAP_BBLKMGMT ) { + ret =nvm_init_sysblock (dev, &info); +if (ret) +return ret; + }memcpy (&dev->sb, &info,sizeof (struct nvm_sb_info ));
@@ -1113,7 +1117,10 @@ static long nvm_ioctl_dev_factory(struct file *file, void __user *arg) dev->mt =NULL ; } -return nvm_dev_factory (dev, fact.flags); +if (dev->identity.cap &NVM_ID_DCAP_BBLKMGMT ) +return nvm_dev_factory (dev, fact.flags); + +return 0 ; }static long nvm_ctl_ioctl (struct file *file,uint cmd,unsigned long arg)
include/linux/lightnvm.h +4 -0
@@ -135,6 +135,10 @@ enum {/* Memory types */ NVM_ID_FMTYPE_SLC =0 ,NVM_ID_FMTYPE_MLC =1 , + +/* Device capabilities */ +NVM_ID_DCAP_BBLKMGMT =0x1 , + NVM_UD_DCAP_ECC = 0x2, }; struct nvm_id_lp_mlc {
Signature · 1 line
2.1.4
Jens Axboe
AppliedQuoted 10 lines · Matias Bjørling
Hi Jens,
(Sorry for double post. Missed Signed-off-by)
A couple of patches to fix a couple of bugs.
One patch from Javier that fixes intersection locking after multi page functionality was added and another that adds a warning if interrupts are disabled during address locking.
Quoted 8 lines
A patch from Wenwei that makes sure we return bio if mempool allocation fails.
Two patches from me. One that fixes calculation of MLC memory pairs for lower page table and another that allows the
null_blkto have a media manager added without having a storage backend.Please pick up when convenient.
Applied, thanks.
Signature · 1 line
Jens Axboe