generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / ceph / 003
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. ceph/005
6 #
7 # Test copy_file_range with infile = outfile
8 #
9 . ./common/preamble
10 _begin_fstest auto quick copy_range
11
12 # get standard environment
13 . common/filter
14 . common/attr
15 . common/reflink
16
17 # real QA test starts here
18 _supported_fs ceph
19
20 _require_xfs_io_command "copy_range"
21 _exclude_test_mount_option "test_dummy_encryption"
22 _require_attrs
23 _require_test
24
25 workdir=$TEST_DIR/test-$seq
26 rm -rf $workdir
27 mkdir $workdir
28
29 check_range()
30 {
31         local file=$1
32         local off0=$2
33         local off1=$3
34         local val=$4
35         _read_range $file $off0 $off1 | grep -v -q $val
36         [ $? -eq 0 ] && echo "file $file is not '$val' in [ $off0 $off1 ]"
37 }
38
39 objsz=4194304
40 halfobj=$(($objsz / 2))
41 file="$workdir/file-$objsz"
42 copy="$workdir/copy-$objsz"
43 dest="$workdir/dest-$objsz"
44 backup="$file.backup"
45
46 # object_size has to be a multiple of stripe_unit
47 _ceph_create_file_layout $file $objsz 1 $objsz
48 _ceph_create_file_layout $backup $objsz 1 $objsz
49
50 $XFS_IO_PROG -c "pwrite -S 0x61 0 $objsz" $file >> $seqres.full 2>&1
51 $XFS_IO_PROG -c "pwrite -S 0x62 $objsz $objsz" $file >> $seqres.full 2>&1
52 $XFS_IO_PROG -c "pwrite -S 0x63 $(($objsz * 2)) $objsz" $file >> $seqres.full 2>&1
53
54 cp $file $backup
55
56 echo "  Copy single object to the end:"
57 echo "    aaaa|bbbb|cccc => aaaa|bbbb|aaaa"
58 $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz * 2)) -l $objsz $file" "$file"
59 check_range $file 0 $objsz 61
60 check_range $file $objsz $objsz 62
61 check_range $file $(($objsz * 2)) $objsz 61
62
63 echo "  Copy single object to the beginning:"
64 echo "    aaaa|bbbb|aaaa => bbbb|bbbb|aaaa"
65 $XFS_IO_PROG -c "copy_range -s $objsz -d 0 -l $objsz $file" "$file"
66 check_range $file 0 $(($objsz * 2)) 62
67 check_range $file $(($objsz * 2)) $objsz 61
68
69 echo "  Copy single object to the middle:"
70 echo "    bbbb|bbbb|aaaa => bbbb|aaaa|aaaa"
71 $XFS_IO_PROG -c "copy_range -s $(($objsz * 2)) -d $objsz -l $objsz $file" "$file"
72 check_range $file 0 $objsz 62
73 check_range $file $objsz $(($objsz * 2)) 61
74
75 cp $backup $file
76 echo "  Cross object boundary (no full object copy)"
77 echo "    aaaa|bbbb|cccc => aaaa|bbaa|aacc"
78 $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz + $halfobj)) -l $objsz $file" "$file"
79 check_range $file 0 $objsz 61
80 check_range $file $objsz $halfobj 62
81 check_range $file $(($objsz + $halfobj)) $objsz 61
82 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 63
83
84 cp $backup $file
85 echo "    aaaa|bbbb|cccc => aaaa|bbaa|bbcc"
86 $XFS_IO_PROG -c "copy_range -s $halfobj -d $(($objsz + $halfobj)) -l $objsz $file" "$file"
87 check_range $file 0 $objsz 61
88 check_range $file $objsz $halfobj 62
89 check_range $file $(($objsz + $halfobj)) $halfobj 61
90 check_range $file $(($objsz * 2)) $halfobj 62
91 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 63
92
93 cp $backup $file
94 echo "    aaaa|bbbb|cccc => aaaa|bbbb|aabb"
95 $XFS_IO_PROG -c "copy_range -s $halfobj -d $(($objsz * 2)) -l $objsz $file" "$file"
96 check_range $file 0 $objsz 61
97 check_range $file $objsz $objsz 62
98 check_range $file $(($objsz * 2)) $halfobj 61
99 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 62
100
101 #success, all done
102 status=0
103 exit