This is a note to let you know that I've just added the patch titled zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone() to the 5.11-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: zonefs-fix-to-update-.i_wr_refcnt-correctly-in-zonefs_open_zone.patch and it can be found in the queue-5.11 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 6980d29ce4da223ad7f0751c7f1d61d3c6b54ab3 Mon Sep 17 00:00:00 2001 From: Chao Yu <yuchao0@xxxxxxxxxx> Date: Tue, 16 Mar 2021 20:30:26 +0800 Subject: zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone() From: Chao Yu <yuchao0@xxxxxxxxxx> 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@xxxxxxxxxxxxxxx> Signed-off-by: Chao Yu <yuchao0@xxxxxxxxxx> Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/zonefs/super.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -1032,9 +1032,7 @@ static int zonefs_open_zone(struct 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 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 } } + zi->i_wr_refcnt++; + unlock: mutex_unlock(&zi->i_truncate_mutex); Patches currently in stable-queue which might be from yuchao0@xxxxxxxxxx are queue-5.11/zonefs-fix-to-update-.i_wr_refcnt-correctly-in-zonefs_open_zone.patch