提交 6980d29c 编写于 作者: C Chao Yu 提交者: Damien Le Moal

zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone()

In zonefs_open_zone(), if opened zone count is larger than
.s_max_open_zones threshold, we missed to recover .i_wr_refcnt,
fix this.

Fixes: b5c00e97 ("zonefs: open/close zone on file open/close")
Cc: <stable@vger.kernel.org>
Signed-off-by: NChao Yu <yuchao0@huawei.com>
Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
上级 ebfd68cd
......@@ -1040,9 +1040,7 @@ static int zonefs_open_zone(struct inode *inode)
mutex_lock(&zi->i_truncate_mutex);
zi->i_wr_refcnt++;
if (zi->i_wr_refcnt == 1) {
if (!zi->i_wr_refcnt) {
if (atomic_inc_return(&sbi->s_open_zones) > sbi->s_max_open_zones) {
atomic_dec(&sbi->s_open_zones);
ret = -EBUSY;
......@@ -1052,7 +1050,6 @@ static int zonefs_open_zone(struct inode *inode)
if (i_size_read(inode) < zi->i_max_size) {
ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_OPEN);
if (ret) {
zi->i_wr_refcnt--;
atomic_dec(&sbi->s_open_zones);
goto unlock;
}
......@@ -1060,6 +1057,8 @@ static int zonefs_open_zone(struct inode *inode)
}
}
zi->i_wr_refcnt++;
unlock:
mutex_unlock(&zi->i_truncate_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册