This is a note to let you know that I've just added the patch titled btrfs: zoned: fix critical section of relocation inode writeback to the 5.18-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: btrfs-zoned-fix-critical-section-of-relocation-inode-writeback.patch and it can be found in the queue-5.18 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 19ab78ca86981e0e1e73036fb73a508731a7c078 Mon Sep 17 00:00:00 2001 From: Naohiro Aota <naohiro.aota@xxxxxxx> Date: Tue, 7 Jun 2022 16:08:30 +0900 Subject: btrfs: zoned: fix critical section of relocation inode writeback From: Naohiro Aota <naohiro.aota@xxxxxxx> commit 19ab78ca86981e0e1e73036fb73a508731a7c078 upstream. We use btrfs_zoned_data_reloc_{lock,unlock} to allow only one process to write out to the relocation inode. That critical section must include all the IO submission for the inode. However, flush_write_bio() in extent_writepages() is out of the critical section, causing an IO submission outside of the lock. This leads to an out of the order IO submission and fail the relocation process. Fix it by extending the critical section. Fixes: 35156d852762 ("btrfs: zoned: only allow one process to add pages to a relocation inode") CC: stable@xxxxxxxxxxxxxxx # 5.16+ Reviewed-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx> Signed-off-by: Naohiro Aota <naohiro.aota@xxxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/extent_io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -5214,13 +5214,14 @@ int extent_writepages(struct address_spa */ btrfs_zoned_data_reloc_lock(BTRFS_I(inode)); ret = extent_write_cache_pages(mapping, wbc, &epd); - btrfs_zoned_data_reloc_unlock(BTRFS_I(inode)); ASSERT(ret <= 0); if (ret < 0) { + btrfs_zoned_data_reloc_unlock(BTRFS_I(inode)); end_write_bio(&epd, ret); return ret; } ret = flush_write_bio(&epd); + btrfs_zoned_data_reloc_unlock(BTRFS_I(inode)); return ret; } Patches currently in stable-queue which might be from naohiro.aota@xxxxxxx are queue-5.18/btrfs-zoned-fix-critical-section-of-relocation-inode-writeback.patch queue-5.18/btrfs-zoned-prevent-allocation-from-previous-data-relocation-bg.patch queue-5.18/btrfs-zoned-drop-optimization-of-zone-finish.patch