_scratch_xfs_admin()
{
local options=("$SCRATCH_DEV")
+ local rt_opts=()
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
options+=("$SCRATCH_LOGDEV")
- $XFS_ADMIN_PROG "$@" "${options[@]}"
+ if [ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ]; then
+ $XFS_ADMIN_PROG --help 2>&1 | grep -q 'rtdev' || \
+ _notrun 'xfs_admin does not support rt devices'
+ rt_opts+=(-r "$SCRATCH_RTDEV")
+ fi
+
+ # xfs_admin in xfsprogs 5.11 has a bug where an external log device
+ # forces xfs_db to be invoked, potentially with zero command arguments.
+ # When this happens, xfs_db will wait for input on stdin, which causes
+ # fstests to hang. Since xfs_admin is not an interactive tool, we
+ # can redirect stdin from /dev/null to prevent this issue.
+ $XFS_ADMIN_PROG "${rt_opts[@]}" "$@" "${options[@]}" < /dev/null
}
_scratch_xfs_logprint()
_xfs_check $SCRATCH_OPTIONS $* $SCRATCH_DEV
}
+# Check for secret debugging hooks in xfs_repair
+_require_libxfs_debug_flag() {
+ local hook="$1"
+
+ grep -q "$hook" "$(type -P xfs_repair)" || \
+ _notrun "libxfs debug hook $hook not detected?"
+}
+
_scratch_xfs_repair()
{
SCRATCH_OPTIONS=""
_fail "Can't find cowgc interval procfs knob?"
fi
}
+
+# Print the status of the given features on the scratch filesystem.
+# Returns 0 if all features are found, 1 otherwise.
+_check_scratch_xfs_features()
+{
+ local features="$(_scratch_xfs_db -c 'version')"
+ local output=("FEATURES:")
+ local found=0
+
+ for feature in "$@"; do
+ local status="NO"
+ if echo "${features}" | grep -q -w "${feature}"; then
+ status="YES"
+ found=$((found + 1))
+ fi
+ output+=("${feature}:${status}")
+ done
+
+ echo "${output[@]}"
+ test "${found}" -eq "$#"
+}
+
+# Decide if xfs_repair knows how to set (or clear) a filesystem feature.
+_require_xfs_repair_upgrade()
+{
+ local type="$1"
+
+ $XFS_REPAIR_PROG -c "$type=garbagevalue" 2>&1 | \
+ grep -q 'unknown option' && \
+ _notrun "xfs_repair does not support upgrading fs with $type"
+}
+
+# Require that the scratch device exists, that mkfs can format with inobtcount
+# enabled, and that the kernel can mount such a filesystem.
+_require_scratch_xfs_inobtcount()
+{
+ _require_scratch
+
+ _scratch_mkfs -m inobtcount=1 &> /dev/null || \
+ _notrun "mkfs.xfs doesn't support inobtcount feature"
+ _try_scratch_mount || \
+ _notrun "kernel doesn't support xfs inobtcount feature"
+ _scratch_unmount
+}