linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path
@ 2017-10-01 13:26 Rakesh Pandit
  2017-10-02 12:44 ` Javier González
  0 siblings, 1 reply; 3+ messages in thread
From: Rakesh Pandit @ 2017-10-01 13:26 UTC (permalink / raw)
  To: Matias Bjørling, linux-block, linux-kernel; +Cc: Javier González

If pblk_core_init fails lets destroy all global caches.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
---
 drivers/lightnvm/pblk-init.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 519e5cf..9f39800 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -246,7 +246,7 @@ static int pblk_core_init(struct pblk *pblk)
 	pblk->page_bio_pool = mempool_create_page_pool(nvm_max_phys_sects(dev),
 									0);
 	if (!pblk->page_bio_pool)
-		return -ENOMEM;
+		goto free_global_caches;
 
 	pblk->gen_ws_pool = mempool_create_slab_pool(PBLK_GEN_WS_POOL_SIZE,
 							pblk_ws_cache);
@@ -314,6 +314,12 @@ static int pblk_core_init(struct pblk *pblk)
 	mempool_destroy(pblk->gen_ws_pool);
 free_page_bio_pool:
 	mempool_destroy(pblk->page_bio_pool);
+free_global_caches:
+	kmem_cache_destroy(pblk_ws_cache);
+	kmem_cache_destroy(pblk_rec_cache);
+	kmem_cache_destroy(pblk_g_rq_cache);
+	kmem_cache_destroy(pblk_e_rq_cache);
+	kmem_cache_destroy(pblk_w_rq_cache);
 	return -ENOMEM;
 }
 
-- 
2.7.4

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

* Re: [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path
  2017-10-01 13:26 [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path Rakesh Pandit
@ 2017-10-02 12:44 ` Javier González
  2017-10-02 17:21   ` Rakesh Pandit
  0 siblings, 1 reply; 3+ messages in thread
From: Javier González @ 2017-10-02 12:44 UTC (permalink / raw)
  To: Rakesh Pandit; +Cc: Matias Bjørling, linux-block, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]

> On 1 Oct 2017, at 15.26, Rakesh Pandit <rakesh@tuxera.com> wrote:
> 
> If pblk_core_init fails lets destroy all global caches.
> 
> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> ---
> drivers/lightnvm/pblk-init.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
> index 519e5cf..9f39800 100644
> --- a/drivers/lightnvm/pblk-init.c
> +++ b/drivers/lightnvm/pblk-init.c
> @@ -246,7 +246,7 @@ static int pblk_core_init(struct pblk *pblk)
> 	pblk->page_bio_pool = mempool_create_page_pool(nvm_max_phys_sects(dev),
> 									0);
> 	if (!pblk->page_bio_pool)
> -		return -ENOMEM;
> +		goto free_global_caches;
> 
> 	pblk->gen_ws_pool = mempool_create_slab_pool(PBLK_GEN_WS_POOL_SIZE,
> 							pblk_ws_cache);
> @@ -314,6 +314,12 @@ static int pblk_core_init(struct pblk *pblk)
> 	mempool_destroy(pblk->gen_ws_pool);
> free_page_bio_pool:
> 	mempool_destroy(pblk->page_bio_pool);
> +free_global_caches:
> +	kmem_cache_destroy(pblk_ws_cache);
> +	kmem_cache_destroy(pblk_rec_cache);
> +	kmem_cache_destroy(pblk_g_rq_cache);
> +	kmem_cache_destroy(pblk_e_rq_cache);
> +	kmem_cache_destroy(pblk_w_rq_cache);
> 	return -ENOMEM;
> }
> 
> --
> 2.7.4

Looks good. I'll refactor it on a single function so that we can reuse
it on tear down. It will also be simpler to add/remove caches in the
future.

Since it depends on the last patch, I'll wait until you reply to it
before making the changes.

Javier

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path
  2017-10-02 12:44 ` Javier González
@ 2017-10-02 17:21   ` Rakesh Pandit
  0 siblings, 0 replies; 3+ messages in thread
From: Rakesh Pandit @ 2017-10-02 17:21 UTC (permalink / raw)
  To: Javier González; +Cc: Matias Bjørling, linux-block, linux-kernel

On Mon, Oct 02, 2017 at 02:44:23PM +0200, Javier Gonz�lez wrote:
> > On 1 Oct 2017, at 15.26, Rakesh Pandit <rakesh@tuxera.com> wrote:
> > 
> > If pblk_core_init fails lets destroy all global caches.
> > 
> > Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> > ---
> > drivers/lightnvm/pblk-init.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
> > index 519e5cf..9f39800 100644
> > --- a/drivers/lightnvm/pblk-init.c
> > +++ b/drivers/lightnvm/pblk-init.c
> > @@ -246,7 +246,7 @@ static int pblk_core_init(struct pblk *pblk)
> > 	pblk->page_bio_pool = mempool_create_page_pool(nvm_max_phys_sects(dev),
> > 									0);
> > 	if (!pblk->page_bio_pool)
> > -		return -ENOMEM;
> > +		goto free_global_caches;
> > 
> > 	pblk->gen_ws_pool = mempool_create_slab_pool(PBLK_GEN_WS_POOL_SIZE,
> > 							pblk_ws_cache);
> > @@ -314,6 +314,12 @@ static int pblk_core_init(struct pblk *pblk)
> > 	mempool_destroy(pblk->gen_ws_pool);
> > free_page_bio_pool:
> > 	mempool_destroy(pblk->page_bio_pool);
> > +free_global_caches:
> > +	kmem_cache_destroy(pblk_ws_cache);
> > +	kmem_cache_destroy(pblk_rec_cache);
> > +	kmem_cache_destroy(pblk_g_rq_cache);
> > +	kmem_cache_destroy(pblk_e_rq_cache);
> > +	kmem_cache_destroy(pblk_w_rq_cache);
> > 	return -ENOMEM;
> > }
> > 
> > --
> > 2.7.4
> 
> Looks good. I'll refactor it on a single function so that we can reuse
> it on tear down. It will also be simpler to add/remove caches in the
> future.
> 
> Since it depends on the last patch, I'll wait until you reply to it
> before making the changes.

Please go ahead.  Now that previous patch is can be ignored, you can
adjust accordingly.

Thank you.

> 
> Javier

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

end of thread, other threads:[~2017-10-02 17:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-01 13:26 [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path Rakesh Pandit
2017-10-02 12:44 ` Javier González
2017-10-02 17:21   ` Rakesh Pandit

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