]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_fsr: Improve handling of attribute forks V2
authorDave Chinner <dchinner@redhat.com>
Tue, 6 Apr 2010 09:19:01 +0000 (19:19 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 6 Apr 2010 09:19:01 +0000 (19:19 +1000)
commitbdb041f58dc436dcb10b698ed8715fb889589b90
tree55906bf73174cc79b7434c8c69bec16558df74ed
parent3917bb8857aa0181d5c719dce81bb7956afd636a
xfs_fsr: Improve handling of attribute forks V2

If the file being defragmented has attributes, then fsr puts a dummy
attribute on the temporary file to try to ensure that the inode
attribute fork offset is set correctly. This works perfectly well
for the old style of attributes that use a fixed fork offset - the
presence of any attribute of any size or shape will result in fsr
doing the correct thing.

However, for attr2 filesystems, the attribute fork offset is
dependent on the size and shape of both the data and attribute
forks. Hence setting a small attribute on the file does not
guarantee that the two inodes have the same fork offset and
therefore compatible for a data fork swap.

This patch improves the attribute fork handling of fsr. It checks
the filesystem version to see if the old style attributes are in
use, and if so uses the current method.

If attr2 is in use, fsr uses bulkstat output to determine what the
fork offset is. If the attribute fork offsets differ then fsr will
try to create attributes that will result in the correct offset. If
that fails, or the attribute fork is too large, it will give up and just
attempt the swap.

This fork offset value in bulkstat new functionality in the kernel,
so if there are attributes and a zero fork offset, then the kernel
does not support this feature and we simply fall back to the existing,
less effective code.

Version 2:
- simplify the attribute creation to use a small fixed size attribute
- handle the fork offset not changing as attributes are added - it can take a
  few attributes to move it from one offset to another
- comment the code better
- passes test 226 and reduces the number of unswappable inode pairs passed to
  the (fixed) kernel to zero

Signed-off-by: Dave Chinner <dchinner@redhat.com>
fsr/xfs_fsr.c
include/xfs_fs.h