提交 e9b76a80 编写于 作者: W Wenwei Tao 提交者: Jens Axboe

lightnvm: refactor spin_unlock in gennvm_get_blk

The spin_unlock is duplicated multiple times. Jump to a single unlock
to improve the code flow.
Signed-off-by: NWenwei Tao <ww.tao0320@gmail.com>
Signed-off-by: NMatias Bjørling <m@bjorling.me>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 d3d1a438
...@@ -262,14 +262,11 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev, ...@@ -262,14 +262,11 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
if (list_empty(&lun->free_list)) { if (list_empty(&lun->free_list)) {
pr_err_ratelimited("gennvm: lun %u have no free pages available", pr_err_ratelimited("gennvm: lun %u have no free pages available",
lun->vlun.id); lun->vlun.id);
spin_unlock(&vlun->lock);
goto out; goto out;
} }
while (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks) { if (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks)
spin_unlock(&vlun->lock);
goto out; goto out;
}
blk = list_first_entry(&lun->free_list, struct nvm_block, list); blk = list_first_entry(&lun->free_list, struct nvm_block, list);
list_move_tail(&blk->list, &lun->used_list); list_move_tail(&blk->list, &lun->used_list);
...@@ -278,8 +275,8 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev, ...@@ -278,8 +275,8 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
lun->vlun.nr_free_blocks--; lun->vlun.nr_free_blocks--;
lun->vlun.nr_inuse_blocks++; lun->vlun.nr_inuse_blocks++;
spin_unlock(&vlun->lock);
out: out:
spin_unlock(&vlun->lock);
return blk; return blk;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册