All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matias Bjørling" <m@bjorling.me>
To: axboe@fb.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Javier González" <javier@cnexlabs.com>,
	"Matias Bjørling" <m@bjorling.me>
Subject: [GIT PULL 21/58] lightnvm: pblk: remove checks on mempool alloc.
Date: Fri, 13 Oct 2017 14:46:10 +0200	[thread overview]
Message-ID: <20171013124647.32668-22-m@bjorling.me> (raw)
In-Reply-To: <20171013124647.32668-1-m@bjorling.me>

From: Javier González <javier@cnexlabs.com>

As part of the mempool audit on pblk, remove unnecessary mempool
allocation checks on mempools.

Reported-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/lightnvm/pblk-core.c     |  4 ----
 drivers/lightnvm/pblk-read.c     |  8 --------
 drivers/lightnvm/pblk-recovery.c | 35 +++++++----------------------------
 drivers/lightnvm/pblk-write.c    | 24 +++++-------------------
 4 files changed, 12 insertions(+), 59 deletions(-)

diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 215aadb..0da5886 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -206,8 +206,6 @@ int pblk_bio_add_pages(struct pblk *pblk, struct bio *bio, gfp_t flags,
 
 	for (i = 0; i < nr_pages; i++) {
 		page = mempool_alloc(pblk->page_bio_pool, flags);
-		if (!page)
-			goto err;
 
 		ret = bio_add_pc_page(q, bio, page, PBLK_EXPOSED_PAGE_SIZE, 0);
 		if (ret != PBLK_EXPOSED_PAGE_SIZE) {
@@ -1653,8 +1651,6 @@ void pblk_gen_run_ws(struct pblk *pblk, struct pblk_line *line, void *priv,
 	struct pblk_line_ws *line_ws;
 
 	line_ws = mempool_alloc(pblk->gen_ws_pool, gfp_mask);
-	if (!line_ws)
-		return;
 
 	line_ws->pblk = pblk;
 	line_ws->line = line;
diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c
index 402c732..d2b6e2a 100644
--- a/drivers/lightnvm/pblk-read.c
+++ b/drivers/lightnvm/pblk-read.c
@@ -168,10 +168,6 @@ static int pblk_fill_partial_read_bio(struct pblk *pblk, struct nvm_rq *rqd,
 	DECLARE_COMPLETION_ONSTACK(wait);
 
 	new_bio = bio_alloc(GFP_KERNEL, nr_holes);
-	if (!new_bio) {
-		pr_err("pblk: could not alloc read bio\n");
-		return NVM_IO_ERR;
-	}
 
 	if (pblk_bio_add_pages(pblk, new_bio, GFP_KERNEL, nr_holes))
 		goto err;
@@ -321,10 +317,6 @@ int pblk_submit_read(struct pblk *pblk, struct bio *bio)
 	bitmap_zero(&read_bitmap, nr_secs);
 
 	rqd = pblk_alloc_rqd(pblk, READ);
-	if (IS_ERR(rqd)) {
-		pr_err_ratelimited("pblk: not able to alloc rqd");
-		return NVM_IO_ERR;
-	}
 
 	rqd->opcode = NVM_OP_PREAD;
 	rqd->bio = bio;
diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
index de52707..6b6b418 100644
--- a/drivers/lightnvm/pblk-recovery.c
+++ b/drivers/lightnvm/pblk-recovery.c
@@ -34,10 +34,6 @@ void pblk_submit_rec(struct work_struct *work)
 								max_secs);
 
 	bio = bio_alloc(GFP_KERNEL, nr_rec_secs);
-	if (!bio) {
-		pr_err("pblk: not able to create recovery bio\n");
-		return;
-	}
 
 	bio->bi_iter.bi_sector = 0;
 	bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
@@ -85,11 +81,6 @@ int pblk_recov_setup_rq(struct pblk *pblk, struct pblk_c_ctx *c_ctx,
 	int nr_entries = c_ctx->nr_valid + c_ctx->nr_padded;
 
 	rec_rqd = pblk_alloc_rqd(pblk, WRITE);
-	if (IS_ERR(rec_rqd)) {
-		pr_err("pblk: could not create recovery req.\n");
-		return -ENOMEM;
-	}
-
 	rec_ctx = nvm_rq_to_pdu(rec_rqd);
 
 	/* Copy completion bitmap, but exclude the first X completed entries */
@@ -404,22 +395,18 @@ static int pblk_recov_pad_oob(struct pblk *pblk, struct pblk_line *line,
 	ppa_list = (void *)(meta_list) + pblk_dma_meta_size;
 	dma_ppa_list = dma_meta_list + pblk_dma_meta_size;
 
-	rqd = pblk_alloc_rqd(pblk, WRITE);
-	if (IS_ERR(rqd)) {
-		ret = PTR_ERR(rqd);
-		goto fail_free_meta;
-	}
-
 	bio = pblk_bio_map_addr(pblk, data, rq_ppas, rq_len,
 						PBLK_VMALLOC_META, GFP_KERNEL);
 	if (IS_ERR(bio)) {
 		ret = PTR_ERR(bio);
-		goto fail_free_rqd;
+		goto fail_free_meta;
 	}
 
 	bio->bi_iter.bi_sector = 0; /* internal bio */
 	bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
 
+	rqd = pblk_alloc_rqd(pblk, WRITE);
+
 	rqd->bio = bio;
 	rqd->opcode = NVM_OP_PWRITE;
 	rqd->flags = pblk_set_progr_mode(pblk, WRITE);
@@ -490,8 +477,6 @@ static int pblk_recov_pad_oob(struct pblk *pblk, struct pblk_line *line,
 
 fail_free_bio:
 	bio_put(bio);
-fail_free_rqd:
-	pblk_free_rqd(pblk, rqd, WRITE);
 fail_free_meta:
 	nvm_dev_dma_free(dev->parent, meta_list, dma_meta_list);
 fail_free_pad:
@@ -785,15 +770,9 @@ static int pblk_recov_l2p_from_oob(struct pblk *pblk, struct pblk_line *line)
 	dma_addr_t dma_ppa_list, dma_meta_list;
 	int done, ret = 0;
 
-	rqd = pblk_alloc_rqd(pblk, READ);
-	if (IS_ERR(rqd))
-		return PTR_ERR(rqd);
-
 	meta_list = nvm_dev_dma_alloc(dev->parent, GFP_KERNEL, &dma_meta_list);
-	if (!meta_list) {
-		ret = -ENOMEM;
-		goto free_rqd;
-	}
+	if (!meta_list)
+		return -ENOMEM;
 
 	ppa_list = (void *)(meta_list) + pblk_dma_meta_size;
 	dma_ppa_list = dma_meta_list + pblk_dma_meta_size;
@@ -804,6 +783,8 @@ static int pblk_recov_l2p_from_oob(struct pblk *pblk, struct pblk_line *line)
 		goto free_meta_list;
 	}
 
+	rqd = pblk_alloc_rqd(pblk, READ);
+
 	p.ppa_list = ppa_list;
 	p.meta_list = meta_list;
 	p.rqd = rqd;
@@ -832,8 +813,6 @@ static int pblk_recov_l2p_from_oob(struct pblk *pblk, struct pblk_line *line)
 	kfree(data);
 free_meta_list:
 	nvm_dev_dma_free(dev->parent, meta_list, dma_meta_list);
-free_rqd:
-	pblk_free_rqd(pblk, rqd, READ);
 
 	return ret;
 }
diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
index 26c2b83..0fb8f26 100644
--- a/drivers/lightnvm/pblk-write.c
+++ b/drivers/lightnvm/pblk-write.c
@@ -111,10 +111,7 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd)
 		ppa_list = &rqd->ppa_addr;
 
 	recovery = mempool_alloc(pblk->rec_pool, GFP_ATOMIC);
-	if (!recovery) {
-		pr_err("pblk: could not allocate recovery context\n");
-		return;
-	}
+
 	INIT_LIST_HEAD(&recovery->failed);
 
 	bit = -1;
@@ -375,10 +372,7 @@ int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line)
 	int ret;
 
 	rqd = pblk_alloc_rqd(pblk, READ);
-	if (IS_ERR(rqd)) {
-		pr_err("pblk: cannot allocate write req.\n");
-		return PTR_ERR(rqd);
-	}
+
 	m_ctx = nvm_rq_to_pdu(rqd);
 	m_ctx->private = meta_line;
 
@@ -546,19 +540,12 @@ static int pblk_submit_write(struct pblk *pblk)
 	if (!secs_to_flush && secs_avail < pblk->min_write_pgs)
 		return 1;
 
-	rqd = pblk_alloc_rqd(pblk, WRITE);
-	if (IS_ERR(rqd)) {
-		pr_err("pblk: cannot allocate write req.\n");
-		return 1;
-	}
-
 	bio = bio_alloc(GFP_KERNEL, pblk->max_write_pgs);
-	if (!bio) {
-		pr_err("pblk: cannot allocate write bio\n");
-		goto fail_free_rqd;
-	}
+
 	bio->bi_iter.bi_sector = 0; /* internal bio */
 	bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
+
+	rqd = pblk_alloc_rqd(pblk, WRITE);
 	rqd->bio = bio;
 
 	secs_to_sync = pblk_calc_secs_to_sync(pblk, secs_avail, secs_to_flush);
@@ -589,7 +576,6 @@ static int pblk_submit_write(struct pblk *pblk)
 	pblk_free_write_rqd(pblk, rqd);
 fail_put_bio:
 	bio_put(bio);
-fail_free_rqd:
 	pblk_free_rqd(pblk, rqd, WRITE);
 
 	return 1;
-- 
2.9.3

  parent reply	other threads:[~2017-10-13 12:47 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13 12:45 [GIT PULL 00/58] LightNVM updates for 4.15 Matias Bjørling
2017-10-13 12:45 ` [GIT PULL 01/58] lightnvm: prevent target type module removal when in use Matias Bjørling
2017-10-13 12:45 ` [GIT PULL 02/58] lightnvm: prevent bd removal if busy Matias Bjørling
2017-10-13 14:58   ` Christoph Hellwig
2017-10-13 14:58     ` Christoph Hellwig
2017-10-13 15:35     ` Rakesh Pandit
2017-10-13 15:35       ` Rakesh Pandit
2017-10-13 15:58       ` Javier González
2017-10-13 15:58         ` Javier González
2017-10-14  6:04         ` Javier González
2017-10-14  6:04           ` Javier González
2017-10-16 15:14       ` Matias Bjørling
2017-10-16 15:14         ` Matias Bjørling
2017-10-13 12:45 ` [GIT PULL 03/58] lightnvm: protect target type list with correct locks Matias Bjørling
2017-10-13 12:45 ` [GIT PULL 04/58] lightnvm: remove already calculated nr_chnls Matias Bjørling
2017-10-13 12:45 ` [GIT PULL 05/58] lightnvm: pblk: fix error path in pblk_lines_alloc_metadata Matias Bjørling
2017-10-13 12:45 ` [GIT PULL 06/58] lightnvm: include NVM Express driver if OCSSD is selected for build Matias Bjørling
2017-10-13 12:45 ` [GIT PULL 07/58] lightnvm: pblk: protect line bitmap while submitting meta io Matias Bjørling
2017-10-13 12:45 ` [GIT PULL 08/58] lightnvm: pblk: fix message if L2P MAP is in device Matias Bjørling
2017-10-13 12:45 ` [GIT PULL 09/58] lightnvm: pblk: improve error message if down_timeout fails Matias Bjørling
2017-10-13 12:45 ` [GIT PULL 10/58] lightnvm: pblk: print incompatible line version correctly Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 11/58] lightnvm: pblk: reuse pblk_gc_should_kick Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 12/58] lightnvm: pblk: initialize debug stat counter Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 13/58] lightnvm: pblk: use right flag for GC allocation Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 14/58] lightnvm: pblk: free padded entries in write buffer Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 15/58] lightnvm: pblk: fix write I/O sync stat Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 16/58] lightnvm: pblk: avoid deadlock on low LUN config Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 17/58] lightnvm: pblk: fix min size for page mempool Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 18/58] lightnvm: pblk: simplify work_queue mempool Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 19/58] lightnvm: pblk: decouple read/erase mempools Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 20/58] lightnvm: pblk: do not use a mempool for line bitmaps Matias Bjørling
2017-10-13 12:46 ` Matias Bjørling [this message]
2017-10-13 12:46 ` [GIT PULL 22/58] lightnvm: pblk: use constant for GC max inflight Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 23/58] lightnvm: pblk: normalize ppa namings Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 24/58] lightnvm: pblk: refactor read lba sanity check Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 25/58] lightnvm: pblk: simplify data validity check on GC Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 26/58] lightnvm: pblk: refactor read path " Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 27/58] lightnvm: pblk: put bio on bio completion Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 28/58] lightnvm: pblk: simplify path on REQ_PREFLUSH Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 29/58] lightnvm: pblk: allocate bio size more accurately Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 30/58] lightnvm: pblk: improve naming for internal req Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 31/58] lightnvm: pblk: refactor rqd alloc/free Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 32/58] lightnvm: pblk: use rqd->end_io for completion Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 33/58] lightnvm: pblk: check lba sanity on read path Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 34/58] lightnvm: pblk: guarantee line integrity on reads Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 35/58] lightnvm: pblk: remove redundant check on read path Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 36/58] lightnvm: pblk: remove I/O dependency on write path Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 37/58] lightnvm: pblk: enable 1 LUN configuration Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 38/58] lightnvm: pblk: ensure right bad block calculation Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 39/58] lightnvm: pblk: fix changing GC group list for a line Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 40/58] lightnvm: pblk: remove useless line Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 41/58] lightnvm: remove unused argument from nvm_set_tgt_bb_tbl Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 42/58] lightnvm: remove stale extern and unused exported symbols Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 43/58] lightnvm: pblk: reduce arguments in __pblk_rb_update_l2p Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 44/58] lightnvm: pblk: fix releases of kmem cache in error path Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 45/58] lightnvm: pblk: prevent gc kicks when gc is not operational Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 46/58] lightnvm: pblk: recover partially written lines correctly Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 47/58] lightnvm: pblk: free full lines during recovery Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 48/58] lightnvm: pblk: start gc if needed during init Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 49/58] lightnvm: pblk: consider bad sectors in emeta during recovery Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 50/58] lightnvm: pblk: shut down gc gracefully during exit Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 51/58] lightnvm: pblk: add l2p crc debug printouts Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 52/58] lightnvm: pblk: gc all lines in the pipeline before exit Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 53/58] lightnvm: pblk: correct valid lba count calculation Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 54/58] lightnvm: pblk: remove spinlock when freeing line metadata Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 55/58] lightnvm: pblk: cleanup unused and static functions Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 56/58] lightnvm: pblk: avoid being reported as hung on rated GC Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 57/58] lightnvm: fail fast on passthrough commands Matias Bjørling
2017-10-13 12:46 ` [GIT PULL 58/58] lightnvm: implement generic path for sync I/O Matias Bjørling
2017-10-13 14:36 ` [GIT PULL 00/58] LightNVM updates for 4.15 Jens Axboe
2017-10-13 14:36   ` 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=20171013124647.32668-22-m@bjorling.me \
    --to=m@bjorling.me \
    --cc=axboe@fb.com \
    --cc=javier@cnexlabs.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.