diff options
author | Boris Burkov <boris@bur.io> | 2024-10-19 01:44:34 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-10-22 17:10:13 +0300 |
commit | 7a2339058ed71f54c1e12e1b3c25aab1b1ba7943 (patch) | |
tree | 616f6805ada252d4910482cad95f2f2e1ccb5d43 /scripts/decode_stacktrace.sh | |
parent | f10f59f91a6278e9637327d1206140d28e2d5004 (diff) | |
download | linux-7a2339058ed71f54c1e12e1b3c25aab1b1ba7943.tar.xz |
btrfs: fix read corruption due to race with extent map merging
In debugging some corrupt squashfs files, we observed symptoms of
corrupt page cache pages but correct on-disk contents. Further
investigation revealed that the exact symptom was a correct page
followed by an incorrect, duplicate, page. This got us thinking about
extent maps.
commit ac05ca913e9f ("Btrfs: fix race between using extent maps and merging them")
enforces a reference count on the primary `em` extent_map being merged,
as that one gets modified.
However, since,
commit 3d2ac9922465 ("btrfs: introduce new members for extent_map")
both 'em' and 'merge' get modified, which started modifying 'merge'
and thus introduced the same race.
We were able to reproduce this by looping the affected squashfs workload
in parallel on a bunch of separate btrfs-es while also dropping caches.
We are still working on a simple enough reproducer to make into an fstest.
The simplest fix is to stop modifying 'merge', which is not essential,
as it is dropped immediately after the merge. This behavior is simply
a consequence of the order of the two extent maps being important in
computing the new values. Modify merge_ondisk_extents to take prev and
next by const* and also take a third merged parameter that it puts the
results in. Note that this introduces the rather odd behavior of passing
'em' to merge_ondisk_extents as a const * and as a regular ptr.
Fixes: 3d2ac9922465 ("btrfs: introduce new members for extent_map")
CC: stable@vger.kernel.org # 6.11+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'scripts/decode_stacktrace.sh')
0 files changed, 0 insertions, 0 deletions