[PATCH 0/3] btrfs: handle missing block group and raid stripe tree roots

"Dongjiang Zhu" <[email protected]>
Newsgroups org.kernel.vger.linux-btrfs
Message-ID <[email protected]>
The rescue=ignorebadroots mount option allows mounting to continue when
some tree roots cannot be loaded. For the block group tree and raid stripe
tree, this leaves the corresponding root pointer NULL while the on-disk
feature bit remains set.

btrfs_update_global_block_rsv() accounts both trees based only on their
feature bits. It therefore dereferences the missing root while mounting.
A missing block group tree root reaches this path through fill_dummy_bgs(),
while a missing raid stripe tree root reaches it after the block groups
have been read.

After the raid stripe tree reserve issue is handled, data reads that need
the raid stripe tree can reach btrfs_get_raid_extent_offset() without a
stripe root. btrfs_search_slot() prevents a NULL pointer dereference, but
returns -EINVAL without any diagnostic.

The series checks that both roots were loaded before accounting them in the
global reserve. It also reports a missing raid stripe tree root during
lookup and returns -EUCLEAN.

Dongjiang Zhu (3):
  btrfs: avoid NULL pointer dereference when block group tree root is
    missing
  btrfs: avoid NULL pointer dereference when raid stripe tree root is
    missing
  btrfs: report missing raid stripe tree root during lookup

 fs/btrfs/block-group.c      | 7 ++++---
 fs/btrfs/block-rsv.c        | 6 ++++--
 fs/btrfs/raid-stripe-tree.c | 7 +++++++
 3 files changed, 15 insertions(+), 5 deletions(-)

-- 
2.39.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.