Skip to content

Commit 19ab78c

Browse files
naotakdave
authored andcommitted
btrfs: zoned: fix critical section of relocation inode writeback
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: 35156d8 ("btrfs: zoned: only allow one process to add pages to a relocation inode") CC: [email protected] # 5.16+ Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 343d8a3 commit 19ab78c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/btrfs/extent_io.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5240,13 +5240,14 @@ int extent_writepages(struct address_space *mapping,
52405240
*/
52415241
btrfs_zoned_data_reloc_lock(BTRFS_I(inode));
52425242
ret = extent_write_cache_pages(mapping, wbc, &epd);
5243-
btrfs_zoned_data_reloc_unlock(BTRFS_I(inode));
52445243
ASSERT(ret <= 0);
52455244
if (ret < 0) {
5245+
btrfs_zoned_data_reloc_unlock(BTRFS_I(inode));
52465246
end_write_bio(&epd, ret);
52475247
return ret;
52485248
}
52495249
flush_write_bio(&epd);
5250+
btrfs_zoned_data_reloc_unlock(BTRFS_I(inode));
52505251
return ret;
52515252
}
52525253

0 commit comments

Comments
 (0)