2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. ceph/005
7 # Test copy_file_range with infile = outfile
10 _begin_fstest auto quick copy_range
12 # get standard environment
17 # real QA test starts here
20 _require_xfs_io_command "copy_range"
24 workdir=$TEST_DIR/test-$seq
34 _read_range $file $off0 $off1 | grep -v -q $val
35 [ $? -eq 0 ] && echo "file $file is not '$val' in [ $off0 $off1 ]"
39 halfobj=$(($objsz / 2))
40 file="$workdir/file-$objsz"
41 copy="$workdir/copy-$objsz"
42 dest="$workdir/dest-$objsz"
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
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
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
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
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
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
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
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