linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: tree-checker: Add checks to detect missing INODE_ITEM
@ 2019-08-26  7:40 Qu Wenruo
  2019-08-26  7:40 ` [PATCH 1/2] btrfs: tree-checker: Try " Qu Wenruo
  2019-08-26  7:40 ` [PATCH 2/2] btrfs: tree-checker: Add check for INODE_REF Qu Wenruo
  0 siblings, 2 replies; 8+ messages in thread
From: Qu Wenruo @ 2019-08-26  7:40 UTC (permalink / raw)
  To: linux-btrfs

For the following items, key->objectid is inode number:
- DIR_ITEM
- DIR_INDEX
- XATTR_ITEM
- EXTENT_DATA
- INODE_REF

So in btrfs btree, such items must have its previous item shares the
same objectid, e.g.:
 (257 INODE_ITEM 0)
 (257 DIR_INDEX xxx)
 (257 DIR_ITEM xxx)
 (258 INODE_ITEM 0)
 (258 INODE_REF 0)
 (258 XATTR_ITEM 0)
 (258 EXTENT_DATA 0)

But if we have the following sequence, then there is definitely
something wrong, normally some INODE_ITEM is missing, like:
 (257 INODE_ITEM 0)
 (257 DIR_INDEX xxx)
 (257 DIR_ITEM xxx)
 (258 XATTR_ITEM 0)  <<< objecitd suddenly changed to 258
 (258 EXTENT_DATA 0)

So just by checking the previous key for above inode based key types, we
can detect missing inode item.

In this patchset, we will enhance existing check_dir_item() and
check_extent_data_item() to detect missing INODE_ITEM first, then add
INODE_REF checker.

So now we can cover the INODE_ITEM missing case in tree-checker without
much cost, but achieve the check which is normally done by btrfs-check.
(I'm already a little concerned about the fact that kernel tree-checker
is getting stronger and stronger while btrfs-progs can't fix all
problems)

Of course, there is still a limitation that the first key of a leaf
can't be verified, but we have already cover all the rest keys, which is
way better than "good enough"(TM).

Qu Wenruo (2):
  btrfs: tree-checker: Try to detect missing INODE_ITEM
  btrfs: tree-checker: Add check for INODE_REF

 fs/btrfs/tree-checker.c | 78 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 76 insertions(+), 2 deletions(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-09-23 15:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26  7:40 [PATCH 0/2] btrfs: tree-checker: Add checks to detect missing INODE_ITEM Qu Wenruo
2019-08-26  7:40 ` [PATCH 1/2] btrfs: tree-checker: Try " Qu Wenruo
2019-08-26 11:46   ` Nikolay Borisov
2019-08-26  7:40 ` [PATCH 2/2] btrfs: tree-checker: Add check for INODE_REF Qu Wenruo
2019-08-26 11:45   ` Nikolay Borisov
2019-08-26 11:50     ` Qu Wenruo
2019-09-23 15:45       ` David Sterba
2019-09-23 15:47   ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).