lkml.org 
[lkml]   [2017]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] lightnvm: pblk: use vfree_atomic when freeing line metadata
Date
From: Hans Holmberg <hans.holmberg@cnexlabs.com>

The commit bf22e37a6413 ("mm: add vfree_atomic()") made vfree unsafe to
call in atomic context (unless the call came from an interrupt) and
introduced vfree_atomic that is safe to call in atomic context.

So, since we're holding locks when freeing line metadata, we need to
use the atomic version of vfree.

Fix this by introducing an atomic variant of pblk_mfree and
switching to that in pblk_line_meta_free.

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
---

The patch is for:
https://github.com/OpenChannelSSD/linux branch for-4.15/pblk

drivers/lightnvm/pblk-init.c | 3 ++-
drivers/lightnvm/pblk.h | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index c452478..3a191a6 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -396,7 +396,8 @@ static void pblk_line_meta_free(struct pblk *pblk)
spin_lock(&l_mg->free_lock);
for (i = 0; i < PBLK_DATA_LINES; i++) {
kfree(l_mg->sline_meta[i]);
- pblk_mfree(l_mg->eline_meta[i]->buf, l_mg->emeta_alloc_type);
+ pblk_mfree_atomic(l_mg->eline_meta[i]->buf,
+ l_mg->emeta_alloc_type);
kfree(l_mg->eline_meta[i]);
}
spin_unlock(&l_mg->free_lock);
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index 03965da..93f98e3 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -881,6 +881,14 @@ static inline void pblk_mfree(void *ptr, int type)
vfree(ptr);
}

+static inline void pblk_mfree_atomic(void *ptr, int type)
+{
+ if (type == PBLK_KMALLOC_META)
+ kfree(ptr);
+ else
+ vfree_atomic(ptr);
+}
+
static inline struct nvm_rq *nvm_rq_from_c_ctx(void *c_ctx)
{
return c_ctx - sizeof(struct nvm_rq);
--
2.7.4
\
 
 \ /
  Last update: 2017-10-03 15:51    [W:0.047 / U:0.828 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site