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


Groups > linux.kernel > #1727576 > unrolled thread

[PATCH 1/6] lightnvm: pblk: check for failed mempool alloc.

Started by"Javier González" <jg@lightnvm.io>
First post2017-09-06 17:10 +0200
Last post2017-09-06 17:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/6] lightnvm: pblk: check for failed mempool alloc. "Javier González" <jg@lightnvm.io> - 2017-09-06 17:10 +0200
    Re: [PATCH 1/6] lightnvm: pblk: check for failed mempool alloc. Johannes Thumshirn <jthumshirn@suse.de> - 2017-09-06 17:10 +0200

#1727576 — [PATCH 1/6] lightnvm: pblk: check for failed mempool alloc.

From"Javier González" <jg@lightnvm.io>
Date2017-09-06 17:10 +0200
Subject[PATCH 1/6] lightnvm: pblk: check for failed mempool alloc.
Message-ID<umK7L-3vz-17@gated-at.bofh.it>
Check for failed mempool allocations and act accordingly.

Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
---
 drivers/lightnvm/pblk-core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 81501644fb15..acb07bbcb416 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -165,6 +165,8 @@ struct nvm_rq *pblk_alloc_rqd(struct pblk *pblk, int rw)
 	}
 
 	rqd = mempool_alloc(pool, GFP_KERNEL);
+	if (!rqd)
+		return NULL;
 	memset(rqd, 0, rq_size);
 
 	return rqd;
@@ -1478,6 +1480,8 @@ int pblk_blk_erase_async(struct pblk *pblk, struct ppa_addr ppa)
 	int err;
 
 	rqd = mempool_alloc(pblk->g_rq_pool, GFP_KERNEL);
+	if (!rqd)
+		return -ENOMEM;
 	memset(rqd, 0, pblk_g_rq_size);
 
 	pblk_setup_e_rq(pblk, rqd, ppa);
-- 
2.7.4

[toc] | [next] | [standalone]


#1727583

FromJohannes Thumshirn <jthumshirn@suse.de>
Date2017-09-06 17:10 +0200
Message-ID<umK7L-3vz-19@gated-at.bofh.it>
In reply to#1727576
On Wed, Sep 06, 2017 at 05:01:01PM +0200, Javier González wrote:
> Check for failed mempool allocations and act accordingly.

Are you sure it is needed? Quoting from mempool_alloc()s Documentation:
"[...] Note that due to preallocation, this function *never* fails when called
from process contexts. (it might fail if called from an IRQ context.) [...]"


Byte,
	Johannes

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web