btrfs: zoned: fix critical section of relocation inode writeback
authorNaohiro Aota <naohiro.aota@wdc.com>
Tue, 7 Jun 2022 07:08:30 +0000 (16:08 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Aug 2022 11:07:52 +0000 (13:07 +0200)
commit37b385c78cd57edcc9c2350a37763012c28982cd
tree632e59a6baf3dd9a4b2fc662c69a441ef8672a63
parent5e04c8bf42d810986b609b989955347c2913b1be
btrfs: zoned: fix critical section of relocation inode writeback

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@vger.kernel.org # 5.16+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/extent_io.c