xfs: project quota ineritance flag test
authorZorro Lang <zlang@redhat.com>
Wed, 19 Jun 2019 10:10:47 +0000 (18:10 +0800)
committerEryu Guan <guaneryu@gmail.com>
Fri, 28 Jun 2019 06:53:35 +0000 (14:53 +0800)
This case is used to cover xfsprogs bug fixed by commit b136f48b19a5
("xfs_quota: fix false error reporting of project inheritance flag
is not set") at first. Then test more behavior when project
ineritance flag is set or removed.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/xfs/508 [new file with mode: 0755]
tests/xfs/508.out [new file with mode: 0644]
tests/xfs/group

diff --git a/tests/xfs/508 b/tests/xfs/508
new file mode 100755 (executable)
index 0000000..3a62b19
--- /dev/null
@@ -0,0 +1,117 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test 508
+#
+# Test project quota inheritance flag, uncover xfsprogs bug fixed by xfsprogs
+# commit b136f48b19a5 ("xfs_quota: fix false error reporting of project
+# inheritance flag is not set")
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/quota
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs xfs
+_supported_os Linux
+_require_scratch
+_require_xfs_quota
+
+cat >$tmp.projects <<EOF
+10:$SCRATCH_MNT/dir
+EOF
+
+cat >$tmp.projid <<EOF
+root:0
+test:10
+EOF
+
+QUOTA_CMD="$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid"
+
+filter_xfs_pquota()
+{
+        perl -ne "
+s,$tmp.projects,[PROJECTS_FILE],;
+s,$SCRATCH_MNT,[SCR_MNT],;
+s,$SCRATCH_DEV,[SCR_DEV],;
+        print;"
+}
+
+do_quota_nospc()
+{
+       local file=$1
+       local exp=$2
+
+       echo "Write $file, expect $exp:" | _filter_scratch
+       $XFS_IO_PROG -t -f -c "pwrite 0 5m" $file 2>&1 >/dev/null | \
+               _filter_xfs_io_error
+       rm -f $file
+}
+
+_scratch_mkfs_xfs >>$seqres.full 2>&1
+_qmount_option "prjquota"
+_qmount
+_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=1m bhard=2m 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
+# not set" on regular file.
+echo "== The parent directory has Project inheritance bit by default =="
+touch $SCRATCH_MNT/dir/foo
+mkdir $SCRATCH_MNT/dir/dir_inherit
+touch $SCRATCH_MNT/dir/dir_inherit/foo
+$QUOTA_CMD -x -c 'project -c test' $SCRATCH_MNT | filter_xfs_pquota
+echo ""
+
+# test the quota and the project inheritance quota work well
+do_quota_nospc $SCRATCH_MNT/dir/foo ENOSPC
+do_quota_nospc $SCRATCH_MNT/dir/dir_inherit/foo ENOSPC
+echo ""
+
+# test the project quota won't be inherited, if removing the Project
+# inheritance bit
+echo "== After removing parent directory has Project inheritance bit =="
+$XFS_IO_PROG -x -c "chattr -P" $SCRATCH_MNT/dir
+touch $SCRATCH_MNT/dir/foo
+mkdir $SCRATCH_MNT/dir/dir_uninherit
+touch $SCRATCH_MNT/dir/dir_uninherit/foo
+$QUOTA_CMD -x -c 'project -c test' $SCRATCH_MNT | filter_xfs_pquota
+echo ""
+
+# after remove the Project inheritance bit of the original parent directory,
+# then verify:
+# 1) there's not any limit on the original parent directory and files under it
+# 2) the quota limit of sub-directory which has inherited still works
+# 3) there's not limit on the new sub-dirctory (not inherit from parent)
+do_quota_nospc $SCRATCH_MNT/dir/foo Success
+do_quota_nospc $SCRATCH_MNT/dir/dir_inherit/foo ENOSPC
+do_quota_nospc $SCRATCH_MNT/dir/dir_uninherit/foo Success
+
+_scratch_unmount
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/508.out b/tests/xfs/508.out
new file mode 100644 (file)
index 0000000..89779f5
--- /dev/null
@@ -0,0 +1,23 @@
+QA output created by 508
+== The parent directory has Project inheritance bit by default ==
+Checking project test (path [SCR_MNT]/dir)...
+Processed 1 ([PROJECTS_FILE] and cmdline) paths for project test with recursion depth infinite (-1).
+
+Write SCRATCH_MNT/dir/foo, expect ENOSPC:
+pwrite: No space left on device
+Write SCRATCH_MNT/dir/dir_inherit/foo, expect ENOSPC:
+pwrite: No space left on device
+
+== After removing parent directory has Project inheritance bit ==
+Checking project test (path [SCR_MNT]/dir)...
+[SCR_MNT]/dir - project inheritance flag is not set
+[SCR_MNT]/dir/foo - project identifier is not set (inode=0, tree=10)
+[SCR_MNT]/dir/dir_uninherit - project identifier is not set (inode=0, tree=10)
+[SCR_MNT]/dir/dir_uninherit - project inheritance flag is not set
+[SCR_MNT]/dir/dir_uninherit/foo - project identifier is not set (inode=0, tree=10)
+Processed 1 ([PROJECTS_FILE] and cmdline) paths for project test with recursion depth infinite (-1).
+
+Write SCRATCH_MNT/dir/foo, expect Success:
+Write SCRATCH_MNT/dir/dir_inherit/foo, expect ENOSPC:
+pwrite: No space left on device
+Write SCRATCH_MNT/dir/dir_uninherit/foo, expect Success:
index 608b19691a316428a74948c3d551a6e9270aa8ba..270d82ff81c79636211c5c6ba625f1cb307ce834 100644 (file)
 505 auto quick spaceman
 506 auto quick health
 507 clone
+508 auto quick quota