mbox series

[v1.2,0/3] btrfs: tree-checker: Add extent items check

Message ID 20190809012424.11420-1-wqu@suse.com (mailing list archive)
Headers show
Series btrfs: tree-checker: Add extent items check | expand

Message

Qu Wenruo Aug. 9, 2019, 1:24 a.m. UTC
Finally, we are going to add tree-checker support for extent items,
which includes:
- EXTENT_ITEM/METADATA_ITEM
  Which futher contains inline backrefs of:
  * TREE_BLOCK_REF
  * SHARED_BLOCK_REF
  * EXETNT_DATA_REF
  * SHARED_DATA_REF

- TREE_BLOCK_REF
- SHARED_BLOCK_REF
- EXTENT_DATA_REF
- SHARED_DATA_REF
  Keyed version of the above types

The complexity of the on-disk format can be found in the first patch,
which contains a basic introduction as comment.

Hidden pitfalls are everywhere, e.g. inlined EXTENT_DATA_REF don't use
iref->offset, but put its own data at iref->offset.
But SHARED_DATA_REF uses iref->offset, and put extra data after iref.

Such on-disk layout makes sense, but definitely a mess to read.
Thankfully we at least have print-tree code from btrfs-progs as a
reference.

Changelog:
v1.1:
- If branches optimization
  Make some if branches more readable.

- Range notion update
  Use regular set notion ([],[),(],()) to show possible value range.

- Fix a wrong range notion
  The valid range for tree level is [0, MAX_LEVEL - 1], not
  [0, MAX_LEVEL -1)

v1.2:
- Use "unsigned long" for pointer convertion

- Use "%zu" format for sizeof() in the 3rd patch

Qu Wenruo (3):
  btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check
  btrfs: tree-checker: Add simple keyed refs check
  btrfs: tree-checker: Add EXTENT_DATA_REF check

 fs/btrfs/ctree.h        |   1 +
 fs/btrfs/extent-tree.c  |   2 +-
 fs/btrfs/tree-checker.c | 336 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 338 insertions(+), 1 deletion(-)

Comments

David Sterba Aug. 22, 2019, 3:08 p.m. UTC | #1
On Fri, Aug 09, 2019 at 09:24:21AM +0800, Qu Wenruo wrote:
> Finally, we are going to add tree-checker support for extent items,
> which includes:
> - EXTENT_ITEM/METADATA_ITEM
>   Which futher contains inline backrefs of:
>   * TREE_BLOCK_REF
>   * SHARED_BLOCK_REF
>   * EXETNT_DATA_REF
>   * SHARED_DATA_REF
> 
> - TREE_BLOCK_REF
> - SHARED_BLOCK_REF
> - EXTENT_DATA_REF
> - SHARED_DATA_REF
>   Keyed version of the above types

Great, thanks.

> v1.2:
  ^^^^

Please use integers for patchsets, ie. this is v3 for me.

> - Use "unsigned long" for pointer convertion
> 
> - Use "%zu" format for sizeof() in the 3rd patch
> 
> Qu Wenruo (3):
>   btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check
>   btrfs: tree-checker: Add simple keyed refs check
>   btrfs: tree-checker: Add EXTENT_DATA_REF check

I'll update patch 1 with the goto -> return and fix the comments, no
need to resend. V2 has been in for-next, there were no significant
changes since so I'll add v3 to misc-next. Thanks.