2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Red Hat, Inc. All Rights Reserved.
7 # Test project quota inheritance flag, uncover xfsprogs bug fixed by xfsprogs
8 # commit b136f48b19a5 ("xfs_quota: fix false error reporting of project
9 # inheritance flag is not set")
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
31 # remove previous $seqres.full before test
34 # real QA test starts here
39 cat >$tmp.projects <<EOF
43 cat >$tmp.projid <<EOF
48 QUOTA_CMD="$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid"
53 s,$tmp.projects,[PROJECTS_FILE],;
54 s,$SCRATCH_MNT,[SCR_MNT],;
55 s,$SCRATCH_DEV,[SCR_DEV],;
64 echo "Write $file, expect $exp:" | _filter_scratch
65 $XFS_IO_PROG -t -f -c "pwrite 0 5m" $file 2>&1 >/dev/null | \
70 _scratch_mkfs_xfs >>$seqres.full 2>&1
71 _qmount_option "prjquota"
73 _require_prjquota $SCRATCH_DEV
75 mkdir $SCRATCH_MNT/dir
76 $QUOTA_CMD -x -c 'project -s test' $SCRATCH_MNT >>$seqres.full 2>&1
77 $QUOTA_CMD -x -c 'limit -p bsoft=1m bhard=2m test' $SCRATCH_MNT
79 # test the Project inheritance bit is a directory only flag, and it's set on
80 # directory by default. Expect no complain about "project inheritance flag is
81 # not set" on regular file.
82 echo "== The parent directory has Project inheritance bit by default =="
83 touch $SCRATCH_MNT/dir/foo
84 mkdir $SCRATCH_MNT/dir/dir_inherit
85 touch $SCRATCH_MNT/dir/dir_inherit/foo
86 $QUOTA_CMD -x -c 'project -c test' $SCRATCH_MNT | filter_xfs_pquota
89 # test the quota and the project inheritance quota work well
90 do_quota_nospc $SCRATCH_MNT/dir/foo ENOSPC
91 do_quota_nospc $SCRATCH_MNT/dir/dir_inherit/foo ENOSPC
94 # test the project quota won't be inherited, if removing the Project
96 echo "== After removing parent directory has Project inheritance bit =="
97 $XFS_IO_PROG -x -c "chattr -P" $SCRATCH_MNT/dir
98 touch $SCRATCH_MNT/dir/foo
99 mkdir $SCRATCH_MNT/dir/dir_uninherit
100 touch $SCRATCH_MNT/dir/dir_uninherit/foo
101 $QUOTA_CMD -x -c 'project -c test' $SCRATCH_MNT | filter_xfs_pquota
104 # after remove the Project inheritance bit of the original parent directory,
106 # 1) there's not any limit on the original parent directory and files under it
107 # 2) the quota limit of sub-directory which has inherited still works
108 # 3) there's not limit on the new sub-dirctory (not inherit from parent)
109 do_quota_nospc $SCRATCH_MNT/dir/foo Success
110 do_quota_nospc $SCRATCH_MNT/dir/dir_inherit/foo ENOSPC
111 do_quota_nospc $SCRATCH_MNT/dir/dir_uninherit/foo Success