]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: tree-checker: add more cross checks for free space tree
authorQu Wenruo <wqu@suse.com>
Mon, 11 May 2026 00:56:51 +0000 (10:26 +0930)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jun 2026 13:53:33 +0000 (15:53 +0200)
commitdfd70996e5894214ac49255131a2def1b8b9c19f
tree43964dbec71e129752455e304bda0bae9db8d6fe
parentc37d09450c2e6d646d6dfc248e6c94f8669264d9
btrfs: tree-checker: add more cross checks for free space tree

This introduces extra checks using the previous key.

If there is a previous key, we can do extra validations:

- The previous key is FREE_SPACE_INFO
  This means the current extent/bitmap should be inside the
  free space info key range.

  And matches the type of the free space info.

- The previous key is FREE_SPACE_EXTENT or FREE_SPACE_BITMAP
  In that case both the current and previous key should belong to the same
  block group.

  Thus the key type must match, and no overlap between the two keys.

These extra checks are inspired by the recently added type checks during
free space tree loading.

The new tree-checker checks will allow earlier detection, but the
loading time checks are still needed, as the tree-checker checks are
still inside the same leaf, not matching per-bg level checks.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-checker.c