Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9b76a80 authored by Wenwei Tao's avatar Wenwei Tao Committed by Jens Axboe
Browse files

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: default avatarWenwei Tao <ww.tao0320@gmail.com>
Signed-off-by: default avatarMatias Bjørling <m@bjorling.me>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent d3d1a438
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -262,14 +262,11 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
	if (list_empty(&lun->free_list)) {
		pr_err_ratelimited("gennvm: lun %u have no free pages available",
								lun->vlun.id);
		spin_unlock(&vlun->lock);
		goto out;
	}

	while (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks) {
		spin_unlock(&vlun->lock);
	if (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks)
		goto out;
	}

	blk = list_first_entry(&lun->free_list, struct nvm_block, list);
	list_move_tail(&blk->list, &lun->used_list);
@@ -278,8 +275,8 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
	lun->vlun.nr_free_blocks--;
	lun->vlun.nr_inuse_blocks++;

	spin_unlock(&vlun->lock);
out:
	spin_unlock(&vlun->lock);
	return blk;
}