diff options
author | Filipe Manana <fdmanana@suse.com> | 2022-09-19 15:06:28 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-10-21 12:37:47 +0200 |
commit | f271c264908f5f9207352f2ea0a50429252ac829 (patch) | |
tree | ffb499b6d462bd5b58bdc41e498f2d46d07fd5d0 /fs/nfsd/state.h | |
parent | 6c22f86dd221eba0c7af645b1af73dcbc04ee27b (diff) | |
download | linux-stable-f271c264908f5f9207352f2ea0a50429252ac829.tar.gz linux-stable-f271c264908f5f9207352f2ea0a50429252ac829.tar.bz2 linux-stable-f271c264908f5f9207352f2ea0a50429252ac829.zip |
btrfs: fix missed extent on fsync after dropping extent maps
commit cef7820d6abf8d61f8e1db411eae3c712f6d72a2 upstream.
When dropping extent maps for a range, through btrfs_drop_extent_cache(),
if we find an extent map that starts before our target range and/or ends
before the target range, and we are not able to allocate extent maps for
splitting that extent map, then we don't fail and simply remove the entire
extent map from the inode's extent map tree.
This is generally fine, because in case anyone needs to access the extent
map, it can just load it again later from the respective file extent
item(s) in the subvolume btree. However, if that extent map is new and is
in the list of modified extents, then a fast fsync will miss the parts of
the extent that were outside our range (that needed to be split),
therefore not logging them. Fix that by marking the inode for a full
fsync. This issue was introduced after removing BUG_ON()s triggered when
the split extent map allocations failed, done by commit 7014cdb49305ed
("Btrfs: btrfs_drop_extent_cache should never fail"), back in 2012, and
the fast fsync path already existed but was very recent.
Also, in the case where we could allocate extent maps for the split
operations but then fail to add a split extent map to the tree, mark the
inode for a full fsync as well. This is not supposed to ever fail, and we
assert that, but in case assertions are disabled (CONFIG_BTRFS_ASSERT is
not set), it's the correct thing to do to make sure a fast fsync will not
miss a new extent.
CC: stable@vger.kernel.org # 5.15+
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/nfsd/state.h')
0 files changed, 0 insertions, 0 deletions