2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Red Hat, Inc. All Rights Reserved.
7 # Test individual user ID quota grace period extension
8 # This is the xfs_quota version of the test
10 # This test only exercises user quota because it's not known whether the
11 # filesystem can set individual grace timers for each quota type
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
33 # remove previous $seqres.full before test
36 # real QA test starts here
42 # for xfs_quota on generic fs
43 _require_xfs_quota_foreign
44 # for repquota (if setquota supports it, repquota does too)
45 _require_setquota_project
47 _scratch_mkfs >$seqres.full 2>&1
48 _qmount_option "usrquota"
51 echo "Silence is golden"
53 # Test individual timer update functionality; if "-d" is accepted
54 # this is xfs_quota that can do default /or/ individual timers
55 $XFS_QUOTA_PROG -x -c "timer 0 -d" $SCRATCH_MNT 2>&1 \
57 && _notrun "xfs_quota does not support individual grace extension"
59 # Set a default user inode grace period of 1 second
60 $XFS_QUOTA_PROG -x -c "timer -u -i -d 1" $SCRATCH_MNT
61 # Soft inode limit 1, hard limit 5
62 $XFS_QUOTA_PROG -x -c "limit -u isoft=1 ihard=5 $qa_user" $SCRATCH_MNT
63 # Run qa user over soft limit and go over grace period
64 su $qa_user -c "touch $SCRATCH_MNT/file1 $SCRATCH_MNT/file2"
66 # Extend grace to now + 100s
69 $XFS_QUOTA_PROG -x -c "timer -u -i 100 $qa_user" $SCRATCH_MNT
70 # XXX We use repquota because xfs_quota doesn't know how to return
71 # raw ("since epoch") grace expiry
72 get=`repquota -up $SCRATCH_MNT | grep "^$qa_user" | awk '{print $NF}'`
74 if [ "$get" != "$set" ]; then
75 echo "set grace to $set but got grace $get"