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


Groups > linux.kernel > #1742796 > unrolled thread

[PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path

Started byRakesh Pandit <rakesh@tuxera.com>
First post2017-10-01 15:30 +0200
Last post2017-10-02 22:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path Rakesh Pandit <rakesh@tuxera.com> - 2017-10-01 15:30 +0200
    Re: [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error  path Javier González <jg@lightnvm.io> - 2017-10-02 14:50 +0200
      Re: [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error  path Rakesh Pandit <rakesh@tuxera.com> - 2017-10-02 22:50 +0200

#1742796 — [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path

FromRakesh Pandit <rakesh@tuxera.com>
Date2017-10-01 15:30 +0200
Subject[PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path
Message-ID<uvMtI-2Hh-11@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1743193 — Re: [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path

FromJavier González <jg@lightnvm.io>
Date2017-10-02 14:50 +0200
SubjectRe: [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path
Message-ID<uw8kz-7kS-27@gated-at.bofh.it>
In reply to#1742796

[Multipart message — attachments visible in raw view] — view raw

> 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

[toc] | [prev] | [next] | [standalone]


#1743285 — Re: [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path

FromRakesh Pandit <rakesh@tuxera.com>
Date2017-10-02 22:50 +0200
SubjectRe: [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path
Message-ID<uwfPc-ur-181@gated-at.bofh.it>
In reply to#1743193
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web