fstests: move test group info to test files
[xfstests-dev.git] / tests / xfs / 145
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 145
6 #
7 # Regression test for failing to undo delalloc quota reservations when changing
8 # project id but we fail some other part of FSSETXATTR validation.  If we fail
9 # the test, we trip debugging assertions in dmesg.  This is a regression test
10 # for commit 1aecf3734a95 ("xfs: fix chown leaking delalloc quota blocks when
11 # fssetxattr fails").
12
13 . ./common/preamble
14 _begin_fstest auto quick quota
15
16 # Import common functions.
17 . ./common/quota
18
19 # real QA test starts here
20 _supported_fs xfs
21 _require_command "$FILEFRAG_PROG" filefrag
22 _require_test_program "chprojid_fail"
23 _require_quota
24 _require_scratch
25
26 echo "Format filesystem" | tee -a $seqres.full
27 _scratch_mkfs > $seqres.full
28 _qmount_option 'prjquota'
29 _qmount
30 _require_prjquota $SCRATCH_DEV
31
32 # Make sure that a regular buffered write produces delalloc reservations.
33 $XFS_IO_PROG -f -c 'pwrite 0 64k' $SCRATCH_MNT/testy &> /dev/null
34 $FILEFRAG_PROG -v $SCRATCH_MNT/testy 2>&1 | grep -q delalloc || \
35         _notrun "test requires delayed allocation writes"
36 rm -f $SCRATCH_MNT/testy
37
38 echo "Run test program"
39 $XFS_QUOTA_PROG -x -c 'report -ap' $SCRATCH_MNT >> $seqres.full
40 $here/src/chprojid_fail $SCRATCH_MNT/blah
41
42 # The regression we're testing for is an accounting bug involving delalloc
43 # reservations.  FSSETXATTR does not itself cause dirty data writeback, so we
44 # assume that if the file still has delalloc extents, then it must have had
45 # them when chprojid_fail was running, and therefore the test was set up
46 # correctly.  There's a slight chance that background writeback can sneak in
47 # and flush the file, but this should be a small enough gap.
48 $FILEFRAG_PROG -v $SCRATCH_MNT/blah 2>&1 | grep -q delalloc || \
49         echo "file didn't get delalloc extents, test invalid?"
50
51 # Make a note of current quota status for diagnostic purposes
52 $XFS_QUOTA_PROG -x -c 'report -ap' $SCRATCH_MNT >> $seqres.full
53
54 # success, all done
55 status=0
56 exit