xfs/029: filter out "extended-header: cycle: 1" from output
[xfstests-dev.git] / tests / xfs / 443
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 443
6 #
7 # Regression test for the XFS rmapbt based extent swap algorithm. The extent
8 # swap algorithm for rmapbt=1 filesystems unmaps/remaps individual extents to
9 # rectify the rmapbt for each extent swapped between inodes. If one of the
10 # inodes happens to straddle the extent <-> btree format boundary (which can
11 # vary depending on inode size), the unmap/remap sequence can bounce the inodes
12 # back and forth between formats many times during the swap. Since extent ->
13 # btree format conversion requires a block allocation, this can consume more
14 # blocks than expected, lead to block reservation overrun and free space
15 # accounting inconsistency.
16 #
17 seq=`basename $0`
18 seqres=$RESULT_DIR/$seq
19 echo "QA output created by $seq"
20
21 here=`pwd`
22 tmp=/tmp/$$
23 status=1        # failure is the default!
24 trap "_cleanup; exit \$status" 0 1 2 3 15
25
26 _cleanup()
27 {
28         cd /
29         rm -f $tmp.*
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35 . ./common/punch
36
37 # remove previous $seqres.full before test
38 rm -f $seqres.full
39
40 # real QA test starts here
41
42 # Modify as appropriate.
43 _supported_fs generic
44 _supported_os Linux
45 _require_scratch
46 _require_test_program "punch-alternating"
47 _require_xfs_io_command "falloc"
48 _require_xfs_io_command "fpunch"
49 _require_xfs_io_command "swapext"
50
51 _scratch_mkfs | _filter_mkfs >> $seqres.full 2> $tmp.mkfs
52 _scratch_mount
53
54 # get fs block size
55 . $tmp.mkfs
56
57 file1=$SCRATCH_MNT/file1
58 file2=$SCRATCH_MNT/file2
59
60 # The goal is run an extent swap where one of the associated files has the
61 # minimum number of extents to remain in btree format. First, create a couple
62 # files with large enough extent counts (200 or so should be plenty) to ensure
63 # btree format on the largest possible inode size filesystems.
64 $XFS_IO_PROG -fc "falloc 0 $((400 * dbsize))" $file1
65 $here/src/punch-alternating $file1
66 $XFS_IO_PROG -fc "falloc 0 $((400 * dbsize))" $file2
67 $here/src/punch-alternating $file2
68
69 # Now run an extent swap at every possible extent count down to 0. Depending on
70 # inode size, one of these swaps will cover the boundary case between extent and
71 # btree format.
72 for i in $(seq 1 2 399); do
73         # punch one extent from the tmpfile and swap
74         $XFS_IO_PROG -c "fpunch $((i * dbsize)) $dbsize" $file2
75         $XFS_IO_PROG -c "swapext $file2" $file1
76
77         # punch the same extent from the old fork (now in file2) to resync the
78         # extent counts and repeat
79         $XFS_IO_PROG -c "fpunch $((i * dbsize)) $dbsize" $file2
80 done
81
82 # sanity check that no extents are left over
83 $XFS_IO_PROG -c "fiemap" $file1 | _filter_fiemap
84 $XFS_IO_PROG -c "fiemap" $file2 | _filter_fiemap
85
86 # failure results in fs corruption and possible assert failure
87 echo Silence is golden
88
89 # success, all done
90 status=0
91 exit