]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfs: fix quota tests to adapt to realtime quota
authorDarrick J. Wong <djwong@kernel.org>
Thu, 21 Nov 2024 00:27:28 +0000 (16:27 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 23 Jan 2025 21:19:57 +0000 (13:19 -0800)
Fix or limit the scope of tests so that we can turn on testing for
realtime quotas.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
32 files changed:
common/quota
tests/generic/219
tests/generic/230
tests/generic/305
tests/generic/326
tests/generic/327
tests/generic/328
tests/generic/566
tests/generic/587
tests/generic/603
tests/generic/691
tests/generic/710
tests/xfs/050
tests/xfs/096
tests/xfs/106
tests/xfs/108
tests/xfs/152
tests/xfs/153
tests/xfs/161
tests/xfs/213
tests/xfs/214
tests/xfs/220
tests/xfs/299
tests/xfs/330
tests/xfs/434
tests/xfs/435
tests/xfs/440
tests/xfs/441
tests/xfs/442
tests/xfs/508
tests/xfs/511
tests/xfs/720

index 6735d0fec48991f8a1a5469e5e58a58192186976..2f5ccd2fa17363c2f43e0b50d072f5bf94a455b1 100644 (file)
@@ -436,5 +436,30 @@ _restore_project_quota()
        sed -i "/:$id$/d" /etc/projid
 }
 
+# Reconfigure the mounted fs as needed so that we can test the VFS quota
+# utilities.  They do not support realtime block limits or reporting, so
+# we forcibly inhibit rtinherit on XFS filesystems.
+_force_vfs_quota_testing()
+{
+       local mount="${1:-$TEST_DIR}"
+
+       test "$FSTYP" = "xfs" && _xfs_force_bdev data "$mount"
+}
+
+# Does the mounted scratch filesystem have a realtime volume where quota works?
+# Returns nonzero if any of the above are false.
+_scratch_supports_rtquota()
+{
+       case "$FSTYP" in
+       "xfs")
+               if [ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ]; then
+                       _xfs_scratch_supports_rtquota
+                       return
+               fi
+       esac
+
+       return 1
+}
+
 # make sure this script returns success
 /bin/true
index d72aa745fdfcf14e0fcc0ddceb011bd06de80ef3..cc2ec119eb429899ec00f510c6e9b6716cb48376 100755 (executable)
@@ -92,6 +92,7 @@ test_accounting()
 _scratch_unmount 2>/dev/null
 _scratch_mkfs >> $seqres.full 2>&1
 _scratch_mount "-o usrquota,grpquota"
+_force_vfs_quota_testing $SCRATCH_MNT
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
 quotaon $SCRATCH_MNT 2>/dev/null
 _scratch_unmount
index 18e20f4b2e94392a6092ac78ac56e40e1e222ff8..a8caf5a808c3c763e064256c9895b392396caa19 100755 (executable)
@@ -100,6 +100,7 @@ _qmount_option 'defaults'
 
 _scratch_mkfs >> $seqres.full 2>&1
 _scratch_mount "-o usrquota,grpquota"
+_force_vfs_quota_testing $SCRATCH_MNT
 BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
 quotaon $SCRATCH_MNT 2>/dev/null
index 6ccbb3d07c70c24823800f35fc05b8c3689c5794..373abf57037ed66ce57c155a84a2de11ec5ac841 100755 (executable)
@@ -26,6 +26,7 @@ echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
 _scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT
 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
 quotaon $SCRATCH_MNT 2> /dev/null
 
index 321e7dc6a8e54c614bcfc1b6f652b2c48ca3bd46..d16e95aabaecd59d286731498b98102ba2412d1a 100755 (executable)
@@ -27,6 +27,7 @@ echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
 _scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT
 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
 quotaon $SCRATCH_MNT 2> /dev/null
 
index 18cfcd1f655bd7a4c8747b60e0fc9aba3011f90d..9102cbd6841072dcbec8f9a11c61aae64f64a920 100755 (executable)
@@ -25,6 +25,7 @@ echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
 _scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT
 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
 quotaon $SCRATCH_MNT 2> /dev/null
 
index fa33bdb78dba120c5b1a7c767b22dba611bc5ad1..db785475db87d67ea6e7871ae541b7f890c9cbc1 100755 (executable)
@@ -26,6 +26,7 @@ echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
 _scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT
 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
 quotaon $SCRATCH_MNT 2> /dev/null
 
index a41e04852ed88c7229785af809e067b341d08069..a6ec82fd36d8bb3a63a104fd07c3fc652660c327 100755 (executable)
@@ -35,7 +35,9 @@ _qmount
 dir="$SCRATCH_MNT/dummy"
 mkdir -p $dir
 chown $qa_user $dir
-$XFS_QUOTA_PROG -x -c "limit -g bsoft=100k bhard=100k $qa_user" $SCRATCH_MNT
+_scratch_supports_rtquota && \
+       extra_limits="rtbsoft=100k rtbhard=100k"
+$XFS_QUOTA_PROG -x -c "limit -g bsoft=100k bhard=100k $extra_limits $qa_user" $SCRATCH_MNT
 
 $XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m' $dir/foo >> $seqres.full
 chown $qa_user "${dir}/foo"
index 466596799431f784584c0f73f174548b84534932..49fcade72790d67dddc9c758d53b533f34f33bc0 100755 (executable)
@@ -56,6 +56,7 @@ _scratch_mkfs > $seqres.full
 # This test must have user quota enabled
 _qmount_option usrquota
 _qmount >> $seqres.full
+_force_vfs_quota_testing $SCRATCH_MNT
 
 testfile=$SCRATCH_MNT/test-$seq
 touch $testfile
index b199f801a8f03f90619db11006a67436389e5adf..9b5e824577b38237759994d06ee8835e01002089 100755 (executable)
@@ -120,6 +120,7 @@ _scratch_mkfs >$seqres.full 2>&1
 _scratch_enable_pquota
 _qmount_option "usrquota,grpquota,prjquota"
 _qmount
+_force_vfs_quota_testing $SCRATCH_MNT
 _require_prjquota $SCRATCH_DEV
 BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 rm -rf $SCRATCH_MNT/t
index 30ae4a1e384a056c22791e09264a917ef7664e19..fa682fb73b04174c00f4eabf915568932af20754 100755 (executable)
@@ -39,6 +39,7 @@ _scratch_mkfs >$seqres.full 2>&1
 _scratch_enable_pquota
 _qmount_option "prjquota"
 _qmount
+_force_vfs_quota_testing $SCRATCH_MNT
 _require_prjquota $SCRATCH_DEV
 
 filter_quota()
@@ -66,6 +67,7 @@ exercise()
                _scratch_enable_pquota
        fi
        _qmount
+       _force_vfs_quota_testing $SCRATCH_MNT
        if [ "$type" = "P" ];then
                _create_project_quota $SCRATCH_MNT/t $projid $qa_user
                file=$SCRATCH_MNT/t/testfile
index 072cddf570f444039c2cd721c61797ceaebfc328..16f7276d3d4b04cd6c11a395c24b0d664b180dc1 100755 (executable)
@@ -32,7 +32,9 @@ $XFS_IO_PROG -f -c 'pwrite -S 0x59 0 64k -b 64k' -c 'truncate 256k' $SCRATCH_MNT
 chown nobody $SCRATCH_MNT/b
 
 # Set up a quota limit
-$XFS_QUOTA_PROG -x -c "limit -u bhard=70k nobody" $SCRATCH_MNT
+_scratch_supports_rtquota && \
+       extra_limits="rtbhard=70k"
+$XFS_QUOTA_PROG -x -c "limit -u bhard=70k $extra_limits nobody" $SCRATCH_MNT
 
 echo before exchangerange >> $seqres.full
 $XFS_QUOTA_PROG -x -c 'report -a' $SCRATCH_MNT >> $seqres.full
index 1e40ab90a843e8a31ca50212a05e92603b99697b..46c60a4bdd6b6621bf53c4209ae4a46f2a16e586 100755 (executable)
@@ -33,6 +33,7 @@ _scratch_mkfs >/dev/null 2>&1
 orig_mntopts="$MOUNT_OPTIONS"
 _qmount_option "uquota"
 _scratch_mount
+_force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 bsize=$(_get_file_block_size $SCRATCH_MNT)
 # needs quota enabled to compute the number of metadata dir files
 HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT)
@@ -75,6 +76,7 @@ _exercise()
        . $tmp.mkfs
 
        _qmount
+       _force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 
        # Figure out whether we're doing large allocations
        # (bail out if they're so large they stuff the test up)
index f1f5d562d4fa18802ffda36cd3db5187e372244e..4c4fdfa12ef8405c4b4d6258d4ecea19843942a3 100755 (executable)
@@ -20,6 +20,10 @@ _require_scratch
 _require_xfs_quota
 _require_xfs_nocrc
 
+if [ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ]; then
+       _notrun "Realtime quotas not supported on V4 filesystems"
+fi
+
 function option_string()
 {
        VAL=$1
index 10cbd1052bbc899bdeb99efebbd3c5c18206fede..108cd0b8c3061a37aa27b4657facb7644b420619 100755 (executable)
@@ -195,6 +195,7 @@ test_xfs_quota()
 {
        _qmount_option $1
        _qmount
+       _force_vfs_quota_testing $SCRATCH_MNT    # golden output encodes block usage
 
        if [ $type == "p" ]; then
                _require_prjquota $SCRATCH_DEV
index 149d76eeb17a42b28296d21842baaf7bb4588913..8adc63d4e56e4ff099fa93dff8ec21672cb44ef1 100755 (executable)
@@ -63,6 +63,7 @@ test_accounting()
 export MOUNT_OPTIONS="-opquota"
 _scratch_mkfs_xfs >> $seqres.full
 _qmount
+_force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 _require_prjquota $SCRATCH_DEV
 
 rm -f $tmp.projects $seqres.full
@@ -70,6 +71,7 @@ _scratch_unmount 2>/dev/null
 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
 cat $tmp.mkfs >>$seqres.full
 _scratch_mount
+_force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 
 uid=1
 gid=2
index 94428b35d22a875552d0215c5c25d4f65582abfa..7ba00c4bfac9ff9415eb8d0c46d748e8cb49bf0a 100755 (executable)
@@ -240,6 +240,7 @@ qmount_idmapped()
 {
        wipe_mounts
        _try_scratch_mount || _fail "qmount failed"
+       _force_vfs_quota_testing $SCRATCH_MNT    # golden output encodes block usage
 
        mkdir -p "${SCRATCH_MNT}/unmapped"
        mkdir -p "${SCRATCH_MNT}/idmapped"
index 2ce22b8c44b298a99162599d46605606aaf75a10..27db71e7738d08cd768fccdb01fd515916e8e774 100755 (executable)
@@ -38,6 +38,7 @@ _scratch_mkfs >/dev/null 2>&1
 orig_mntopts="$MOUNT_OPTIONS"
 _qmount_option "uquota"
 _scratch_mount
+_force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 bsize=$(_get_file_block_size $SCRATCH_MNT)
 # needs quota enabled to compute the number of metadata dir files
 HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT)
@@ -80,6 +81,7 @@ run_tests()
        . $tmp.mkfs
 
        _qmount
+       _force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 
        # Figure out whether we're doing large allocations
        # (bail out if they're so large they stuff the test up)
index e13a646a5053bdf0533f32da0675e3d7b3350990..c35bcabb5eda901a8e89ed05bd2e33de07a43678 100755 (executable)
@@ -36,6 +36,7 @@ _qmount_option "usrquota"
 _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
 _scratch_mount >> $seqres.full
 
+_xfs_force_bdev data $SCRATCH_MNT
 
 min_blksz=65536
 file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
index 7b27e3c09a815a954c29565f4649a2c26883ecd5..a9e97ee01cabced4e8602e4d301131719ceec38f 100755 (executable)
@@ -28,6 +28,7 @@ echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
 _scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT  # repquota
 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
 quotaon $SCRATCH_MNT 2> /dev/null
 
index f2f23b3fb33f5d0e7eca4849d63614f29b1392a0..c316a92baa4404e8a0fbc7e5945b7a9970882575 100755 (executable)
@@ -29,6 +29,7 @@ echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
 _scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT  # repquota
 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
 quotaon $SCRATCH_MNT 2> /dev/null
 
index f89c976fb850afb8c72e87b4541fe5b866c96119..d34764301b9e0618688f64c6acafa52d70cdc074 100755 (executable)
@@ -37,6 +37,7 @@ _scratch_mkfs_xfs >/dev/null 2>&1
 
 # mount  with quotas enabled
 _scratch_mount -o uquota
+_force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 
 # turn off quota
 $XFS_QUOTA_PROG -x -c off $SCRATCH_DEV
@@ -49,6 +50,7 @@ _scratch_mkfs_xfs >/dev/null 2>&1
 
 # mount  with quotas enabled
 _scratch_mount -o uquota
+_force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 
 # turn off quota accounting...
 $XFS_QUOTA_PROG -x -c off $SCRATCH_DEV
index 3986f8fb904e5d321f1ef46dfab8c38f5b8d33b0..9f8b6631ccabfb03151cbe9670daf97697ec654b 100755 (executable)
@@ -153,6 +153,7 @@ projid_file="$tmp.projid"
 echo "*** user, group, and project"
 _qmount_option "uquota,gquota,pquota"
 _qmount
+_force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 
 bsize=$(_get_file_block_size $SCRATCH_MNT)
 HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT)
@@ -180,6 +181,7 @@ cat $tmp.mkfs >>$seqres.full
 echo "*** uqnoenforce, gqnoenforce, and pqnoenforce"
 _qmount_option "uqnoenforce,gqnoenforce,pqnoenforce"
 _qmount
+_force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 _exercise uno
 _exercise gno
 _exercise pno
index 30c09ff5906e12ac7d75b7751d7a752565bfcd71..ca74929b1d26fcb1464d8fc483e87f0404ae7b10 100755 (executable)
@@ -36,6 +36,7 @@ echo "Format and mount"
 _scratch_mkfs > "$seqres.full" 2>&1
 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
 _scratch_mount >> "$seqres.full" 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT   # golden output encodes block usage
 HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT)
 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
 quotaon $SCRATCH_MNT 2> /dev/null
index fe609b138d732bfcea8ee594e776c5d5d4e9834a..2dec1b084e080125e0b56678c60c360c9c2172af 100755 (executable)
@@ -44,6 +44,7 @@ _scratch_mount -o noquota >> "$seqres.full" 2>&1
 
 testdir="$SCRATCH_MNT/test-$seq"
 blksz=65536
+_require_congruent_file_oplen $SCRATCH_MNT $blksz
 blks=3
 mkdir "$testdir"
 
index 22c02fbd1289bbfa513ee3a23470d22b083f1cc1..c1d6a40e00fc1f567bbc8d6c6d3b275e859185b1 100755 (executable)
@@ -35,6 +35,7 @@ _scratch_mount -o quota >> "$seqres.full" 2>&1
 
 testdir="$SCRATCH_MNT/test-$seq"
 blksz=65536
+_require_congruent_file_oplen $SCRATCH_MNT $blksz
 blks=3
 mkdir "$testdir"
 
index c0b6756ba976652f3d6fafefaaaedfd7108c7ad0..8c283fd28bbf9e48c7c17bf85e4f4d8eff459177 100755 (executable)
@@ -32,6 +32,9 @@ echo "Format and mount"
 _scratch_mkfs > "$seqres.full" 2>&1
 _scratch_mount "-o usrquota,grpquota" >> "$seqres.full" 2>&1
 
+# Make sure all our files are on the data device
+_xfs_force_bdev data $SCRATCH_MNT
+
 echo "Create files"
 $XFS_IO_PROG -c "cowextsize 1m" $SCRATCH_MNT
 touch $SCRATCH_MNT/a $SCRATCH_MNT/force_fsgqa
index ca3c576ad9cc660687c6bc4a52c893430ba1c31a..a64da1d815047b54a3ae1858246ea9d96293e1e8 100755 (executable)
@@ -31,6 +31,7 @@ check_quota() {
 echo "Format and mount (noquota)"
 _scratch_mkfs > "$seqres.full" 2>&1
 _scratch_mount "-o noquota" >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT   # _check_quota_usage uses repquota
 
 echo "Create files"
 _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full
index 08f0aac40433ee114b39c4a49b50e6098efbc1e4..9bb055ce4d02de204ecd9a33a1b653f6ca50252f 100755 (executable)
@@ -60,6 +60,7 @@ _qmount_option "usrquota,grpquota,prjquota"
 # tests now have separate faster-running regression tests.
 _scratch_mkfs_sized $((1600 * 1048576)) > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT   # _check_quota_usage uses repquota
 
 nr_cpus=$((LOAD_FACTOR * 4))
 nr_ops=$((25000 * TIME_FACTOR))
index 1bd13e98c9f641e54715c43146b62dc615427719..df38dd3fbd50e4fc1b64ffe6db40846f44606c1e 100755 (executable)
@@ -57,6 +57,8 @@ _require_prjquota $SCRATCH_DEV
 mkdir $SCRATCH_MNT/dir
 $QUOTA_CMD -x -c 'project -s test' $SCRATCH_MNT >>$seqres.full 2>&1
 $QUOTA_CMD -x -c 'limit -p bsoft=10m bhard=20m test' $SCRATCH_MNT
+_scratch_supports_rtquota && \
+       $QUOTA_CMD -x -c 'limit -p rtbsoft=10m rtbhard=20m test' $SCRATCH_MNT
 
 # test the Project inheritance bit is a directory only flag, and it's set on
 # directory by default. Expect no complain about "project inheritance flag is
index a942e92e3af32d4d1242cd11d7c96d12b1a2117a..0c7e137203ddb71aa3c326a68b5fd4a10462cb6f 100755 (executable)
@@ -38,11 +38,19 @@ $XFS_IO_PROG -f -c "pwrite 0 65536" -c syncfs $SCRATCH_MNT/t/file >>$seqres.full
 quota_cmd="$XFS_QUOTA_PROG -x"
 $quota_cmd -c "project -s -p $SCRATCH_MNT/t 42" $SCRATCH_MNT >/dev/null 2>&1
 $quota_cmd -c 'limit -p isoft=53 bsoft=100m 42' $SCRATCH_MNT
+_scratch_supports_rtquota && \
+       $quota_cmd -c 'limit -p rtbsoft=100m 42' $SCRATCH_MNT
+
+# The golden output for this test was written with the assumption that the file
+# allocation unit divides 64k evenly, so the file block usage would be exactly
+# 64k.  On realtime filesystems this isn't always true (e.g. -rextsize=28k) so
+# we'll accept the space usage being the same as what du reports for the file.
+file_nblocks=$(du -B 1024 $SCRATCH_MNT/t/file | awk '{print $1}')
 
 # The itotal and size should be 53 and 102400(k), as above project quota limit.
 # The isued and used should be 2 and 64(k), as this case takes.
 df -k --output=file,itotal,iused,size,used $SCRATCH_MNT/t | \
-       _filter_scratch | _filter_spaces
+       _filter_scratch | _filter_spaces | sed -e "s|$file_nblocks$|64|"
 
 # success, all done
 status=0
index 97b3d2579cbd7ff41e391162a253ec16c2f8858b..565373bef71e88342fab8c55c6a76b1531b61bb7 100755 (executable)
@@ -30,6 +30,11 @@ _scratch_mkfs > "$seqres.full" 2>&1
 _qmount_option usrquota
 _qmount
 
+# This test tries to exceed quota limits by creating an N>2 block bmbt, setting
+# the block limit to 2N, and rebuilding the bmbt.  Hence we must force the
+# files to be created on the data device.
+_xfs_force_bdev data $SCRATCH_MNT
+
 blocksize=$(_get_block_size $SCRATCH_MNT)
 alloc_unit=$(_get_file_block_size $SCRATCH_MNT)