All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.cz>
Subject: [PATCH 09/14] btrfs-progs: add section of overall filesystem usage
Date: Tue, 29 Apr 2014 18:02:30 +0200	[thread overview]
Message-ID: <f654600bbcbf756d6f6584768808ab2e669cb6eb.1398786620.git.dsterba@suse.cz> (raw)
In-Reply-To: <cover.1398786620.git.dsterba@suse.cz>

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


  parent reply	other threads:[~2014-04-29 16:02 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` David Sterba [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f654600bbcbf756d6f6584768808ab2e669cb6eb.1398786620.git.dsterba@suse.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.