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 _begin_fstest auto quick quota
14 # Import common functions.
18 # real QA test starts here
23 cat >$tmp.projects <<EOF
27 cat >$tmp.projid <<EOF
32 QUOTA_CMD="$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid"
37 s,$tmp.projects,[PROJECTS_FILE],;
38 s,$SCRATCH_MNT,[SCR_MNT],;
39 s,$SCRATCH_DEV,[SCR_DEV],;
48 echo "Write $file, expect $exp:" | _filter_scratch
49 $XFS_IO_PROG -t -f -c "pwrite 0 5m" $file 2>&1 >/dev/null | \
54 _scratch_mkfs_xfs >>$seqres.full 2>&1
55 _qmount_option "prjquota"
57 _require_prjquota $SCRATCH_DEV
59 mkdir $SCRATCH_MNT/dir
60 $QUOTA_CMD -x -c 'project -s test' $SCRATCH_MNT >>$seqres.full 2>&1
61 $QUOTA_CMD -x -c 'limit -p bsoft=1m bhard=2m test' $SCRATCH_MNT
63 # test the Project inheritance bit is a directory only flag, and it's set on
64 # directory by default. Expect no complain about "project inheritance flag is
65 # not set" on regular file.
66 echo "== The parent directory has Project inheritance bit by default =="
67 touch $SCRATCH_MNT/dir/foo
68 mkdir $SCRATCH_MNT/dir/dir_inherit
69 touch $SCRATCH_MNT/dir/dir_inherit/foo
70 $QUOTA_CMD -x -c 'project -c test' $SCRATCH_MNT | filter_xfs_pquota
73 # test the quota and the project inheritance quota work well
74 do_quota_nospc $SCRATCH_MNT/dir/foo ENOSPC
75 do_quota_nospc $SCRATCH_MNT/dir/dir_inherit/foo ENOSPC
78 # test the project quota won't be inherited, if removing the Project
80 echo "== After removing parent directory has Project inheritance bit =="
81 $XFS_IO_PROG -x -c "chattr -P" $SCRATCH_MNT/dir
82 touch $SCRATCH_MNT/dir/foo
83 mkdir $SCRATCH_MNT/dir/dir_uninherit
84 touch $SCRATCH_MNT/dir/dir_uninherit/foo
85 $QUOTA_CMD -x -c 'project -c test' $SCRATCH_MNT | filter_xfs_pquota
88 # after remove the Project inheritance bit of the original parent directory,
90 # 1) there's not any limit on the original parent directory and files under it
91 # 2) the quota limit of sub-directory which has inherited still works
92 # 3) there's not limit on the new sub-dirctory (not inherit from parent)
93 do_quota_nospc $SCRATCH_MNT/dir/foo Success
94 do_quota_nospc $SCRATCH_MNT/dir/dir_inherit/foo ENOSPC
95 do_quota_nospc $SCRATCH_MNT/dir/dir_uninherit/foo Success