btrfsprogs/0026-btrfs-progs-add-section-of-overall-filesystem-usage.patch
Dominique Leuenberger f40e3b35b5 Accepting request 259577 from filesystems
- version 3.17
  - check: --init-csum-tree acutally does something useful, rebuilds the whole
    csum tree
  - /dev scanning for btrfs devices is gone
  - /proc/partitions scanning is gone, blkid is used exclusively
  - new subcommand subvolume sync
  - filesystem df: new options to set unit format
  - convert: allow to copy label from the origin, or specify a new one

OBS-URL: https://build.opensuse.org/request/show/259577
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/btrfsprogs?expand=0&rev=48
2014-11-11 08:59:17 +00:00

108 lines
3.1 KiB
Diff

From d8f3097050e2b7545aed2119e39e9763f21923a3 Mon Sep 17 00:00:00 2001
From: David Sterba <dsterba@suse.cz>
Date: Fri, 25 Apr 2014 17:24:40 +0200
Subject: [PATCH 15/42] btrfs-progs: add section of overall filesystem usage
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 0ee6e6bb5dc4..92402bea314c 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);
--
2.1.1