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 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment
30 # real QA test starts here
33 _require_xfs_io_command "copy_range"
37 workdir=$TEST_DIR/test-$seq
48 _read_range $file $off0 $off1 | grep -v -q $val
49 [ $? -eq 0 ] && echo "file $file is not '$val' in [ $off0 $off1 ]"
53 halfobj=$(($objsz / 2))
54 file="$workdir/file-$objsz"
55 copy="$workdir/copy-$objsz"
56 dest="$workdir/dest-$objsz"
59 # object_size has to be a multiple of stripe_unit
60 _ceph_create_file_layout $file $objsz 1 $objsz
61 _ceph_create_file_layout $backup $objsz 1 $objsz
63 $XFS_IO_PROG -c "pwrite -S 0x61 0 $objsz" $file >> $seqres.full 2>&1
64 $XFS_IO_PROG -c "pwrite -S 0x62 $objsz $objsz" $file >> $seqres.full 2>&1
65 $XFS_IO_PROG -c "pwrite -S 0x63 $(($objsz * 2)) $objsz" $file >> $seqres.full 2>&1
69 echo " Copy single object to the end:"
70 echo " aaaa|bbbb|cccc => aaaa|bbbb|aaaa"
71 $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz * 2)) -l $objsz $file" "$file"
72 check_range $file 0 $objsz 61
73 check_range $file $objsz $objsz 62
74 check_range $file $(($objsz * 2)) $objsz 61
76 echo " Copy single object to the beginning:"
77 echo " aaaa|bbbb|aaaa => bbbb|bbbb|aaaa"
78 $XFS_IO_PROG -c "copy_range -s $objsz -d 0 -l $objsz $file" "$file"
79 check_range $file 0 $(($objsz * 2)) 62
80 check_range $file $(($objsz * 2)) $objsz 61
82 echo " Copy single object to the middle:"
83 echo " bbbb|bbbb|aaaa => bbbb|aaaa|aaaa"
84 $XFS_IO_PROG -c "copy_range -s $(($objsz * 2)) -d $objsz -l $objsz $file" "$file"
85 check_range $file 0 $objsz 62
86 check_range $file $objsz $(($objsz * 2)) 61
89 echo " Cross object boundary (no full object copy)"
90 echo " aaaa|bbbb|cccc => aaaa|bbaa|aacc"
91 $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz + $halfobj)) -l $objsz $file" "$file"
92 check_range $file 0 $objsz 61
93 check_range $file $objsz $halfobj 62
94 check_range $file $(($objsz + $halfobj)) $objsz 61
95 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 63
98 echo " aaaa|bbbb|cccc => aaaa|bbaa|bbcc"
99 $XFS_IO_PROG -c "copy_range -s $halfobj -d $(($objsz + $halfobj)) -l $objsz $file" "$file"
100 check_range $file 0 $objsz 61
101 check_range $file $objsz $halfobj 62
102 check_range $file $(($objsz + $halfobj)) $halfobj 61
103 check_range $file $(($objsz * 2)) $halfobj 62
104 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 63
107 echo " aaaa|bbbb|cccc => aaaa|bbbb|aabb"
108 $XFS_IO_PROG -c "copy_range -s $halfobj -d $(($objsz * 2)) -l $objsz $file" "$file"
109 check_range $file 0 $objsz 61
110 check_range $file $objsz $objsz 62
111 check_range $file $(($objsz * 2)) $halfobj 61
112 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 62