提交 f680f19a 编写于 作者: J Javier González 提交者: Jens Axboe

lightnvm: pblk: simplify meta. memory allocation

smeta size will always be suitable for a kmalloc allocation. Simplify
the code and leave the vmalloc fallback only for emeta, where the pblk
configuration has an impact.
Signed-off-by: NJavier González <javier@cnexlabs.com>
Signed-off-by: NMatias Bjørling <matias@cnexlabs.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 f9c10152
...@@ -665,7 +665,8 @@ static int pblk_line_submit_emeta_io(struct pblk *pblk, struct pblk_line *line, ...@@ -665,7 +665,8 @@ static int pblk_line_submit_emeta_io(struct pblk *pblk, struct pblk_line *line,
} }
reinit_completion(&wait); reinit_completion(&wait);
bio_put(bio); if (likely(pblk->l_mg.emeta_alloc_type == PBLK_VMALLOC_META))
bio_put(bio);
if (rqd.error) { if (rqd.error) {
if (dir == WRITE) if (dir == WRITE)
......
...@@ -355,9 +355,9 @@ static void pblk_line_meta_free(struct pblk *pblk) ...@@ -355,9 +355,9 @@ static void pblk_line_meta_free(struct pblk *pblk)
kfree(l_mg->vsc_list); kfree(l_mg->vsc_list);
for (i = 0; i < PBLK_DATA_LINES; i++) { for (i = 0; i < PBLK_DATA_LINES; i++) {
pblk_mfree(&l_mg->sline_meta[i], l_mg->smeta_alloc_type); kfree(l_mg->sline_meta[i]);
pblk_mfree(l_mg->eline_meta[i]->buf, l_mg->emeta_alloc_type); pblk_mfree(l_mg->eline_meta[i]->buf, l_mg->emeta_alloc_type);
kfree(&l_mg->eline_meta[i]); kfree(l_mg->eline_meta[i]);
} }
kfree(pblk->lines); kfree(pblk->lines);
...@@ -550,7 +550,6 @@ static int pblk_lines_alloc_metadata(struct pblk *pblk) ...@@ -550,7 +550,6 @@ static int pblk_lines_alloc_metadata(struct pblk *pblk)
/* smeta is always small enough to fit on a kmalloc memory allocation, /* smeta is always small enough to fit on a kmalloc memory allocation,
* emeta depends on the number of LUNs allocated to the pblk instance * emeta depends on the number of LUNs allocated to the pblk instance
*/ */
l_mg->smeta_alloc_type = PBLK_KMALLOC_META;
for (i = 0; i < PBLK_DATA_LINES; i++) { for (i = 0; i < PBLK_DATA_LINES; i++) {
l_mg->sline_meta[i] = kmalloc(lm->smeta_len, GFP_KERNEL); l_mg->sline_meta[i] = kmalloc(lm->smeta_len, GFP_KERNEL);
if (!l_mg->sline_meta[i]) if (!l_mg->sline_meta[i])
...@@ -604,12 +603,12 @@ static int pblk_lines_alloc_metadata(struct pblk *pblk) ...@@ -604,12 +603,12 @@ static int pblk_lines_alloc_metadata(struct pblk *pblk)
fail_free_emeta: fail_free_emeta:
while (--i >= 0) { while (--i >= 0) {
vfree(l_mg->eline_meta[i]->buf); vfree(l_mg->eline_meta[i]->buf);
kfree(&l_mg->eline_meta[i]); kfree(l_mg->eline_meta[i]);
} }
fail_free_smeta: fail_free_smeta:
for (i = 0; i < PBLK_DATA_LINES; i++) for (i = 0; i < PBLK_DATA_LINES; i++)
pblk_mfree(&l_mg->sline_meta[i], l_mg->smeta_alloc_type); kfree(l_mg->sline_meta[i]);
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -442,7 +442,8 @@ int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line) ...@@ -442,7 +442,8 @@ int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line)
list_add(&meta_line->list, &meta_line->list); list_add(&meta_line->list, &meta_line->list);
spin_unlock(&l_mg->close_lock); spin_unlock(&l_mg->close_lock);
fail_free_bio: fail_free_bio:
bio_put(bio); if (likely(l_mg->emeta_alloc_type == PBLK_VMALLOC_META))
bio_put(bio);
fail_free_rqd: fail_free_rqd:
pblk_free_rqd(pblk, rqd, READ); pblk_free_rqd(pblk, rqd, READ);
return ret; return ret;
......
...@@ -446,7 +446,6 @@ struct pblk_line_mgmt { ...@@ -446,7 +446,6 @@ struct pblk_line_mgmt {
__le32 *vsc_list; /* Valid sector counts for all lines */ __le32 *vsc_list; /* Valid sector counts for all lines */
/* Metadata allocation type: VMALLOC | KMALLOC */ /* Metadata allocation type: VMALLOC | KMALLOC */
int smeta_alloc_type;
int emeta_alloc_type; int emeta_alloc_type;
/* Pre-allocated metadata for data lines */ /* Pre-allocated metadata for data lines */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册