xfs: test what happens when we reset the root dir and it has xattrs
[xfstests-dev.git] / tests / xfs / 511
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 511
6 #
7 # Test statfs when project quota is set.
8 # Uncover de7243057 fs/xfs: fix f_ffree value for statfs when project quota is set
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         _scratch_unmount
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/quota
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs xfs
36 _require_scratch
37 _require_xfs_quota
38
39 _scratch_mkfs >/dev/null 2>&1
40 _scratch_enable_pquota
41 _qmount_option "prjquota"
42 _qmount
43 _require_prjquota $SCRATCH_DEV
44
45 # Create a directory to be project object, and create a file to take 64k space
46 mkdir $SCRATCH_MNT/t
47 $XFS_IO_PROG -f -c "pwrite 0 65536" -c sync $SCRATCH_MNT/t/file >>$seqres.full
48
49 quota_cmd="$XFS_QUOTA_PROG -x"
50 $quota_cmd -c "project -s -p $SCRATCH_MNT/t 42" $SCRATCH_MNT >/dev/null 2>&1
51 $quota_cmd -c 'limit -p isoft=53 bsoft=100m 42' $SCRATCH_MNT
52
53 # The itotal and size should be 53 and 102400(k), as above project quota limit.
54 # The isued and used should be 2 and 64(k), as this case takes.
55 df -k --output=file,itotal,iused,size,used $SCRATCH_MNT/t | \
56         _filter_scratch | _filter_spaces
57
58 # success, all done
59 status=0
60 exit