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"
21 _exclude_test_mount_option "test_dummy_encryption"
25 workdir=$TEST_DIR/test-$seq
35 _read_range $file $off0 $off1 | grep -v -q $val
36 [ $? -eq 0 ] && echo "file $file is not '$val' in [ $off0 $off1 ]"
40 halfobj=$(($objsz / 2))
41 file="$workdir/file-$objsz"
42 copy="$workdir/copy-$objsz"
43 dest="$workdir/dest-$objsz"
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
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
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
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
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
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
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
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