common/rc: factor out _scratch_xfs_[get|set]_sb_field
[xfstests-dev.git] / common / quota
index 678bc43c83b8b8eb37fe363d056cf951ad258abd..2611c484ee35a8f3437ca8507b8e17c4d19fe486 100644 (file)
@@ -34,7 +34,7 @@ _require_quota()
            _notrun "Installed kernel does not support quotas"
        fi
        ;;
-    gfs2)
+    gfs2|ocfs2)
        ;;
     xfs)
        if [ ! -f /proc/fs/xfs/xqmstat ]; then
@@ -51,13 +51,6 @@ _require_quota()
        _notrun "disk quotas not supported by this filesystem type: $FSTYP"
        ;;
     esac
-
-    # SELinux adds extra xattrs which can mess up our expected output.
-    # So, mount with a context, and they won't be created
-    # nfs_t is a "liberal" context so we can use it.
-    if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
-        export SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
-    fi
 }
 
 #
@@ -108,6 +101,16 @@ _require_prjquota()
     fi
 }
 
+#
+# Do we have GETNEXTQUOTA?  Querying ID 0 should work.
+#
+_require_getnextquota()
+{
+       _require_test_program "test-nextquota"
+       $here/src/test-nextquota -i 0 -u -d $SCRATCH_DEV &> $seqres.full || \
+               _notrun "No GETNEXTQUOTA support"
+}
+
 #
 # ext4 (for now) is unique in that we must enable the project quota feature
 # prior to mount.  This is a relatively new feature ...
@@ -116,6 +119,9 @@ _scratch_enable_pquota()
        [ "$FSTYP" != "ext4" ] && return
 
        tune2fs -O quota,project $SCRATCH_DEV >>$seqres.full 2>&1
+       _scratch_mount >/dev/null 2>&1 \
+               || _notrun "kernel doesn't support project feature on $FSTYP"
+       _scratch_unmount
 }
 
 #
@@ -261,6 +267,12 @@ _check_quota_usage()
                VFS_QUOTA=1
                quotaon -f -u -g $SCRATCH_MNT 2>/dev/null
                ;;
+       xfs)
+               # Clear out speculative preallocations to eliminate them
+               # as a source of intermittent orig/checked differences.
+               test -x "$XFS_SPACEMAN_PROG" && \
+                       "$XFS_SPACEMAN_PROG" -c 'prealloc -s' $SCRATCH_MNT
+               ;;
        *)
                ;;
        esac
@@ -292,5 +304,15 @@ _check_quota_usage()
        }
 }
 
+# Report the block usage of root, $qa_user, and nobody
+_report_quota_blocks() {
+       repquota $1 | egrep "^($qa_user|root|nobody)" | awk '{print $1, $3, $4, $5}'
+}
+
+# Report the inode usage of root, $qa_user, and nobody
+_report_quota_inodes() {
+       repquota $1 | egrep "^($qa_user|root|nobody)" | awk '{print $1, $6, $7, $8}'
+}
+
 # make sure this script returns success
 /bin/true