{
local mkfs_cmd="`_scratch_mkfs_xfs_opts`"
local mkfs_filter="sed -e '/less than device physical sector/d' \
- -e '/switching to logical sector/d'"
- local tmp=`mktemp`
+ -e '/switching to logical sector/d' \
+ -e '/Default configuration/d'"
+ local tmp=`mktemp -u`
local mkfs_status
_scratch_do_mkfs "$mkfs_cmd" "$mkfs_filter" $* 2>$tmp.mkfserr 1>$tmp.mkfsstd
# output mkfs stdout and stderr
cat $tmp.mkfsstd
cat $tmp.mkfserr >&2
- rm -f $tmp*
+ rm -f $tmp.mkfserr $tmp.mkfsstd
return $mkfs_status
}
_notrun "xfs_db $command support is missing"
}
+# Does the filesystem mounted from a particular device support scrub?
+_supports_xfs_scrub()
+{
+ local mountpoint="$1"
+ local device="$2"
+
+ if [ ! -b "$device" ] || [ ! -e "$mountpoint" ]; then
+ echo "Usage: _supports_xfs_scrub mountpoint device"
+ exit 1
+ fi
+
+ test "$FSTYP" = "xfs" || return 1
+ test -x "$XFS_SCRUB_PROG" || return 1
+
+ # Probe for kernel support...
+ $XFS_IO_PROG -c 'help scrub' 2>&1 | grep -q 'types are:.*probe' || return 1
+ $XFS_IO_PROG -c "scrub probe 0" "$mountpoint" 2>&1 | grep -q "Inappropriate ioctl" && return 1
+
+ # Scrub can't run on norecovery mounts
+ _fs_options "$device" | grep -q "norecovery" && return 1
+
+ return 0
+}
+
# run xfs_check and friends on a FS.
_check_xfs_filesystem()
{
type=`_fs_type $device`
ok=1
- if [ "$type" = "xfs" ]; then
- if [ -n "$TEST_XFS_SCRUB" ] && [ -x "$XFS_SCRUB_PROG" ]; then
- "$XFS_SCRUB_PROG" $scrubflag -vd $device >>$seqres.full
- if [ $? -ne 0 ]; then
- _log_err "filesystem on $device failed scrub"
- ok=0
- fi
+ # Run online scrub if we can.
+ mntpt="$(_is_mounted $device)"
+ if [ -n "$mntpt" ] && _supports_xfs_scrub "$mntpt" "$device"; then
+ "$XFS_SCRUB_PROG" $scrubflag -v -d -n $device > $tmp.scrub 2>&1
+ if [ $? -ne 0 ]; then
+ _log_err "_check_xfs_filesystem: filesystem on $device failed scrub"
+ echo "*** xfs_scrub $scrubflag -v -d -n output ***" >> $seqres.full
+ cat $tmp.scrub >> $seqres.full
+ echo "*** end xfs_scrub output" >> $serqres.full
+ ok=0
fi
+ rm -f $tmp.scrub
+ fi
+
+ if [ "$type" = "xfs" ]; then
# mounted ...
mountpoint=`_umount_or_remount_ro $device`
fi
TEST_RT="$TEST_RTDEV"
_check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
-
- # check for ipath consistency
- if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
- # errors go to stderr
- xfs_check_ipaths $TEST_DIR >/dev/null
- xfs_repair_ipaths -n $TEST_DIR >/dev/null
- fi
+ return $?
}
_require_xfs_test_rmapbt()
|| _notrun "need case-insensitive naming support in mkfs.xfs"
}
-# xfs generates WARNINGs on purpose when applications mix buffered/mmap IO with
-# direct IO on the same file. This is a helper for _check_dmesg() to filter out
-# such warnings.
-_filter_xfs_dmesg()
-{
- local warn1="WARNING:.*fs/xfs/xfs_file\.c:.*xfs_file_dio_aio_write.*"
- local warn2="WARNING:.*fs/xfs/xfs_file\.c:.*xfs_file_dio_aio_read.*"
- local warn3="WARNING:.*fs/xfs/xfs_file\.c:.*xfs_file_read_iter.*"
- local warn4="WARNING:.*fs/xfs/xfs_file\.c:.*xfs_file_aio_read.*"
- local warn5="WARNING:.*fs/iomap\.c:.*iomap_dio_rw.*"
- local warn6="WARNING:.*fs/xfs/xfs_aops\.c:.*__xfs_get_blocks.*"
- sed -e "s#$warn1#Intentional warnings in xfs_file_dio_aio_write#" \
- -e "s#$warn2#Intentional warnings in xfs_file_dio_aio_read#" \
- -e "s#$warn3#Intentional warnings in xfs_file_read_iter#" \
- -e "s#$warn4#Intentional warnings in xfs_file_aio_read#" \
- -e "s#$warn5#Intentional warnings in iomap_dio_rw#" \
- -e "s#$warn6#Intentional warnings in __xfs_get_blocks#"
+# XFS_DEBUG requirements
+_require_xfs_debug()
+{
+ if grep -q "debug 0" /proc/fs/xfs/stat; then
+ _notrun "Require XFS built with CONFIG_XFS_DEBUG"
+ fi
+}
+_require_no_xfs_debug()
+{
+ if grep -q "debug 1" /proc/fs/xfs/stat; then
+ _notrun "Require XFS built without CONFIG_XFS_DEBUG"
+ fi
}