common/xfs: refactor xfs_scrub presence testing

Move all the requirements checking for xfs_scrub into a helper function.
Make sure the helper properly detects the presence of the scrub ioctl
and situations where we can't run scrub (e.g. norecovery).

Refactor the existing three xfs_scrub call sites to use the helper to
check if it's appropriate to run scrub.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Darrick J. Wong
2017-10-27 13:21:46 -07:00
committed by Eryu Guan
parent 4b69106b60
commit 5cd65cb761
5 changed files with 42 additions and 31 deletions
+2 -10
View File
@@ -136,10 +136,8 @@ echo "Test XFS online scrub, if applicable"
# Only run this on xfs if xfs_scrub is available and has the unicode checker
check_xfs_scrub() {
# Ignore non-XFS fs or no scrub program...
if [ "${FSTYP}" != "xfs" ] || [ ! -x "${XFS_SCRUB_PROG}" ]; then
return 1
fi
[ "$FSTYP" == "xfs" ] || return 1
_supports_xfs_scrub "$SCRATCH_MNT" "$SCRATCH_DEV" || return 1
# We only care if xfs_scrub has unicode string support...
if ! type ldd > /dev/null 2>&1 || \
@@ -147,12 +145,6 @@ check_xfs_scrub() {
return 1
fi
# Does the ioctl work?
if $XFS_IO_PROG -x -c "scrub probe 0" $SCRATCH_MNT 2>&1 | \
grep -q "Inappropriate ioctl"; then
return 1
fi
return 0
}