linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] LightNVM updates for next 4.5-rc
@ 2016-02-04 13:57 Matias Bjørling
  2016-02-04 13:57 ` [PATCH 1/5] lightnvm: put bio before return Matias Bjørling
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Matias Bjørling @ 2016-02-04 13:57 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe; +Cc: Matias Bjørling

Hi Jens,

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(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] lightnvm: put bio before return
  2016-02-04 13:57 [PATCH 0/5] LightNVM updates for next 4.5-rc Matias Bjørling
@ 2016-02-04 13:57 ` Matias Bjørling
  2016-02-04 13:57 ` [PATCH 2/5] lightnvm: warn if irqs are disabled in lock laddr Matias Bjørling
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Matias Bjørling @ 2016-02-04 13:57 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe; +Cc: Wenwei Tao

From: Wenwei Tao <ww.tao0320@gmail.com>

The bio is not returned if the data page cannot be allocated.

Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
---
 drivers/lightnvm/rrpc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
index c4d0b04..775bf6c2 100644
--- a/drivers/lightnvm/rrpc.c
+++ b/drivers/lightnvm/rrpc.c
@@ -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) {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] lightnvm: warn if irqs are disabled in lock laddr
  2016-02-04 13:57 [PATCH 0/5] LightNVM updates for next 4.5-rc Matias Bjørling
  2016-02-04 13:57 ` [PATCH 1/5] lightnvm: put bio before return Matias Bjørling
@ 2016-02-04 13:57 ` Matias Bjørling
  2016-02-04 13:57 ` [PATCH 3/5] lightnvm: fix request intersection locking in rrpc Matias Bjørling
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Matias Bjørling @ 2016-02-04 13:57 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe
  Cc: Javier González, Javier González

From: Javier González <jg@lightnvm.io>

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.

Signed-off-by: Javier González <javier@cnexlabs.com>
---
 drivers/lightnvm/rrpc.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/lightnvm/rrpc.h b/drivers/lightnvm/rrpc.h
index dfca5c4..c27283a 100644
--- a/drivers/lightnvm/rrpc.h
+++ b/drivers/lightnvm/rrpc.h
@@ -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))) {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] lightnvm: fix request intersection locking in rrpc
  2016-02-04 13:57 [PATCH 0/5] LightNVM updates for next 4.5-rc Matias Bjørling
  2016-02-04 13:57 ` [PATCH 1/5] lightnvm: put bio before return Matias Bjørling
  2016-02-04 13:57 ` [PATCH 2/5] lightnvm: warn if irqs are disabled in lock laddr Matias Bjørling
@ 2016-02-04 13:57 ` Matias Bjørling
  2016-02-04 13:57 ` [PATCH 4/5] lightnvm: check overflow and correct mlc pairs Matias Bjørling
  2016-02-04 13:57 ` [PATCH 5/5] lightnvm: allow to force mm initialization Matias Bjørling
  4 siblings, 0 replies; 7+ messages in thread
From: Matias Bjørling @ 2016-02-04 13:57 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe
  Cc: Javier González, Javier González

From: Javier González <jg@lightnvm.io>

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.

Signed-off-by: Javier González <javier@cnexlabs.com>
---
 drivers/lightnvm/rrpc.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/lightnvm/rrpc.h b/drivers/lightnvm/rrpc.h
index c27283a..3989d65 100644
--- a/drivers/lightnvm/rrpc.h
+++ b/drivers/lightnvm/rrpc.h
@@ -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,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] lightnvm: check overflow and correct mlc pairs
  2016-02-04 13:57 [PATCH 0/5] LightNVM updates for next 4.5-rc Matias Bjørling
                   ` (2 preceding siblings ...)
  2016-02-04 13:57 ` [PATCH 3/5] lightnvm: fix request intersection locking in rrpc Matias Bjørling
@ 2016-02-04 13:57 ` Matias Bjørling
  2016-02-04 13:57 ` [PATCH 5/5] lightnvm: allow to force mm initialization Matias Bjørling
  4 siblings, 0 replies; 7+ messages in thread
From: Matias Bjørling @ 2016-02-04 13:57 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe; +Cc: Matias Bjørling

The 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.

Fixes: ca5927e7ab53 "lightnvm: introduce mlc lower page table mappings"
---
 drivers/nvme/host/lightnvm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 0f0864f..55dab93 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -146,9 +146,10 @@ struct nvme_nvm_command {
 	};
 };
 
+#define NVME_NVM_LP_MLC_PAIRS 886
 struct 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);
 		}
 	}
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] lightnvm: allow to force mm initialization
  2016-02-04 13:57 [PATCH 0/5] LightNVM updates for next 4.5-rc Matias Bjørling
                   ` (3 preceding siblings ...)
  2016-02-04 13:57 ` [PATCH 4/5] lightnvm: check overflow and correct mlc pairs Matias Bjørling
@ 2016-02-04 13:57 ` Matias Bjørling
  4 siblings, 0 replies; 7+ messages in thread
From: Matias Bjørling @ 2016-02-04 13:57 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe; +Cc: Matias Bjørling

System 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(-)

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 8ba1e97..ae05d31 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -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;
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 5471cc5..c3d4b54 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -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)
diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h
index b94f2d5..08c1e14 100644
--- a/include/linux/lightnvm.h
+++ b/include/linux/lightnvm.h
@@ -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 {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] lightnvm: check overflow and correct mlc pairs
  2016-02-04 14:13 [PATCH v2 0/5] LightNVM updates for next 4.5-rc Matias Bjørling
@ 2016-02-04 14:13 ` Matias Bjørling
  0 siblings, 0 replies; 7+ messages in thread
From: Matias Bjørling @ 2016-02-04 14:13 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe; +Cc: Matias Bjørling

The 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.

Fixes: ca5927e7ab53 "lightnvm: introduce mlc lower page table mappings"
Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/nvme/host/lightnvm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 0f0864f..55dab93 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -146,9 +146,10 @@ struct nvme_nvm_command {
 	};
 };
 
+#define NVME_NVM_LP_MLC_PAIRS 886
 struct 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);
 		}
 	}
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-02-04 14:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-04 13:57 [PATCH 0/5] LightNVM updates for next 4.5-rc Matias Bjørling
2016-02-04 13:57 ` [PATCH 1/5] lightnvm: put bio before return Matias Bjørling
2016-02-04 13:57 ` [PATCH 2/5] lightnvm: warn if irqs are disabled in lock laddr Matias Bjørling
2016-02-04 13:57 ` [PATCH 3/5] lightnvm: fix request intersection locking in rrpc Matias Bjørling
2016-02-04 13:57 ` [PATCH 4/5] lightnvm: check overflow and correct mlc pairs Matias Bjørling
2016-02-04 13:57 ` [PATCH 5/5] lightnvm: allow to force mm initialization Matias Bjørling
2016-02-04 14:13 [PATCH v2 0/5] LightNVM updates for next 4.5-rc Matias Bjørling
2016-02-04 14:13 ` [PATCH 4/5] lightnvm: check overflow and correct mlc pairs Matias Bjørling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).