mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 09:31:14 +00:00
lightnvm: put blks when luns configure failed
Put the allocated blocks back to the free list when the luns configure failed, to make these blocks useable to others. Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com> Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
parent
f27a629953
commit
d3d1a43842
1 changed files with 19 additions and 2 deletions
|
@ -202,6 +202,20 @@ static void rrpc_put_blk(struct rrpc *rrpc, struct rrpc_block *rblk)
|
||||||
nvm_put_blk(rrpc->dev, rblk->parent);
|
nvm_put_blk(rrpc->dev, rblk->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rrpc_put_blks(struct rrpc *rrpc)
|
||||||
|
{
|
||||||
|
struct rrpc_lun *rlun;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < rrpc->nr_luns; i++) {
|
||||||
|
rlun = &rrpc->luns[i];
|
||||||
|
if (rlun->cur)
|
||||||
|
rrpc_put_blk(rrpc, rlun->cur);
|
||||||
|
if (rlun->gc_cur)
|
||||||
|
rrpc_put_blk(rrpc, rlun->gc_cur);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static struct rrpc_lun *get_next_lun(struct rrpc *rrpc)
|
static struct rrpc_lun *get_next_lun(struct rrpc *rrpc)
|
||||||
{
|
{
|
||||||
int next = atomic_inc_return(&rrpc->next_lun);
|
int next = atomic_inc_return(&rrpc->next_lun);
|
||||||
|
@ -1224,18 +1238,21 @@ static int rrpc_luns_configure(struct rrpc *rrpc)
|
||||||
|
|
||||||
rblk = rrpc_get_blk(rrpc, rlun, 0);
|
rblk = rrpc_get_blk(rrpc, rlun, 0);
|
||||||
if (!rblk)
|
if (!rblk)
|
||||||
return -EINVAL;
|
goto err;
|
||||||
|
|
||||||
rrpc_set_lun_cur(rlun, rblk);
|
rrpc_set_lun_cur(rlun, rblk);
|
||||||
|
|
||||||
/* Emergency gc block */
|
/* Emergency gc block */
|
||||||
rblk = rrpc_get_blk(rrpc, rlun, 1);
|
rblk = rrpc_get_blk(rrpc, rlun, 1);
|
||||||
if (!rblk)
|
if (!rblk)
|
||||||
return -EINVAL;
|
goto err;
|
||||||
rlun->gc_cur = rblk;
|
rlun->gc_cur = rblk;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
err:
|
||||||
|
rrpc_put_blks(rrpc);
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct nvm_tgt_type tt_rrpc;
|
static struct nvm_tgt_type tt_rrpc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue