btrfs: check qgroup doesn't crash when beyond limit
[xfstests-dev.git] / tests / btrfs / 172
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 172
6 #
7 # Validate that without no-holes we do not get an i_size that is after a gap in
8 # the file extents on disk.  This is fixed by the following patches
9 #
10 #     btrfs: use the file extent tree infrastructure
11 #     btrfs: replace all uses of btrfs_ordered_update_i_size
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/dmlogwrites
32
33 # remove previous $seqres.full before test
34 rm -f $seqres.full
35
36 # real QA test starts here
37
38 # Modify as appropriate.
39 _supported_fs btrfs
40 _require_scratch
41 _require_log_writes
42 _require_xfs_io_command "sync_range"
43
44 _log_writes_init $SCRATCH_DEV
45 _log_writes_mkfs "-O ^no-holes" >> $seqres.full 2>&1
46
47 # There's not a straightforward way to commit the transaction without also
48 # flushing dirty pages, so shorten the commit interval to 1 so we're sure to get
49 # a commit with our broken file
50 _log_writes_mount -o commit=1
51
52 $XFS_IO_PROG -f -c "pwrite 0 5m" $SCRATCH_MNT/file | _filter_xfs_io
53 $XFS_IO_PROG -f -c "sync_range -abw 4m 1m" $SCRATCH_MNT/file | _filter_xfs_io
54
55 # Now wait for a transaction commit to happen, wait 2x just to be super sure
56 sleep 2
57
58 _log_writes_unmount
59 _log_writes_remove
60
61 cur=$(_log_writes_find_next_fua 0)
62 echo "cur=$cur" >> $seqres.full
63 while [ ! -z "$cur" ]; do
64         _log_writes_replay_log_range $cur $SCRATCH_DEV >> $seqres.full
65
66         # We only care about the fs consistency, so just run fsck, we don't have
67         # to mount the fs to validate it
68         _check_scratch_fs
69
70         cur=$(_log_writes_find_next_fua $(($cur + 1)))
71 done
72
73 # success, all done
74 status=0
75 exit