summaryrefslogtreecommitdiff
path: root/fs/zonefs
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2021-03-16 20:30:26 +0800
committerDamien Le Moal <damien.lemoal@wdc.com>2021-03-17 08:56:50 +0900
commit6980d29ce4da223ad7f0751c7f1d61d3c6b54ab3 (patch)
treef7fb9368e4f8844a26b918eea89c1ef0dc6be4cb /fs/zonefs
parentebfd68cd0c1e81267c757332385cb96df30dacce (diff)
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: 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>
Diffstat (limited to 'fs/zonefs')
-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 3427c99abb4d..049e36c69ed7 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -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);