From patchwork Sat Jan 21 08:08:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9530061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F54E600CA for ; Sat, 21 Jan 2017 08:09:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DB582842E for ; Sat, 21 Jan 2017 08:09:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3290528620; Sat, 21 Jan 2017 08:09:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E3A72842E for ; Sat, 21 Jan 2017 08:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751276AbdAUIJJ (ORCPT ); Sat, 21 Jan 2017 03:09:09 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:20534 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751169AbdAUIJI (ORCPT ); Sat, 21 Jan 2017 03:09:08 -0500 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v0L895C7017479 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 21 Jan 2017 08:09:06 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v0L894We022163 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 21 Jan 2017 08:09:05 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v0L894gi000761; Sat, 21 Jan 2017 08:09:04 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 21 Jan 2017 00:09:04 -0800 Subject: [PATCH 08/17] xfs_spaceman: add group summary mode From: "Darrick J. Wong" To: sandeen@redhat.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Date: Sat, 21 Jan 2017 00:08:57 -0800 Message-ID: <148498613711.16675.15774860273433058318.stgit@birch.djwong.org> In-Reply-To: <148498608472.16675.14848042961636871812.stgit@birch.djwong.org> References: <148498608472.16675.14848042961636871812.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a -g switch to show only a per-group summary. Signed-off-by: Darrick J. Wong --- man/man8/xfs_spaceman.8 | 8 +++++++- spaceman/freesp.c | 27 ++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/man/man8/xfs_spaceman.8 b/man/man8/xfs_spaceman.8 index c1d19c0..a57a0c3 100644 --- a/man/man8/xfs_spaceman.8 +++ b/man/man8/xfs_spaceman.8 @@ -25,7 +25,7 @@ then the program exits. .SH COMMANDS .TP -.BI "freesp [ \-sr ] [ \-b | \-e bsize | \-h h1 [ \-m bmult ]] [-a agno]" +.BI "freesp [ \-srg ] [ \-b | \-e bsize | \-h h1 [ \-m bmult ]] [-a agno]" With no arguments, .B freesp shows a histogram of all free space extents in the filesystem. @@ -49,6 +49,12 @@ option may be specified multiple times. A summary of free space information will be printed if the .B -s option is given. +The +.B -g +option prints a brief per-AG summary of the free space found in that AG. +If +.B -r +is specified it will also report on free space in the realtime device. .TP .BR "help [ " command " ]" Display a brief description of one or all commands. diff --git a/spaceman/freesp.c b/spaceman/freesp.c index ffe2fdb..3073e24 100644 --- a/spaceman/freesp.c +++ b/spaceman/freesp.c @@ -42,6 +42,7 @@ static int histcount; static int multsize; static int seen1; static int summaryflag; +static int gflag; static bool rtflag; static long long totblocks; static long long totexts; @@ -159,6 +160,8 @@ scan_ag( off64_t bperag; off64_t aglen; xfs_agblock_t agbno; + unsigned long long freeblks = 0; + unsigned long long freeexts = 0; int ret; int i; @@ -211,6 +214,8 @@ scan_ag( agbno = (extent->fmr_physical - (bperag * agno)) / blocksize; aglen = extent->fmr_length / blocksize; + freeblks += aglen; + freeexts++; addtohist(agno, agbno, aglen); } @@ -221,6 +226,15 @@ scan_ag( fsmap->fmh_keys[0] = *p; } + + if (gflag) { + if (agno == NULLAGNUMBER) + printf(_(" rtdev %10llu %10llu\n"), freeexts, + freeblks); + else + printf(_("%10u %10llu %10llu\n"), agno, freeexts, + freeblks); + } } static void aglistadd( @@ -245,7 +259,7 @@ init( aglist = NULL; hist = NULL; rtflag = false; - while ((c = getopt(argc, argv, "a:bde:h:m:rs")) != EOF) { + while ((c = getopt(argc, argv, "a:bde:gh:m:rs")) != EOF) { switch (c) { case 'a': aglistadd(optarg); @@ -265,6 +279,10 @@ init( equalsize = atoi(optarg); speced = 1; break; + case 'g': + histcount = 0; + gflag++; + break; case 'h': if (speced && !histcount) return 0; @@ -307,13 +325,15 @@ freesp_f( if (!init(argc, argv)) return 0; + if (gflag) + printf(_(" AG extents blocks\n")); if (rtflag) scan_ag(NULLAGNUMBER); for (agno = 0; !rtflag && agno < file->geom.agcount; agno++) { if (inaglist(agno)) scan_ag(agno); } - if (histcount) + if (histcount && !gflag) printhist(); if (summaryflag) { printf(_("total free extents %lld\n"), totexts); @@ -335,10 +355,11 @@ freesp_help(void) "\n" "Examine filesystem free space\n" "\n" -"Options: [-bcds] [-a agno] [-e bsize] [-h h1]... [-m bmult]\n" +"Options: [-bcdgs] [-a agno] [-e bsize] [-h h1]... [-m bmult]\n" "\n" " -b -- binary histogram bin size\n" " -d -- debug output\n" +" -g -- print per-AG summary\n" " -r -- display realtime device free space information\n" " -s -- emit freespace summary information\n" " -a agno -- scan only the given AG agno\n"