[Top] [All Lists]

Re: XFS shrink (step 0)

To: Ruben Porras <ruben.porras@xxxxxxxxxxx>
Subject: Re: XFS shrink (step 0)
From: David Chinner <dgc@xxxxxxx>
Date: Fri, 29 Jun 2007 16:55:25 +1000
Cc: xfs@xxxxxxxxxxx, iusty@xxxxxxxxx
In-reply-to: <46838FB4.1040906@xxxxxxxxxxx>
References: <1180715974.10796.46.camel@localhost> <20070604001632.GA86004887@xxxxxxx> <1182291751.5289.9.camel@localhost> <20070619234248.GT86004887@xxxxxxx> <46838FB4.1040906@xxxxxxxxxxx>
Sender: xfs-bounce@xxxxxxxxxxx
User-agent: Mutt/
On Thu, Jun 28, 2007 at 12:38:44PM +0200, Ruben Porras wrote:
> David Chinner wrote:
> >No, there isn't anything currently in existence to do this.
> >
> >It's not difficult, though. What you need to do is count the number of
> >used blocks in the AGs that will be truncated off, and check whether
> >there is enough free space in the remaining AGs to hold all the
> >blocks that we are going to move.
> >
> >I think this could be done we a single loop across the perag
> >array or with a simple xfs_db wrapper and some shell/awk/perl
> >magic.
> >  
> Do you mind that is it ok to depend on shell/awk/perl?

Sure. We have a few programs that are just shell wrappers
of other xfs programs

        xfs_bmap: shell script that calls xfs_io
        xfs_check: shell script that calls xfs_db
        xfs_info: shell script that calls xfs_growfs

> I'll do it in C looping through the perag array.

For something like this it's probably easier to do with shell/perl/awk.

e.g. in shell, the number of ags in the filesystem:

iterate all ags:

numags=`xfs_db -r -c "sb 0" -c "p agcount" /dev/sdb8 | sed -e 's/.* = //'`
lastag=`expr $numags - 1`
for ags in `seq 0 1 $lastag`; do

Free space in an AG 0:

xfs_db -r -c "freesp -s -a 0" /dev/sdb8 | awk '/total free blocks/ {print $4}'

And so on. You can peek into pretty much any structure on disk with xfs_db
and you can do it online so it's pretty much perfect for this sort of
checking. I'd start with something like this, and if it gets too complex
then we need to look at integrating it into xfs_db (i.e. writing it in C)....


Dave Chinner
Principal Engineer
SGI Australian Software Group

<Prev in Thread] Current Thread [Next in Thread>