2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle, Inc. All Rights Reserved.
7 # Force enable all XFS quotas, run fsstress until the fs runs out of
8 # space, and make sure the quotas are still correct when we're done.
9 # This is a general regression/stress test for numerous quota bugs with
10 # reflink and copy on write.
13 _begin_fstest auto stress clone quota
15 # Override the default cleanup function.
20 $KILLALL_PROG -9 fsstress > /dev/null 2>&1
23 # Import common functions.
28 # Modify as appropriate.
31 _require_scratch_reflink
33 _require_command "$KILLALL_PROG" "killall"
35 report_quota_blocks() {
36 $XFS_QUOTA_PROG -x -c "report $1" $SCRATCH_MNT | \
37 awk '{x += $2;} END { print(x); }'
40 compare_quota_to_du() {
41 test $1 -eq $2 || echo "$3 quota $2 blocks does not match du $1 blocks?"
44 # Make sure the user/group/project quota block counts match the du output.
45 # This ensures that we did the quota accounting correctly and that we're
46 # accurately reporting cow preallocation blocks in stat.
47 check_quota_du_blocks() {
49 #$XFS_QUOTA_PROG -x -c 'report' $SCRATCH_MNT >> $seqres.full
50 du_rep=$(du -ks $SCRATCH_MNT | awk '{print $1}')
51 u_rep=$(report_quota_blocks -u)
52 g_rep=$(report_quota_blocks -g)
53 p_rep=$(report_quota_blocks -p)
55 compare_quota_to_du $du_rep $u_rep "user"
56 compare_quota_to_du $du_rep $g_rep "group"
57 compare_quota_to_du $du_rep $p_rep "project"
60 echo "Format and fsstress"
62 _qmount_option "usrquota,grpquota,prjquota"
63 # We use a small volume so that we hit ENOSPC. This is critical for
64 # regression testing a bug in the directio write code that could result in fs
65 # corruption ("xfs: check reflink allocation mappings").
67 # This started as a test for quota accounting problems ("xfs: treat CoW fork
68 # operations as delalloc for quota accounting") and ("xfs: call
69 # xfs_qm_dqattach before performing reflink operations") though each of those
70 # tests now have separate faster-running regression tests.
71 _scratch_mkfs_sized $((1600 * 1048576)) > $seqres.full 2>&1
72 _scratch_mount >> $seqres.full 2>&1
74 nr_cpus=$((LOAD_FACTOR * 4))
75 nr_ops=$((25000 * nr_cpus * TIME_FACTOR))
76 $FSSTRESS_PROG $FSSTRESS_AVOID -w -d $SCRATCH_MNT -n $nr_ops -p $nr_cpus >> $seqres.full
78 echo "Check quota before remount"
81 # Clear out all the preallocations before we quotacheck.
82 # The count comparison in _check_quota_usage will be unhappy if we don't
83 # manage to clean out all the cow preallocations before the remount.
87 # Make sure the usage doesn't change after quotacheck.
88 echo "Check quota after remount"