return $mkfs_status
}
+# Returns the minimum XFS log size, in units of log blocks.
+_scratch_find_xfs_min_logblocks()
+{
+ local mkfs_cmd="`_scratch_mkfs_xfs_opts`"
+
+ # The smallest log size we can specify is 2M (XFS_MIN_LOG_BYTES) so
+ # pass that in and see if mkfs succeeds or tells us what is the
+ # minimum log size.
+ local XFS_MIN_LOG_BYTES=2097152
+
+ # Try formatting the filesystem with all the options given and the
+ # minimum log size. We hope either that this succeeds or that mkfs
+ # tells us the required minimum log size for the feature set.
+ #
+ # We cannot use _scratch_do_mkfs because it will retry /any/ failed
+ # mkfs with MKFS_OPTIONS removed even if the only "failure" was that
+ # the log was too small.
+ local extra_mkfs_options="$* -N -l size=$XFS_MIN_LOG_BYTES"
+ eval "$mkfs_cmd $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV" \
+ 2>$tmp.mkfserr 1>$tmp.mkfsstd
+ local mkfs_status=$?
+
+ # If the format fails for a reason other than the log being too small,
+ # try again without MKFS_OPTIONS because that's what _scratch_do_mkfs
+ # will do if we pass in the log size option.
+ if [ $mkfs_status -ne 0 ] &&
+ ! grep -q 'log size.*too small, minimum' $tmp.mkfserr; then
+ eval "$mkfs_cmd $extra_mkfs_options $SCRATCH_DEV" \
+ 2>$tmp.mkfserr 1>$tmp.mkfsstd
+ mkfs_status=$?
+ fi
+
+ # mkfs suceeded, so we must pick out the log block size to do the
+ # unit conversion
+ if [ $mkfs_status -eq 0 ]; then
+ blksz="$(grep '^log.*bsize' $tmp.mkfsstd | \
+ sed -e 's/log.*bsize=\([0-9]*\).*$/\1/g')"
+ echo $((XFS_MIN_LOG_BYTES / blksz))
+ rm -f $tmp.mkfsstd $tmp.mkfserr
+ return
+ fi
+
+ # Usually mkfs will tell us the minimum log size...
+ if grep -q 'minimum size is' $tmp.mkfserr; then
+ grep 'minimum size is' $tmp.mkfserr | \
+ sed -e 's/^.*minimum size is \([0-9]*\) blocks/\1/g'
+ rm -f $tmp.mkfsstd $tmp.mkfserr
+ return
+ fi
+
+ # Don't know what to do, so fail
+ echo "Cannot determine minimum log size" >&2
+ cat $tmp.mkfsstd >> $seqres.full
+ cat $tmp.mkfserr >> $seqres.full
+ rm -f $tmp.mkfsstd $tmp.mkfserr
+}
+
_scratch_mkfs_xfs()
{
local mkfs_cmd="`_scratch_mkfs_xfs_opts`"
_require_command "$XFS_SPACEMAN_PROG" "xfs_spaceman"
testfile=$TEST_DIR/$$.xfs_spaceman
+ touch $testfile
case $command in
+ "health")
+ testio=`$XFS_SPACEMAN_PROG -c "health $param" $TEST_DIR 2>&1`
+ param_checked=1
+ ;;
*)
testio=`$XFS_SPACEMAN_PROG -c "help $command" $TEST_DIR 2>&1`
esac
_notrun "xfs_spaceman $command failed (old kernel/wrong fs/bad args?)"
echo $testio | grep -q "foreign file active" && \
_notrun "xfs_spaceman $command not supported on $FSTYP"
+ echo $testio | grep -q "Inappropriate ioctl for device" && \
+ _notrun "xfs_spaceman $command support is missing (missing ioctl?)"
echo $testio | grep -q "Function not implemented" && \
_notrun "xfs_spaceman $command support is missing (missing syscall?)"
fi
echo "MOUNT_OPTIONS = $MOUNT_OPTIONS" >>$seqres.full
}
+
+# Find AG count of mounted filesystem
+_xfs_mount_agcount()
+{
+ $XFS_INFO_PROG "$1" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g'
+}