Skip to content

Commit 6980d29

Browse files
chaseyudamien-lemoal
authored andcommitted
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: b5c00e9 ("zonefs: open/close zone on file open/close") Cc: <[email protected]> Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Damien Le Moal <[email protected]>
1 parent ebfd68c commit 6980d29

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

fs/zonefs/super.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,9 +1040,7 @@ static int zonefs_open_zone(struct inode *inode)
10401040

10411041
mutex_lock(&zi->i_truncate_mutex);
10421042

1043-
zi->i_wr_refcnt++;
1044-
if (zi->i_wr_refcnt == 1) {
1045-
1043+
if (!zi->i_wr_refcnt) {
10461044
if (atomic_inc_return(&sbi->s_open_zones) > sbi->s_max_open_zones) {
10471045
atomic_dec(&sbi->s_open_zones);
10481046
ret = -EBUSY;
@@ -1052,14 +1050,15 @@ static int zonefs_open_zone(struct inode *inode)
10521050
if (i_size_read(inode) < zi->i_max_size) {
10531051
ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_OPEN);
10541052
if (ret) {
1055-
zi->i_wr_refcnt--;
10561053
atomic_dec(&sbi->s_open_zones);
10571054
goto unlock;
10581055
}
10591056
zi->i_flags |= ZONEFS_ZONE_OPEN;
10601057
}
10611058
}
10621059

1060+
zi->i_wr_refcnt++;
1061+
10631062
unlock:
10641063
mutex_unlock(&zi->i_truncate_mutex);
10651064

0 commit comments

Comments
 (0)