summaryrefslogtreecommitdiff
path: root/fs/zonefs/super.c
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2021-03-16 15:30:26 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-03-25 11:04:05 +0300
commit78486cf1f31e3f646a981f91f4be3db62689265e (patch)
tree1d4b7706b310655f9f204929ee38249c147cf966 /fs/zonefs/super.c
parent9c1c5e81a00250628b1dea74b815fc641ee77952 (diff)
downloadlinux-78486cf1f31e3f646a981f91f4be3db62689265e.tar.xz
zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone()
commit 6980d29ce4da223ad7f0751c7f1d61d3c6b54ab3 upstream. 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: b5c00e975779 ("zonefs: open/close zone on file open/close") Cc: <stable@vger.kernel.org> Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/zonefs/super.c')
-rw-r--r--fs/zonefs/super.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index b8f3444497b2..2243dc1fb48f 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -1032,9 +1032,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;
@@ -1044,7 +1042,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;
}
@@ -1052,6 +1049,8 @@ static int zonefs_open_zone(struct inode *inode)
}
}
+ zi->i_wr_refcnt++;
+
unlock:
mutex_unlock(&zi->i_truncate_mutex);