generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 601
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 902
6 #
7 # Test individual user ID quota grace period extension
8 # This is the xfs_quota version of the test
9 #
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
12 #
13 . ./common/preamble
14 _begin_fstest auto quick quota
15
16 # Import common functions.
17 . ./common/filter
18 . ./common/quota
19
20 # real QA test starts here
21 _supported_fs generic
22 _require_scratch
23 _require_quota
24 _require_user
25 # for xfs_quota on generic fs
26 _require_xfs_quota_foreign
27 # for repquota (if setquota supports it, repquota does too)
28 _require_setquota_project
29
30 _scratch_mkfs >$seqres.full 2>&1
31 _qmount_option "usrquota"
32 _qmount
33
34 echo "Silence is golden"
35
36 # Test individual timer update functionality; if "-d" is accepted
37 # this is xfs_quota that can do default /or/ individual timers
38 $XFS_QUOTA_PROG -x -c "timer 0 -d" $SCRATCH_MNT 2>&1 \
39         | grep -q ^timer \
40         && _notrun "xfs_quota does not support individual grace extension"
41
42 # Set a default user inode grace period of 1 second
43 $XFS_QUOTA_PROG -x -c "timer -u -i -d 1" $SCRATCH_MNT
44 # Soft inode limit 1, hard limit 5
45 $XFS_QUOTA_PROG -x -c "limit -u isoft=1 ihard=5 $qa_user" $SCRATCH_MNT
46 # Run qa user over soft limit and go over grace period
47 su $qa_user -c "touch $SCRATCH_MNT/file1 $SCRATCH_MNT/file2"
48 sleep 3
49 # Extend grace to now + 100s
50 now=`date +%s`
51 let set=now+100
52 $XFS_QUOTA_PROG -x -c "timer -u -i 100 $qa_user" $SCRATCH_MNT
53 # XXX We use repquota because xfs_quota doesn't know how to return
54 # raw ("since epoch") grace expiry
55 get=`repquota -up $SCRATCH_MNT | grep  "^$qa_user" | awk '{print $NF}'`
56
57 # Either the new expiry must match; or be one second after the set time, to
58 # deal with the seconds counter incrementing.
59 if [ "$get" != "$set" ] && [ "$get" -ne "$((set + 1))" ]; then
60         echo "set grace to $set but got grace $get"
61 fi
62
63 # success, all done
64 status=0
65 exit