generic: test MADV_POPULATE_READ with IO errors
[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 _fixed_by_kernel_commit 1aecf3734a95 \
22         "xfs: fix chown leaking delalloc quota blocks when fssetxattr fails"
23
24 _require_command "$FILEFRAG_PROG" filefrag
25 _require_test_program "chprojid_fail"
26 _require_quota
27 _require_scratch
28
29 echo "Format filesystem" | tee -a $seqres.full
30 _scratch_mkfs > $seqres.full
31 _qmount_option 'prjquota'
32 _qmount
33 _require_prjquota $SCRATCH_DEV
34
35 # Make sure that a regular buffered write produces delalloc reservations.
36 $XFS_IO_PROG -f -c 'pwrite 0 64k' $SCRATCH_MNT/testy &> /dev/null
37 $FILEFRAG_PROG -v $SCRATCH_MNT/testy 2>&1 | grep -q delalloc || \
38         _notrun "test requires delayed allocation writes"
39 rm -f $SCRATCH_MNT/testy
40
41 echo "Run test program"
42 $XFS_QUOTA_PROG -x -c 'report -ap' $SCRATCH_MNT >> $seqres.full
43 $here/src/chprojid_fail $SCRATCH_MNT/blah
44
45 # The regression we're testing for is an accounting bug involving delalloc
46 # reservations.  FSSETXATTR does not itself cause dirty data writeback, so we
47 # assume that if the file still has delalloc extents, then it must have had
48 # them when chprojid_fail was running, and therefore the test was set up
49 # correctly.  There's a slight chance that background writeback can sneak in
50 # and flush the file, but this should be a small enough gap.
51 $FILEFRAG_PROG -v $SCRATCH_MNT/blah 2>&1 | grep -q delalloc || \
52         echo "file didn't get delalloc extents, test invalid?"
53
54 # Make a note of current quota status for diagnostic purposes
55 $XFS_QUOTA_PROG -x -c 'report -ap' $SCRATCH_MNT >> $seqres.full
56
57 # success, all done
58 status=0
59 exit