All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] Enhanced df - followup
@ 2014-04-29 15:56 David Sterba
  2014-04-29 15:57 ` [PATCH 01/14] btrfs-progs: read global reserve size from space infos David Sterba
                   ` (15 more replies)
  0 siblings, 16 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 15:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Hi,

this is a followup to the df (space usage) enhancements, Goffredo's
patches are merged without changes, though the code needs updates.

But, given the patchset size, net benefit of the enriched output and
longstanding need of the update, I've deliberately skipped the process of
incremental rewiew/resend loop that should normally take place and implemented
the changes that were agreed in previous discussions and did code cleanups
along the way.

The basic layout of the command output has been kept, there are some
tweaks or additions.

Changes:
* btrfs filesystem disk_usage - renamed to usage
  * added a section of overall filesystem usage, that used to be in the
    'fi df' output
* btrfs device disk_usage - renamed to usage
  * the device size prints both blockdevie size and the size that's occupied
    by the filesystem
  * device ID is printed
* btrfs filesystem df - reverted to the original output
* btrfs filesystem df - now prints the GlobalReserve info
* units print B for bytes
* the ioctls FS_INFO and DEV_INFO need root (patches sent to drop that
  requirement), so there's a warning printed instead
* no documentation for now

It's not finished, I've tried to scan all the previous iteration of the
patches for the suggested UI tweaks and probably missed some, but IMO in a
state that can go to git and be scheduled for a near release.

The major UI changes are there, we can tweak it further of course.


David Sterba (14):
  btrfs-progs: read global reserve size from space infos
  btrfs-progs: add original 'df' and rename 'disk_usage' to 'usage'
  btrfs-progs: move device usage to cmds-device, more cleanups
  btrfs-progs: check if we can't get info from ioctls due to permissions
  btrfs-progs: zero out structures before calling ioctl
  btrfs-progs: print B for bytes
  btrfs-progs: Print more info about device sizes
  btrfs-progs: compare unallocated space against the correct value
  btrfs-progs: add section of overall filesystem usage
  btrfs-progs: cleanup filesystem/device usage code
  btrfs-progs: extend pretty printers with unit mode
  btrfs-progs: replace df_pretty_sizes with pretty_size_mode
  btrfs-progs: clean up return codes and paths
  btrfs-progs: move global reserve to overall summary

 cmds-device.c        |  92 +++++++-
 cmds-fi-disk_usage.c | 631 +++++++++++++++++++--------------------------------
 cmds-fi-disk_usage.h |  35 ++-
 cmds-filesystem.c    |  55 ++++-
 ctree.h              |   6 +
 utils.c              |  78 +++++--
 utils.h              |  21 +-
 7 files changed, 482 insertions(+), 436 deletions(-)

-- 
1.9.0


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 01/14] btrfs-progs: read global reserve size from space infos
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
@ 2014-04-29 15:57 ` David Sterba
  2014-04-29 15:57 ` [PATCH 02/14] btrfs-progs: add original 'df' and rename 'disk_usage' to 'usage' David Sterba
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 15:57 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Kernels >= 3.15 export the global block reserve as a space info presented
by 'btrfs fi df' but would display 'unknown' instead of some meaningful
string.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 ctree.h | 6 ++++++
 utils.c | 7 ++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ctree.h b/ctree.h
index 8ac17619b9dc..5c43fc5f5f6e 100644
--- a/ctree.h
+++ b/ctree.h
@@ -862,6 +862,12 @@ struct btrfs_csum_item {
 /* used in struct btrfs_balance_args fields */
 #define BTRFS_AVAIL_ALLOC_BIT_SINGLE	(1ULL << 48)
 
+/*
+ * GLOBAL_RSV does not exist as a on-disk block group type and is used
+ * internally for exporting info about global block reserve from space infos
+ */
+#define BTRFS_SPACE_INFO_GLOBAL_RSV    (1ULL << 49)
+
 #define BTRFS_QGROUP_STATUS_OFF			0
 #define BTRFS_QGROUP_STATUS_ON			1
 #define BTRFS_QGROUP_STATUS_SCANNING		2
diff --git a/utils.c b/utils.c
index f2ab416c28b2..ca150404ea6f 100644
--- a/utils.c
+++ b/utils.c
@@ -2240,7 +2240,10 @@ u64 get_partition_size(char *dev)
  */
 const char *group_type_str(u64 flag)
 {
-	switch (flag & BTRFS_BLOCK_GROUP_TYPE_MASK) {
+	u64 mask = BTRFS_BLOCK_GROUP_TYPE_MASK |
+		BTRFS_SPACE_INFO_GLOBAL_RSV;
+
+	switch (flag & mask) {
 	case BTRFS_BLOCK_GROUP_DATA:
 		return "Data";
 	case BTRFS_BLOCK_GROUP_SYSTEM:
@@ -2249,6 +2252,8 @@ const char *group_type_str(u64 flag)
 		return "Metadata";
 	case BTRFS_BLOCK_GROUP_DATA|BTRFS_BLOCK_GROUP_METADATA:
 		return "Data+Metadata";
+	case BTRFS_SPACE_INFO_GLOBAL_RSV:
+		return "GlobalReserve";
 	default:
 		return "unknown";
 	}
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 02/14] btrfs-progs: add original 'df' and rename 'disk_usage' to 'usage'
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
  2014-04-29 15:57 ` [PATCH 01/14] btrfs-progs: read global reserve size from space infos David Sterba
@ 2014-04-29 15:57 ` David Sterba
  2014-04-29 15:58 ` [PATCH 03/14] btrfs-progs: move device usage to cmds-device, more cleanups David Sterba
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 15:57 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Add back the original output of the 'btrfs fi df' command for backward
compatibility. The rich output is moved from 'disk_usage' to 'usage'.

Agreed in http://www.spinics.net/lists/linux-btrfs/msg31698.html

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-fi-disk_usage.c | 85 ++++++++++------------------------------------------
 cmds-fi-disk_usage.h |  7 ++---
 cmds-filesystem.c    | 55 ++++++++++++++++++++++++++++++++--
 3 files changed, 71 insertions(+), 76 deletions(-)

diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 2bd591db0f8a..400863d9764f 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -328,6 +328,8 @@ static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path)
 	return sargs;
 }
 
+/* Not used, keep for later */
+#if 0
 /*
  * This function computes the space occuped by a *single* RAID5/RAID6 chunk.
  * The computation is performed on the basis of the number of stripes
@@ -465,62 +467,7 @@ exit:
 
 	return ret;
 }
-
-const char * const cmd_filesystem_df_usage[] = {
-	"btrfs filesystem df [-b] <path> [<path>..]",
-	"Show space usage information for a mount point(s).",
-	"",
-	"-b\tSet byte as unit",
-	NULL
-};
-
-int cmd_filesystem_df(int argc, char **argv)
-{
-
-	int	flags = DF_HUMAN_UNIT;
-	int	i, more_than_one = 0;
-
-	optind = 1;
-	while (1) {
-		char	c = getopt(argc, argv, "b");
-		if (c < 0)
-			break;
-
-		switch (c) {
-		case 'b':
-			flags &= ~DF_HUMAN_UNIT;
-			break;
-		default:
-			usage(cmd_filesystem_df_usage);
-		}
-	}
-
-	if (check_argc_min(argc - optind, 1))
-		usage(cmd_filesystem_df_usage);
-
-	for (i = optind; i < argc ; i++) {
-		int r, fd;
-		DIR *dirstream = NULL;
-		if (more_than_one)
-			printf("\n");
-
-		fd = open_file_or_dir(argv[i], &dirstream);
-		if (fd < 0) {
-			fprintf(stderr, "ERROR: can't access to '%s'\n",
-				argv[1]);
-			return 12;
-		}
-		r = _cmd_disk_free(fd, argv[i], flags);
-		close_file_or_dir(fd, dirstream);
-
-		if (r)
-			return r;
-		more_than_one = 1;
-
-	}
-
-	return 0;
-}
+#endif
 
 /*
  *  Helper to sort the disk_info structure
@@ -612,10 +559,10 @@ static u64 calc_chunk_size(struct chunk_info *ci)
 }
 
 /*
- *  This function print the results of the command btrfs fi disk-usage
+ *  This function print the results of the command "btrfs fi usage"
  *  in tabular format
  */
-static void _cmd_filesystem_disk_usage_tabular(int mode,
+static void _cmd_filesystem_usage_tabular(int mode,
 					struct btrfs_ioctl_space_args *sargs,
 					struct chunk_info *chunks_info_ptr,
 					int chunks_info_count,
@@ -795,10 +742,10 @@ static void print_chunk_disks(u64 chunk_type,
 }
 
 /*
- *  This function print the results of the command btrfs fi disk-usage
+ *  This function print the results of the command "btrfs fi usage"
  *  in linear format
  */
-static void _cmd_filesystem_disk_usage_linear(int mode,
+static void _cmd_filesystem_usage_linear(int mode,
 					struct btrfs_ioctl_space_args *sargs,
 					struct chunk_info *info_ptr,
 					int info_count,
@@ -839,7 +786,7 @@ static void _cmd_filesystem_disk_usage_linear(int mode,
 
 }
 
-static int _cmd_filesystem_disk_usage(int fd, char *path, int mode, int tabular)
+static int _cmd_filesystem_usage(int fd, char *path, int mode, int tabular)
 {
 	struct btrfs_ioctl_space_args *sargs = 0;
 	int info_count = 0;
@@ -860,11 +807,11 @@ static int _cmd_filesystem_disk_usage(int fd, char *path, int mode, int tabular)
 	}
 
 	if (tabular)
-		_cmd_filesystem_disk_usage_tabular(mode, sargs,
+		_cmd_filesystem_usage_tabular(mode, sargs,
 					info_ptr, info_count,
 					disks_info_ptr, disks_info_count);
 	else
-		_cmd_filesystem_disk_usage_linear(mode, sargs,
+		_cmd_filesystem_usage_linear(mode, sargs,
 					info_ptr, info_count,
 					disks_info_ptr, disks_info_count);
 
@@ -880,8 +827,8 @@ exit:
 	return ret;
 }
 
-const char * const cmd_filesystem_disk_usage_usage[] = {
-	"btrfs filesystem disk-usage [-b][-t] <path> [<path>..]",
+const char * const cmd_filesystem_usage_usage[] = {
+	"btrfs filesystem usage [-b][-t] <path> [<path>..]",
 	"Show in which disk the chunks are allocated.",
 	"",
 	"-b\tSet byte as unit",
@@ -889,7 +836,7 @@ const char * const cmd_filesystem_disk_usage_usage[] = {
 	NULL
 };
 
-int cmd_filesystem_disk_usage(int argc, char **argv)
+int cmd_filesystem_usage(int argc, char **argv)
 {
 
 	int	flags =	DF_HUMAN_UNIT;
@@ -909,12 +856,12 @@ int cmd_filesystem_disk_usage(int argc, char **argv)
 			tabular = 1;
 			break;
 		default:
-			usage(cmd_filesystem_disk_usage_usage);
+			usage(cmd_filesystem_usage_usage);
 		}
 	}
 
 	if (check_argc_min(argc - optind, 1))
-		usage(cmd_filesystem_disk_usage_usage);
+		usage(cmd_filesystem_usage_usage);
 
 	for (i = optind; i < argc ; i++) {
 		int r, fd;
@@ -928,7 +875,7 @@ int cmd_filesystem_disk_usage(int argc, char **argv)
 				argv[1]);
 			return 12;
 		}
-		r = _cmd_filesystem_disk_usage(fd, argv[i], flags, tabular);
+		r = _cmd_filesystem_usage(fd, argv[i], flags, tabular);
 		close_file_or_dir(fd, dirstream);
 
 		if (r)
diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
index c315004cd806..95cf4aabefb4 100644
--- a/cmds-fi-disk_usage.h
+++ b/cmds-fi-disk_usage.h
@@ -19,11 +19,8 @@
 #ifndef __CMDS_FI_DISK_USAGE__
 #define __CMDS_FI_DISK_USAGE__
 
-extern const char * const cmd_filesystem_df_usage[];
-int cmd_filesystem_df(int argc, char **argv);
-
-extern const char * const cmd_filesystem_disk_usage_usage[];
-int cmd_filesystem_disk_usage(int argc, char **argv);
+extern const char * const cmd_filesystem_usage_usage[];
+int cmd_filesystem_usage(int argc, char **argv);
 
 extern const char * const cmd_device_disk_usage_usage[];
 int cmd_device_disk_usage(int argc, char **argv);
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 214a0cda518c..9340cb61cabe 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -113,6 +113,26 @@ static const char * const filesystem_cmd_group_usage[] = {
 	NULL
 };
 
+static const char * const cmd_filesystem_df_usage[] = {
+       "btrfs filesystem df <path>",
+       "Show space usage information for a mount point",
+       NULL
+};
+
+static void print_df(struct btrfs_ioctl_space_args *sargs)
+{
+       u64 i;
+       struct btrfs_ioctl_space_info *sp = sargs->spaces;
+
+       for (i = 0; i < sargs->total_spaces; i++, sp++) {
+               printf("%s, %s: total=%s, used=%s\n",
+                       group_type_str(sp->flags),
+                       group_profile_str(sp->flags),
+                       pretty_size(sp->total_bytes),
+                       pretty_size(sp->used_bytes));
+       }
+}
+
 static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret)
 {
 	u64 count = 0;
@@ -161,6 +181,37 @@ static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret)
 	return 0;
 }
 
+static int cmd_filesystem_df(int argc, char **argv)
+{
+       struct btrfs_ioctl_space_args *sargs = NULL;
+       int ret;
+       int fd;
+       char *path;
+       DIR *dirstream = NULL;
+
+       if (check_argc_exact(argc, 2))
+               usage(cmd_filesystem_df_usage);
+
+       path = argv[1];
+
+       fd = open_file_or_dir(path, &dirstream);
+       if (fd < 0) {
+               fprintf(stderr, "ERROR: can't access '%s'\n", path);
+               return 1;
+       }
+       ret = get_df(fd, &sargs);
+
+       if (!ret && sargs) {
+               print_df(sargs);
+               free(sargs);
+       } else {
+               fprintf(stderr, "ERROR: get_df failed %s\n", strerror(-ret));
+       }
+
+       close_file_or_dir(fd, dirstream);
+       return !!ret;
+}
+
 static int match_search_item_kernel(__u8 *fsid, char *mnt, char *label,
 					char *search)
 {
@@ -918,8 +969,8 @@ const struct cmd_group filesystem_cmd_group = {
 		{ "balance", cmd_balance, NULL, &balance_cmd_group, 1 },
 		{ "resize", cmd_resize, cmd_resize_usage, NULL, 0 },
 		{ "label", cmd_label, cmd_label_usage, NULL, 0 },
-		{ "disk-usage", cmd_filesystem_disk_usage,
-			cmd_filesystem_disk_usage_usage, NULL, 0 },
+		{ "usage", cmd_filesystem_usage,
+			cmd_filesystem_usage_usage, NULL, 0 },
 
 		NULL_CMD_STRUCT
 	}
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 03/14] btrfs-progs: move device usage to cmds-device, more cleanups
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
  2014-04-29 15:57 ` [PATCH 01/14] btrfs-progs: read global reserve size from space infos David Sterba
  2014-04-29 15:57 ` [PATCH 02/14] btrfs-progs: add original 'df' and rename 'disk_usage' to 'usage' David Sterba
@ 2014-04-29 15:58 ` David Sterba
  2014-04-29 15:58 ` [PATCH 04/14] btrfs-progs: check if we can't get info from ioctls due to permissions David Sterba
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 15:58 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Move the command definitions where they belong, keep common 'usage'
functions in cmds-fi-disk_usage.c and add exports.

Rename structures containing 'disk' to 'device'.

Fix whitespace in the modified code.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-device.c        |  96 +++++++++++++++++-
 cmds-fi-disk_usage.c | 281 ++++++++++++---------------------------------------
 cmds-fi-disk_usage.h |  30 +++++-
 3 files changed, 188 insertions(+), 219 deletions(-)

diff --git a/cmds-device.c b/cmds-device.c
index a9b4a3859390..7a9d808b36dd 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -423,6 +423,98 @@ out:
 	return err;
 }
 
+const char * const cmd_device_usage_usage[] = {
+	"btrfs device usage [-b] <path> [<path>..]",
+	"Show which chunks are in a device.",
+	"",
+	"-b\tSet byte as unit",
+	NULL
+};
+
+static int _cmd_device_usage(int fd, char *path, int mode)
+{
+	int i;
+	int ret = 0;
+	int info_count = 0;
+	struct chunk_info *info_ptr = 0;
+	struct device_info *device_info_ptr = 0;
+	int device_info_count = 0;
+
+	if (load_chunk_info(fd, &info_ptr, &info_count) ||
+	    load_device_info(fd, &device_info_ptr, &device_info_count)) {
+		ret = -1;
+		goto exit;
+	}
+
+	for (i = 0; i < device_info_count; i++) {
+		printf("%s\t%10s\n", device_info_ptr[i].path,
+			df_pretty_sizes(device_info_ptr[i].size, mode));
+
+		print_device_chunks(fd, device_info_ptr[i].devid,
+				device_info_ptr[i].size,
+				info_ptr, info_count,
+				mode);
+		printf("\n");
+	}
+
+exit:
+	if (device_info_ptr)
+		free(device_info_ptr);
+	if (info_ptr)
+		free(info_ptr);
+
+	return ret;
+}
+
+int cmd_device_usage(int argc, char **argv)
+{
+
+	int	flags = DF_HUMAN_UNIT;
+	int	i, more_than_one = 0;
+
+	optind = 1;
+	while (1) {
+		char	c = getopt(argc, argv, "b");
+
+		if (c < 0)
+			break;
+
+		switch (c) {
+		case 'b':
+			flags &= ~DF_HUMAN_UNIT;
+			break;
+		default:
+			usage(cmd_device_usage_usage);
+		}
+	}
+
+	if (check_argc_min(argc - optind, 1))
+		usage(cmd_device_usage_usage);
+
+	for (i = optind; i < argc ; i++) {
+		int r, fd;
+		DIR	*dirstream = NULL;
+		if (more_than_one)
+			printf("\n");
+
+		fd = open_file_or_dir(argv[i], &dirstream);
+		if (fd < 0) {
+			fprintf(stderr, "ERROR: can't access to '%s'\n",
+				argv[1]);
+			return 12;
+		}
+		r = _cmd_device_usage(fd, argv[i], flags);
+		close_file_or_dir(fd, dirstream);
+
+		if (r)
+			return r;
+		more_than_one = 1;
+
+	}
+
+	return 0;
+}
+
 const struct cmd_group device_cmd_group = {
 	device_cmd_group_usage, NULL, {
 		{ "add", cmd_add_dev, cmd_add_dev_usage, NULL, 0 },
@@ -430,8 +522,8 @@ const struct cmd_group device_cmd_group = {
 		{ "scan", cmd_scan_dev, cmd_scan_dev_usage, NULL, 0 },
 		{ "ready", cmd_ready_dev, cmd_ready_dev_usage, NULL, 0 },
 		{ "stats", cmd_dev_stats, cmd_dev_stats_usage, NULL, 0 },
-		{ "disk-usage", cmd_device_disk_usage,
-			cmd_device_disk_usage_usage, NULL, 0 },
+		{ "usage", cmd_device_usage,
+			cmd_device_usage_usage, NULL, 0 },
 		NULL_CMD_STRUCT
 	}
 };
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 400863d9764f..17202de1b6e8 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -26,38 +26,16 @@
 #include "kerncompat.h"
 #include "ctree.h"
 #include "string_table.h"
-
+#include "cmds-fi-disk_usage.h"
 #include "commands.h"
 
 #include "version.h"
 
-#define DF_HUMAN_UNIT		(1<<0)
-
-/*
- * To store the size information about the chunks:
- * the chunks info are grouped by the tuple (type, devid, num_stripes),
- * i.e. if two chunks are of the same type (RAID1, DUP...), are on the
- * same disk, have the same stripes then their sizes are grouped
- */
-struct chunk_info {
-	u64	type;
-	u64	size;
-	u64	devid;
-	u64	num_stripes;
-};
-
-/* to store information about the disks */
-struct disk_info {
-	u64	devid;
-	char	path[BTRFS_DEVICE_PATH_NAME_MAX];
-	u64	size;
-};
-
 /*
  * Pretty print the size
  * PAY ATTENTION: it return a statically buffer
  */
-static char *df_pretty_sizes(u64 size, int mode)
+char *df_pretty_sizes(u64 size, int mode)
 {
 	static char buf[30];
 
@@ -162,14 +140,8 @@ static int cmp_chunk_info(const void *a, const void *b)
 		((struct chunk_info *)b)->type);
 }
 
-/*
- * This function load all the chunk info from the 'fd' filesystem
- */
-static int load_chunk_info(int fd,
-			  struct chunk_info **info_ptr,
-			  int *info_count)
+int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count)
 {
-
 	int ret;
 	struct btrfs_ioctl_search_args args;
 	struct btrfs_ioctl_search_key *sk = &args.key;
@@ -177,7 +149,6 @@ static int load_chunk_info(int fd,
 	unsigned long off = 0;
 	int i, e;
 
-
 	memset(&args, 0, sizeof(args));
 
 	/*
@@ -185,8 +156,6 @@ static int load_chunk_info(int fd,
 	 * snapshots pending deletion, we have to loop through
 	 * them.
 	 */
-
-
 	sk->tree_id = BTRFS_CHUNK_TREE_OBJECTID;
 
 	sk->min_objectid = 0;
@@ -253,7 +222,6 @@ static int load_chunk_info(int fd,
 		cmp_chunk_info);
 
 	return 0;
-
 }
 
 /*
@@ -333,7 +301,7 @@ static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path)
 /*
  * This function computes the space occuped by a *single* RAID5/RAID6 chunk.
  * The computation is performed on the basis of the number of stripes
- * which compose the chunk, which could be different from the number of disks
+ * which compose the chunk, which could be different from the number of devices
  * if a disk is added later.
  */
 static int get_raid56_used(int fd, u64 *raid5_used, u64 *raid6_used)
@@ -367,7 +335,7 @@ static int _cmd_disk_free(int fd, char *path, int mode)
 	int ret = 0;
 	int e, width;
 	u64 total_disk;		/* filesystem size == sum of
-				   disks sizes */
+				   device sizes */
 	u64 total_chunks;	/* sum of chunks sizes on disk(s) */
 	u64 total_used;		/* logical space used */
 	u64 total_free;		/* logical space un-used */
@@ -470,29 +438,27 @@ exit:
 #endif
 
 /*
- *  Helper to sort the disk_info structure
+ *  Helper to sort the device_info structure
  */
-static int cmp_disk_info(const void *a, const void *b)
+static int cmp_device_info(const void *a, const void *b)
 {
-	return strcmp(((struct disk_info *)a)->path,
-			((struct disk_info *)b)->path);
+	return strcmp(((struct device_info *)a)->path,
+			((struct device_info *)b)->path);
 }
 
 /*
- *  This function load the disk_info structure and put them in an array
+ *  This function loads the device_info structure and put them in an array
  */
-static int load_disks_info(int fd,
-			   struct disk_info **disks_info_ptr,
-			   int *disks_info_count)
+int load_device_info(int fd, struct device_info **device_info_ptr,
+			   int *device_info_count)
 {
-
 	int ret, i, ndevs;
 	struct btrfs_ioctl_fs_info_args fi_args;
 	struct btrfs_ioctl_dev_info_args dev_info;
-	struct disk_info *info;
+	struct device_info *info;
 
-	*disks_info_count = 0;
-	*disks_info_ptr = 0;
+	*device_info_count = 0;
+	*device_info_ptr = 0;
 
 	ret = ioctl(fd, BTRFS_IOC_FS_INFO, &fi_args);
 	if (ret < 0) {
@@ -500,7 +466,7 @@ static int load_disks_info(int fd,
 		return -1;
 	}
 
-	info = malloc(sizeof(struct disk_info) * fi_args.num_devices);
+	info = malloc(sizeof(struct device_info) * fi_args.num_devices);
 	if (!info) {
 		fprintf(stderr, "ERROR: not enough memory\n");
 		return -1;
@@ -529,13 +495,12 @@ static int load_disks_info(int fd,
 
 	BUG_ON(ndevs != fi_args.num_devices);
 	qsort(info, fi_args.num_devices,
-		sizeof(struct disk_info), cmp_disk_info);
+		sizeof(struct device_info), cmp_device_info);
 
-	*disks_info_count = fi_args.num_devices;
-	*disks_info_ptr = info;
+	*device_info_count = fi_args.num_devices;
+	*device_info_ptr = info;
 
 	return 0;
-
 }
 
 /*
@@ -566,8 +531,8 @@ static void _cmd_filesystem_usage_tabular(int mode,
 					struct btrfs_ioctl_space_args *sargs,
 					struct chunk_info *chunks_info_ptr,
 					int chunks_info_count,
-					struct disk_info *disks_info_ptr,
-					int disks_info_count)
+					struct device_info *device_info_ptr,
+					int device_info_count)
 {
 	int i;
 	u64 total_unused = 0;
@@ -575,7 +540,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
 	int  ncols, nrows;
 
 	ncols = sargs->total_spaces + 2;
-	nrows = 2 + 1 + disks_info_count + 1 + 2;
+	nrows = 2 + 1 + device_info_count + 1 + 2;
 
 	matrix = table_create(ncols, nrows);
 	if (!matrix) {
@@ -605,24 +570,23 @@ static void _cmd_filesystem_usage_tabular(int mode,
 	table_printf(matrix, 1+sargs->total_spaces, 1, "<Unallocated");
 
 	/* body */
-	for (i = 0 ; i < disks_info_count ; i++) {
+	for (i = 0; i < device_info_count; i++) {
 		int k, col;
 		char *p;
 
 		u64  total_allocated = 0, unused;
 
-		p = strrchr(disks_info_ptr[i].path, '/');
+		p = strrchr(device_info_ptr[i].path, '/');
 		if (!p)
-			p = disks_info_ptr[i].path;
+			p = device_info_ptr[i].path;
 		else
 			p++;
 
-		table_printf(matrix, 0, i+3, "<%s",
-				disks_info_ptr[i].path);
+		table_printf(matrix, 0, i + 3, "<%s", device_info_ptr[i].path);
 
 		for (col = 1, k = 0 ; k < sargs->total_spaces ; k++)  {
 			u64	flags = sargs->spaces[k].flags;
-			u64 devid = disks_info_ptr[i].devid;
+			u64 devid = device_info_ptr[i].devid;
 			int	j;
 			u64 size = 0;
 
@@ -645,8 +609,8 @@ static void _cmd_filesystem_usage_tabular(int mode,
 			col++;
 		}
 
-		unused = get_partition_size(disks_info_ptr[i].path) -
-				total_allocated;
+		unused = get_partition_size(device_info_ptr[i].path)
+				- total_allocated;
 
 		table_printf(matrix, sargs->total_spaces + 1, i + 3,
 			       ">%s", df_pretty_sizes(unused, mode));
@@ -655,28 +619,24 @@ static void _cmd_filesystem_usage_tabular(int mode,
 	}
 
 	for (i = 0; i <= sargs->total_spaces; i++)
-		table_printf(matrix, i + 1, disks_info_count + 3, "=");
-
+		table_printf(matrix, i + 1, device_info_count + 3, "=");
 
 	/* footer */
-	table_printf(matrix, 0, disks_info_count + 4, "<Total");
+	table_printf(matrix, 0, device_info_count + 4, "<Total");
 	for (i = 0; i < sargs->total_spaces; i++)
-		table_printf(matrix, 1 + i, disks_info_count + 4,
-			">%s",
+		table_printf(matrix, 1 + i, device_info_count + 4, ">%s",
 			df_pretty_sizes(sargs->spaces[i].total_bytes, mode));
 
-	table_printf(matrix, sargs->total_spaces+1, disks_info_count+4,
-		">%s", df_pretty_sizes(total_unused, mode));
+	table_printf(matrix, sargs->total_spaces + 1, device_info_count + 4,
+			">%s", df_pretty_sizes(total_unused, mode));
 
-	table_printf(matrix, 0, disks_info_count+5, "<Used");
+	table_printf(matrix, 0, device_info_count + 5, "<Used");
 	for (i = 0; i < sargs->total_spaces; i++)
-		table_printf(matrix, 1+i, disks_info_count+5, ">%s",
+		table_printf(matrix, 1 + i, device_info_count+5, ">%s",
 			df_pretty_sizes(sargs->spaces[i].used_bytes, mode));
 
-
 	table_dump(matrix);
 	table_free(matrix);
-
 }
 
 /*
@@ -684,50 +644,46 @@ static void _cmd_filesystem_usage_tabular(int mode,
  */
 static void print_unused(struct chunk_info *info_ptr,
 			  int info_count,
-			  struct disk_info *disks_info_ptr,
-			  int disks_info_count,
+			  struct device_info *device_info_ptr,
+			  int device_info_count,
 			  int mode)
 {
 	int i;
-	for (i = 0 ; i < disks_info_count ; i++) {
-
+	for (i = 0; i < device_info_count; i++) {
 		int	j;
 		u64	total = 0;
 
-		for (j = 0 ; j < info_count ; j++)
-			if (info_ptr[j].devid == disks_info_ptr[i].devid)
+		for (j = 0; j < info_count; j++)
+			if (info_ptr[j].devid == device_info_ptr[i].devid)
 				total += calc_chunk_size(info_ptr+j);
 
 		printf("   %s\t%10s\n",
-			disks_info_ptr[i].path,
-			df_pretty_sizes(disks_info_ptr[i].size - total, mode));
-
+			device_info_ptr[i].path,
+			df_pretty_sizes(device_info_ptr[i].size - total, mode));
 	}
-
 }
 
 /*
  *  This function prints the allocated chunk per every disk
  */
-static void print_chunk_disks(u64 chunk_type,
+static void print_chunk_device(u64 chunk_type,
 				struct chunk_info *chunks_info_ptr,
 				int chunks_info_count,
-				struct disk_info *disks_info_ptr,
-				int disks_info_count,
+				struct device_info *device_info_ptr,
+				int device_info_count,
 				int mode)
 {
 	int i;
 
-	for (i = 0 ; i < disks_info_count ; i++) {
-
+	for (i = 0; i < device_info_count; i++) {
 		int	j;
 		u64	total = 0;
 
-		for (j = 0 ; j < chunks_info_count ; j++) {
+		for (j = 0; j < chunks_info_count; j++) {
 
 			if (chunks_info_ptr[j].type != chunk_type)
 				continue;
-			if (chunks_info_ptr[j].devid != disks_info_ptr[i].devid)
+			if (chunks_info_ptr[j].devid != device_info_ptr[i].devid)
 				continue;
 
 			total += calc_chunk_size(&(chunks_info_ptr[j]));
@@ -736,7 +692,7 @@ static void print_chunk_disks(u64 chunk_type,
 
 		if (total > 0)
 			printf("   %s\t%10s\n",
-				disks_info_ptr[i].path,
+				device_info_ptr[i].path,
 				df_pretty_sizes(total, mode));
 	}
 }
@@ -749,8 +705,8 @@ static void _cmd_filesystem_usage_linear(int mode,
 					struct btrfs_ioctl_space_args *sargs,
 					struct chunk_info *info_ptr,
 					int info_count,
-					struct disk_info *disks_info_ptr,
-					int disks_info_count)
+					struct device_info *device_info_ptr,
+					int device_info_count)
 {
 	int i;
 
@@ -768,22 +724,15 @@ static void _cmd_filesystem_usage_linear(int mode,
 			df_pretty_sizes(sargs->spaces[i].total_bytes ,
 			    mode));
 		printf("Used:%s\n",
-			df_pretty_sizes(sargs->spaces[i].used_bytes,
-					mode));
-		print_chunk_disks(flags, info_ptr, info_count,
-				disks_info_ptr, disks_info_count,
-				mode);
+			df_pretty_sizes(sargs->spaces[i].used_bytes, mode));
+		print_chunk_device(flags, info_ptr, info_count,
+				device_info_ptr, device_info_count, mode);
 		printf("\n");
-
 	}
 
 	printf("Unallocated:\n");
-	print_unused(info_ptr, info_count,
-			disks_info_ptr, disks_info_count,
+	print_unused(info_ptr, info_count, device_info_ptr, device_info_count,
 			mode);
-
-
-
 }
 
 static int _cmd_filesystem_usage(int fd, char *path, int mode, int tabular)
@@ -791,12 +740,12 @@ static int _cmd_filesystem_usage(int fd, char *path, int mode, int tabular)
 	struct btrfs_ioctl_space_args *sargs = 0;
 	int info_count = 0;
 	struct chunk_info *info_ptr = 0;
-	struct disk_info *disks_info_ptr = 0;
-	int disks_info_count = 0;
+	struct device_info *device_info_ptr = 0;
+	int device_info_count = 0;
 	int ret = 0;
 
 	if (load_chunk_info(fd, &info_ptr, &info_count) ||
-	    load_disks_info(fd, &disks_info_ptr, &disks_info_count)) {
+	    load_device_info(fd, &device_info_ptr, &device_info_count)) {
 		ret = -1;
 		goto exit;
 	}
@@ -809,18 +758,18 @@ static int _cmd_filesystem_usage(int fd, char *path, int mode, int tabular)
 	if (tabular)
 		_cmd_filesystem_usage_tabular(mode, sargs,
 					info_ptr, info_count,
-					disks_info_ptr, disks_info_count);
+					device_info_ptr, device_info_count);
 	else
 		_cmd_filesystem_usage_linear(mode, sargs,
 					info_ptr, info_count,
-					disks_info_ptr, disks_info_count);
+					device_info_ptr, device_info_count);
 
 exit:
 
 	if (sargs)
 		free(sargs);
-	if (disks_info_ptr)
-		free(disks_info_ptr);
+	if (device_info_ptr)
+		free(device_info_ptr);
 	if (info_ptr)
 		free(info_ptr);
 
@@ -887,12 +836,9 @@ int cmd_filesystem_usage(int argc, char **argv)
 	return 0;
 }
 
-static void print_disk_chunks(int fd,
-				u64 devid,
-				u64 total_size,
-				struct chunk_info *chunks_info_ptr,
-				int chunks_info_count,
-				int mode)
+void print_device_chunks(int fd, u64 devid, u64 total_size,
+		struct chunk_info *chunks_info_ptr,
+		int chunks_info_count, int mode)
 {
 	int i;
 	u64 allocated = 0;
@@ -925,98 +871,3 @@ static void print_disk_chunks(int fd,
 		df_pretty_sizes(total_size - allocated, mode));
 
 }
-
-static int _cmd_device_disk_usage(int fd, char *path, int mode)
-{
-	int i;
-	int ret = 0;
-	int info_count = 0;
-	struct chunk_info *info_ptr = 0;
-	struct disk_info *disks_info_ptr = 0;
-	int disks_info_count = 0;
-
-	if (load_chunk_info(fd, &info_ptr, &info_count) ||
-	    load_disks_info(fd, &disks_info_ptr, &disks_info_count)) {
-		ret = -1;
-		goto exit;
-	}
-
-	for (i = 0 ; i < disks_info_count ; i++) {
-		printf("%s\t%10s\n", disks_info_ptr[i].path,
-			df_pretty_sizes(disks_info_ptr[i].size, mode));
-
-		print_disk_chunks(fd, disks_info_ptr[i].devid,
-				disks_info_ptr[i].size,
-				info_ptr, info_count,
-				mode);
-		printf("\n");
-
-	}
-
-
-exit:
-
-	if (disks_info_ptr)
-		free(disks_info_ptr);
-	if (info_ptr)
-		free(info_ptr);
-
-	return ret;
-}
-
-const char * const cmd_device_disk_usage_usage[] = {
-	"btrfs device disk-usage [-b] <path> [<path>..]",
-	"Show which chunks are in a device.",
-	"",
-	"-b\tSet byte as unit",
-	NULL
-};
-
-int cmd_device_disk_usage(int argc, char **argv)
-{
-
-	int	flags = DF_HUMAN_UNIT;
-	int	i, more_than_one = 0;
-
-	optind = 1;
-	while (1) {
-		char	c = getopt(argc, argv, "b");
-
-		if (c < 0)
-			break;
-
-		switch (c) {
-		case 'b':
-			flags &= ~DF_HUMAN_UNIT;
-			break;
-		default:
-			usage(cmd_device_disk_usage_usage);
-		}
-	}
-
-	if (check_argc_min(argc - optind, 1))
-		usage(cmd_device_disk_usage_usage);
-
-	for (i = optind; i < argc ; i++) {
-		int r, fd;
-		DIR	*dirstream = NULL;
-		if (more_than_one)
-			printf("\n");
-
-		fd = open_file_or_dir(argv[i], &dirstream);
-		if (fd < 0) {
-			fprintf(stderr, "ERROR: can't access to '%s'\n",
-				argv[1]);
-			return 12;
-		}
-		r = _cmd_device_disk_usage(fd, argv[i], flags);
-		close_file_or_dir(fd, dirstream);
-
-		if (r)
-			return r;
-		more_than_one = 1;
-
-	}
-
-	return 0;
-}
diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
index 95cf4aabefb4..787b4eb56acf 100644
--- a/cmds-fi-disk_usage.h
+++ b/cmds-fi-disk_usage.h
@@ -19,10 +19,36 @@
 #ifndef __CMDS_FI_DISK_USAGE__
 #define __CMDS_FI_DISK_USAGE__
 
+#define DF_HUMAN_UNIT		(1<<0)
+
 extern const char * const cmd_filesystem_usage_usage[];
 int cmd_filesystem_usage(int argc, char **argv);
 
-extern const char * const cmd_device_disk_usage_usage[];
-int cmd_device_disk_usage(int argc, char **argv);
+struct device_info {
+	u64	devid;
+	char	path[BTRFS_DEVICE_PATH_NAME_MAX];
+	u64	size;
+};
+
+/*
+ * To store the size information about the chunks:
+ * the chunks info are grouped by the tuple (type, devid, num_stripes),
+ * i.e. if two chunks are of the same type (RAID1, DUP...), are on the
+ * same disk, have the same stripes then their sizes are grouped
+ */
+struct chunk_info {
+	u64	type;
+	u64	size;
+	u64	devid;
+	u64	num_stripes;
+};
+
+int load_device_info(int fd, struct device_info **device_info_ptr,
+		int *device_info_count);
+int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count);
+char *df_pretty_sizes(u64 size, int mode);
+void print_device_chunks(int fd, u64 devid, u64 total_size,
+		struct chunk_info *chunks_info_ptr,
+		int chunks_info_count, int mode);
 
 #endif
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 04/14] btrfs-progs: check if we can't get info from ioctls due to permissions
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (2 preceding siblings ...)
  2014-04-29 15:58 ` [PATCH 03/14] btrfs-progs: move device usage to cmds-device, more cleanups David Sterba
@ 2014-04-29 15:58 ` David Sterba
  2014-04-29 16:01 ` [PATCH 05/14] btrfs-progs: zero out structures before calling ioctl David Sterba
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 15:58 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The TREE_SEARCH ioctl is root-only, FS_INFO will be available for
non-root users with an updated kernel, let the user know.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-fi-disk_usage.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 17202de1b6e8..64c85acafd51 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -171,6 +171,12 @@ int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count)
 	while (1) {
 		ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
 		e = errno;
+		if (ret == -EPERM) {
+			fprintf(stderr,
+				"ERROR: can't read detailed chunk info from ioctl(TREE_SEARCH), run as root\n");
+			return 0;
+		}
+
 		if (ret < 0) {
 			fprintf(stderr,
 				"ERROR: can't perform the search - %s\n",
@@ -461,6 +467,10 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
 	*device_info_ptr = 0;
 
 	ret = ioctl(fd, BTRFS_IOC_FS_INFO, &fi_args);
+	if (ret == -EPERM) {
+		fprintf(stderr, "ERROR: can't get filesystem info from ioctl(FS_INFO), run as root\n");
+		return -1;
+	}
 	if (ret < 0) {
 		fprintf(stderr, "ERROR: cannot get filesystem info\n");
 		return -1;
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 05/14] btrfs-progs: zero out structures before calling ioctl
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (3 preceding siblings ...)
  2014-04-29 15:58 ` [PATCH 04/14] btrfs-progs: check if we can't get info from ioctls due to permissions David Sterba
@ 2014-04-29 16:01 ` David Sterba
  2014-04-29 16:02 ` [PATCH 06/14] btrfs-progs: print B for bytes David Sterba
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 16:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-fi-disk_usage.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 64c85acafd51..067c60078710 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -248,7 +248,7 @@ static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path)
 	struct btrfs_ioctl_space_args *sargs = 0, *sargs_orig = 0;
 	int e, ret, count;
 
-	sargs_orig = sargs = malloc(sizeof(struct btrfs_ioctl_space_args));
+	sargs_orig = sargs = calloc(1, sizeof(struct btrfs_ioctl_space_args));
 	if (!sargs) {
 		fprintf(stderr, "ERROR: not enough memory\n");
 		return NULL;
@@ -476,15 +476,15 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
 		return -1;
 	}
 
-	info = malloc(sizeof(struct device_info) * fi_args.num_devices);
+	info = calloc(fi_args.num_devices, sizeof(struct device_info));
 	if (!info) {
 		fprintf(stderr, "ERROR: not enough memory\n");
 		return -1;
 	}
 
 	for (i = 0, ndevs = 0 ; i <= fi_args.max_id ; i++) {
-
 		BUG_ON(ndevs >= fi_args.num_devices);
+		memset(&dev_info, 0, sizeof(dev_info));
 		ret = get_device_info(fd, i, &dev_info);
 
 		if (ret == -ENODEV)
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 06/14] btrfs-progs: print B for bytes
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (4 preceding siblings ...)
  2014-04-29 16:01 ` [PATCH 05/14] btrfs-progs: zero out structures before calling ioctl David Sterba
@ 2014-04-29 16:02 ` David Sterba
  2014-04-29 16:02 ` [PATCH 07/14] btrfs-progs: Print more info about device sizes David Sterba
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 16:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

This arguably helps parsers.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils.c b/utils.c
index ca150404ea6f..159abf8bd0e4 100644
--- a/utils.c
+++ b/utils.c
@@ -1252,7 +1252,7 @@ out:
 	return ret;
 }
 
-static char *size_strs[] = { "", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"};
+static char *size_strs[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"};
 int pretty_size_snprintf(u64 size, char *str, size_t str_bytes)
 {
 	int num_divs = 0;
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (5 preceding siblings ...)
  2014-04-29 16:02 ` [PATCH 06/14] btrfs-progs: print B for bytes David Sterba
@ 2014-04-29 16:02 ` David Sterba
  2014-04-29 19:23   ` Mike Fleetwood
  2014-04-29 16:02 ` [PATCH 08/14] btrfs-progs: compare unallocated space against the correct value David Sterba
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 35+ messages in thread
From: David Sterba @ 2014-04-29 16:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The entire device size may not be available to the filesystem, eg. if
it's modified via resize. Print this information if it can be obtained
from the DEV_INFO ioctl.

Print the device ID on the same line as the device name and move size to
the next line.

Sample:
/dev/sda7, ID: 3
   Device size:            10.00GiB
   FS occuppied:            5.00GiB
   Data,RAID10:           512.00MiB
   Metadata,RAID10:       512.00MiB
   System,RAID10:           4.00MiB
   Unallocated:             9.00GiB

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-device.c        |  6 +++---
 cmds-fi-disk_usage.c | 13 ++++++++++++-
 cmds-fi-disk_usage.h |  6 +++++-
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/cmds-device.c b/cmds-device.c
index 7a9d808b36dd..519725f83e8c 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -447,9 +447,9 @@ static int _cmd_device_usage(int fd, char *path, int mode)
 	}
 
 	for (i = 0; i < device_info_count; i++) {
-		printf("%s\t%10s\n", device_info_ptr[i].path,
-			df_pretty_sizes(device_info_ptr[i].size, mode));
-
+		printf("%s, ID: %llu\n", device_info_ptr[i].path,
+				device_info_ptr[i].devid);
+		print_device_sizes(fd, &device_info_ptr[i], mode);
 		print_device_chunks(fd, device_info_ptr[i].devid,
 				device_info_ptr[i].size,
 				info_ptr, info_count,
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 067c60078710..ddb064cc4c66 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -499,7 +499,8 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
 
 		info[ndevs].devid = dev_info.devid;
 		strcpy(info[ndevs].path, (char *)dev_info.path);
-		info[ndevs].size = get_partition_size((char *)dev_info.path);
+		info[ndevs].device_size = get_partition_size((char *)dev_info.path);
+		info[ndevs].size = dev_info.total_size;
 		++ndevs;
 	}
 
@@ -879,5 +880,15 @@ void print_device_chunks(int fd, u64 devid, u64 total_size,
 	printf("   Unallocated: %*s%10s\n",
 		(int)(20 - strlen("Unallocated")), "",
 		df_pretty_sizes(total_size - allocated, mode));
+}
 
+void print_device_sizes(int fd, struct device_info *devinfo, int mode)
+{
+	printf("   Device size: %*s%10s\n",
+		(int)(20 - strlen("Device size")), "",
+		df_pretty_sizes(devinfo->device_size, mode));
+	printf("   FS occuppied:%*s%10s\n",
+		(int)(20 - strlen("FS occupied")), "",
+		df_pretty_sizes(devinfo->size, mode));
+	}
 }
diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
index 787b4eb56acf..79cc2a115bc5 100644
--- a/cmds-fi-disk_usage.h
+++ b/cmds-fi-disk_usage.h
@@ -27,7 +27,10 @@ int cmd_filesystem_usage(int argc, char **argv);
 struct device_info {
 	u64	devid;
 	char	path[BTRFS_DEVICE_PATH_NAME_MAX];
-	u64	size;
+	/* Size of the block device */
+	u64	device_size;
+	/* Size that's occupied by the filesystem, can be changed via resize */
+	u64     size;
 };
 
 /*
@@ -50,5 +53,6 @@ char *df_pretty_sizes(u64 size, int mode);
 void print_device_chunks(int fd, u64 devid, u64 total_size,
 		struct chunk_info *chunks_info_ptr,
 		int chunks_info_count, int mode);
+void print_device_sizes(int fd, struct device_info *devinfo, int mode);
 
 #endif
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 08/14] btrfs-progs: compare unallocated space against the correct value
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (6 preceding siblings ...)
  2014-04-29 16:02 ` [PATCH 07/14] btrfs-progs: Print more info about device sizes David Sterba
@ 2014-04-29 16:02 ` David Sterba
  2014-04-29 16:02 ` [PATCH 09/14] btrfs-progs: add section of overall filesystem usage David Sterba
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 16:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The device may not be fully occupied by the filesystem, the value of
Unallocated should not be calculated against the device size but the
size provided by DEV_INFO.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-device.c        | 6 ++----
 cmds-fi-disk_usage.c | 9 ++++-----
 cmds-fi-disk_usage.h | 2 +-
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/cmds-device.c b/cmds-device.c
index 519725f83e8c..d7889f93d343 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -450,10 +450,8 @@ static int _cmd_device_usage(int fd, char *path, int mode)
 		printf("%s, ID: %llu\n", device_info_ptr[i].path,
 				device_info_ptr[i].devid);
 		print_device_sizes(fd, &device_info_ptr[i], mode);
-		print_device_chunks(fd, device_info_ptr[i].devid,
-				device_info_ptr[i].size,
-				info_ptr, info_count,
-				mode);
+		print_device_chunks(fd, &device_info_ptr[i],
+				info_ptr, info_count, mode);
 		printf("\n");
 	}
 
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index ddb064cc4c66..7d0334086dbd 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -500,7 +500,7 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
 		info[ndevs].devid = dev_info.devid;
 		strcpy(info[ndevs].path, (char *)dev_info.path);
 		info[ndevs].device_size = get_partition_size((char *)dev_info.path);
-		info[ndevs].size = dev_info.total_size;
+		info[ndevs].size = dev_info.total_bytes;
 		++ndevs;
 	}
 
@@ -847,7 +847,7 @@ int cmd_filesystem_usage(int argc, char **argv)
 	return 0;
 }
 
-void print_device_chunks(int fd, u64 devid, u64 total_size,
+void print_device_chunks(int fd, struct device_info *devinfo,
 		struct chunk_info *chunks_info_ptr,
 		int chunks_info_count, int mode)
 {
@@ -860,7 +860,7 @@ void print_device_chunks(int fd, u64 devid, u64 total_size,
 		u64 flags;
 		u64 size;
 
-		if (chunks_info_ptr[i].devid != devid)
+		if (chunks_info_ptr[i].devid != devinfo->devid)
 			continue;
 
 		flags = chunks_info_ptr[i].type;
@@ -879,7 +879,7 @@ void print_device_chunks(int fd, u64 devid, u64 total_size,
 	}
 	printf("   Unallocated: %*s%10s\n",
 		(int)(20 - strlen("Unallocated")), "",
-		df_pretty_sizes(total_size - allocated, mode));
+		df_pretty_sizes(devinfo->size - allocated, mode));
 }
 
 void print_device_sizes(int fd, struct device_info *devinfo, int mode)
@@ -890,5 +890,4 @@ void print_device_sizes(int fd, struct device_info *devinfo, int mode)
 	printf("   FS occuppied:%*s%10s\n",
 		(int)(20 - strlen("FS occupied")), "",
 		df_pretty_sizes(devinfo->size, mode));
-	}
 }
diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
index 79cc2a115bc5..dbc2a10f31eb 100644
--- a/cmds-fi-disk_usage.h
+++ b/cmds-fi-disk_usage.h
@@ -50,7 +50,7 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
 		int *device_info_count);
 int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count);
 char *df_pretty_sizes(u64 size, int mode);
-void print_device_chunks(int fd, u64 devid, u64 total_size,
+void print_device_chunks(int fd, struct device_info *devinfo,
 		struct chunk_info *chunks_info_ptr,
 		int chunks_info_count, int mode);
 void print_device_sizes(int fd, struct device_info *devinfo, int mode);
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 09/14] btrfs-progs: add section of overall filesystem usage
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (7 preceding siblings ...)
  2014-04-29 16:02 ` [PATCH 08/14] btrfs-progs: compare unallocated space against the correct value David Sterba
@ 2014-04-29 16:02 ` David Sterba
  2014-04-29 16:02 ` [PATCH 10/14] btrfs-progs: cleanup filesystem/device usage code David Sterba
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 16:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The 'fi usage' lacks an overall report, this used to be in the enhanced
df command. Add it back.

Sample:
Overall:
    Device size:                  35.00GiB
    Device allocated:              8.07GiB
    Device unallocated:           26.93GiB
    Used:                          1.12MiB
    Free (Estimated):             17.57GiB      (Max: 30.98GiB, min: 17.52GiB)
    Data to device ratio:             50 %
...

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-fi-disk_usage.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 7d0334086dbd..d76fa3552136 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -302,8 +302,6 @@ static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path)
 	return sargs;
 }
 
-/* Not used, keep for later */
-#if 0
 /*
  * This function computes the space occuped by a *single* RAID5/RAID6 chunk.
  * The computation is performed on the basis of the number of stripes
@@ -331,7 +329,6 @@ static int get_raid56_used(int fd, u64 *raid5_used, u64 *raid6_used)
 	free(info_ptr);
 
 	return 0;
-
 }
 
 static int _cmd_disk_free(int fd, char *path, int mode)
@@ -416,22 +413,24 @@ static int _cmd_disk_free(int fd, char *path, int mode)
 	else
 		width = 18;
 
-	printf("Disk size:\t\t%*s\n", width,
+	printf("Overall:\n");
+
+	printf("    Device size:\t\t%*s\n", width,
 		df_pretty_sizes(total_disk, mode));
-	printf("Disk allocated:\t\t%*s\n", width,
+	printf("    Device allocated:\t\t%*s\n", width,
 		df_pretty_sizes(total_chunks, mode));
-	printf("Disk unallocated:\t%*s\n", width,
+	printf("    Device unallocated:\t\t%*s\n", width,
 		df_pretty_sizes(total_disk-total_chunks, mode));
-	printf("Used:\t\t\t%*s\n", width,
+	printf("    Used:\t\t\t%*s\n", width,
 		df_pretty_sizes(total_used, mode));
-	printf("Free (Estimated):\t%*s\t(",
+	printf("    Free (Estimated):\t\t%*s\t(",
 		width,
 		df_pretty_sizes((u64)(K*total_disk-total_used), mode));
 	printf("Max: %s, ",
 		df_pretty_sizes(total_disk-total_chunks+total_free, mode));
 	printf("min: %s)\n",
 		df_pretty_sizes((total_disk-total_chunks)/2+total_free, mode));
-	printf("Data to disk ratio:\t%*.0f %%\n",
+	printf("    Data to device ratio:\t%*.0f %%\n",
 		width-2, K*100);
 
 exit:
@@ -441,7 +440,6 @@ exit:
 
 	return ret;
 }
-#endif
 
 /*
  *  Helper to sort the device_info structure
@@ -826,8 +824,6 @@ int cmd_filesystem_usage(int argc, char **argv)
 	for (i = optind; i < argc ; i++) {
 		int r, fd;
 		DIR	*dirstream = NULL;
-		if (more_than_one)
-			printf("\n");
 
 		fd = open_file_or_dir(argv[i], &dirstream);
 		if (fd < 0) {
@@ -835,6 +831,11 @@ int cmd_filesystem_usage(int argc, char **argv)
 				argv[1]);
 			return 12;
 		}
+		if (more_than_one)
+			printf("\n");
+
+		r = _cmd_disk_free(fd, argv[i], flags);
+		printf("\n");
 		r = _cmd_filesystem_usage(fd, argv[i], flags, tabular);
 		close_file_or_dir(fd, dirstream);
 
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 10/14] btrfs-progs: cleanup filesystem/device usage code
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (8 preceding siblings ...)
  2014-04-29 16:02 ` [PATCH 09/14] btrfs-progs: add section of overall filesystem usage David Sterba
@ 2014-04-29 16:02 ` David Sterba
  2014-04-29 16:02 ` [PATCH 11/14] btrfs-progs: extend pretty printers with unit mode David Sterba
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 16:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The main point of this is to load the device and chunk infos at one
place and pass down to the printers. The EPERM is handled separately, in
case kernel does not give us all the information about chunks or
devices, but we want to warn and print at least something.

For non-root users, 'filesystem usage' prints only the overall stats and
warns about RAID5/6.

The sole cleanup changes affect mostly the modified code and the related
functions, should be reasonably small.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-device.c        |  31 +++++-----
 cmds-fi-disk_usage.c | 163 +++++++++++++++++++++++++++------------------------
 cmds-fi-disk_usage.h |   5 +-
 3 files changed, 105 insertions(+), 94 deletions(-)

diff --git a/cmds-device.c b/cmds-device.c
index d7889f93d343..29eeaf6bbd0f 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -435,31 +435,29 @@ static int _cmd_device_usage(int fd, char *path, int mode)
 {
 	int i;
 	int ret = 0;
-	int info_count = 0;
-	struct chunk_info *info_ptr = 0;
-	struct device_info *device_info_ptr = 0;
-	int device_info_count = 0;
+	struct chunk_info *chunkinfo = NULL;
+	struct device_info *devinfo = NULL;
+	int chunkcount = 0;
+	int devcount = 0;
 
-	if (load_chunk_info(fd, &info_ptr, &info_count) ||
-	    load_device_info(fd, &device_info_ptr, &device_info_count)) {
+	ret = load_chunk_and_device_info(fd, &chunkinfo, &chunkcount, &devinfo,
+			&devcount);
+	if (ret) {
 		ret = -1;
 		goto exit;
 	}
 
-	for (i = 0; i < device_info_count; i++) {
-		printf("%s, ID: %llu\n", device_info_ptr[i].path,
-				device_info_ptr[i].devid);
-		print_device_sizes(fd, &device_info_ptr[i], mode);
-		print_device_chunks(fd, &device_info_ptr[i],
-				info_ptr, info_count, mode);
+	for (i = 0; i < devcount; i++) {
+		printf("%s, ID: %llu\n", devinfo[i].path, devinfo[i].devid);
+		print_device_sizes(fd, &devinfo[i], mode);
+		print_device_chunks(fd, &devinfo[i], chunkinfo, chunkcount,
+				mode);
 		printf("\n");
 	}
 
 exit:
-	if (device_info_ptr)
-		free(device_info_ptr);
-	if (info_ptr)
-		free(info_ptr);
+	free(devinfo);
+	free(chunkinfo);
 
 	return ret;
 }
@@ -501,6 +499,7 @@ int cmd_device_usage(int argc, char **argv)
 				argv[1]);
 			return 12;
 		}
+
 		r = _cmd_device_usage(fd, argv[i], flags);
 		close_file_or_dir(fd, dirstream);
 
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index d76fa3552136..e472833c646d 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -140,7 +140,7 @@ static int cmp_chunk_info(const void *a, const void *b)
 		((struct chunk_info *)b)->type);
 }
 
-int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count)
+static int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count)
 {
 	int ret;
 	struct btrfs_ioctl_search_args args;
@@ -171,11 +171,8 @@ int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count)
 	while (1) {
 		ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
 		e = errno;
-		if (ret == -EPERM) {
-			fprintf(stderr,
-				"ERROR: can't read detailed chunk info from ioctl(TREE_SEARCH), run as root\n");
-			return 0;
-		}
+		if (ret == -EPERM)
+			return ret;
 
 		if (ret < 0) {
 			fprintf(stderr,
@@ -308,30 +305,23 @@ static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path)
  * which compose the chunk, which could be different from the number of devices
  * if a disk is added later.
  */
-static int get_raid56_used(int fd, u64 *raid5_used, u64 *raid6_used)
+static void get_raid56_used(int fd, struct chunk_info *chunks, int chunkcount,
+		u64 *raid5_used, u64 *raid6_used)
 {
-	struct chunk_info *info_ptr=0, *p;
-	int info_count=0;
-	int ret;
-
-	*raid5_used = *raid6_used =0;
-
-	ret = load_chunk_info(fd, &info_ptr, &info_count);
-	if( ret < 0)
-		return ret;
-
-	for ( p = info_ptr; info_count ; info_count--, p++ ) {
-		if (p->type & BTRFS_BLOCK_GROUP_RAID5)
-			(*raid5_used) += p->size / (p->num_stripes -1);
-		if (p->type & BTRFS_BLOCK_GROUP_RAID6)
-			(*raid6_used) += p->size / (p->num_stripes -2);
+	*raid5_used = 0;
+	*raid6_used = 0;
+
+	while (chunkcount-- > 0) {
+		if (chunks->type & BTRFS_BLOCK_GROUP_RAID5)
+			(*raid5_used) += chunks->size / (chunks->num_stripes - 1);
+		if (chunks->type & BTRFS_BLOCK_GROUP_RAID6)
+			(*raid6_used) += chunks->size / (chunks->num_stripes - 2);
 	}
-	free(info_ptr);
-
-	return 0;
 }
 
-static int _cmd_disk_free(int fd, char *path, int mode)
+static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
+		int chunkcount, struct device_info *devinfo, int devcount,
+		char *path, int mode)
 {
 	struct btrfs_ioctl_space_args *sargs = 0;
 	int i;
@@ -360,15 +350,11 @@ static int _cmd_disk_free(int fd, char *path, int mode)
 		ret = 19;
 		goto exit;
 	}
-	if (get_raid56_used(fd, &raid5_used, &raid6_used) < 0) {
-		fprintf(stderr,
-			"ERROR: couldn't get space info on '%s'\n",
-			path );
-		ret = 20;
-		goto exit;
-	}
+	get_raid56_used(fd, chunkinfo, chunkcount, &raid5_used, &raid6_used);
 
-	total_chunks = total_used = total_free = 0;
+	total_chunks = 0;
+	total_used = 0;
+	total_free = 0;
 
 	for (i = 0; i < sargs->total_spaces; i++) {
 		float ratio = 1;
@@ -453,7 +439,7 @@ static int cmp_device_info(const void *a, const void *b)
 /*
  *  This function loads the device_info structure and put them in an array
  */
-int load_device_info(int fd, struct device_info **device_info_ptr,
+static int load_device_info(int fd, struct device_info **device_info_ptr,
 			   int *device_info_count)
 {
 	int ret, i, ndevs;
@@ -465,10 +451,8 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
 	*device_info_ptr = 0;
 
 	ret = ioctl(fd, BTRFS_IOC_FS_INFO, &fi_args);
-	if (ret == -EPERM) {
-		fprintf(stderr, "ERROR: can't get filesystem info from ioctl(FS_INFO), run as root\n");
-		return -1;
-	}
+	if (ret == -EPERM)
+		return ret;
 	if (ret < 0) {
 		fprintf(stderr, "ERROR: cannot get filesystem info\n");
 		return -1;
@@ -512,6 +496,29 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
 	return 0;
 }
 
+int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo,
+		int *chunkcount, struct device_info **devinfo, int *devcount)
+{
+	int ret;
+
+	ret = load_chunk_info(fd, chunkinfo, chunkcount);
+	if (ret == -EPERM) {
+		fprintf(stderr,
+			"WARNING: can't read detailed chunk info, RAID5/6 numbers will be incorrect, run as root\n");
+	} else if (ret) {
+		return ret;
+	}
+
+	ret = load_device_info(fd, devinfo, devcount);
+	if (ret == -EPERM) {
+		fprintf(stderr,
+			"WARNING: can't get filesystem info from ioctl(FS_INFO), run as root\n");
+		ret = 0;
+	}
+
+	return ret;
+}
+
 /*
  *  This function computes the size of a chunk in a disk
  */
@@ -744,43 +751,32 @@ static void _cmd_filesystem_usage_linear(int mode,
 			mode);
 }
 
-static int _cmd_filesystem_usage(int fd, char *path, int mode, int tabular)
+static int print_filesystem_usage_by_chunk(int fd,
+		struct chunk_info *chunkinfo, int chunkcount,
+		struct device_info *devinfo, int devcount,
+		char *path, int mode, int tabular)
 {
-	struct btrfs_ioctl_space_args *sargs = 0;
-	int info_count = 0;
-	struct chunk_info *info_ptr = 0;
-	struct device_info *device_info_ptr = 0;
-	int device_info_count = 0;
+	struct btrfs_ioctl_space_args *sargs;
 	int ret = 0;
 
-	if (load_chunk_info(fd, &info_ptr, &info_count) ||
-	    load_device_info(fd, &device_info_ptr, &device_info_count)) {
-		ret = -1;
-		goto exit;
-	}
+	if (!chunkinfo)
+		return 0;
 
-	if ((sargs = load_space_info(fd, path)) == NULL) {
-		ret = -1;
+	sargs = load_space_info(fd, path);
+	if (!sargs) {
+		ret = 1;
 		goto exit;
 	}
 
 	if (tabular)
-		_cmd_filesystem_usage_tabular(mode, sargs,
-					info_ptr, info_count,
-					device_info_ptr, device_info_count);
+		_cmd_filesystem_usage_tabular(mode, sargs, chunkinfo,
+				chunkcount, devinfo, devcount);
 	else
-		_cmd_filesystem_usage_linear(mode, sargs,
-					info_ptr, info_count,
-					device_info_ptr, device_info_count);
+		_cmd_filesystem_usage_linear(mode, sargs, chunkinfo,
+				chunkcount, devinfo, devcount);
 
 exit:
-
-	if (sargs)
-		free(sargs);
-	if (device_info_ptr)
-		free(device_info_ptr);
-	if (info_ptr)
-		free(info_ptr);
+	free(sargs);
 
 	return ret;
 }
@@ -796,16 +792,17 @@ const char * const cmd_filesystem_usage_usage[] = {
 
 int cmd_filesystem_usage(int argc, char **argv)
 {
-
 	int	flags =	DF_HUMAN_UNIT;
 	int	i, more_than_one = 0;
 	int	tabular = 0;
 
 	optind = 1;
 	while (1) {
-		char	c = getopt(argc, argv, "bt");
+		int c = getopt(argc, argv, "bt");
+
 		if (c < 0)
 			break;
+
 		switch (c) {
 		case 'b':
 			flags &= ~DF_HUMAN_UNIT;
@@ -821,9 +818,14 @@ int cmd_filesystem_usage(int argc, char **argv)
 	if (check_argc_min(argc - optind, 1))
 		usage(cmd_filesystem_usage_usage);
 
-	for (i = optind; i < argc ; i++) {
-		int r, fd;
-		DIR	*dirstream = NULL;
+	for (i = optind; i < argc; i++) {
+		int ret;
+		int fd;
+		DIR *dirstream = NULL;
+		struct chunk_info *chunkinfo = NULL;
+		struct device_info *devinfo = NULL;
+		int chunkcount = 0;
+		int devcount = 0;
 
 		fd = open_file_or_dir(argv[i], &dirstream);
 		if (fd < 0) {
@@ -834,15 +836,26 @@ int cmd_filesystem_usage(int argc, char **argv)
 		if (more_than_one)
 			printf("\n");
 
-		r = _cmd_disk_free(fd, argv[i], flags);
+		ret = load_chunk_and_device_info(fd, &chunkinfo, &chunkcount,
+				&devinfo, &devcount);
+		if (ret)
+			goto cleanup;
+
+		ret = print_filesystem_usage_overall(fd, chunkinfo, chunkcount,
+				devinfo, devcount, argv[i], flags);
+		if (ret)
+			goto cleanup;
 		printf("\n");
-		r = _cmd_filesystem_usage(fd, argv[i], flags, tabular);
+		ret = print_filesystem_usage_by_chunk(fd, chunkinfo, chunkcount,
+				devinfo, devcount, argv[i], flags, tabular);
+cleanup:
 		close_file_or_dir(fd, dirstream);
+		free(chunkinfo);
+		free(devinfo);
 
-		if (r)
-			return r;
+		if (ret)
+			return ret;
 		more_than_one = 1;
-
 	}
 
 	return 0;
diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
index dbc2a10f31eb..0779defc71db 100644
--- a/cmds-fi-disk_usage.h
+++ b/cmds-fi-disk_usage.h
@@ -46,9 +46,8 @@ struct chunk_info {
 	u64	num_stripes;
 };
 
-int load_device_info(int fd, struct device_info **device_info_ptr,
-		int *device_info_count);
-int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count);
+int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo,
+		int *chunkcount, struct device_info **devinfo, int *devcount);
 char *df_pretty_sizes(u64 size, int mode);
 void print_device_chunks(int fd, struct device_info *devinfo,
 		struct chunk_info *chunks_info_ptr,
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 11/14] btrfs-progs: extend pretty printers with unit mode
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (9 preceding siblings ...)
  2014-04-29 16:02 ` [PATCH 10/14] btrfs-progs: cleanup filesystem/device usage code David Sterba
@ 2014-04-29 16:02 ` David Sterba
  2014-04-29 16:02 ` [PATCH 12/14] btrfs-progs: replace df_pretty_sizes with pretty_size_mode David Sterba
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 16:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The functionality of pretty unit printing was duplicated by
df_pretty_sizes, merge it with pretty_size and enhance the interface
with more suffix mode. Raw, binary or decimal.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-fi-disk_usage.c |  9 ++-----
 utils.c              | 71 ++++++++++++++++++++++++++++++++++++----------------
 utils.h              | 21 +++++++++++-----
 3 files changed, 66 insertions(+), 35 deletions(-)

diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index e472833c646d..c823223ee8a8 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -33,18 +33,13 @@
 
 /*
  * Pretty print the size
- * PAY ATTENTION: it return a statically buffer
  */
 char *df_pretty_sizes(u64 size, int mode)
 {
-	static char buf[30];
-
 	if (mode & DF_HUMAN_UNIT)
-		(void)pretty_size_snprintf(size, buf, sizeof(buf));
+		return pretty_size_mode(size, UNITS_HUMAN);
 	else
-		sprintf(buf, "%llu", size);
-
-	return buf;
+		return pretty_size_mode(size, UNITS_RAW);
 }
 
 /*
diff --git a/utils.c b/utils.c
index 159abf8bd0e4..69112be51cb2 100644
--- a/utils.c
+++ b/utils.c
@@ -1252,35 +1252,62 @@ out:
 	return ret;
 }
 
-static char *size_strs[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"};
-int pretty_size_snprintf(u64 size, char *str, size_t str_bytes)
+static const char const *unit_suffix_binary[] =
+	{ "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"};
+static const char const *unit_suffix_decimal[] =
+	{ "B", "KB", "MB", "GB", "TB", "PB", "EB"};
+
+int pretty_size_snprintf(u64 size, char *str, size_t str_size, int unit_mode)
 {
-	int num_divs = 0;
+	int num_divs;
 	float fraction;
+	int base = 0;
+	const char const **suffix = NULL;
+	u64 last_size;
 
-	if (str_bytes == 0)
+	if (str_size == 0)
 		return 0;
 
-	if( size < 1024 ){
-		fraction = size;
-		num_divs = 0;
-	} else {
-		u64 last_size = size;
-		num_divs = 0;
-		while(size >= 1024){
-			last_size = size;
-			size /= 1024;
-			num_divs ++;
-		}
+	if (unit_mode == UNITS_RAW) {
+		snprintf(str, str_size, "%llu", size);
+		return 0;
+	}
 
-		if (num_divs >= ARRAY_SIZE(size_strs)) {
-			str[0] = '\0';
-			return -1;
-		}
-		fraction = (float)last_size / 1024;
+	if (unit_mode == UNITS_BINARY) {
+		base = 1024;
+		suffix = unit_suffix_binary;
+	} else if (unit_mode == UNITS_DECIMAL) {
+		base = 1000;
+		suffix = unit_suffix_decimal;
 	}
-	return snprintf(str, str_bytes, "%.2f%s", fraction,
-			size_strs[num_divs]);
+
+	/* Unknown mode */
+	if (!base) {
+		fprintf(stderr, "INTERNAL ERROR: unknown unit base, mode %d",
+				unit_mode);
+		assert(0);
+		return -1;
+	}
+
+	num_divs = 0;
+	last_size = size;
+
+	while (size >= base) {
+		last_size = size;
+		size /= base;
+		num_divs++;
+	}
+
+	if (num_divs >= ARRAY_SIZE(unit_suffix_binary)) {
+		str[0] = '\0';
+		printf("INTERNAL ERROR: unsupported unit suffix, index %d\n",
+				num_divs);
+		assert(0);
+		return -1;
+	}
+	fraction = (float)last_size / base;
+
+	return snprintf(str, str_size, "%.2f%s", fraction, suffix[num_divs]);
 }
 
 /*
diff --git a/utils.h b/utils.h
index 2d08e0b2a3a4..3aea8b47d9e7 100644
--- a/utils.h
+++ b/utils.h
@@ -39,6 +39,14 @@
 
 #define BTRFS_UUID_UNPARSED_SIZE	37
 
+/*
+ * Output mode of byte units
+ */
+#define UNITS_RAW			(1)
+#define UNITS_BINARY			(2)
+#define UNITS_DECIMAL			(3)
+#define UNITS_HUMAN			UNITS_BINARY
+
 int make_btrfs(int fd, const char *device, const char *label,
 	       u64 blocks[6], u64 num_bytes, u32 nodesize,
 	       u32 leafsize, u32 sectorsize, u32 stripesize, u64 features);
@@ -59,12 +67,13 @@ int check_mounted_where(int fd, const char *file, char *where, int size,
 int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
 				 int super_offset);
 
-int pretty_size_snprintf(u64 size, char *str, size_t str_bytes);
-#define pretty_size(size) 						\
-	({								\
-		static __thread char _str[24];				\
-		(void)pretty_size_snprintf((size), _str, sizeof(_str));	\
-		_str;							\
+int pretty_size_snprintf(u64 size, char *str, size_t str_bytes, int unit_mode);
+#define pretty_size(size) 	pretty_size_mode(size, UNITS_BINARY)
+#define pretty_size_mode(size, mode) 					      \
+	({								      \
+		static __thread char _str[32];				      \
+		(void)pretty_size_snprintf((size), _str, sizeof(_str), mode); \
+		_str;							      \
 	})
 
 int get_mountpt(char *dev, char *mntpt, size_t size);
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 12/14] btrfs-progs: replace df_pretty_sizes with pretty_size_mode
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (10 preceding siblings ...)
  2014-04-29 16:02 ` [PATCH 11/14] btrfs-progs: extend pretty printers with unit mode David Sterba
@ 2014-04-29 16:02 ` David Sterba
  2014-04-29 16:02 ` [PATCH 13/14] btrfs-progs: clean up return codes and paths David Sterba
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 16:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-device.c        |  8 +++----
 cmds-fi-disk_usage.c | 63 ++++++++++++++++++++++------------------------------
 cmds-fi-disk_usage.h |  3 ---
 3 files changed, 30 insertions(+), 44 deletions(-)

diff --git a/cmds-device.c b/cmds-device.c
index 29eeaf6bbd0f..b2773f249cba 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -465,19 +465,19 @@ exit:
 int cmd_device_usage(int argc, char **argv)
 {
 
-	int	flags = DF_HUMAN_UNIT;
+	int mode = UNITS_HUMAN;
 	int	i, more_than_one = 0;
 
 	optind = 1;
 	while (1) {
-		char	c = getopt(argc, argv, "b");
+		int c = getopt(argc, argv, "b");
 
 		if (c < 0)
 			break;
 
 		switch (c) {
 		case 'b':
-			flags &= ~DF_HUMAN_UNIT;
+			mode = UNITS_RAW;
 			break;
 		default:
 			usage(cmd_device_usage_usage);
@@ -500,7 +500,7 @@ int cmd_device_usage(int argc, char **argv)
 			return 12;
 		}
 
-		r = _cmd_device_usage(fd, argv[i], flags);
+		r = _cmd_device_usage(fd, argv[i], mode);
 		close_file_or_dir(fd, dirstream);
 
 		if (r)
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index c823223ee8a8..632ded0d21ab 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -32,17 +32,6 @@
 #include "version.h"
 
 /*
- * Pretty print the size
- */
-char *df_pretty_sizes(u64 size, int mode)
-{
-	if (mode & DF_HUMAN_UNIT)
-		return pretty_size_mode(size, UNITS_HUMAN);
-	else
-		return pretty_size_mode(size, UNITS_RAW);
-}
-
-/*
  * Add the chunk info to the chunk_info list
  */
 static int add_info_to_list(struct chunk_info **info_ptr,
@@ -389,7 +378,7 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
 
 	K = ((double)total_used + (double)total_free) /	(double)total_chunks;
 
-	if (mode & DF_HUMAN_UNIT)
+	if (mode == UNITS_HUMAN)
 		width = 10;
 	else
 		width = 18;
@@ -397,22 +386,22 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
 	printf("Overall:\n");
 
 	printf("    Device size:\t\t%*s\n", width,
-		df_pretty_sizes(total_disk, mode));
+		pretty_size_mode(total_disk, mode));
 	printf("    Device allocated:\t\t%*s\n", width,
-		df_pretty_sizes(total_chunks, mode));
+		pretty_size_mode(total_chunks, mode));
 	printf("    Device unallocated:\t\t%*s\n", width,
-		df_pretty_sizes(total_disk-total_chunks, mode));
+		pretty_size_mode(total_disk - total_chunks, mode));
 	printf("    Used:\t\t\t%*s\n", width,
-		df_pretty_sizes(total_used, mode));
+		pretty_size_mode(total_used, mode));
 	printf("    Free (Estimated):\t\t%*s\t(",
 		width,
-		df_pretty_sizes((u64)(K*total_disk-total_used), mode));
+		pretty_size_mode((u64)(K * total_disk - total_used), mode));
 	printf("Max: %s, ",
-		df_pretty_sizes(total_disk-total_chunks+total_free, mode));
+		pretty_size_mode(total_disk - total_chunks + total_free, mode));
 	printf("min: %s)\n",
-		df_pretty_sizes((total_disk-total_chunks)/2+total_free, mode));
+		pretty_size_mode((total_disk-total_chunks) / 2 + total_free, mode));
 	printf("    Data to device ratio:\t%*.0f %%\n",
-		width-2, K*100);
+		width - 2, K * 100);
 
 exit:
 
@@ -612,7 +601,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
 
 			if (size)
 				table_printf(matrix, col, i+3,
-					">%s", df_pretty_sizes(size, mode));
+					">%s", pretty_size_mode(size, mode));
 			else
 				table_printf(matrix, col, i+3, ">-");
 
@@ -624,7 +613,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
 				- total_allocated;
 
 		table_printf(matrix, sargs->total_spaces + 1, i + 3,
-			       ">%s", df_pretty_sizes(unused, mode));
+			       ">%s", pretty_size_mode(unused, mode));
 		total_unused += unused;
 
 	}
@@ -636,15 +625,15 @@ static void _cmd_filesystem_usage_tabular(int mode,
 	table_printf(matrix, 0, device_info_count + 4, "<Total");
 	for (i = 0; i < sargs->total_spaces; i++)
 		table_printf(matrix, 1 + i, device_info_count + 4, ">%s",
-			df_pretty_sizes(sargs->spaces[i].total_bytes, mode));
+			pretty_size_mode(sargs->spaces[i].total_bytes, mode));
 
 	table_printf(matrix, sargs->total_spaces + 1, device_info_count + 4,
-			">%s", df_pretty_sizes(total_unused, mode));
+			">%s", pretty_size_mode(total_unused, mode));
 
 	table_printf(matrix, 0, device_info_count + 5, "<Used");
 	for (i = 0; i < sargs->total_spaces; i++)
 		table_printf(matrix, 1 + i, device_info_count+5, ">%s",
-			df_pretty_sizes(sargs->spaces[i].used_bytes, mode));
+			pretty_size_mode(sargs->spaces[i].used_bytes, mode));
 
 	table_dump(matrix);
 	table_free(matrix);
@@ -670,7 +659,7 @@ static void print_unused(struct chunk_info *info_ptr,
 
 		printf("   %s\t%10s\n",
 			device_info_ptr[i].path,
-			df_pretty_sizes(device_info_ptr[i].size - total, mode));
+			pretty_size_mode(device_info_ptr[i].size - total, mode));
 	}
 }
 
@@ -704,7 +693,7 @@ static void print_chunk_device(u64 chunk_type,
 		if (total > 0)
 			printf("   %s\t%10s\n",
 				device_info_ptr[i].path,
-				df_pretty_sizes(total, mode));
+				pretty_size_mode(total, mode));
 	}
 }
 
@@ -732,10 +721,10 @@ static void _cmd_filesystem_usage_linear(int mode,
 		printf("%s,%s: Size:%s, ",
 			description,
 			r_mode,
-			df_pretty_sizes(sargs->spaces[i].total_bytes ,
+			pretty_size_mode(sargs->spaces[i].total_bytes,
 			    mode));
 		printf("Used:%s\n",
-			df_pretty_sizes(sargs->spaces[i].used_bytes, mode));
+			pretty_size_mode(sargs->spaces[i].used_bytes, mode));
 		print_chunk_device(flags, info_ptr, info_count,
 				device_info_ptr, device_info_count, mode);
 		printf("\n");
@@ -787,7 +776,7 @@ const char * const cmd_filesystem_usage_usage[] = {
 
 int cmd_filesystem_usage(int argc, char **argv)
 {
-	int	flags =	DF_HUMAN_UNIT;
+	int mode = UNITS_HUMAN;
 	int	i, more_than_one = 0;
 	int	tabular = 0;
 
@@ -800,7 +789,7 @@ int cmd_filesystem_usage(int argc, char **argv)
 
 		switch (c) {
 		case 'b':
-			flags &= ~DF_HUMAN_UNIT;
+			mode = UNITS_RAW;
 			break;
 		case 't':
 			tabular = 1;
@@ -837,12 +826,12 @@ int cmd_filesystem_usage(int argc, char **argv)
 			goto cleanup;
 
 		ret = print_filesystem_usage_overall(fd, chunkinfo, chunkcount,
-				devinfo, devcount, argv[i], flags);
+				devinfo, devcount, argv[i], mode);
 		if (ret)
 			goto cleanup;
 		printf("\n");
 		ret = print_filesystem_usage_by_chunk(fd, chunkinfo, chunkcount,
-				devinfo, devcount, argv[i], flags, tabular);
+				devinfo, devcount, argv[i], mode, tabular);
 cleanup:
 		close_file_or_dir(fd, dirstream);
 		free(chunkinfo);
@@ -881,22 +870,22 @@ void print_device_chunks(int fd, struct device_info *devinfo,
 			description,
 			r_mode,
 			(int)(20 - strlen(description) - strlen(r_mode)), "",
-			df_pretty_sizes(size, mode));
+			pretty_size_mode(size, mode));
 
 		allocated += size;
 
 	}
 	printf("   Unallocated: %*s%10s\n",
 		(int)(20 - strlen("Unallocated")), "",
-		df_pretty_sizes(devinfo->size - allocated, mode));
+		pretty_size_mode(devinfo->size - allocated, mode));
 }
 
 void print_device_sizes(int fd, struct device_info *devinfo, int mode)
 {
 	printf("   Device size: %*s%10s\n",
 		(int)(20 - strlen("Device size")), "",
-		df_pretty_sizes(devinfo->device_size, mode));
+		pretty_size_mode(devinfo->device_size, mode));
 	printf("   FS occuppied:%*s%10s\n",
 		(int)(20 - strlen("FS occupied")), "",
-		df_pretty_sizes(devinfo->size, mode));
+		pretty_size_mode(devinfo->size, mode));
 }
diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
index 0779defc71db..8a0c60f011e4 100644
--- a/cmds-fi-disk_usage.h
+++ b/cmds-fi-disk_usage.h
@@ -19,8 +19,6 @@
 #ifndef __CMDS_FI_DISK_USAGE__
 #define __CMDS_FI_DISK_USAGE__
 
-#define DF_HUMAN_UNIT		(1<<0)
-
 extern const char * const cmd_filesystem_usage_usage[];
 int cmd_filesystem_usage(int argc, char **argv);
 
@@ -48,7 +46,6 @@ struct chunk_info {
 
 int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo,
 		int *chunkcount, struct device_info **devinfo, int *devcount);
-char *df_pretty_sizes(u64 size, int mode);
 void print_device_chunks(int fd, struct device_info *devinfo,
 		struct chunk_info *chunks_info_ptr,
 		int chunks_info_count, int mode);
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 13/14] btrfs-progs: clean up return codes and paths
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (11 preceding siblings ...)
  2014-04-29 16:02 ` [PATCH 12/14] btrfs-progs: replace df_pretty_sizes with pretty_size_mode David Sterba
@ 2014-04-29 16:02 ` David Sterba
  2014-04-29 16:03 ` [PATCH 14/14] btrfs-progs: move global reserve to overall summary David Sterba
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 16:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Use the common patterns with one return statement at the end, pass down error

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-device.c        | 27 +++++++++++++--------------
 cmds-fi-disk_usage.c | 39 +++++++++++++++++++++------------------
 2 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/cmds-device.c b/cmds-device.c
index b2773f249cba..41a5a5c6ca8e 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -442,10 +442,8 @@ static int _cmd_device_usage(int fd, char *path, int mode)
 
 	ret = load_chunk_and_device_info(fd, &chunkinfo, &chunkcount, &devinfo,
 			&devcount);
-	if (ret) {
-		ret = -1;
-		goto exit;
-	}
+	if (ret)
+		goto out;
 
 	for (i = 0; i < devcount; i++) {
 		printf("%s, ID: %llu\n", devinfo[i].path, devinfo[i].devid);
@@ -455,7 +453,7 @@ static int _cmd_device_usage(int fd, char *path, int mode)
 		printf("\n");
 	}
 
-exit:
+out:
 	free(devinfo);
 	free(chunkinfo);
 
@@ -466,6 +464,7 @@ int cmd_device_usage(int argc, char **argv)
 {
 
 	int mode = UNITS_HUMAN;
+	int ret = 0;
 	int	i, more_than_one = 0;
 
 	optind = 1;
@@ -488,28 +487,28 @@ int cmd_device_usage(int argc, char **argv)
 		usage(cmd_device_usage_usage);
 
 	for (i = optind; i < argc ; i++) {
-		int r, fd;
+		int fd;
 		DIR	*dirstream = NULL;
 		if (more_than_one)
 			printf("\n");
 
 		fd = open_file_or_dir(argv[i], &dirstream);
 		if (fd < 0) {
-			fprintf(stderr, "ERROR: can't access to '%s'\n",
+			fprintf(stderr, "ERROR: can't access '%s'\n",
 				argv[1]);
-			return 12;
+			ret = 1;
+			goto out;
 		}
 
-		r = _cmd_device_usage(fd, argv[i], mode);
+		ret = _cmd_device_usage(fd, argv[i], mode);
 		close_file_or_dir(fd, dirstream);
 
-		if (r)
-			return r;
+		if (ret)
+			goto out;
 		more_than_one = 1;
-
 	}
-
-	return 0;
+out:
+	return !!ret;
 }
 
 const struct cmd_group device_cmd_group = {
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 632ded0d21ab..d0b061ec7eb0 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -67,7 +67,7 @@ static int add_info_to_list(struct chunk_info **info_ptr,
 
 			if (!res) {
 				fprintf(stderr, "ERROR: not enough memory\n");
-				return -1;
+				return -ENOMEM;
 			}
 
 			*info_ptr = res;
@@ -162,7 +162,7 @@ static int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count
 			fprintf(stderr,
 				"ERROR: can't perform the search - %s\n",
 				strerror(e));
-			return -99;
+			return ret;
 		}
 		/* the ioctl returns the number of item it found in nr_items */
 
@@ -178,10 +178,11 @@ static int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count
 			off += sizeof(*sh);
 			item = (struct btrfs_chunk *)(args.buf + off);
 
-			if (add_info_to_list(info_ptr, info_count, item)) {
+			ret = add_info_to_list(info_ptr, info_count, item);
+			if (ret) {
 				*info_ptr = 0;
 				free(*info_ptr);
-				return -100;
+				return ret;
 			}
 
 			off += sh->len;
@@ -319,8 +320,9 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
 	double K;
 	u64 raid5_used, raid6_used;
 
-	if ((sargs = load_space_info(fd, path)) == NULL) {
-		ret = -1;
+	sargs = load_space_info(fd, path);
+	if (!sargs) {
+		ret = 1;
 		goto exit;
 	}
 
@@ -331,7 +333,7 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
 			"ERROR: couldn't get space info on '%s' - %s\n",
 			path, strerror(e));
 
-		ret = 19;
+		ret = 1;
 		goto exit;
 	}
 	get_raid56_used(fd, chunkinfo, chunkcount, &raid5_used, &raid6_used);
@@ -439,13 +441,13 @@ static int load_device_info(int fd, struct device_info **device_info_ptr,
 		return ret;
 	if (ret < 0) {
 		fprintf(stderr, "ERROR: cannot get filesystem info\n");
-		return -1;
+		return ret;
 	}
 
 	info = calloc(fi_args.num_devices, sizeof(struct device_info));
 	if (!info) {
 		fprintf(stderr, "ERROR: not enough memory\n");
-		return -1;
+		return ret;
 	}
 
 	for (i = 0, ndevs = 0 ; i <= fi_args.max_id ; i++) {
@@ -460,7 +462,7 @@ static int load_device_info(int fd, struct device_info **device_info_ptr,
 			    "ERROR: cannot get info about device devid=%d\n",
 			    i);
 			free(info);
-			return -1;
+			return ret;
 		}
 
 		info[ndevs].devid = dev_info.devid;
@@ -749,7 +751,7 @@ static int print_filesystem_usage_by_chunk(int fd,
 	sargs = load_space_info(fd, path);
 	if (!sargs) {
 		ret = 1;
-		goto exit;
+		goto out;
 	}
 
 	if (tabular)
@@ -759,9 +761,8 @@ static int print_filesystem_usage_by_chunk(int fd,
 		_cmd_filesystem_usage_linear(mode, sargs, chunkinfo,
 				chunkcount, devinfo, devcount);
 
-exit:
 	free(sargs);
-
+out:
 	return ret;
 }
 
@@ -777,6 +778,7 @@ const char * const cmd_filesystem_usage_usage[] = {
 int cmd_filesystem_usage(int argc, char **argv)
 {
 	int mode = UNITS_HUMAN;
+	int ret = 0;
 	int	i, more_than_one = 0;
 	int	tabular = 0;
 
@@ -803,7 +805,6 @@ int cmd_filesystem_usage(int argc, char **argv)
 		usage(cmd_filesystem_usage_usage);
 
 	for (i = optind; i < argc; i++) {
-		int ret;
 		int fd;
 		DIR *dirstream = NULL;
 		struct chunk_info *chunkinfo = NULL;
@@ -813,9 +814,10 @@ int cmd_filesystem_usage(int argc, char **argv)
 
 		fd = open_file_or_dir(argv[i], &dirstream);
 		if (fd < 0) {
-			fprintf(stderr, "ERROR: can't access to '%s'\n",
+			fprintf(stderr, "ERROR: can't access '%s'\n",
 				argv[1]);
-			return 12;
+			ret = 1;
+			goto out;
 		}
 		if (more_than_one)
 			printf("\n");
@@ -838,11 +840,12 @@ cleanup:
 		free(devinfo);
 
 		if (ret)
-			return ret;
+			goto out;
 		more_than_one = 1;
 	}
 
-	return 0;
+out:
+	return !!ret;
 }
 
 void print_device_chunks(int fd, struct device_info *devinfo,
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 14/14] btrfs-progs: move global reserve to overall summary
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (12 preceding siblings ...)
  2014-04-29 16:02 ` [PATCH 13/14] btrfs-progs: clean up return codes and paths David Sterba
@ 2014-04-29 16:03 ` David Sterba
  2014-04-29 17:10 ` [PATCH 00/14] Enhanced df - followup Duncan
  2014-04-29 19:14 ` Mike Fleetwood
  15 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-29 16:03 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

It looks confusing among the chunks, it is not in fact a chunk type.

Sample:
Overall:
    Device size:                  35.00GiB
    Device allocated:              8.07GiB
    Device unallocated:           26.93GiB
    Used:                          1.12MiB
    Free (Estimated):             17.57GiB      (Max: 30.98GiB, min: 17.52GiB)
    Data to device ratio:             50 %
    Global reserve:               16.00MiB      (used: 0.00B)
...

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 cmds-fi-disk_usage.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index d0b061ec7eb0..d8222d4d094d 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -319,6 +319,8 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
 	u64 total_free;		/* logical space un-used */
 	double K;
 	u64 raid5_used, raid6_used;
+	u64 global_reserve;
+	u64 global_reserve_used;
 
 	sargs = load_space_info(fd, path);
 	if (!sargs) {
@@ -341,6 +343,8 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
 	total_chunks = 0;
 	total_used = 0;
 	total_free = 0;
+	global_reserve = 0;
+	global_reserve_used = 0;
 
 	for (i = 0; i < sargs->total_spaces; i++) {
 		float ratio = 1;
@@ -366,6 +370,11 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
 		else
 			ratio = 1;
 
+		if (flags & BTRFS_SPACE_INFO_GLOBAL_RSV) {
+			global_reserve = sargs->spaces[i].total_bytes;
+			global_reserve_used = sargs->spaces[i].used_bytes;
+		}
+
 		allocated = sargs->spaces[i].total_bytes * ratio;
 
 		total_chunks += allocated;
@@ -404,6 +413,9 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
 		pretty_size_mode((total_disk-total_chunks) / 2 + total_free, mode));
 	printf("    Data to device ratio:\t%*.0f %%\n",
 		width - 2, K * 100);
+	printf("    Global reserve:\t\t%*s\t(used: %s)\n", width,
+		pretty_size_mode(global_reserve, mode),
+		pretty_size_mode(global_reserve_used, mode));
 
 exit:
 
@@ -553,8 +565,11 @@ static void _cmd_filesystem_usage_tabular(int mode,
 	/* header */
 	for (i = 0; i < sargs->total_spaces; i++) {
 		const char *description;
-
 		u64 flags = sargs->spaces[i].flags;
+
+		if (flags & BTRFS_SPACE_INFO_GLOBAL_RSV)
+			continue;
+
 		description = group_type_str(flags);
 
 		table_printf(matrix, 1+i, 0, "<%s", description);
@@ -715,8 +730,11 @@ static void _cmd_filesystem_usage_linear(int mode,
 	for (i = 0; i < sargs->total_spaces; i++) {
 		const char *description;
 		const char *r_mode;
-
 		u64 flags = sargs->spaces[i].flags;
+
+		if (flags & BTRFS_SPACE_INFO_GLOBAL_RSV)
+			continue;
+
 		description= group_type_str(flags);
 		r_mode = group_profile_str(flags);
 
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/14] Enhanced df - followup
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (13 preceding siblings ...)
  2014-04-29 16:03 ` [PATCH 14/14] btrfs-progs: move global reserve to overall summary David Sterba
@ 2014-04-29 17:10 ` Duncan
  2014-04-29 17:17   ` Marc MERLIN
  2014-04-30 13:01   ` David Sterba
  2014-04-29 19:14 ` Mike Fleetwood
  15 siblings, 2 replies; 35+ messages in thread
From: Duncan @ 2014-04-29 17:10 UTC (permalink / raw)
  To: linux-btrfs

David Sterba posted on Tue, 29 Apr 2014 17:56:47 +0200 as excerpted:

> Changes:
> * btrfs filesystem disk_usage - renamed to usage

Hopefully this isn't rehashing an old discussion, but...

Simpler is good, and getting rid of the _ is good, but...

To users familiar with Unix/POSIX/Linux CLI, "usage" (as --usage) is most 
often seen as a rather less common and generally briefer form of --help, 
usually with the distinction being that --help may be a screen or more of 
output, while --usage is much shorter, perhaps a single line.

While I had seen it listed in manpages and --help output often enough, 
once I actually went looking for real examples I had a hard time finding 
some, but eventually found some in the grub (grub2) command set.

$ grub-bios-setup --usage
Usage: grub-bios-setup [-afsv?V] [-b FILE] [-c FILE] [-d DIR] [-m FILE]
            [--allow-floppy] [--boot-image=FILE] [--core-image=FILE]
            [--directory=DIR] [--force] [--device-map=FILE] [--no-rs-
codes]
            [--skip-fs-probe] [--verbose] [--help] [--usage] [--version]
            DEVICE

(For brevity, just printing the line-count for the following few example 
grub-* commands, not the full output.)

$ grub-bios-setup --help | wc -l
30

$ grub-probe --usage | wc -l
3

$ grub-probe --help | wc -l
23

$ grub-editenv --usage | wc -l
2

$ grub-editenv --help | wc -l
23


While --usage does normally appear with the usual long-option double-dash 
and the proposal for btrfs does not, I'd still consider a simple
"btrfs filesystem usage" confusing at best, expecting it to print out a 
short help/usage for the "btrfs filesystem" command, either due to not 
understanding the token and thus printing command usage, or understanding 
it as a request to print command usage, NOT the actual filesystem usage.

OTOH, for CLI veterans anyway, standard old "du" (btrfs fi du) should be 
as immediately understood as "df".


Given that confusion, I'd suggest either simply making it du, or making 
it "device_usage" but with "du" a documented alias printing exactly the 
same output, thus giving folks an easy way to avoid the _.

-- 
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


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/14] Enhanced df - followup
  2014-04-29 17:10 ` [PATCH 00/14] Enhanced df - followup Duncan
@ 2014-04-29 17:17   ` Marc MERLIN
  2014-04-29 17:33     ` Holger Hoffstätte
  2014-04-30 13:01   ` David Sterba
  1 sibling, 1 reply; 35+ messages in thread
From: Marc MERLIN @ 2014-04-29 17:17 UTC (permalink / raw)
  To: Duncan; +Cc: linux-btrfs

On Tue, Apr 29, 2014 at 05:10:31PM +0000, Duncan wrote:
> David Sterba posted on Tue, 29 Apr 2014 17:56:47 +0200 as excerpted:
> 
> > Changes:
> > * btrfs filesystem disk_usage - renamed to usage
> 
> Hopefully this isn't rehashing an old discussion, but...
> 
> Simpler is good, and getting rid of the _ is good, but...
(...) 
> Given that confusion, I'd suggest either simply making it du, or making 
> it "device_usage" but with "du" a documented alias printing exactly the 
> same output, thus giving folks an easy way to avoid the _.

It's also fine to just use disk-usage instead of disk_usage.

Marc
-- 
"A mouse is a device used to point at the xterm you want to type in" - A.S.R.
Microsoft is to operating systems ....
                                      .... what McDonalds is to gourmet cooking
Home page: http://marc.merlins.org/                         | PGP 1024R/763BE901

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/14] Enhanced df - followup
  2014-04-29 17:17   ` Marc MERLIN
@ 2014-04-29 17:33     ` Holger Hoffstätte
  2014-04-30  0:42       ` Duncan
  0 siblings, 1 reply; 35+ messages in thread
From: Holger Hoffstätte @ 2014-04-29 17:33 UTC (permalink / raw)
  To: linux-btrfs

On Tue, 29 Apr 2014 10:17:49 -0700, Marc MERLIN wrote:

> On Tue, Apr 29, 2014 at 05:10:31PM +0000, Duncan wrote:
>> David Sterba posted on Tue, 29 Apr 2014 17:56:47 +0200 as excerpted:
>> 
>> > Changes:
>> > * btrfs filesystem disk_usage - renamed to usage
>> 
>> Hopefully this isn't rehashing an old discussion, but...
>> 
>> Simpler is good, and getting rid of the _ is good, but...
> (...) 
>> Given that confusion, I'd suggest either simply making it du, or making 
>> it "device_usage" but with "du" a documented alias printing exactly the 
>> same output, thus giving folks an easy way to avoid the _.
> 
> It's also fine to just use disk-usage instead of disk_usage.

I think the point was to have the same term for both filesystem and
device categories, which IMHO makes a lot of sense and is less
to remember. Categorical polymorphism: it's a good thing. :)

-h


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/14] Enhanced df - followup
  2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
                   ` (14 preceding siblings ...)
  2014-04-29 17:10 ` [PATCH 00/14] Enhanced df - followup Duncan
@ 2014-04-29 19:14 ` Mike Fleetwood
  2014-04-30 12:22   ` David Sterba
  15 siblings, 1 reply; 35+ messages in thread
From: Mike Fleetwood @ 2014-04-29 19:14 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs

On 29 April 2014 16:56, David Sterba <dsterba@suse.cz> wrote:
> Changes:
> * btrfs filesystem disk_usage - renamed to usage
>   * added a section of overall filesystem usage, that used to be in the
>     'fi df' output
> * btrfs device disk_usage - renamed to usage
>   * the device size prints both blockdevie size and the size that's occupied
>     by the filesystem
>   * device ID is printed

>  cmds-fi-disk_usage.c | 631 +++++++++++++++++++--------------------------------
>  cmds-fi-disk_usage.h |  35 ++-

After renaming the commands btrfs ... disk_usage to btrfs ... usage
should the source files also be renamed to cmds-fi-usage.[ch]?

Thanks,
Mike

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-29 16:02 ` [PATCH 07/14] btrfs-progs: Print more info about device sizes David Sterba
@ 2014-04-29 19:23   ` Mike Fleetwood
  2014-04-30 11:39     ` Goffredo Baroncelli
  2014-04-30 11:52     ` David Sterba
  0 siblings, 2 replies; 35+ messages in thread
From: Mike Fleetwood @ 2014-04-29 19:23 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs

On 29 April 2014 17:02, David Sterba <dsterba@suse.cz> wrote:
> The entire device size may not be available to the filesystem, eg. if
> it's modified via resize. Print this information if it can be obtained
> from the DEV_INFO ioctl.
>
> Print the device ID on the same line as the device name and move size to
> the next line.
>
> Sample:
> /dev/sda7, ID: 3
>    Device size:            10.00GiB
>    FS occuppied:            5.00GiB

Spelling mistake.  s/occuppied/occupied/.

>    Data,RAID10:           512.00MiB
>    Metadata,RAID10:       512.00MiB
>    System,RAID10:           4.00MiB
>    Unallocated:             9.00GiB
>
> Signed-off-by: David Sterba <dsterba@suse.cz>
> ---
>  cmds-device.c        |  6 +++---
>  cmds-fi-disk_usage.c | 13 ++++++++++++-
>  cmds-fi-disk_usage.h |  6 +++++-
>  3 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/cmds-device.c b/cmds-device.c
> index 7a9d808b36dd..519725f83e8c 100644
> --- a/cmds-device.c
> +++ b/cmds-device.c
> @@ -447,9 +447,9 @@ static int _cmd_device_usage(int fd, char *path, int mode)
>         }
>
>         for (i = 0; i < device_info_count; i++) {
> -               printf("%s\t%10s\n", device_info_ptr[i].path,
> -                       df_pretty_sizes(device_info_ptr[i].size, mode));
> -
> +               printf("%s, ID: %llu\n", device_info_ptr[i].path,
> +                               device_info_ptr[i].devid);
> +               print_device_sizes(fd, &device_info_ptr[i], mode);
>                 print_device_chunks(fd, device_info_ptr[i].devid,
>                                 device_info_ptr[i].size,
>                                 info_ptr, info_count,
> diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
> index 067c60078710..ddb064cc4c66 100644
> --- a/cmds-fi-disk_usage.c
> +++ b/cmds-fi-disk_usage.c
> @@ -499,7 +499,8 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
>
>                 info[ndevs].devid = dev_info.devid;
>                 strcpy(info[ndevs].path, (char *)dev_info.path);
> -               info[ndevs].size = get_partition_size((char *)dev_info.path);
> +               info[ndevs].device_size = get_partition_size((char *)dev_info.path);
> +               info[ndevs].size = dev_info.total_size;
>                 ++ndevs;
>         }
>
> @@ -879,5 +880,15 @@ void print_device_chunks(int fd, u64 devid, u64 total_size,
>         printf("   Unallocated: %*s%10s\n",
>                 (int)(20 - strlen("Unallocated")), "",
>                 df_pretty_sizes(total_size - allocated, mode));
> +}
>
> +void print_device_sizes(int fd, struct device_info *devinfo, int mode)
> +{
> +       printf("   Device size: %*s%10s\n",
> +               (int)(20 - strlen("Device size")), "",
> +               df_pretty_sizes(devinfo->device_size, mode));
> +       printf("   FS occuppied:%*s%10s\n",

Here too.  s/occuppied/occupied/.

> +               (int)(20 - strlen("FS occupied")), "",
> +               df_pretty_sizes(devinfo->size, mode));
> +       }
>  }
> diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
> index 787b4eb56acf..79cc2a115bc5 100644
> --- a/cmds-fi-disk_usage.h
> +++ b/cmds-fi-disk_usage.h
> @@ -27,7 +27,10 @@ int cmd_filesystem_usage(int argc, char **argv);
>  struct device_info {
>         u64     devid;
>         char    path[BTRFS_DEVICE_PATH_NAME_MAX];
> -       u64     size;
> +       /* Size of the block device */
> +       u64     device_size;
> +       /* Size that's occupied by the filesystem, can be changed via resize */
> +       u64     size;
>  };
>
>  /*
> @@ -50,5 +53,6 @@ char *df_pretty_sizes(u64 size, int mode);
>  void print_device_chunks(int fd, u64 devid, u64 total_size,
>                 struct chunk_info *chunks_info_ptr,
>                 int chunks_info_count, int mode);
> +void print_device_sizes(int fd, struct device_info *devinfo, int mode);
>
>  #endif
> --
> 1.9.0

Same spelling mistake (occuppied) also occurs in the following patches too:
 [PATCH 08/14] btrfs-progs: compare unallocated space against the correct value
 [PATCH 12/14] btrfs-progs: replace df_pretty_sizes with pretty_size_mode

Thanks,
Mike

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/14] Enhanced df - followup
  2014-04-29 17:33     ` Holger Hoffstätte
@ 2014-04-30  0:42       ` Duncan
  2014-04-30  8:15         ` Martin Steigerwald
  0 siblings, 1 reply; 35+ messages in thread
From: Duncan @ 2014-04-30  0:42 UTC (permalink / raw)
  To: linux-btrfs

Holger Hoffstätte posted on Tue, 29 Apr 2014 17:33:09 +0000 as excerpted:

>> On Tue, Apr 29, 2014 at 05:10:31PM +0000, Duncan wrote:
>>> David Sterba posted on Tue, 29 Apr 2014 17:56:47 +0200 as excerpted:
>>> 
>>> > Changes:
>>> > * btrfs filesystem disk_usage - renamed to usage
>>> 
>>> [On the CLI, "usage" is often used to print a briefer "help",
>>> and thus shouldn't be used for an actual command.]
> 
> I think the point was to have the same term for both filesystem and
> device categories, which IMHO makes a lot of sense and is less to
> remember. Categorical polymorphism: it's a good thing. :)

Good idea to use the same term.

Bad idea (IMO) to make that term "usage", by itself.

=:^)

-- 
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


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/14] Enhanced df - followup
  2014-04-30  0:42       ` Duncan
@ 2014-04-30  8:15         ` Martin Steigerwald
  2014-04-30 12:37           ` David Sterba
  0 siblings, 1 reply; 35+ messages in thread
From: Martin Steigerwald @ 2014-04-30  8:15 UTC (permalink / raw)
  To: linux-btrfs

[keeping dropped CC although not customary on this list]

Am Mittwoch, 30. April 2014, 00:42:44 schrieb Duncan:
> Holger Hoffstätte posted on Tue, 29 Apr 2014 17:33:09 +0000 as excerpted:
> >> On Tue, Apr 29, 2014 at 05:10:31PM +0000, Duncan wrote:
> >>> David Sterba posted on Tue, 29 Apr 2014 17:56:47 +0200 as excerpted:
> >>> > Changes:
> >>> > * btrfs filesystem disk_usage - renamed to usage
> >>> 
> >>> [On the CLI, "usage" is often used to print a briefer "help",
> >>> and thus shouldn't be used for an actual command.]
> > 
> > I think the point was to have the same term for both filesystem and
> > device categories, which IMHO makes a lot of sense and is less to
> > remember. Categorical polymorphism: it's a good thing. :)
> 
> Good idea to use the same term.
> 
> Bad idea (IMO) to make that term "usage", by itself.
> 
> =:^)

Hmmm, I disagree. What it basically displays is usage. So the term "usage" is 
just about right.

And it isn´t an option either.

Additionally I never ever used the option "--usage". I didn´t even know it 
existed.

But if you have a different equally short sugestion, I am all ears.

Anyway, I´d personally wouldn´t block the patch going in due to this.

Thanks,
-- 
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-29 19:23   ` Mike Fleetwood
@ 2014-04-30 11:39     ` Goffredo Baroncelli
  2014-04-30 12:11       ` David Sterba
  2014-04-30 11:52     ` David Sterba
  1 sibling, 1 reply; 35+ messages in thread
From: Goffredo Baroncelli @ 2014-04-30 11:39 UTC (permalink / raw)
  To: David Sterba; +Cc: Mike Fleetwood, linux-btrfs

I David
thanks, to take care of these enhancements.

On 04/29/2014 09:23 PM, Mike Fleetwood wrote:
> On 29 April 2014 17:02, David Sterba <dsterba@suse.cz> wrote:
>> The entire device size may not be available to the filesystem, eg. if
>> it's modified via resize. Print this information if it can be obtained
>> from the DEV_INFO ioctl.
>>
>> Print the device ID on the same line as the device name and move size to
>> the next line.
>>
>> Sample:
>> /dev/sda7, ID: 3
>>    Device size:            10.00GiB
>>    FS occuppied:            5.00GiB
> 
> Spelling mistake.  s/occuppied/occupied/.

I found a bit unclear the "FS occupied" terms. 
Can I suggest "Resized to:" instead of "FS occupied:", and to show it only when the two values differ ? In fact this value has a meaning only if a filesystem is resized.

BR
G.Baroncelli

> 
>>    Data,RAID10:           512.00MiB
>>    Metadata,RAID10:       512.00MiB
>>    System,RAID10:           4.00MiB
>>    Unallocated:             9.00GiB
>>
>> Signed-off-by: David Sterba <dsterba@suse.cz>
>> ---
>>  cmds-device.c        |  6 +++---
>>  cmds-fi-disk_usage.c | 13 ++++++++++++-
>>  cmds-fi-disk_usage.h |  6 +++++-
>>  3 files changed, 20 insertions(+), 5 deletions(-)
>>
>> diff --git a/cmds-device.c b/cmds-device.c
>> index 7a9d808b36dd..519725f83e8c 100644
>> --- a/cmds-device.c
>> +++ b/cmds-device.c
>> @@ -447,9 +447,9 @@ static int _cmd_device_usage(int fd, char *path, int mode)
>>         }
>>
>>         for (i = 0; i < device_info_count; i++) {
>> -               printf("%s\t%10s\n", device_info_ptr[i].path,
>> -                       df_pretty_sizes(device_info_ptr[i].size, mode));
>> -
>> +               printf("%s, ID: %llu\n", device_info_ptr[i].path,
>> +                               device_info_ptr[i].devid);
>> +               print_device_sizes(fd, &device_info_ptr[i], mode);
>>                 print_device_chunks(fd, device_info_ptr[i].devid,
>>                                 device_info_ptr[i].size,
>>                                 info_ptr, info_count,
>> diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
>> index 067c60078710..ddb064cc4c66 100644
>> --- a/cmds-fi-disk_usage.c
>> +++ b/cmds-fi-disk_usage.c
>> @@ -499,7 +499,8 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
>>
>>                 info[ndevs].devid = dev_info.devid;
>>                 strcpy(info[ndevs].path, (char *)dev_info.path);
>> -               info[ndevs].size = get_partition_size((char *)dev_info.path);
>> +               info[ndevs].device_size = get_partition_size((char *)dev_info.path);
>> +               info[ndevs].size = dev_info.total_size;
>>                 ++ndevs;
>>         }
>>
>> @@ -879,5 +880,15 @@ void print_device_chunks(int fd, u64 devid, u64 total_size,
>>         printf("   Unallocated: %*s%10s\n",
>>                 (int)(20 - strlen("Unallocated")), "",
>>                 df_pretty_sizes(total_size - allocated, mode));
>> +}
>>
>> +void print_device_sizes(int fd, struct device_info *devinfo, int mode)
>> +{
>> +       printf("   Device size: %*s%10s\n",
>> +               (int)(20 - strlen("Device size")), "",
>> +               df_pretty_sizes(devinfo->device_size, mode));
>> +       printf("   FS occuppied:%*s%10s\n",
> 
> Here too.  s/occuppied/occupied/.
> 
>> +               (int)(20 - strlen("FS occupied")), "",
>> +               df_pretty_sizes(devinfo->size, mode));
>> +       }
>>  }
>> diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
>> index 787b4eb56acf..79cc2a115bc5 100644
>> --- a/cmds-fi-disk_usage.h
>> +++ b/cmds-fi-disk_usage.h
>> @@ -27,7 +27,10 @@ int cmd_filesystem_usage(int argc, char **argv);
>>  struct device_info {
>>         u64     devid;
>>         char    path[BTRFS_DEVICE_PATH_NAME_MAX];
>> -       u64     size;
>> +       /* Size of the block device */
>> +       u64     device_size;
>> +       /* Size that's occupied by the filesystem, can be changed via resize */
>> +       u64     size;
>>  };
>>
>>  /*
>> @@ -50,5 +53,6 @@ char *df_pretty_sizes(u64 size, int mode);
>>  void print_device_chunks(int fd, u64 devid, u64 total_size,
>>                 struct chunk_info *chunks_info_ptr,
>>                 int chunks_info_count, int mode);
>> +void print_device_sizes(int fd, struct device_info *devinfo, int mode);
>>
>>  #endif
>> --
>> 1.9.0
> 
> Same spelling mistake (occuppied) also occurs in the following patches too:
>  [PATCH 08/14] btrfs-progs: compare unallocated space against the correct value
>  [PATCH 12/14] btrfs-progs: replace df_pretty_sizes with pretty_size_mode
> 
> Thanks,
> Mike
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-29 19:23   ` Mike Fleetwood
  2014-04-30 11:39     ` Goffredo Baroncelli
@ 2014-04-30 11:52     ` David Sterba
  1 sibling, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-30 11:52 UTC (permalink / raw)
  To: Mike Fleetwood; +Cc: David Sterba, linux-btrfs

On Tue, Apr 29, 2014 at 08:23:08PM +0100, Mike Fleetwood wrote:
> > /dev/sda7, ID: 3
> >    Device size:            10.00GiB
> >    FS occuppied:            5.00GiB
> 
> Spelling mistake.  s/occuppied/occupied/.

> > +void print_device_sizes(int fd, struct device_info *devinfo, int mode)
> > +{
> > +       printf("   Device size: %*s%10s\n",
> > +               (int)(20 - strlen("Device size")), "",
> > +               df_pretty_sizes(devinfo->device_size, mode));
> > +       printf("   FS occuppied:%*s%10s\n",
> 
> Here too.  s/occuppied/occupied/.
> 
> > +               (int)(20 - strlen("FS occupied")), "",
> > +               df_pretty_sizes(devinfo->size, mode));
> > +       }
> >  }
> 
> Same spelling mistake (occuppied) also occurs in the following patches too:
>  [PATCH 08/14] btrfs-progs: compare unallocated space against the correct value
>  [PATCH 12/14] btrfs-progs: replace df_pretty_sizes with pretty_size_mode

Thanks for catching it.


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-30 11:39     ` Goffredo Baroncelli
@ 2014-04-30 12:11       ` David Sterba
  2014-04-30 13:31         ` Frank Kingswood
  0 siblings, 1 reply; 35+ messages in thread
From: David Sterba @ 2014-04-30 12:11 UTC (permalink / raw)
  To: kreijack; +Cc: David Sterba, Mike Fleetwood, linux-btrfs

On Wed, Apr 30, 2014 at 01:39:27PM +0200, Goffredo Baroncelli wrote:
> >> Sample:
> >> /dev/sda7, ID: 3
> >>    Device size:            10.00GiB
> >>    FS occuppied:            5.00GiB
> > 
> > Spelling mistake.  s/occuppied/occupied/.
> 
> I found a bit unclear the "FS occupied" terms. 

We're running out of terms to describe and distinguish the space that
the filesystem uses.

Here's what we have already:

- used
- allocated
- reserved
- total

'occupied' seemed like a good choice to me, though it may be not obvious
at first. The rationale behind is to denote space that the filesystem
can potentially use on the device - in one word.

> Can I suggest "Resized to:" instead of "FS occupied:", and to show it
> only when the two values differ ? In fact this value has a meaning
> only if a filesystem is resized.

'Resized to' sounds good to me and makes sense in the context of the
output:

/dev/sda6, ID: 2
   Device size:            10.00GiB
   Resized to:              5.00GiB
   Data,RAID10:           512.00MiB
   Metadata,RAID10:       512.00MiB
   System,RAID10:           4.00MiB
   Unallocated:             9.00GiB

The next point, display only if it's different from size. This makes
calculating the filesystem size conditional and if eg. I filter the
output I can't simply do 'grep -i occupied'.

The points against that are that this makes the output longer and the
resized devices are probably not the most common scenario.

So as a compromise, we can add an option to enable more verbose output.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/14] Enhanced df - followup
  2014-04-29 19:14 ` Mike Fleetwood
@ 2014-04-30 12:22   ` David Sterba
  0 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-30 12:22 UTC (permalink / raw)
  To: Mike Fleetwood; +Cc: David Sterba, linux-btrfs

On Tue, Apr 29, 2014 at 08:14:30PM +0100, Mike Fleetwood wrote:
> On 29 April 2014 16:56, David Sterba <dsterba@suse.cz> wrote:
> > Changes:
> > * btrfs filesystem disk_usage - renamed to usage
> >   * added a section of overall filesystem usage, that used to be in the
> >     'fi df' output
> > * btrfs device disk_usage - renamed to usage
> >   * the device size prints both blockdevie size and the size that's occupied
> >     by the filesystem
> >   * device ID is printed
> 
> >  cmds-fi-disk_usage.c | 631 +++++++++++++++++++--------------------------------
> >  cmds-fi-disk_usage.h |  35 ++-
> 
> After renaming the commands btrfs ... disk_usage to btrfs ... usage
> should the source files also be renamed to cmds-fi-usage.[ch]?

I should have mentioned that in the cover letter why they've been left
as-is - to keep the amount of unrelated cleanup changes low. The files
contain helpers for loading/calculating the space information etc and
will be moved to a separate file, possibly usable from libbtrfs.

This can be done independently of the 'enhanced df' changes.

Thanks.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/14] Enhanced df - followup
  2014-04-30  8:15         ` Martin Steigerwald
@ 2014-04-30 12:37           ` David Sterba
  0 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-04-30 12:37 UTC (permalink / raw)
  To: Martin Steigerwald; +Cc: linux-btrfs

On Wed, Apr 30, 2014 at 10:15:11AM +0200, Martin Steigerwald wrote:
> [keeping dropped CC although not customary on this list]
> 
> Am Mittwoch, 30. April 2014, 00:42:44 schrieb Duncan:
> > >>> > * btrfs filesystem disk_usage - renamed to usage
> > >>> 
> > >>> [On the CLI, "usage" is often used to print a briefer "help",
> > >>> and thus shouldn't be used for an actual command.]
> > > 
> > > I think the point was to have the same term for both filesystem and
> > > device categories, which IMHO makes a lot of sense and is less to
> > > remember. Categorical polymorphism: it's a good thing. :)
> > 
> > Good idea to use the same term.
> > 
> > Bad idea (IMO) to make that term "usage", by itself.
> > 
> > =:^)
> 
> Hmmm, I disagree. What it basically displays is usage. So the term "usage" is 
> just about right.
> 
> And it isn´t an option either.
> 
> Additionally I never ever used the option "--usage". I didn´t even know it 
> existed.
> 
> But if you have a different equally short sugestion, I am all ears.
> 
> Anyway, I´d personally wouldn´t block the patch going in due to this.

I agree with all your points.

For the reference, the term 'usage' has been agreed in the previous
iteration.

[1] http://www.spinics.net/lists/linux-btrfs/msg31698.html
[2] http://www.spinics.net/lists/linux-btrfs/msg31694.html

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/14] Enhanced df - followup
  2014-04-29 17:10 ` [PATCH 00/14] Enhanced df - followup Duncan
  2014-04-29 17:17   ` Marc MERLIN
@ 2014-04-30 13:01   ` David Sterba
  2014-04-30 17:25     ` Duncan
  1 sibling, 1 reply; 35+ messages in thread
From: David Sterba @ 2014-04-30 13:01 UTC (permalink / raw)
  To: Duncan; +Cc: linux-btrfs

On Tue, Apr 29, 2014 at 05:10:31PM +0000, Duncan wrote:
> To users familiar with Unix/POSIX/Linux CLI, "usage" (as --usage) is most 
> often seen as a rather less common and generally briefer form of --help, 
> usually with the distinction being that --help may be a screen or more of 
> output, while --usage is much shorter, perhaps a single line.

I did a quick check of ~20 randomly chosen binaries in /usr/bin and none
of them had --usage among options, unlike --help.

> While I had seen it listed in manpages and --help output often enough, 
> once I actually went looking for real examples I had a hard time finding 
> some, but eventually found some in the grub (grub2) command set.

We can put usage examples to the man pages, following git here.

> OTOH, for CLI veterans anyway, standard old "du" (btrfs fi du) should be 
> as immediately understood as "df".

> Given that confusion, I'd suggest either simply making it du, or making 
> it "device_usage" but with "du" a documented alias printing exactly the 
> same output, thus giving folks an easy way to avoid the _.

Though adding a command alias is trivial, I'd rather not do that right
now. Let's see if we can live with 'btrfs fi us'. I worked for me during
developing the patch series.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-30 12:11       ` David Sterba
@ 2014-04-30 13:31         ` Frank Kingswood
  2014-04-30 13:37           ` David Taylor
  2014-05-14 18:00           ` David Sterba
  0 siblings, 2 replies; 35+ messages in thread
From: Frank Kingswood @ 2014-04-30 13:31 UTC (permalink / raw)
  To: linux-btrfs

On 30/04/14 13:11, David Sterba wrote:
> On Wed, Apr 30, 2014 at 01:39:27PM +0200, Goffredo Baroncelli wrote:
>>>> Sample:
>>>> /dev/sda7, ID: 3
>>>>     Device size:            10.00GiB
>>>>     FS occuppied:            5.00GiB
>>>
>>> Spelling mistake.  s/occuppied/occupied/.
>>
>> I found a bit unclear the "FS occupied" terms.
>
> We're running out of terms to describe and distinguish the space that
> the filesystem uses.

> 'occupied' seemed like a good choice to me, though it may be not obvious

The space that the filesystem uses in total seems to me is called the 
"size". It has nothing to do with utilization.

/dev/sda6, ID: 2
     Device size:            10.00GiB
     Filesystem size:         5.00GiB

and perhaps only show that "Device size" line if it differs from the 
filesystem size by more than a block.

Frank


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-30 13:31         ` Frank Kingswood
@ 2014-04-30 13:37           ` David Taylor
  2014-04-30 17:38             ` Goffredo Baroncelli
  2014-05-02 13:15             ` David Sterba
  2014-05-14 18:00           ` David Sterba
  1 sibling, 2 replies; 35+ messages in thread
From: David Taylor @ 2014-04-30 13:37 UTC (permalink / raw)
  To: linux-btrfs

On Wed, 30 Apr 2014, Frank Kingswood wrote:
> On 30/04/14 13:11, David Sterba wrote:
>> On Wed, Apr 30, 2014 at 01:39:27PM +0200, Goffredo Baroncelli wrote:
>>>
>>> I found a bit unclear the "FS occupied" terms.
>>
>> We're running out of terms to describe and distinguish the space that
>> the filesystem uses.
>> 
>> 'occupied' seemed like a good choice to me, though it may be not obvious
> 
> The space that the filesystem uses in total seems to me is called the
> "size". It has nothing to do with utilization.
> 
> /dev/sda6, ID: 2
>     Device size:            10.00GiB
>     Filesystem size:         5.00GiB

FS size was what I was about to suggest, before I saw your reply.

It makes more sense to me than 'Occupied' and seems cleaner than
'Resized To'.  It sort of mirrors how LVM describes PV / VG / LV
sizes, too.

-- 
David Taylor

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/14] Enhanced df - followup
  2014-04-30 13:01   ` David Sterba
@ 2014-04-30 17:25     ` Duncan
  0 siblings, 0 replies; 35+ messages in thread
From: Duncan @ 2014-04-30 17:25 UTC (permalink / raw)
  To: linux-btrfs

David Sterba posted on Wed, 30 Apr 2014 15:01:34 +0200 as excerpted:

> On Tue, Apr 29, 2014 at 05:10:31PM +0000, Duncan wrote:
>> To users familiar with Unix/POSIX/Linux CLI, "usage" (as --usage) is
>> most often seen as a rather less common and generally briefer form of
>> --help
> 
> I did a quick check of ~20 randomly chosen binaries in /usr/bin and none
> of them had --usage among options, unlike --help.

Yes, it wasn't nearly as common as I had the impression it was (I would 
have guessed about a third coverage, now it looks like a tenth at best), 
when I went to check, as well.  But I did find some.

> Though adding a command alias is trivial, I'd rather not do that right
> now. Let's see if we can live with 'btrfs fi us'. I worked for me during
> developing the patch series.

Actually, that suggests a nice, short, non-conflicting alternative, 
"use". =:^)

"Use" doesn't conflict with other (not-so) common usage like "usage", 
doesn't have the hard to type implications of a compound device_usage or 
the like, either, and is nice and short on its own. =:^)


Regardless, I don't feel particularly strongly about it, and as both you 
and I found, the other use of "usage" is less common than I had at first 
thought.  It might be slightly confusing here, that's all.  As others 
don't seem to have that problem I'm now happy either way and the existing 
patches use usage, so leaving them as they are is fine by me. =:^)

-- 
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


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-30 13:37           ` David Taylor
@ 2014-04-30 17:38             ` Goffredo Baroncelli
  2014-05-02 13:13               ` David Sterba
  2014-05-02 13:15             ` David Sterba
  1 sibling, 1 reply; 35+ messages in thread
From: Goffredo Baroncelli @ 2014-04-30 17:38 UTC (permalink / raw)
  To: linux-btrfs

On 04/30/2014 03:37 PM, David Taylor wrote:
> On Wed, 30 Apr 2014, Frank Kingswood wrote:
>> On 30/04/14 13:11, David Sterba wrote:
>>> On Wed, Apr 30, 2014 at 01:39:27PM +0200, Goffredo Baroncelli wrote:
>>>>
>>>> I found a bit unclear the "FS occupied" terms.
>>>
>>> We're running out of terms to describe and distinguish the space that
>>> the filesystem uses.
>>>
>>> 'occupied' seemed like a good choice to me, though it may be not obvious
>>
>> The space that the filesystem uses in total seems to me is called the
>> "size". It has nothing to do with utilization.
>>
>> /dev/sda6, ID: 2
>>     Device size:            10.00GiB
>>     Filesystem size:         5.00GiB
> 
> FS size was what I was about to suggest, before I saw your reply.

Pay attention that this value is not the Filesystem size, 
but to the maximum space the of THE DEVICE the filesystem is allowed to use.

The filesystem size (the space available or the sum of the space available and
the one occupied) is based on this value but it should be very different (think
about a RAID 1 on three device of different sizes....)

> 
> It makes more sense to me than 'Occupied' and seems cleaner than
> 'Resized To'.  It sort of mirrors how LVM describes PV / VG / LV
> sizes, too.
> 


-- 
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-30 17:38             ` Goffredo Baroncelli
@ 2014-05-02 13:13               ` David Sterba
  0 siblings, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-05-02 13:13 UTC (permalink / raw)
  To: kreijack; +Cc: linux-btrfs

On Wed, Apr 30, 2014 at 07:38:00PM +0200, Goffredo Baroncelli wrote:
> On 04/30/2014 03:37 PM, David Taylor wrote:
> > On Wed, 30 Apr 2014, Frank Kingswood wrote:
> >> On 30/04/14 13:11, David Sterba wrote:
> >>> On Wed, Apr 30, 2014 at 01:39:27PM +0200, Goffredo Baroncelli wrote:
> >>>>
> >>>> I found a bit unclear the "FS occupied" terms.
> >>>
> >>> We're running out of terms to describe and distinguish the space that
> >>> the filesystem uses.
> >>>
> >>> 'occupied' seemed like a good choice to me, though it may be not obvious
> >>
> >> The space that the filesystem uses in total seems to me is called the
> >> "size". It has nothing to do with utilization.
> >>
> >> /dev/sda6, ID: 2
> >>     Device size:            10.00GiB
> >>     Filesystem size:         5.00GiB
> > 
> > FS size was what I was about to suggest, before I saw your reply.
> 
> Pay attention that this value is not the Filesystem size, 
> but to the maximum space the of THE DEVICE the filesystem is allowed to use.

I agree that plain 'Filesystem size' could be misleading, using the same
term that has an established meaning can cause misuderstandings in
bugreports.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-30 13:37           ` David Taylor
  2014-04-30 17:38             ` Goffredo Baroncelli
@ 2014-05-02 13:15             ` David Sterba
  1 sibling, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-05-02 13:15 UTC (permalink / raw)
  To: linux-btrfs

On Wed, Apr 30, 2014 at 02:37:16PM +0100, David Taylor wrote:
> It makes more sense to me than 'Occupied' and seems cleaner than
> 'Resized To'.  It sort of mirrors how LVM describes PV / VG / LV
> sizes, too.

Do you have a concrete example how we could map the btrfs sizes based on
LVM?

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/14] btrfs-progs: Print more info about device sizes
  2014-04-30 13:31         ` Frank Kingswood
  2014-04-30 13:37           ` David Taylor
@ 2014-05-14 18:00           ` David Sterba
  1 sibling, 0 replies; 35+ messages in thread
From: David Sterba @ 2014-05-14 18:00 UTC (permalink / raw)
  To: Frank Kingswood; +Cc: dsterba, kreijack, Mike Fleetwood, linux-btrfs

On Wed, Apr 30, 2014 at 02:31:18PM +0100, Frank Kingswood wrote:
> >>>>    Device size:            10.00GiB
> >>>>    FS occuppied:            5.00GiB
> >>>
> >>I found a bit unclear the "FS occupied" terms.
> >
> >We're running out of terms to describe and distinguish the space that
> >the filesystem uses.
> 
> >'occupied' seemed like a good choice to me, though it may be not obvious
> 
> The space that the filesystem uses in total seems to me is called the
> "size". It has nothing to do with utilization.
> 
> /dev/sda6, ID: 2
>     Device size:            10.00GiB
>     Filesystem size:         5.00GiB
> 
> and perhaps only show that "Device size" line if it differs from the
> filesystem size by more than a block.

I have noticed that the help text of 'btrfs fi resize' already uses
'occupy':

$ btrfs fi resize --help
usage: btrfs filesystem resize [devid:][+/-]<newsize>[gkm]|[devid:]max <path>

    Resize a filesystem

    If 'max' is passed, the filesystem will occupy all available space
    on the device 'devid'.


First appeared in

commit 35401ac1902544637ac26634e139f04ae31c2cbf
Author: Goffredo Baroncelli <kreijack@inwind.it>
Date:   Thu Mar 11 22:32:50 2010 +0100

I've been thinking about all the proposals and I'm not feeling
comfortable to pick the winner yet.

So, I'll hide the entry from the output for now so the patchset can be
pushed next step upstream but does not introduce something that's
visible in UI but not agreed on.



^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2014-05-14 18:00 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-29 15:56 [PATCH 00/14] Enhanced df - followup David Sterba
2014-04-29 15:57 ` [PATCH 01/14] btrfs-progs: read global reserve size from space infos David Sterba
2014-04-29 15:57 ` [PATCH 02/14] btrfs-progs: add original 'df' and rename 'disk_usage' to 'usage' David Sterba
2014-04-29 15:58 ` [PATCH 03/14] btrfs-progs: move device usage to cmds-device, more cleanups David Sterba
2014-04-29 15:58 ` [PATCH 04/14] btrfs-progs: check if we can't get info from ioctls due to permissions David Sterba
2014-04-29 16:01 ` [PATCH 05/14] btrfs-progs: zero out structures before calling ioctl David Sterba
2014-04-29 16:02 ` [PATCH 06/14] btrfs-progs: print B for bytes David Sterba
2014-04-29 16:02 ` [PATCH 07/14] btrfs-progs: Print more info about device sizes David Sterba
2014-04-29 19:23   ` Mike Fleetwood
2014-04-30 11:39     ` Goffredo Baroncelli
2014-04-30 12:11       ` David Sterba
2014-04-30 13:31         ` Frank Kingswood
2014-04-30 13:37           ` David Taylor
2014-04-30 17:38             ` Goffredo Baroncelli
2014-05-02 13:13               ` David Sterba
2014-05-02 13:15             ` David Sterba
2014-05-14 18:00           ` David Sterba
2014-04-30 11:52     ` David Sterba
2014-04-29 16:02 ` [PATCH 08/14] btrfs-progs: compare unallocated space against the correct value David Sterba
2014-04-29 16:02 ` [PATCH 09/14] btrfs-progs: add section of overall filesystem usage David Sterba
2014-04-29 16:02 ` [PATCH 10/14] btrfs-progs: cleanup filesystem/device usage code David Sterba
2014-04-29 16:02 ` [PATCH 11/14] btrfs-progs: extend pretty printers with unit mode David Sterba
2014-04-29 16:02 ` [PATCH 12/14] btrfs-progs: replace df_pretty_sizes with pretty_size_mode David Sterba
2014-04-29 16:02 ` [PATCH 13/14] btrfs-progs: clean up return codes and paths David Sterba
2014-04-29 16:03 ` [PATCH 14/14] btrfs-progs: move global reserve to overall summary David Sterba
2014-04-29 17:10 ` [PATCH 00/14] Enhanced df - followup Duncan
2014-04-29 17:17   ` Marc MERLIN
2014-04-29 17:33     ` Holger Hoffstätte
2014-04-30  0:42       ` Duncan
2014-04-30  8:15         ` Martin Steigerwald
2014-04-30 12:37           ` David Sterba
2014-04-30 13:01   ` David Sterba
2014-04-30 17:25     ` Duncan
2014-04-29 19:14 ` Mike Fleetwood
2014-04-30 12:22   ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.