xfs: filter out mount options that don't work on v4 filesystems
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 18 Dec 2018 20:36:16 +0000 (12:36 -0800)
committerEryu Guan <guaneryu@gmail.com>
Sat, 22 Dec 2018 15:45:29 +0000 (23:45 +0800)
A few tests require v4 filesystems and enforce this by disabling
crc's in the _scratch_mkfs call.  However, if the user specified
MOUNT_OPTIONS that only work with v5 filesystems, these tests fail.
If we detect a test creating a v4 scratch filesystem, filter out
incompatible mount options that don't work on v4, such as
simultaneous group/project quota.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/xfs

index d971b4a8406980ba0bf27d594e993dd9cf7228aa..24065813ca2afc0eb618e65c12d372358c95eaf9 100644 (file)
@@ -89,6 +89,7 @@ _scratch_mkfs_xfs()
        _scratch_do_mkfs "$mkfs_cmd" "$mkfs_filter" $* 2>$tmp.mkfserr 1>$tmp.mkfsstd
        mkfs_status=$?
 
+       grep -q crc=0 $tmp.mkfsstd && _force_xfsv4_mount_options
 
        if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
                # manually parse the mkfs output to get the fs size in bytes
@@ -789,3 +790,26 @@ _scratch_get_bmx_prefix() {
        _scratch_xfs_db -c "inode ${ino}" -c 'p' >> $seqres.full
        return 1
 }
+
+#
+# Ensures that we don't pass any mount options incompatible with XFS v4
+#
+_force_xfsv4_mount_options()
+{
+       local gquota=0
+       local pquota=0
+
+       # Can't have group and project quotas in XFS v4
+       echo "$MOUNT_OPTIONS" | egrep -q "(gquota|grpquota|grpjquota=|gqnoenforce)" && gquota=1
+       echo "$MOUNT_OPTIONS" | egrep -q "(\bpquota|prjquota|pqnoenforce)" && pquota=1
+
+       if [ $gquota -gt 0 ] && [ $pquota -gt 0 ]; then
+               export MOUNT_OPTIONS=$(echo $MOUNT_OPTIONS \
+                       | sed   -e 's/gquota/QUOTA/g'      \
+                               -e 's/grpquota/QUOTA/g'    \
+                               -e 's/grpjquota=[^, ]/QUOTA/g' \
+                               -e 's/gqnoenforce/QUOTA/g' \
+                               -e "s/QUOTA/defaults/g")
+       fi
+       echo "MOUNT_OPTIONS = $MOUNT_OPTIONS" >>$seqres.full
+}