misc: tag all tests that examine crash recovery in a loop
[xfstests-dev.git] / tests / btrfs / 206
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 206
6 #
7 # Validate that without no-holes we do not get a i_size that is after a gap in
8 # the file extents on disk when punching a hole past i_size.  This is fixed by
9 # the following patches
10 #
11 #       btrfs: use the file extent tree infrastructure
12 #       btrfs: replace all uses of btrfs_ordered_update_i_size
13 #
14 . ./common/preamble
15 _begin_fstest auto quick log replay recoveryloop
16
17 # Import common functions.
18 . ./common/filter
19 . ./common/dmlogwrites
20
21 # real QA test starts here
22 _supported_fs btrfs
23 _require_test
24 _require_scratch
25 _require_log_writes
26 _require_xfs_io_command "falloc" "-k"
27 _require_xfs_io_command "fpunch"
28
29 _log_writes_init $SCRATCH_DEV
30 _log_writes_mkfs "-O ^no-holes" >> $seqres.full 2>&1
31
32 # There's not a straightforward way to commit the transaction without also
33 # flushing dirty pages, so shorten the commit interval to 1 so we're sure to get
34 # a commit with our broken file
35 _log_writes_mount -o commit=1
36
37 # This creates a gap extent because fpunch doesn't insert hole extents past
38 # i_size
39 $XFS_IO_PROG -f -c "falloc -k 4k 8k" $SCRATCH_MNT/file
40 $XFS_IO_PROG -f -c "fpunch 4k 4k" $SCRATCH_MNT/file
41
42 # The pwrite extends the i_size to cover the gap extent, and then the truncate
43 # sets the disk_i_size to 12k because it assumes everything was a-ok.
44 $XFS_IO_PROG -f -c "pwrite 0 4k" $SCRATCH_MNT/file | _filter_xfs_io
45 $XFS_IO_PROG -f -c "pwrite 0 8k" $SCRATCH_MNT/file | _filter_xfs_io
46 $XFS_IO_PROG -f -c "truncate 12k" $SCRATCH_MNT/file
47
48 # Wait for a transaction commit
49 sleep 2
50
51 _log_writes_unmount
52 _log_writes_remove
53
54 cur=$(_log_writes_find_next_fua 0)
55 echo "cur=$cur" >> $seqres.full
56 while [ ! -z "$cur" ]; do
57         _log_writes_replay_log_range $cur $SCRATCH_DEV >> $seqres.full
58
59         # We only care about the fs consistency, so just run fsck, we don't have
60         # to mount the fs to validate it
61         _check_scratch_fs
62
63         cur=$(_log_writes_find_next_fua $(($cur + 1)))
64 done
65
66 # success, all done
67 status=0
68 exit