Skip to contentSkip to conversation

btrfs-progs: copy functionality of btrfs-debug-tree to inspect-internal subcommand

PATCH In review Alexander Fougner 3 participants 4 messages Feb 22, 2016 – Feb 23, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 btrfs-progs: copy functionality of btrfs-debug-tree to inspect-internal subcommand

The long-term plan is to merge the features of standalone tools into the btrfs binary, reducing the number of shipped binaries.

---
 Makefile.in              |   2 +-
 btrfs-debug-tree.c       | 435 +-------------------------------------------
 cmds-inspect-dump-tree.c | 462 +++++++++++++++++++++++++++++++++++++++++++++++
 cmds-inspect-dump-tree.h |  26 +++
 cmds-inspect.c           |   8 +
 5 files changed, 504 insertions(+), 429 deletions(-)
 create mode 100644 cmds-inspect-dump-tree.c
 create mode 100644 cmds-inspect-dump-tree.h
Makefile.in +1 -1
index 19697ff..14dab76 100644
@@ -70,7 +70,7 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
 	  extent-cache.o extent_io.o volumes.o utils.o repair.o \
 	  qgroup.o raid6.o free-space-cache.o list_sort.o props.o \
 	  ulist.o qgroup-verify.o backref.o string-table.o task-utils.o \
-	  inode.o file.o find-root.o free-space-tree.o help.o
+	  inode.o file.o find-root.o free-space-tree.o help.o cmds-inspect-dump-tree.o
 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
 	       cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
 	       cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
btrfs-debug-tree.c +7 -428

454 lines not on this page · raw message

cmds-inspect-dump-tree.c new file +462 -0

462 lines not on this page · raw message

cmds-inspect-dump-tree.h new file +26 -0
new file mode 100644
index 0000000..0341e20
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2007 Oracle.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
+ #ifndef __CMDS_INSPECT_DUMP_TREE_H__
+ #define __CMDS_INSPECT_DUMP_TREE_H__
+
+int cmd_inspect_dump_tree(int ac, char **av);
+
+extern const char * const cmd_inspect_dump_tree_usage[];
+
+#endif
cmds-inspect.c +8 -0
index 7fa4881..25ddd4c 100644
@@ -31,6 +31,7 @@
 #include "disk-io.h"
 #include "commands.h"
 #include "btrfs-list.h"
+#include "cmds-inspect-dump-tree.h"
 
 static const char * const inspect_cmd_group_usage[] = {
 	"btrfs inspect-internal <command> <args>",
@@ -619,6 +620,11 @@ out:
 	return !!ret;
 }
 
+static int cmd_inspect_dump_tree_hook(int ac, char **av)
+{
+	return cmd_inspect_dump_tree(ac, av);
+}
+
 static const char inspect_cmd_group_info[] =
 "query various internal information";
 
@@ -634,6 +640,8 @@ const struct cmd_group inspect_cmd_group = {
 			0 },
 		{ "min-dev-size", cmd_inspect_min_dev_size,
 			cmd_inspect_min_dev_size_usage, NULL, 0 },
+		{ "dump-tree", cmd_inspect_dump_tree_hook,
+				cmd_inspect_dump_tree_usage, NULL, 0 },
 		NULL_CMD_STRUCT
 	}
 };
Signature · 1 line
2.7.1
#1 lore raw

PATCH v2 2/2 btrfs-progs: update docs and completion for inspect-internal dump-tree

---
 Documentation/btrfs-debug-tree.asciidoc       |  7 +++++++
 Documentation/btrfs-inspect-internal.asciidoc | 26 ++++++++++++++++++++++++++
 btrfs-completion                              |  8 ++++----
 3 files changed, 37 insertions(+), 4 deletions(-)
Documentation/btrfs-debug-tree.asciidoc +7 -0
index 23fc115..6d6d884 100644
@@ -25,8 +25,15 @@ Print detailed extents info.
 Print info of btrfs device and root tree dirs only.
 -r::
 Print info of roots only.
+-R::
+Print info of roots and root backups.
+-u::
+Print info of UUID tree only.
 -b <block_num>::
 Print info of the specified block only.
+-t <tree_id>::
+Print only the tree with the specified ID.
+
 
 EXIT STATUS
 -----------
Documentation/btrfs-inspect-internal.asciidoc +26 -0
index 1c7c361..25e6b8b 100644
@@ -67,6 +67,32 @@ inode number 2), but such subvolume does not contain any files anyway
 +
 resolve the absolute path of a the subvolume id 'subvolid'
 
+*dump-tree* [options] <device>::
+(needs root privileges)
++
+Dump the whole tree of the given device.
+This is useful for analyzing filesystem state or inconsistence and has
+a positive educational effect on understanding the internal structure.
+<device> is the device file where the filesystem is stored.
++
+`Options`
++
+-e::::
+Print detailed extents info.
+-d::::
+Print info of btrfs device and root tree dirs only.
+-r::::
+Print info of roots only.
+-R::::
+Print info of roots and root backups.
+-u::::
+Print info of UUID tree only.
+-b <block_num>::::
+Print info of the specified block only.
+-t <tree_id>::::
+Print only the tree with the specified ID.
+
+
 EXIT STATUS
 -----------
 *btrfs inspect-internal* returns a zero exit status if it succeeds. Non zero is
btrfs-completion +4 -4
index a34191b..7631911 100644
@@ -20,13 +20,13 @@ _btrfs_mnts()
 	COMPREPLY+=( $( compgen -W "$MNTS" -- "$cur" ) )
 }
 
-_btrfs() 
+_btrfs()
 {
 	local cur prev words cword
     _init_completion || return
 
     COMPREPLY=()
-    
+
 	local cmd=${words[1]}
 
     commands='subvolume filesystem balance device scrub check rescue restore inspect-internal property send receive quota qgroup replace help version'
@@ -36,7 +36,7 @@ _btrfs()
     commands_device='scan add delete remove ready stats usage'
     commands_scrub='start cancel resume status'
     commands_rescue='chunk-recover super-recover'
-    commands_inspect_internal='inode-resolve logical-resolve subvolid-resolve rootid min-dev-size'
+    commands_inspect_internal='inode-resolve logical-resolve subvolid-resolve rootid min-dev-size dump-tree'
     commands_property='get set list'
     commands_quota='enable disable rescan'
     commands_qgroup='assign remove create destroy show limit'
@@ -146,7 +146,7 @@ _btrfs()
     fi
 
     _filedir -d
-    return 0  
+    return 0
 }
 
 complete -F _btrfs btrfs
Signature · 1 line
2.7.1
#2 lore raw
In reply to Alexander Fougner

Alexander Fougner posted on Mon, 22 Feb 2016 15:49:49 +0100 as excerpted:

Quoted 5 lines

The long-term plan is to merge the features of standalone tools into the btrfs binary, reducing the number of shipped binaries.

---

Typically, V2+ also includes a short, often one-line, description of what changed between versions. This helps reviewers and others who may have reviewed/tested previous versions, or who may simply be interested in following the evolution of the patch as it improves toward acceptance and merging, since it avoids everyone having to do the diffs for themselves.

It's also useful to others who may be considering submitting their own patches, since it can give them hints on avoiding some of the same initial mistakes and thus avoiding a round-trip or two, as they may be able to correct some of the issues before they post their patches the first time (or the second time, if they notice the practice of including the changes description on existing patch revision posts and include it themselves without anyone having to ask). =:^)

Unfortunately, while the subject says v2, I don't see any such changes since v1 description, here. =:^(

There's many examples on the list if you need one. Here's a link to the first one I happened to find, a good example of how it can look on slightly more advanced patch series of several patches, once they've gone thru several revisions. (Click the topic link on the left to see the individual patches, which here don't include individual changelogs as they're in the 00/19 post.)

http://permalink.gmane.org/gmane.comp.file-systems.btrfs/53306

Signature · 3 lines
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman