]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_db: scan entire file system when using 'frag'
authorJorge Guerra <jorgeguerra@fb.com>
Fri, 3 May 2019 16:52:32 +0000 (11:52 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 3 May 2019 16:52:32 +0000 (11:52 -0500)
commit0c1d69102f6fdff233a58c9b8f0e1beb39c89386
tree7a45e92022765cc64cb581d2ea31434174f0fc33
parent868d0cce41645d5a240a7728cdf33b074b3d01f0
xfs_db: scan entire file system when using 'frag'

While running the 'frag' command of 'xfs_db' we noticed that the
tool is not scanning all the files in the file system.  We noticed
this when we modified the tool to print the inodes of all the files
scanned.  For example:

 $ find /mnt/xfsdisk -type f | wc -l
 1782674
 $ xfs_db -r -c frag /dev/sdXX  | grep MB | awk '{print $5}' | paste -s -d+ | bc
 656818

Upon inspecting the code we noticed that the scanfunc_ino function
stops processing a given inode block once it encounters a free leaf.
However, in practice we see that inodes are necessarily always layed
out contiguously on the leaf node.  This resulted in the 'frag'
command skipping some valid inodes.

In this change we modify the scanfunc_ino function to skip freed
inodes.  With the change in place we ran the same experiment again
and noticed a more accurate file count:

 $ find /mnt/d0 -type f | wc -l
 1810442
 $ xfs_db -r -c frag /dev/sdXX  | grep MB | awk '{print $5}' | paste -s -d+ | bc
 1810442

Fixes: 2a5eb70c ("xfs_db: teach the frag command about sparse inode chunks")
Signed-off-by: Jorge Guerra <jorgeguerra@fb.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/frag.c