Commit Graph

18 Commits (master)

Author SHA1 Message Date
Qu Wenruo c003709191 btrfs-progs: print-tree: Use BFS as default traversal method
When debugging tree nodes with higher level, default DFS is not that
reader friendly:

  file tree key (262 ROOT_ITEM 16)
  node 33800192 level 2 items 4 free 117 generation 16 owner 262
  fs uuid 2d66d111-6850-4ca1-ae73-03f50adde41c
  chunk uuid 11141e63-2534-4d04-a0bd-c0531a8f5b88
  	key (256 INODE_ITEM 0) block 33771520 gen 15
  	key (330 EXTENT_DATA 0) block 33325056 gen 11
  	key (438 EXTENT_DATA 0) block 33652736 gen 15
  	key (654 EXTENT_DATA 0) block 33644544 gen 15
  node 33771520 level 1 items 59 free 62 generation 15 owner 256
  fs uuid 2d66d111-6850-4ca1-ae73-03f50adde41c
  chunk uuid 11141e63-2534-4d04-a0bd-c0531a8f5b88
  	key (256 INODE_ITEM 0) block 33787904 gen 15
  	key (256 DIR_ITEM 273597024) block 33124352 gen 9
  	[...]
  leaf 33787904 items 30 free space 1868 generation 15 owner 256
  fs uuid 2d66d111-6850-4ca1-ae73-03f50adde41c
  chunk uuid 11141e63-2534-4d04-a0bd-c0531a8f5b88
  	item 0 key (256 INODE_ITEM 0) itemoff 3835 itemsize 160
  		generation 6 transid 15 size 12954 nbytes 0
  		block group 0 mode 40755 links 1 uid 0 gid 0 rdev 0
  		sequence 528 flags 0x0(none)
  		atime 1565071339.446118888 (2019-08-06 14:02:19)
  		ctime 1565071339.449452222 (2019-08-06 14:02:19)
  		mtime 1565071339.449452222 (2019-08-06 14:02:19)
  		otime 1565071338.89452221 (2019-08-06 14:02:18)
  	item 1 key (256 INODE_REF 256) itemoff 3823 itemsize 12
  		index 0 namelen 2 name: ..
  	item 2 key (256 DIR_ITEM 2487323) itemoff 3781 itemsize 42
  		location key (487 INODE_ITEM 0) type FILE
  		transid 7 data_len 0 name_len 12
  		name: file_reg_115
  	[...]
  leaf 33124352 items 31 free space 1873 generation 9 owner 256
  	[...]

However such DFS will show the leaves before nodes. If tracing things
like drop_progress, we want to see nodes first then leaves.

So change default behavior to BFS to life of developers easier.

This affects 'btrfs inspect-internal dump-tree' output, the traversal
order can be selected by --dfs or --bfs options.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:27:28 +02:00
Qu Wenruo 9f6d9ec10c btrfs-progs: print-tree: Use bool for @follow
Just a minor cleanup to make the parameter easier to read.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo 0bbd407cbb btrfs-progs: print-tree: Introduce --bfs and --dfs options
Originally print-tree uses depth first search to print trees.
This works fine until we reach 3 level trees (root node level is 2).

For tall trees whose root level is 2 or higher, DFS will mix nodes and
leaves like the following example:

Level 2                       A
                             / \
Level 1                     B   C
                          / |   | \
Level 0                  D  E   F  G

DFS will cause the following output sequence:
A   B   D   E   C   F   G
Which in term of node/leave is:
N   N   L   L   N   L   L

Such mixed node/leave result is sometimes hard for human to read.

This patch will introduce 2 new options, --bfs and --dfs.

  --dfs: keeps the original output sequence, and to keep things
         compatible it's the default behavior.

  --bfs: uses breadth-first search, and will cause better output
         sequence like:

	 A   B   C   D   E   F   G
	 Which in term of node/leave is:
	 N   N   N   L   L   L   L

Much better sorted and may become default in the future.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo 26c1dafbf6 btrfs-progs: print-tree: Remove btrfs_root parameter
Just like kernel cleanup made by David, btrfs_print_leaf() and
btrfs_print_tree() doesn't need btrfs_root parameter at all.

With previous patches as preparation, now we can remove the btrfs_root
parameter.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-04-24 13:00:11 +02:00
David Sterba 1224f7343e btrfs-progs: print-tree: rename item callbacks to match the key name
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
Qu Wenruo 00045ff485 btrfs-progs: Enhance and export print_key_type function
Just the same thing done for print_objectid().

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:07 +02:00
Qu Wenruo 7aafabd2b8 btrfs-progs: Enhance and export print_objectid function
This function is quite useful for a lot of error report.
Enhance it to support custom output other than stdout.
And export it for later btrfsck enhancement.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:04 +02:00
David Sterba 07ce7005fc btrfs-progs: unify header file inclusion protections
There are missing ifdefs or defines with very generic names.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-21 17:49:26 +01:00
Mark Fasheh 96ec888aad btrfs-progs: add quota group verify code
This patch adds functionality (in qgroup-verify.c) to compute bytecounts in
subvolume quota groups. The original groups are read in and stored in memory
so that after we compute our own bytecounts, we can compare them with those
on disk. A print function is provided to do this comparison and show the
results on the console.

A 'qgroup check' pass is added to btrfsck. If any subvolume quota groups
differ from what we compute, the differences for them are printed.  We also
provide an option '--qgroup-report' which will run only the quota check code
and print a report on all quota groups.  Other than making it possible to
verify that our qgroup changes work correctly, this mode can also be used in
xfstests for automated checking after qgroup tests.

This patch does not address the following:
- compressed counts are identical to non compressed, because kernel doesn't
  make the distinction yet.  Adding the code to verify compressed counts
  shouldn't be hard at all though once kernel can do this.
- It is only concerned with subvolume quota groups (like most of
  btrfs-progs).

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:39:33 +02:00
Gui Hecheng bddb8e0fd7 btrfs-progs: add sys_chunk_array and backup roots info to show-super
Add sys chunk array and backup roots info if the new option '-f'
if specified.
This may be useful for debugging sys_chunk related issues.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:39:31 +02:00
Chris Mason 075587c96c Btrfs: add btrfs-debug-tree -b <block number> to print a single block 2010-04-06 09:30:17 -04:00
Shen Feng 61907d4e81 Update btrfs-debug-tree to output more readable strings.
output objectid in btrfs_disk_key with human readable strings.
Other updates are included for more readable output.

Thanks Fengguang's fix to this patch.

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-06-03 12:15:40 -04:00
Yan 7777e63b42 Update btrfs-progs to match kernel sources 2008-01-04 10:38:22 -05:00
Chris Mason d9f1317c7d add GPLv2 2007-06-12 09:07:11 -04:00
Chris Mason f247156e4f transaction handles everywhere 2007-03-16 16:20:31 -04:00
Chris Mason 7a0a809b4c variable block size support 2007-03-14 14:14:43 -04:00
Chris Mason aa60202f13 rename funcs and structs to btrfs 2007-03-13 10:46:10 -04:00
Chris Mason 74556aa757 Break up ctree.c a little
Extent fixes
2007-02-24 06:24:44 -05:00