Skip to content

tree-checker bug fix and enhancement.

Qu Wenruo linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 10 repliesIn review
  2. v13 patches 3 repliesSuperseded

Changes in v2 from the cover letter

Rename btrfs_check_leaf() to btrfs_check_leaf_full() and btrfs_check_leaf_relaxed() to better show their difference. Suggested by David.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3btrfs: tree-checker: Fix false panic for sanity testfs/btrfs/disk-io.c fs/btrfs/tree-checker.c fs/btrfs/tree-checker.h+43 -85 replies
2/3btrfs: tree-checker: Add checker for dir itemfs/btrfs/tree-checker.c+141 -04 replies
3/3btrfs: Cleanup existing name_len checksfs/btrfs/ctree.h fs/btrfs/dir-item.c fs/btrfs/export.c +6 more+9 -1861 reply

Reviews trailers per patch

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

PatchDavid SterbaLiu Bo
1/3R-b R-b
2/3R-b
3/3R-b

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

Read the v2 thread

Cover letter [PATCH v2 0/3] tree-checker bug fix and enhancement.

This patchset fix a false panic introduced by tree-checker, and then introduce dir_item checker, along with cleanups to remove existing checkers sparsed in dir-item.

The 1st patch is a fix to address kernel panic with sanity test in btrfs. The cause is there are several callers which call btrfs_mark_buffer_dirty() while its data is not initialized. (The same patch is resent along with the rest of the patchset)

Considering the number of callers and how many times btrfs_mark_buffer_dirty() is called, the 1st patch will skip item data check, so check in btrfs_mark_buffer_dirty() will keep the old behavior.
(Only item and item pointer overlap check is newly introduced in this case)

The 2nd patch introduce comprehensive check for dir item, which is used for 3 key types: DIR_ITEM, DIR_INDEX and XATTR.
(Unlike previous attempts to check all items with variable length)

Except existing checks, new checks are:
1) Enhanced dir type check
Now only XATTR key can have FT_ATTR dir item.

2) name hash for DIR_ITEM/XATTR_ITEM
Original introduced in btrfs-progs for a corrupted (non-fuzzed) image.

The last patch will cleanup the related existing code, mostly related to verify_dir_item() and btrfs_is_name_len_valid().

Unlike btrfs_check_leaf() called in btrfs_mark_buffer_dirty(), all the verification calls are in read path, so we won't lost any early warning since they didn't exist from the beginning.

Changelog:
v2:
Rename btrfs_check_leaf() to btrfs_check_leaf_full() and btrfs_check_leaf_relaxed() to better show their difference. Suggested by David.

Unintend message in 2nd patch.

Qu Wenruo (3):
btrfs: tree-checker: Fix false panic for sanity test
btrfs: tree-checker: Add checker for dir item
btrfs: Cleanup existing name_len checks

 fs/btrfs/ctree.h        |   5 --
 fs/btrfs/dir-item.c     | 108 -------------------------------
 fs/btrfs/disk-io.c      |  10 ++-
 fs/btrfs/export.c       |   5 --
 fs/btrfs/inode.c        |   4 --
 fs/btrfs/props.c        |   7 --
 fs/btrfs/root-tree.c    |   7 --
 fs/btrfs/send.c         |   6 --
 fs/btrfs/tree-checker.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++--
 fs/btrfs/tree-checker.h |  14 +++-
 fs/btrfs/tree-log.c     |  47 +++-----------
 fs/btrfs/xattr.c        |   6 --
 12 files changed, 193 insertions(+), 194 deletions(-)
Signature · 1 line
2.15.0