]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
quota: system project quota files need to be shared
authorDave Chinner <dchinner@redhat.com>
Tue, 26 Nov 2024 21:00:47 +0000 (08:00 +1100)
committerZorro Lang <zlang@kernel.org>
Sun, 8 Dec 2024 14:11:09 +0000 (22:11 +0800)
Tests that treat them as exclusively owned end up tripping over
other tests that do the same. Fix this by using append and filter
techniques to update the files, then using different project quota
ids for each test.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Zorro lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/quota
tests/generic/603
tests/generic/691

index e87489192a9a0c5dcc6289473d114ff3d618abcc..8135b7c044bf4459ef6c91ca749603c74d09cb7e 100644 (file)
@@ -274,7 +274,7 @@ _choose_prid()
 
 _qmount()
 {
-    _scratch_unmount >/dev/null 2>&1
+    _scratch_unmount
     _try_scratch_mount || _fail "qmount failed"
     # xfs doesn't need these setups and quotacheck even fails on xfs
     # redirect the output to $seqres.full for debug purpose and ignore results
@@ -432,39 +432,18 @@ _create_project_quota()
        mkdir $prjdir
        chmod ugo+rwx $prjdir
 
-       if [ -f /etc/projects -a ! -f $tmp.projects.bk ];then
-               cat /etc/projects > $tmp.projects.bk
-               echo >/etc/projects
-       fi
-       if [ -f /etc/projid -a ! -f $tmp.projid.bk ];then
-               cat /etc/projid > $tmp.projid.bk
-               echo >/etc/projid
-       fi
-
-       cat >>/etc/projects <<EOF
-$id:$prjdir
-EOF
-       cat >>/etc/projid <<EOF
-$name:$id
-EOF
+       echo "$id:$prjdir" >> /etc/project
+       echo "$name:$id" >> /etc/projid
        $XFS_IO_PROG -r -c "chproj $id" -c "chattr +P" $prjdir
 }
 
 # If you've called _create_project_quota, then use this function in _cleanup
 _restore_project_quota()
 {
-       if [ -f $tmp.projects.bk ];then
-               cat $tmp.projects.bk > /etc/projects && \
-                       rm -f $tmp.projects.bk
-       else
-               rm -f /etc/projects
-       fi
-       if [ -f $tmp.projid.bk ];then
-               cat $tmp.projid.bk > /etc/projid && \
-                       rm -f $tmp.projid.bk
-       else
-               rm -f /etc/projid
-       fi
+       local id=$1
+
+       sed -i "/^$id:/d" /etc/project
+       sed -i "/:$id$/d" /etc/projid
 }
 
 # make sure this script returns success
index 32dcaeb94152b177e1a21ba06f514b632fdea834..a84695831ef762311fe3097ebd7231f2d888c796 100755 (executable)
 . ./common/preamble
 _begin_fstest auto quick quota
 
+projid=$seq
+
 # Override the default cleanup function.
 _cleanup()
 {
-       _restore_project_quota
+       _restore_project_quota $projid
        cd /
        rm -f $tmp.*
 }
@@ -122,8 +124,8 @@ _require_prjquota $SCRATCH_DEV
 BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 rm -rf $SCRATCH_MNT/t
 mkdir $SCRATCH_MNT/t
-$XFS_IO_PROG -r -c "chproj 100" -c "chattr +P" $SCRATCH_MNT/t
-_create_project_quota $SCRATCH_MNT/t 100 $qa_user
+$XFS_IO_PROG -r -c "chproj $projid" -c "chattr +P" $SCRATCH_MNT/t
+_create_project_quota $SCRATCH_MNT/t $projid $qa_user
 
 echo "### Set up different grace timers to each type of quota"
 UBGRACE=12
index 25ce92bc486dcdf090aa9f7a9e59cee05fbdec06..f33d6edf18a1d166f4bc1951786e4e43858abfe1 100755 (executable)
 . ./common/preamble
 _begin_fstest auto quota
 
+projid=$seq
+
 # Override the default cleanup function.
 _cleanup()
 {
-       _restore_project_quota
+       _restore_project_quota $projid
        cd /
        rm -r -f $tmp.*
 }
@@ -65,7 +67,7 @@ exercise()
        fi
        _qmount
        if [ "$type" = "P" ];then
-               _create_project_quota $SCRATCH_MNT/t 100 $qa_user
+               _create_project_quota $SCRATCH_MNT/t $projid $qa_user
                file=$SCRATCH_MNT/t/testfile
        fi