]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: fix silent IO error loss in encoded writes and zoned split
authorMichal Grzedzicki <mge@meta.com>
Mon, 30 Mar 2026 16:06:44 +0000 (09:06 -0700)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 17:43:50 +0000 (19:43 +0200)
commit3cd181cc46d36aa7bd4af85f14639d86a25beaec
tree66cb6bdf632e4d7208d60697a66bc371e2deee41
parente0dfaebb8f4a1de59a8b805d600e3b662b235efc
btrfs: fix silent IO error loss in encoded writes and zoned split

can_finish_ordered_extent() and btrfs_finish_ordered_zoned() set
BTRFS_ORDERED_IOERR via bare set_bit(). Later,
btrfs_mark_ordered_extent_error() in btrfs_finish_one_ordered() uses
test_and_set_bit(), finds it already set, and skips
mapping_set_error(). The error is never recorded on the inode's
address_space, making it invisible to fsync. For encoded writes this
causes btrfs receive to silently produce files with zero-filled holes.

Fix: replace bare set_bit(BTRFS_ORDERED_IOERR) with
btrfs_mark_ordered_extent_error() which pairs test_and_set_bit() with
mapping_set_error(), guaranteeing the error is recorded exactly once.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Mark Harmstone <mark@harmstone.com>
Signed-off-by: Michal Grzedzicki <mge@meta.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ordered-data.c
fs/btrfs/zoned.c