Skip to contentSkip to conversation

btrfs-progs: introduce inspect-internal dump-super

PATCH Applied Alexander Fougner 2 participants 4 messages Feb 24, 2016

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

PATCH 1/2 btrfs-progs: introduce inspect-internal dump-super

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

---
 Makefile.in               |   3 +-
 btrfs-show-super.c        | 520 +-------------------------------------------
 cmds-inspect-dump-super.c | 539 ++++++++++++++++++++++++++++++++++++++++++++++
 cmds-inspect-dump-super.h |  26 +++
 cmds-inspect.c            |   8 +
 5 files changed, 582 insertions(+), 514 deletions(-)
 create mode 100644 cmds-inspect-dump-super.c
 create mode 100644 cmds-inspect-dump-super.h
Makefile.in +2 -1
index 3bb073a..d528da2 100644
@@ -70,7 +70,8 @@ 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 cmds-inspect-dump-tree.o
+	  inode.o file.o find-root.o free-space-tree.o help.o \
+	  cmds-inspect-dump-tree.o cmds-inspect-dump-super.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-show-super.c +7 -513

534 lines not on this page · raw message

cmds-inspect-dump-super.c new file +539 -0

539 lines not on this page · raw message

cmds-inspect-dump-super.h new file +26 -0
new file mode 100644
index 0000000..86472ef
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2012 STRATO AG.  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_SUPER_H__
+#define __CMDS_INSPECT_DUMP_SUPER_H__
+
+int cmd_inspect_dump_super(int ac, char **av);
+
+extern const char * const cmd_inspect_dump_super_usage[];
+
+#endif
cmds-inspect.c +8 -0
index 25ddd4c..176f836 100644
@@ -32,6 +32,7 @@
 #include "commands.h"
 #include "btrfs-list.h"
 #include "cmds-inspect-dump-tree.h"
+#include "cmds-inspect-dump-super.h"
 
 static const char * const inspect_cmd_group_usage[] = {
 	"btrfs inspect-internal <command> <args>",
@@ -625,6 +626,11 @@ static int cmd_inspect_dump_tree_hook(int ac, char **av)
 	return cmd_inspect_dump_tree(ac, av);
 }
 
+static int cmd_inspect_dump_super_hook(int ac, char **av)
+{
+	return cmd_inspect_dump_super(ac, av);
+}
+
 static const char inspect_cmd_group_info[] =
 "query various internal information";
 
@@ -642,6 +648,8 @@ const struct cmd_group inspect_cmd_group = {
 			cmd_inspect_min_dev_size_usage, NULL, 0 },
 		{ "dump-tree", cmd_inspect_dump_tree_hook,
 				cmd_inspect_dump_tree_usage, NULL, 0 },
+		{ "dump-super", cmd_inspect_dump_super_hook,
+				cmd_inspect_dump_super_usage, NULL, 0 },
 		NULL_CMD_STRUCT
 	}
 };

--
2.7.1

#1 lore raw

PATCH 2/2 btrfs-progs: update docs for inspect-internal dump-super

---
 Documentation/btrfs-inspect-internal.asciidoc | 38 +++++++++++++++++++++++++++
 btrfs-completion                              |  2 +-
 2 files changed, 39 insertions(+), 1 deletion(-)
Documentation/btrfs-inspect-internal.asciidoc +38 -0
index 25e6b8b..a151471 100644
@@ -92,6 +92,44 @@ Print info of the specified block only.
 -t <tree_id>::::
 Print only the tree with the specified ID.
 
+*show-super* [options] <device> [device...]::
+(needs root privileges)
++
+Show btrfs superblock information stored in devices.
+It is used to print the information of superblock,
+you can specify which mirror to print out.
++
+By default, every device's first superblock will be printed out.
++
+Mainly used for debug purpose.
++
+`Options`
++
+
+-f::::
+Print full superblock information.
++
+Including the system chunk array and backup roots.
+
+-a::::
+Print information of all superblocks.
++
+If this option is given, '-i' option will be ignored.
+
+-i <super_mirror>::::
+Specify which mirror to print out.
++
+<super_mirror> is between 0 and 2.
+If several '-i <super_mirror>' are given, only the last one is valid.
+
+-F::::
+Attempt to print the superblock even if no superblock magic is found.  May end
+badly.
+
+-s <bytenr>::::
+specifiy offset to a superblock in a non-standard location at 'bytenr', useful
+for debugging (disables the '-f' option)
+
 
 EXIT STATUS
 -----------
btrfs-completion +1 -1
index 7631911..db0dd97 100644
@@ -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 dump-tree'
+    commands_inspect_internal='inode-resolve logical-resolve subvolid-resolve rootid min-dev-size dump-tree dump-super'
     commands_property='get set list'
     commands_quota='enable disable rescan'
     commands_qgroup='assign remove create destroy show limit'
Signature · 1 line
2.7.1
#2 lore raw

Re: [PATCH 2/2] btrfs-progs: update docs for inspect-internal dump-super

Documentation/btrfs-inspect-internal.asciidoc Print info of the specified block only. · line 95

Quoted 7 lines · Alexander Fougner
Documentation/btrfs-inspect-internal.asciidoc +1 -0
@@ -92,6 +92,44 @@ Print info of the specified block only.
 -t <tree_id>::::
 Print only the tree with the specified ID.
 
+*show-super* [options] <device> [device...]::

The command names are supposed to be in alphabetical order, fixed.

Applied
#3 lore raw
In reply to Alexander Fougner
Quoted 2 lines · Alexander Fougner

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

Applied, thanks.

Makefile.in objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ · line 74

Quoted 9 lines
Makefile.in +2 -1
@@ -70,7 +70,8 @@ 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 cmds-inspect-dump-tree.o
+	  inode.o file.o find-root.o free-space-tree.o help.o \
+	  cmds-inspect-dump-tree.o cmds-inspect-dump-super.o

the objects belong to cmds_objects but needed some further changes to pass the specific objects to the standalone utilities.