From: "Josef 'Jeff' Sipek" <jeffpc@josefsipek.net>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs_df: a df(1)-like command to list per-ag block and inode usage
Date: Thu, 10 Sep 2009 19:31:01 -0400 [thread overview]
Message-ID: <20090910233101.GE2343@josefsipek.net> (raw)
In-Reply-To: <20090910232139.GA27678@infradead.org>
On Thu, Sep 10, 2009 at 07:21:39PM -0400, Christoph Hellwig wrote:
> On Thu, Sep 10, 2009 at 06:46:26PM -0400, Josef 'Jeff' Sipek wrote:
> > +++ b/db/xfs_df.sh
> > @@ -0,0 +1,144 @@
> > +#!/bin/sh
> > +#
> > +# Copyright (c) 2007-2009 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
> > +#
> > +# This program is free software; you can redistribute it and/or modify it
> > +# under the terms of the GNU General Public License version 2 as published
> > +# by the Free Software Foundation.
> > +#
> > +
> > +status=0
> > +DB_OPTS="-p xfs_df -r"
> > +USAGE="Usage: xfs_df [-i] <device>|<mount>"
> > +
> > +while test $# -gt 1; do
> > + case "$1" in
> > + -i)
> > + print_inodes=t
> > + ;;
> > + *)
> > + break
> > + ;;
> > + esac
> > + shift
> > +done
> > +
> > +dev="$1"
>
> Can you use the same boilerplate code as the other wrappers for
> xfs_db parsing the options and showing the usage to make things more
> consistant?
You mean using getopts? Yeah, I was going to, but decided against it since
there's only one option -i, and the other arg is a device name. I'll fix it
up.
> Also any new tools in xfsprogs should really come with a manpage.
Oh, right...documentation :)
> > +case "$print_inodes" in
> > + t)
> > + echo "AG Inodes IUsed IFree Use%"
> > +
> > + tot_ino=0
> > + tot_use=0
> > + tot_fre=0
> > +
> > + for ag in `seq 0 $maxagno`; do
> > + count=`db_wrapper -c "agi $ag" -c "p count"`
> > + freecount=`db_wrapper -c "agi $ag" -c "p freecount"`
> > +
> > + used=`expr $count - $freecount`
> > +
> > + if [ $count -gt 0 ]; then
> > + pused=`expr $used \* 100`
> > + pused=`expr $pused / $count`
> > + else
> > + pused=0
> > + fi
>
> Wouldn't it be much easier to implement all this in C as a new xfs_db
> subcommand?
Ideally, db could do some basic expressions, e.g.,
xfs_db> agi 0
xfs_db> print (count-freecount)/count
expr = 0.12345
I tried looking at db code to make it have a quiet mode (so a print will not
display the 'field = ' part), but I got a bit lost. It's quite possible that
making a df command in db would be simple, I'd have to look at the code
more (it'd certainly run faster).
Josef 'Jeff' Sipek.
--
What is the difference between Mechanical Engineers and Civil Engineers?
Mechanical Engineers build weapons, Civil Engineers build targets.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2009-09-10 23:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-10 22:46 [PATCH] xfs_df: a df(1)-like command to list per-ag block and inode usage Josef 'Jeff' Sipek
2009-09-10 23:21 ` Christoph Hellwig
2009-09-10 23:31 ` Josef 'Jeff' Sipek [this message]
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=20090910233101.GE2343@josefsipek.net \
--to=jeffpc@josefsipek.net \
--cc=hch@infradead.org \
--cc=xfs@oss.sgi.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox