xfs_df: a df(1)-like command to list per-ag block and inode usage
PATCH 1/1 xfs_df: a df(1)-like command to list per-ag block and inode usage
--- db/Makefile | 3 +- db/xfs_df.sh | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 1 deletions(-) create mode 100755 db/xfs_df.sh
db/Makefile +2 -1
@@ -14,7 +14,7 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \ io.h malloc.h metadump.h output.h print.h quit.h sb.h sig.h strvec.h \ text.h type.h write.h attrset.h CFILES = $(HFILES:.h=.c) -LSRCFILES = xfs_admin.sh xfs_check.sh xfs_ncheck.sh xfs_metadump.sh +LSRCFILES = xfs_admin.sh xfs_check.sh xfs_ncheck.sh xfs_metadump.sh xfs_df.sh LSRCFILES += xfs_check64.sh xfs_ncheck64.sh LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD)
@@ -42,4 +42,5 @@ install: default $(INSTALL) -m 755 xfs_check.sh $(PKG_BIN_DIR)/xfs_check $(INSTALL) -m 755 xfs_ncheck.sh $(PKG_BIN_DIR)/xfs_ncheck $(INSTALL) -m 755 xfs_metadump.sh $(PKG_BIN_DIR)/xfs_metadump + $(INSTALL) -m 755 xfs_df.sh $(PKG_BIN_DIR)/xfs_df install-dev:
db/xfs_df.sh new file +144 -0
144 lines not on this page · raw message
Signature · 6 lines
1.6.0.6 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 18 lines · Josef 'Jeff' Sipek
+++
b/db/xfs_df.shdb/xfs_df.sh new file +16
-0@@ -0,0 +1,144 @@ +#!/bin/sh +# +# Copyright (c) 2007-2009 Josef 'Jeff' Sipek <[email protected]> +# +# 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)
db/xfs_df.sh line 26
Quoted 10 lines
db/xfs_df.sh new file +10
-0+ 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?
Also any new tools in xfsprogs should really come with a manpage.
Quoted 10 lines
db/xfs_df.sh new file +10
-0+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"`
db/xfs_df.sh line 98
Quoted 10 lines
db/xfs_df.sh new file +10
-0+ 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?
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 25 lines · Christoph Hellwig
Quoted 24 lines · Josef 'Jeff' Sipek
+++
b/db/xfs_df.shdb/xfs_df.sh new file +22
-0@@ -0,0 +1,144 @@ +#!/bin/sh +# +# Copyright (c) 2007-2009 Josef 'Jeff' Sipek <[email protected]> +# +# 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
Quoted 8 lines
db/xfs_df.sh line 26
Quoted 4 lines
db/xfs_df.sh new file +4
-0+ shift +done + +dev="$1"Can you use the same boilerplate code as the other wrappers for
xfs_dbparsing 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.
Quoted 1 line
Also any new tools in xfsprogs should really come with a manpage.
Oh, right...documentation :)
Quoted 15 lines
Quoted 15 lines
db/xfs_df.sh new file +15
-0+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
Quoted 8 lines
db/xfs_df.sh line 98
Quoted 5 lines
db/xfs_df.sh new file +5
-0+ pused=`expr $used \* 100` + pused=`expr $pused / $count` + else + pused=0 + fiWouldn't it be much easier to implement all this in C as a new
xfs_dbsubcommand?
Ideally, db could do some basic expressions, e.g.,
xfs_db> agi 0xfs_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.
Signature · 7 lines
What is the difference between Mechanical Engineers and Civil Engineers? Mechanical Engineers build weapons, Civil Engineers build targets. _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs