2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
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
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
32 # real QA test starts here
34 _require_command "$FILEFRAG_PROG" filefrag
35 _require_test_program "chprojid_fail"
41 echo "Format filesystem" | tee -a $seqres.full
42 _scratch_mkfs > $seqres.full
43 _qmount_option 'prjquota'
45 _require_prjquota $SCRATCH_DEV
47 # Make sure that a regular buffered write produces delalloc reservations.
48 $XFS_IO_PROG -f -c 'pwrite 0 64k' $SCRATCH_MNT/testy &> /dev/null
49 $FILEFRAG_PROG -v $SCRATCH_MNT/testy 2>&1 | grep -q delalloc || \
50 _notrun "test requires delayed allocation writes"
51 rm -f $SCRATCH_MNT/testy
53 echo "Run test program"
54 $XFS_QUOTA_PROG -x -c 'report -ap' $SCRATCH_MNT >> $seqres.full
55 $here/src/chprojid_fail $SCRATCH_MNT/blah
57 # The regression we're testing for is an accounting bug involving delalloc
58 # reservations. FSSETXATTR does not itself cause dirty data writeback, so we
59 # assume that if the file still has delalloc extents, then it must have had
60 # them when chprojid_fail was running, and therefore the test was set up
61 # correctly. There's a slight chance that background writeback can sneak in
62 # and flush the file, but this should be a small enough gap.
63 $FILEFRAG_PROG -v $SCRATCH_MNT/blah 2>&1 | grep -q delalloc || \
64 echo "file didn't get delalloc extents, test invalid?"
66 # Make a note of current quota status for diagnostic purposes
67 $XFS_QUOTA_PROG -x -c 'report -ap' $SCRATCH_MNT >> $seqres.full