fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 612
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 612
6 #
7 # Regression test for reflink corruption present as of:
8 # 78f0cc9d55cb "xfs: don't use delalloc extents for COW on files with extsize hints"
9 # and (inadvertently) fixed as of:
10 # 36adcbace24e "xfs: fill out the srcmap in iomap_begin"
11 # upstream, and in the 5.4 stable tree with:
12 # aee38af574a1 "xfs: trim IO to found COW extent limit"
13 #
14 . ./common/preamble
15 _begin_fstest auto quick clone
16
17 # Import common functions.
18 . ./common/filter
19 . ./common/reflink
20
21 # real QA test starts here
22
23 # Modify as appropriate.
24 _supported_fs generic
25 _require_test
26 _require_test_reflink
27
28 DIR=$TEST_DIR/dir.$seq
29 mkdir -p $DIR
30 rm -f $DIR/a $DIR/b
31
32 # This test essentially creates an existing COW extent which
33 # covers the first 1M, and then does another IO that overlaps it,
34 # but extends beyond it.  The bug was that we did not trim the
35 # new IO to the end of the existing COW extent, and so the IO
36 # extended past the COW blocks and corrupted the reflinked files(s).
37
38 # Make all files w/ 1m hints; create original 2m file
39 $XFS_IO_PROG -c "extsize 1048576" $DIR >/dev/null 2>&1
40 $XFS_IO_PROG -c "cowextsize 1048576" $DIR >/dev/null 2>&1
41
42 echo "Create file b"
43 $XFS_IO_PROG -f -c "pwrite -S 0x0 0 2m" -c fsync $DIR/b | _filter_xfs_io
44
45 # Make a reflinked copy
46 echo "Reflink copy from b to a"
47 cp --reflink=always $DIR/b $DIR/a
48
49 echo "Contents of b"
50 hexdump -C $DIR/b
51
52 # Cycle mount to get stuff out of cache
53 _test_cycle_mount
54
55 # Create a 1m-hinted IO at offset 0, then
56 # do another IO that overlaps but extends past the 1m hint
57 echo "Write to a"
58 $XFS_IO_PROG -c "pwrite -S 0xa 0k -b 4k 4k" \
59        -c "pwrite -S 0xa 4k -b 1m 1m" \
60        $DIR/a | _filter_xfs_io
61
62 $XFS_IO_PROG -c fsync $DIR/a
63
64 echo "Contents of b now:"
65 hexdump -C $DIR/b
66
67 # success, all done
68 status=0
69 exit