generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 110
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 110
6 #
7 # Tests file clone functionality of btrfs ("reflinks"):
8 #   - Reflink a file
9 #   - Reflink the reflinked file
10 #   - Modify the original file
11 #   - Modify the reflinked file
12 #
13 . ./common/preamble
14 _begin_fstest auto quick clone
15
16 # Override the default cleanup function.
17 _cleanup()
18 {
19     cd /
20     rm -f $tmp.* $testdir
21 }
22
23 # Import common functions.
24 . common/filter
25 . common/reflink
26
27 # real QA test starts here
28 _require_test_reflink
29
30 _require_xfs_io_command "fiemap"
31 _require_cp_reflink
32 _require_test
33
34 testdir1=$TEST_DIR/test-$seq
35 rm -rf $testdir1
36 mkdir $testdir1
37
38 _checksum_files() {
39     for F in original copy1 copy2
40     do
41         md5sum $testdir1/$F | _filter_test_dir
42     done
43 }
44
45 echo "Create the original file and reflink to copy1, copy2"
46 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original \
47     >> $seqres.full 2>&1
48 cp --reflink $testdir1/original $testdir1/copy1
49 cp --reflink $testdir1/copy1 $testdir1/copy2
50 _verify_reflink $testdir1/original $testdir1/copy1
51 _verify_reflink $testdir1/original $testdir1/copy2
52 echo "Original md5sums:"
53 _checksum_files
54
55 echo "Overwrite original file with new data"
56 $XFS_IO_PROG -c 'pwrite -S 0x62 0 9000' $testdir1/original \
57     >> $seqres.full 2>&1
58 echo "md5sums after overwriting original:"
59 _checksum_files
60
61 echo "Overwrite copy1 with different new data"
62 $XFS_IO_PROG -c 'pwrite -S 0x63 0 9000' $testdir1/copy1 \
63     >> $seqres.full 2>&1
64 echo "md5sums after overwriting copy1:"
65 _checksum_files
66
67 # success, all done
68 status=0
69 exit