All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matias Bjørling" <mb@lightnvm.io>
To: axboe@fb.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Matias Bjørling" <mb@lightnvm.io>
Subject: [GIT PULL 10/45] lightnvm: pblk: refactor put line fn on read completion
Date: Tue,  9 Oct 2018 13:11:40 +0200	[thread overview]
Message-ID: <20181009111215.7653-11-mb@lightnvm.io> (raw)
In-Reply-To: <20181009111215.7653-1-mb@lightnvm.io>

The read completion path uses the put_line variable to decide whether
the reference on a line should be released. The function name used for
that is pblk_read_put_rqd_kref, which could lead one to believe that it
is the rqd that is releasing the reference, while it is the line
reference that is put.

Rename and also split the function in two to account for either rqd or
single ppa callers and move it to core, such that it later can be used
in the write path as well.

Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Reviewed-by: Javier González <javier@cnexlabs.com>
Reviewed-by: Heiner Litz <hlitz@ucsc.edu>
---
 drivers/lightnvm/pblk-core.c | 19 +++++++++++++++++++
 drivers/lightnvm/pblk-read.c | 18 +-----------------
 drivers/lightnvm/pblk.h      |  2 ++
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index e0b513d07e14..5f99cf396072 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -1426,6 +1426,25 @@ struct pblk_line *pblk_line_get_first_data(struct pblk *pblk)
 	return line;
 }
 
+void pblk_ppa_to_line_put(struct pblk *pblk, struct ppa_addr ppa)
+{
+	struct pblk_line *line;
+
+	line = &pblk->lines[pblk_ppa_to_line(ppa)];
+	kref_put(&line->ref, pblk_line_put_wq);
+}
+
+void pblk_rq_to_line_put(struct pblk *pblk, struct nvm_rq *rqd)
+{
+	struct ppa_addr *ppa_list;
+	int i;
+
+	ppa_list = (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr;
+
+	for (i = 0; i < rqd->nr_ppas; i++)
+		pblk_ppa_to_line_put(pblk, ppa_list[i]);
+}
+
 static void pblk_stop_writes(struct pblk *pblk, struct pblk_line *line)
 {
 	lockdep_assert_held(&pblk->l_mg.free_lock);
diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c
index ba3dcb6be4c3..ad1d7713bbda 100644
--- a/drivers/lightnvm/pblk-read.c
+++ b/drivers/lightnvm/pblk-read.c
@@ -165,22 +165,6 @@ static void pblk_read_check_rand(struct pblk *pblk, struct nvm_rq *rqd,
 	WARN_ONCE(j != rqd->nr_ppas, "pblk: corrupted random request\n");
 }
 
-static void pblk_read_put_rqd_kref(struct pblk *pblk, struct nvm_rq *rqd)
-{
-	struct ppa_addr *ppa_list;
-	int i;
-
-	ppa_list = (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr;
-
-	for (i = 0; i < rqd->nr_ppas; i++) {
-		struct ppa_addr ppa = ppa_list[i];
-		struct pblk_line *line;
-
-		line = &pblk->lines[pblk_ppa_to_line(ppa)];
-		kref_put(&line->ref, pblk_line_put_wq);
-	}
-}
-
 static void pblk_end_user_read(struct bio *bio)
 {
 #ifdef CONFIG_NVM_PBLK_DEBUG
@@ -208,7 +192,7 @@ static void __pblk_end_io_read(struct pblk *pblk, struct nvm_rq *rqd,
 		bio_put(int_bio);
 
 	if (put_line)
-		pblk_read_put_rqd_kref(pblk, rqd);
+		pblk_rq_to_line_put(pblk, rqd);
 
 #ifdef CONFIG_NVM_PBLK_DEBUG
 	atomic_long_add(rqd->nr_ppas, &pblk->sync_reads);
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index 64ae0c7ed3bb..be67bbfa3d0a 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -787,6 +787,8 @@ struct bio *pblk_bio_map_addr(struct pblk *pblk, void *data,
 struct pblk_line *pblk_line_get(struct pblk *pblk);
 struct pblk_line *pblk_line_get_first_data(struct pblk *pblk);
 struct pblk_line *pblk_line_replace_data(struct pblk *pblk);
+void pblk_ppa_to_line_put(struct pblk *pblk, struct ppa_addr ppa);
+void pblk_rq_to_line_put(struct pblk *pblk, struct nvm_rq *rqd);
 int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line);
 void pblk_line_recov_close(struct pblk *pblk, struct pblk_line *line);
 struct pblk_line *pblk_line_get_data(struct pblk *pblk);
-- 
2.17.1

  parent reply	other threads:[~2018-10-09 18:30 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 11:11 [GIT PULL 00/45] lightnvm updates for 4.20 Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 01/45] lightnvm: remove dependencies on BLK_DEV_NVME and PCI Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 02/45] lightnvm: combine 1.2 and 2.0 command flags Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 03/45] lightnvm: pblk: fix rqd.error return value in pblk_blk_erase_sync Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 04/45] lightnvm: move device L2P detection to core Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 05/45] lightnvm: pblk: fix race condition on metadata I/O Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 06/45] lightnvm: move bad block and chunk state logic to core Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 07/45] lightnvm: pblk: unify vector max req constants Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 08/45] lightnvm: pblk: fix incorrect min_write_pgs Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 09/45] lightnvm: pblk: remove size and out of bounds read check Matias Bjørling
2018-10-09 11:11 ` Matias Bjørling [this message]
2018-10-09 11:11 ` [GIT PULL 11/45] lightnvm: pblk: add helpers for chunk addresses Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 12/45] lightnvm: pblk: improve line helpers Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 13/45] lightnvm: pblk: fix comment typo Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 14/45] lightnvm: pblk: remove unused variable Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 15/45] lightnvm: pblk: guarantee emeta on line close Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 16/45] lightnvm: introduce nvm_rq_to_ppa_list Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 17/45] lightnvm: pblk: allocate line map bitmaps using a mempool Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 18/45] lightnvm: pblk: remove unused parameters in pblk_up_rq Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 19/45] lightnvm: pblk: fix up prints in pblk_read_check_rand Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 20/45] lightnvm: pblk: fix write amplificiation calculation Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 21/45] lightnvm: pblk: remove debug from pblk_[down/up]_page Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 22/45] lightnvm: pblk: add trace events for chunk states Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 23/45] lightnvm: pblk: add trace events for line state changes Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 24/45] lightnvm: pblk: add trace events for pblk " Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 25/45] lightnvm: pblk: add tracing for chunk resets Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 26/45] lightnvm: move ppa transformations to core Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 27/45] lightnvm: pblk: calculate line pad distance in helper Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 28/45] lightnvm: pblk: stop recreating global caches Matias Bjørling
2018-10-09 11:11 ` [GIT PULL 29/45] lightnvm: pblk: fix mapping issue on failed writes Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 30/45] lightnvm: pblk: fix two sleep-in-atomic-context bugs Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 31/45] lightnvm: use internal allocation for chunk log page Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 32/45] lightnvm: pblk: encapsulate rqd dma allocations Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 33/45] lightnvm: pblk: refactor metadata paths Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 34/45] lightnvm: pblk: take write semaphore on metadata Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 35/45] lightnvm: pblk: recover open lines on 2.0 devices Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 36/45] lightnvm: pblk: add SPDX license tag Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 37/45] lightnvm: pblk: fix race on sysfs line state Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 38/45] lightnvm: pblk: remove unused function Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 39/45] lightnvm: pblk: encapsulate rb pointer operations Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 40/45] lightnvm: pblk: move ring buffer alloc/free rb init Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 41/45] lightnvm: pblk: guarantee mw_cunits on read buffer Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 42/45] lightnvm: do no update csecs and sos on 1.2 Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 43/45] lightnvm: pblk: fix error handling of pblk_lines_init() Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 44/45] lightnvm: pblk: consider max hw sectors supported for max_write_pgs Matias Bjørling
2018-10-09 11:12 ` [GIT PULL 45/45] lightnvm: pblk: guarantee that backpointer is respected on writer stall Matias Bjørling
2018-10-09 14:25 ` [GIT PULL 00/45] lightnvm updates for 4.20 Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181009111215.7653-11-mb@lightnvm.io \
    --to=mb@lightnvm.io \
    --cc=axboe@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.