From patchwork Tue Apr 29 16:02:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 4088311 X-Patchwork-Delegate: dave@jikos.cz Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D51049F169 for ; Tue, 29 Apr 2014 16:02:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 08B0E201E7 for ; Tue, 29 Apr 2014 16:02:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A1782011B for ; Tue, 29 Apr 2014 16:02:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758192AbaD2QCe (ORCPT ); Tue, 29 Apr 2014 12:02:34 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57285 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758189AbaD2QCd (ORCPT ); Tue, 29 Apr 2014 12:02:33 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1DD3BAC4F for ; Tue, 29 Apr 2014 16:02:33 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id E02B9DA935; Tue, 29 Apr 2014 18:02:32 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 09/14] btrfs-progs: add section of overall filesystem usage Date: Tue, 29 Apr 2014 18:02:30 +0200 Message-Id: X-Mailer: git-send-email 1.9.0 In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);