faedb48cfeeab861166fc0b84715fc39c0c5849e
[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 _require_attrs
22 _require_test
23
24 workdir=$TEST_DIR/test-$seq
25 rm -rf $workdir
26 mkdir $workdir
27
28 check_range()
29 {
30         local file=$1
31         local off0=$2
32         local off1=$3
33         local val=$4
34         _read_range $file $off0 $off1 | grep -v -q $val
35         [ $? -eq 0 ] && echo "file $file is not '$val' in [ $off0 $off1 ]"
36 }
37
38 objsz=4194304
39 halfobj=$(($objsz / 2))
40 file="$workdir/file-$objsz"
41 copy="$workdir/copy-$objsz"
42 dest="$workdir/dest-$objsz"
43 backup="$file.backup"
44
45 # object_size has to be a multiple of stripe_unit
46 _ceph_create_file_layout $file $objsz 1 $objsz
47 _ceph_create_file_layout $backup $objsz 1 $objsz
48
49 $XFS_IO_PROG -c "pwrite -S 0x61 0 $objsz" $file >> $seqres.full 2>&1
50 $XFS_IO_PROG -c "pwrite -S 0x62 $objsz $objsz" $file >> $seqres.full 2>&1
51 $XFS_IO_PROG -c "pwrite -S 0x63 $(($objsz * 2)) $objsz" $file >> $seqres.full 2>&1
52
53 cp $file $backup
54
55 echo "  Copy single object to the end:"
56 echo "    aaaa|bbbb|cccc => aaaa|bbbb|aaaa"
57 $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz * 2)) -l $objsz $file" "$file"
58 check_range $file 0 $objsz 61
59 check_range $file $objsz $objsz 62
60 check_range $file $(($objsz * 2)) $objsz 61
61
62 echo "  Copy single object to the beginning:"
63 echo "    aaaa|bbbb|aaaa => bbbb|bbbb|aaaa"
64 $XFS_IO_PROG -c "copy_range -s $objsz -d 0 -l $objsz $file" "$file"
65 check_range $file 0 $(($objsz * 2)) 62
66 check_range $file $(($objsz * 2)) $objsz 61
67
68 echo "  Copy single object to the middle:"
69 echo "    bbbb|bbbb|aaaa => bbbb|aaaa|aaaa"
70 $XFS_IO_PROG -c "copy_range -s $(($objsz * 2)) -d $objsz -l $objsz $file" "$file"
71 check_range $file 0 $objsz 62
72 check_range $file $objsz $(($objsz * 2)) 61
73
74 cp $backup $file
75 echo "  Cross object boundary (no full object copy)"
76 echo "    aaaa|bbbb|cccc => aaaa|bbaa|aacc"
77 $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz + $halfobj)) -l $objsz $file" "$file"
78 check_range $file 0 $objsz 61
79 check_range $file $objsz $halfobj 62
80 check_range $file $(($objsz + $halfobj)) $objsz 61
81 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 63
82
83 cp $backup $file
84 echo "    aaaa|bbbb|cccc => aaaa|bbaa|bbcc"
85 $XFS_IO_PROG -c "copy_range -s $halfobj -d $(($objsz + $halfobj)) -l $objsz $file" "$file"
86 check_range $file 0 $objsz 61
87 check_range $file $objsz $halfobj 62
88 check_range $file $(($objsz + $halfobj)) $halfobj 61
89 check_range $file $(($objsz * 2)) $halfobj 62
90 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 63
91
92 cp $backup $file
93 echo "    aaaa|bbbb|cccc => aaaa|bbbb|aabb"
94 $XFS_IO_PROG -c "copy_range -s $halfobj -d $(($objsz * 2)) -l $objsz $file" "$file"
95 check_range $file 0 $objsz 61
96 check_range $file $objsz $objsz 62
97 check_range $file $(($objsz * 2)) $halfobj 61
98 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 62
99
100 #success, all done
101 status=0
102 exit