]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: report missing raid stripe tree root during lookup
authorDongjiang Zhu <zhudongjiang@fnnas.com>
Mon, 13 Jul 2026 08:50:10 +0000 (16:50 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 21 Jul 2026 04:41:11 +0000 (06:41 +0200)
When rescue=ibadroots ignores a failure to load the raid stripe tree root,
fs_info->stripe_root remains NULL. After the rescue mount proceeds, reading
file data that requires the raid stripe tree reaches
btrfs_get_raid_extent_offset().

Currently btrfs_search_slot() handles the NULL root and returns -EINVAL.
This avoids a NULL pointer dereference, but provides no diagnostic and
incorrectly describes missing filesystem metadata as an invalid argument.

Check stripe_root before allocating a path, emit a rate-limited error with
the logical address, and return -EUCLEAN.

Lookups with a valid stripe root are unchanged.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Dongjiang Zhu <zhudongjiang@fnnas.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/raid-stripe-tree.c

index 454a95bf542a0dcce694e76d92bea47dacdf9e36..b210371ce91e389f7dafbbe8d20c4a572d1fc5b4 100644 (file)
@@ -414,6 +414,12 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info,
        int slot;
        int ret;
 
+       if (unlikely(!stripe_root)) {
+               btrfs_err_rl(fs_info, "missing raid stripe tree root for logical %llu",
+                            logical);
+               return -EUCLEAN;
+       }
+
        stripe_key.objectid = logical;
        stripe_key.type = BTRFS_RAID_STRIPE_KEY;
        stripe_key.offset = 0;