Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1387350 > unrolled thread

[PATCH 0/5] LightNVM fixes

Started byMatias Bjørling <m@bjorling.me>
First post2016-04-26 12:40 +0200
Last post2016-04-26 17:00 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/5] LightNVM fixes Matias Bjørling <m@bjorling.me> - 2016-04-26 12:40 +0200
    [PATCH 4/5] lightnvm: make nvm_set_rqd_ppalist() aware of vblks Matias Bjørling <m@bjorling.me> - 2016-04-26 12:40 +0200
    [PATCH 3/5] lightnvm: remove struct factory_blks Matias Bjørling <m@bjorling.me> - 2016-04-26 12:40 +0200
    Re: [PATCH 0/5] LightNVM fixes Jens Axboe <axboe@kernel.dk> - 2016-04-26 16:40 +0200
      Re: [PATCH 0/5] LightNVM fixes Matias Bjørling <m@bjorling.me> - 2016-04-26 17:00 +0200

#1387350 — [PATCH 0/5] LightNVM fixes

FromMatias Bjørling <m@bjorling.me>
Date2016-04-26 12:40 +0200
Subject[PATCH 0/5] LightNVM fixes
Message-ID<rs8zo-652-17@gated-at.bofh.it>
Hi,

A couple of patches for the 4.7 cycle. The first three are cleanups for
iterating ppas, better get_bb_tbl interface and removal of struct
factory_blks. The forth patch enables the caller to control if mapping
should by a single plane or multiple planes. The last patch fixes a bug
when unfolding a virtual block onto multiple die planes.

Matias Bjørling (5):
  lightnvm: introduce nvm_for_each_lun_ppa() macro
  lightnvm: refactor device ops->get_bb_tbl()
  lightnvm: remove struct factory_blks
  lightnvm: make nvm_set_rqd_ppalist() aware of vblks
  lightnvm: set block priority in nvm_set_rqd_ppalist()

 drivers/lightnvm/core.c      |  40 ++++---
 drivers/lightnvm/gennvm.c    |  29 +++--
 drivers/lightnvm/sysblk.c    | 248 +++++++++++++++++++++----------------------
 drivers/nvme/host/lightnvm.c |   6 +-
 include/linux/lightnvm.h     |  15 ++-
 5 files changed, 179 insertions(+), 159 deletions(-)

-- 
2.1.4

[toc] | [next] | [standalone]


#1387351 — [PATCH 4/5] lightnvm: make nvm_set_rqd_ppalist() aware of vblks

FromMatias Bjørling <m@bjorling.me>
Date2016-04-26 12:40 +0200
Subject[PATCH 4/5] lightnvm: make nvm_set_rqd_ppalist() aware of vblks
Message-ID<rs8zp-652-41@gated-at.bofh.it>
In reply to#1387350
A virtual block enables a block to identify multiple physical blocks.
This is useful for metadata where a device media supports multiple
planes. In that case, a block, with multiple planes can be managed
as a single vblk. Reducing the metadata required by one forth.

nvm_set_rqd_ppalist() takes care of expanding a ppa_list with vblks
automatically. However, for some use-cases, where only a single physical
block is required, the ppa_list should not be expanded.

Therefore, add a vblk parameter to nvm_set_rqd_ppalist(), and only
expand the ppa_list if vblk is set.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/lightnvm/core.c   | 31 +++++++++++++++++--------------
 drivers/lightnvm/sysblk.c |  2 +-
 include/linux/lightnvm.h  |  2 +-
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index e6d7a98..de5db7b 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -251,33 +251,36 @@ void nvm_generic_to_addr_mode(struct nvm_dev *dev, struct nvm_rq *rqd)
 EXPORT_SYMBOL(nvm_generic_to_addr_mode);
 
 int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd,
-					struct ppa_addr *ppas, int nr_ppas)
+				struct ppa_addr *ppas, int nr_ppas, int vblk)
 {
 	int i, plane_cnt, pl_idx;
 
-	if (dev->plane_mode == NVM_PLANE_SINGLE && nr_ppas == 1) {
-		rqd->nr_pages = 1;
+	if ((!vblk || dev->plane_mode == NVM_PLANE_SINGLE) && nr_ppas == 1) {
+		rqd->nr_pages = nr_ppas;
 		rqd->ppa_addr = ppas[0];
 
 		return 0;
 	}
 
-	plane_cnt = dev->plane_mode;
-	rqd->nr_pages = plane_cnt * nr_ppas;
-
-	if (dev->ops->max_phys_sect < rqd->nr_pages)
-		return -EINVAL;
-
+	rqd->nr_pages = nr_ppas;
 	rqd->ppa_list = nvm_dev_dma_alloc(dev, GFP_KERNEL, &rqd->dma_ppa_list);
 	if (!rqd->ppa_list) {
 		pr_err("nvm: failed to allocate dma memory\n");
 		return -ENOMEM;
 	}
 
-	for (pl_idx = 0; pl_idx < plane_cnt; pl_idx++) {
+	if (!vblk) {
+		for (i = 0; i < nr_ppas; i++)
+			rqd->ppa_list[i] = ppas[i];
+	} else {
+		plane_cnt = dev->plane_mode;
+		rqd->nr_pages *= plane_cnt;
+
 		for (i = 0; i < nr_ppas; i++) {
-			ppas[i].g.pl = pl_idx;
-			rqd->ppa_list[(pl_idx * nr_ppas) + i] = ppas[i];
+			for (pl_idx = 0; pl_idx < plane_cnt; pl_idx++) {
+				ppas[i].g.pl = pl_idx;
+				rqd->ppa_list[(pl_idx * nr_ppas) + i] = ppas[i];
+			}
 		}
 	}
 
@@ -304,7 +307,7 @@ int nvm_erase_ppa(struct nvm_dev *dev, struct ppa_addr *ppas, int nr_ppas)
 
 	memset(&rqd, 0, sizeof(struct nvm_rq));
 
-	ret = nvm_set_rqd_ppalist(dev, &rqd, ppas, nr_ppas);
+	ret = nvm_set_rqd_ppalist(dev, &rqd, ppas, nr_ppas, 1);
 	if (ret)
 		return ret;
 
@@ -420,7 +423,7 @@ int nvm_submit_ppa(struct nvm_dev *dev, struct ppa_addr *ppa, int nr_ppas,
 	int ret;
 
 	memset(&rqd, 0, sizeof(struct nvm_rq));
-	ret = nvm_set_rqd_ppalist(dev, &rqd, ppa, nr_ppas);
+	ret = nvm_set_rqd_ppalist(dev, &rqd, ppa, nr_ppas, 1);
 	if (ret)
 		return ret;
 
diff --git a/drivers/lightnvm/sysblk.c b/drivers/lightnvm/sysblk.c
index bca6902..737fbc3 100644
--- a/drivers/lightnvm/sysblk.c
+++ b/drivers/lightnvm/sysblk.c
@@ -277,7 +277,7 @@ static int nvm_set_bb_tbl(struct nvm_dev *dev, struct sysblk_scan *s, int type)
 
 	memset(&rqd, 0, sizeof(struct nvm_rq));
 
-	nvm_set_rqd_ppalist(dev, &rqd, s->ppas, s->nr_ppas);
+	nvm_set_rqd_ppalist(dev, &rqd, s->ppas, s->nr_ppas, 1);
 	nvm_generic_to_addr_mode(dev, &rqd);
 
 	ret = dev->ops->set_bb_tbl(dev, &rqd, type);
diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h
index 16d4f2e..9ae0b7c 100644
--- a/include/linux/lightnvm.h
+++ b/include/linux/lightnvm.h
@@ -526,7 +526,7 @@ extern int nvm_submit_io(struct nvm_dev *, struct nvm_rq *);
 extern void nvm_generic_to_addr_mode(struct nvm_dev *, struct nvm_rq *);
 extern void nvm_addr_to_generic_mode(struct nvm_dev *, struct nvm_rq *);
 extern int nvm_set_rqd_ppalist(struct nvm_dev *, struct nvm_rq *,
-							struct ppa_addr *, int);
+						struct ppa_addr *, int, int);
 extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *);
 extern int nvm_erase_ppa(struct nvm_dev *, struct ppa_addr *, int);
 extern int nvm_erase_blk(struct nvm_dev *, struct nvm_block *);
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1387352 — [PATCH 3/5] lightnvm: remove struct factory_blks

FromMatias Bjørling <m@bjorling.me>
Date2016-04-26 12:40 +0200
Subject[PATCH 3/5] lightnvm: remove struct factory_blks
Message-ID<rs8zp-652-47@gated-at.bofh.it>
In reply to#1387350
Now that device ops->get_bb_table no longer uses a callback, the
struct factory_blks can be removed.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/lightnvm/sysblk.c | 62 +++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 34 deletions(-)

diff --git a/drivers/lightnvm/sysblk.c b/drivers/lightnvm/sysblk.c
index dc99c0a..bca6902 100644
--- a/drivers/lightnvm/sysblk.c
+++ b/drivers/lightnvm/sysblk.c
@@ -582,29 +582,23 @@ err_mark:
 	return ret;
 }
 
-struct factory_blks {
-	struct nvm_dev *dev;
-	int flags;
-	unsigned long *blks;
-};
-
 static int factory_nblks(int nblks)
 {
 	/* Round up to nearest BITS_PER_LONG */
 	return (nblks + (BITS_PER_LONG - 1)) & ~(BITS_PER_LONG - 1);
 }
 
-static unsigned int factory_blk_offset(struct nvm_dev *dev, int ch, int lun)
+static unsigned int factory_blk_offset(struct nvm_dev *dev, struct ppa_addr ppa)
 {
 	int nblks = factory_nblks(dev->blks_per_lun);
 
-	return ((ch * dev->luns_per_chnl * nblks) + (lun * nblks)) /
+	return ((ppa.g.ch * dev->luns_per_chnl * nblks) + (ppa.g.lun * nblks)) /
 								BITS_PER_LONG;
 }
 
 static int nvm_factory_blks(struct nvm_dev *dev, struct ppa_addr ppa,
 					u8 *blks, int nr_blks,
-					struct factory_blks *f)
+					unsigned long *blk_bitmap, int flags)
 {
 	int i, lunoff;
 
@@ -612,25 +606,25 @@ static int nvm_factory_blks(struct nvm_dev *dev, struct ppa_addr ppa,
 	if (nr_blks < 0)
 		return nr_blks;
 
-	lunoff = factory_blk_offset(dev, ppa.g.ch, ppa.g.lun);
+	lunoff = factory_blk_offset(dev, ppa);
 
 	/* non-set bits correspond to the block must be erased */
 	for (i = 0; i < nr_blks; i++) {
 		switch (blks[i]) {
 		case NVM_BLK_T_FREE:
-			if (f->flags & NVM_FACTORY_ERASE_ONLY_USER)
-				set_bit(i, &f->blks[lunoff]);
+			if (flags & NVM_FACTORY_ERASE_ONLY_USER)
+				set_bit(i, &blk_bitmap[lunoff]);
 			break;
 		case NVM_BLK_T_HOST:
-			if (!(f->flags & NVM_FACTORY_RESET_HOST_BLKS))
-				set_bit(i, &f->blks[lunoff]);
+			if (!(flags & NVM_FACTORY_RESET_HOST_BLKS))
+				set_bit(i, &blk_bitmap[lunoff]);
 			break;
 		case NVM_BLK_T_GRWN_BAD:
-			if (!(f->flags & NVM_FACTORY_RESET_GRWN_BBLKS))
-				set_bit(i, &f->blks[lunoff]);
+			if (!(flags & NVM_FACTORY_RESET_GRWN_BBLKS))
+				set_bit(i, &blk_bitmap[lunoff]);
 			break;
 		default:
-			set_bit(i, &f->blks[lunoff]);
+			set_bit(i, &blk_bitmap[lunoff]);
 			break;
 		}
 	}
@@ -639,7 +633,7 @@ static int nvm_factory_blks(struct nvm_dev *dev, struct ppa_addr ppa,
 }
 
 static int nvm_fact_get_blks(struct nvm_dev *dev, struct ppa_addr *erase_list,
-					int max_ppas, struct factory_blks *f)
+					int max_ppas, unsigned long *blk_bitmap)
 {
 	struct ppa_addr ppa;
 	int ch, lun, blkid, idx, done = 0, ppa_cnt = 0;
@@ -648,8 +642,8 @@ static int nvm_fact_get_blks(struct nvm_dev *dev, struct ppa_addr *erase_list,
 	while (!done) {
 		done = 1;
 		nvm_for_each_lun_ppa(dev, ppa, ch, lun) {
-			idx = factory_blk_offset(dev, ch, lun);
-			offset = &f->blks[idx];
+			idx = factory_blk_offset(dev, ppa);
+			offset = &blk_bitmap[idx];
 
 			blkid = find_first_zero_bit(offset,
 						dev->blks_per_lun);
@@ -675,10 +669,11 @@ static int nvm_fact_get_blks(struct nvm_dev *dev, struct ppa_addr *erase_list,
 	return ppa_cnt;
 }
 
-static int nvm_fact_select_blks(struct nvm_dev *dev, struct factory_blks *f)
+static int nvm_fact_select_blks(struct nvm_dev *dev, unsigned long *blk_bitmap,
+								int flags)
 {
 	struct ppa_addr ppa;
-	int ch, lun, nr_blks, ret;
+	int ch, lun, nr_blks, ret = 0;
 	u8 *blks;
 
 	nr_blks = dev->blks_per_lun * dev->plane_mode;
@@ -692,43 +687,42 @@ static int nvm_fact_select_blks(struct nvm_dev *dev, struct factory_blks *f)
 			pr_err("nvm: failed bb tbl for ch%u lun%u\n",
 							ppa.g.ch, ppa.g.blk);
 
-		ret = nvm_factory_blks(dev, ppa, blks, nr_blks, f);
+		ret = nvm_factory_blks(dev, ppa, blks, nr_blks, blk_bitmap,
+									flags);
 		if (ret)
-			return ret;
+			break;
 	}
 
 	kfree(blks);
-	return 0;
+	return ret;
 }
 
 int nvm_dev_factory(struct nvm_dev *dev, int flags)
 {
-	struct factory_blks f;
 	struct ppa_addr *ppas;
 	int ppa_cnt, ret = -ENOMEM;
 	int max_ppas = dev->ops->max_phys_sect / dev->nr_planes;
 	struct ppa_addr sysblk_ppas[MAX_SYSBLKS];
 	struct sysblk_scan s;
+	unsigned long *blk_bitmap;
 
-	f.blks = kzalloc(factory_nblks(dev->blks_per_lun) * dev->nr_luns,
+	blk_bitmap = kzalloc(factory_nblks(dev->blks_per_lun) * dev->nr_luns,
 								GFP_KERNEL);
-	if (!f.blks)
+	if (!blk_bitmap)
 		return ret;
 
 	ppas = kcalloc(max_ppas, sizeof(struct ppa_addr), GFP_KERNEL);
 	if (!ppas)
 		goto err_blks;
 
-	f.dev = dev;
-	f.flags = flags;
-
 	/* create list of blks to be erased */
-	ret = nvm_fact_select_blks(dev, &f);
+	ret = nvm_fact_select_blks(dev, blk_bitmap, flags);
 	if (ret)
 		goto err_ppas;
 
 	/* continue to erase until list of blks until empty */
-	while ((ppa_cnt = nvm_fact_get_blks(dev, ppas, max_ppas, &f)) > 0)
+	while ((ppa_cnt =
+			nvm_fact_get_blks(dev, ppas, max_ppas, blk_bitmap)) > 0)
 		nvm_erase_ppa(dev, ppas, ppa_cnt);
 
 	/* mark host reserved blocks free */
@@ -743,7 +737,7 @@ int nvm_dev_factory(struct nvm_dev *dev, int flags)
 err_ppas:
 	kfree(ppas);
 err_blks:
-	kfree(f.blks);
+	kfree(blk_bitmap);
 	return ret;
 }
 EXPORT_SYMBOL(nvm_dev_factory);
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1387541

FromJens Axboe <axboe@kernel.dk>
Date2016-04-26 16:40 +0200
Message-ID<rscjD-TC-9@gated-at.bofh.it>
In reply to#1387350
On 04/26/2016 04:31 AM, Matias Bjørling wrote:
> Hi,
>
> A couple of patches for the 4.7 cycle. The first three are cleanups for
> iterating ppas, better get_bb_tbl interface and removal of struct
> factory_blks. The forth patch enables the caller to control if mapping
> should by a single plane or multiple planes. The last patch fixes a bug
> when unfolding a virtual block onto multiple die planes.

What are these against? Patch #2 fails horribly on both for-4.7/drivers 
and current Linus' master.

-- 
Jens Axboe

[toc] | [prev] | [next] | [standalone]


#1387574

FromMatias Bjørling <m@bjorling.me>
Date2016-04-26 17:00 +0200
Message-ID<rscD0-11Z-17@gated-at.bofh.it>
In reply to#1387541
On 04/26/2016 04:35 PM, Jens Axboe wrote:
> On 04/26/2016 04:31 AM, Matias Bjørling wrote:
>> Hi,
>>
>> A couple of patches for the 4.7 cycle. The first three are cleanups for
>> iterating ppas, better get_bb_tbl interface and removal of struct
>> factory_blks. The forth patch enables the caller to control if mapping
>> should by a single plane or multiple planes. The last patch fixes a bug
>> when unfolding a virtual block onto multiple die planes.
>
> What are these against? Patch #2 fails horribly on both for-4.7/drivers
> and current Linus' master.
>

Ah yes, forgot to add what they were based upon. They are based on the 
https://github.com/OpenChannelSSD/linux.git for-next branch.

I wanted to post these before applying. Will send you a combined patch 
set around -rc6.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web