Skip to contentSkip to conversation

btrfs-progs: copy btrfs-calc-size to inspect-internal tree-stats

PATCH In review Alexander Fougner 2 participants 3 messages Mar 11, 2016 – Mar 21, 2016

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

PATCH 1/2 btrfs-progs: copy btrfs-calc-size to inspect-internal tree-stats

---
 Makefile.in               |   3 +-
 btrfs-calc-size.c         | 482 +------------------------------------------
 cmds-inspect-tree-stats.c | 506 ++++++++++++++++++++++++++++++++++++++++++++++
 cmds-inspect-tree-stats.h |  26 +++
 cmds-inspect.c            |   5 +-
 5 files changed, 545 insertions(+), 477 deletions(-)
 create mode 100644 cmds-inspect-tree-stats.c
 create mode 100644 cmds-inspect-tree-stats.h
Makefile.in +2 -1
index dd30686..a179a36 100644
@@ -76,7 +76,7 @@ cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
 	       cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
 	       cmds-restore.o cmds-rescue.o chunk-recover.o super-recover.o \
 	       cmds-property.o cmds-fi-usage.o cmds-inspect-dump-tree.o \
-	       cmds-inspect-dump-super.o cmds-fi-du.o
+	       cmds-inspect-dump-super.o cmds-inspect-tree-stats.o cmds-fi-du.o
 libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o \
 		   uuid-tree.o utils-lib.o rbtree-utils.o
 libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
@@ -128,6 +128,7 @@ btrfs_convert_libs = @EXT2FS_LIBS@ @COM_ERR_LIBS@
 btrfs_fragments_libs = -lgd -lpng -ljpeg -lfreetype
 btrfs_debug_tree_objects = cmds-inspect-dump-tree.o
 btrfs_show_super_objects = cmds-inspect-dump-super.o
+btrfs_calc_size_objects = cmds-inspect-tree-stats.o
 
 SUBDIRS =
 BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
btrfs-calc-size.c +7 -475

497 lines not on this page · raw message

cmds-inspect-tree-stats.c new file +506 -0

506 lines not on this page · raw message

cmds-inspect-tree-stats.h new file +26 -0
new file mode 100644
index 0000000..eb401da
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2011 Red Hat.  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_TREE_STATS_H__
+#define __CMDS_INSPECT_TREE_STATS_H__
+
+int cmd_inspect_tree_stats(int argc, char **argv);
+
+extern const char * const cmd_inspect_tree_stats_usage[];
+
+#endif
cmds-inspect.c +4 -1
index 04e1ae8..d96b5c2 100644
@@ -33,6 +33,7 @@
 #include "btrfs-list.h"
 #include "cmds-inspect-dump-tree.h"
 #include "cmds-inspect-dump-super.h"
+#include "cmds-inspect-tree-stats.h"
 
 static const char * const inspect_cmd_group_usage[] = {
 	"btrfs inspect-internal <command> <args>",
@@ -293,7 +294,7 @@ static int cmd_inspect_subvolid_resolve(int argc, char **argv)
 
 out:
 	close_file_or_dir(fd, dirstream);
-	return ret ? 1 : 0;
+	return !!ret;
 }
 
 static const char* const cmd_inspect_rootid_usage[] = {
@@ -640,6 +641,8 @@ const struct cmd_group inspect_cmd_group = {
 				cmd_inspect_dump_tree_usage, NULL, 0 },
 		{ "dump-super", cmd_inspect_dump_super,
 				cmd_inspect_dump_super_usage, NULL, 0 },
+		{ "tree-stats", cmd_inspect_tree_stats,
+				cmd_inspect_tree_stats_usage, NULL, 0 },
 		NULL_CMD_STRUCT
 	}
 };
Signature · 1 line
2.7.2
#1 lore raw

PATCH 2/2 btrfs-progs: update docs and completion for tree-stats

---
 Documentation/btrfs-inspect-internal.asciidoc | 10 ++++++++++
 btrfs-completion                              |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)
Documentation/btrfs-inspect-internal.asciidoc +10 -0
index bbbbc59..eb83708 100644
@@ -128,6 +128,16 @@ for debugging (disables the '-f' option)
 +
 resolve the absolute path of a the subvolume id 'subvolid'
 
+*tree-stats* [options] <device>::
+(needs root privileges)
++
+Print sizes and statistics of trees.
++
+`Options`
++
+-b::::
+Print raw numbers in bytes.
+
 EXIT STATUS
 -----------
 *btrfs inspect-internal* returns a zero exit status if it succeeds. Non zero is
btrfs-completion +1 -1
index db0dd97..3ede77b 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 dump-super'
+    commands_inspect_internal='inode-resolve logical-resolve subvolid-resolve rootid min-dev-size dump-tree dump-super tree-stats'
     commands_property='get set list'
     commands_quota='enable disable rescan'
     commands_qgroup='assign remove create destroy show limit'
Signature · 1 line
2.7.2