Skip to content

Fix incorrect splitting logic in btrfs_drop_extent_map_range

Josef Bacik linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4btrfs: fix incorrect splitting in btrfs_drop_extent_map_rangefs/btrfs/extent_map.c+2 -41 reply
2/4btrfs: add extent_map tests for dropping with odd layoutsfs/btrfs/tests/extent-map-tests.c+219 -01 reply
3/4btrfs: add a self test for btrfs_add_extent_mappingfs/btrfs/tests/extent-map-tests.c+57 -01 reply
4/4btrfs: test invalid splitting when skipping pinned drop extent_mapfs/btrfs/tests/extent-map-tests.c+138 -01 reply

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchFilipe Manana
1/4R-b
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/4] Fix incorrect splitting logic in btrfs_drop_extent_map_range

We have been hitting a fair number of warnings in btrfs_drop_extent_map_range and in unpin_extent_map in production. Upon investigation I discovered we were splitting improperly when we call btrfs_drop_extent_map_range with skip_pinned. This results in invalid extent_maps in the inode's io_tree, which in turn wreaks all sorts of havoc, mostly in the form of these WARN_ON()'s. This took me a while to spot so I have a bunch of self-tests that test various functionality of btrfs_drop_extent_map_range and btrfs_add_extent_mapping, with one test that actual exercises the bug.

This has been broken for a while, and thankfully is only triggered in certain cases with relocation on. Our environment uses auto relocation heavily which is why we hit this reliably, but the incident rate is still relatively low. The bug was introduced over 10 years ago, it probably could be limited to being backported to the most recent kernels, basically anytime after Filipe's cleaning up of this code. Thanks,

Josef

Josef Bacik (4):
btrfs: fix incorrect splitting in btrfs_drop_extent_map_range
btrfs: add extent_map tests for dropping with odd layouts
btrfs: add a self test for btrfs_add_extent_mapping
btrfs: test invalid splitting when skipping pinned drop extent_map

 fs/btrfs/extent_map.c             |   6 +-
 fs/btrfs/tests/extent-map-tests.c | 414 ++++++++++++++++++++++++++++++
 2 files changed, 416 insertions(+), 4 deletions(-)
Signature · 1 line
2.26.3