summaryrefslogtreecommitdiff
path: root/tests/ceph/003
blob: 2d6cb393b3f6dbe5eb13abde69e098d8a1912184 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test No. ceph/005
#
# Test copy_file_range with infile = outfile
#
. ./common/preamble
_begin_fstest auto quick copy_range

# get standard environment
. common/filter
. common/attr
. common/reflink

# real QA test starts here
_supported_fs ceph

_require_xfs_io_command "copy_range"
_exclude_test_mount_option "test_dummy_encryption"
_require_attrs
_require_test

workdir=$TEST_DIR/test-$seq
rm -rf $workdir
mkdir $workdir

check_range()
{
	local file=$1
	local off0=$2
	local off1=$3
	local val=$4
	_read_range $file $off0 $off1 | grep -v -q $val
	[ $? -eq 0 ] && echo "file $file is not '$val' in [ $off0 $off1 ]"
}

objsz=4194304
halfobj=$(($objsz / 2))
file="$workdir/file-$objsz"
copy="$workdir/copy-$objsz"
dest="$workdir/dest-$objsz"
backup="$file.backup"

# object_size has to be a multiple of stripe_unit
_ceph_create_file_layout $file $objsz 1 $objsz
_ceph_create_file_layout $backup $objsz 1 $objsz

$XFS_IO_PROG -c "pwrite -S 0x61 0 $objsz" $file >> $seqres.full 2>&1
$XFS_IO_PROG -c "pwrite -S 0x62 $objsz $objsz" $file >> $seqres.full 2>&1
$XFS_IO_PROG -c "pwrite -S 0x63 $(($objsz * 2)) $objsz" $file >> $seqres.full 2>&1

cp $file $backup

echo "  Copy single object to the end:"
echo "    aaaa|bbbb|cccc => aaaa|bbbb|aaaa"
$XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz * 2)) -l $objsz $file" "$file"
check_range $file 0 $objsz 61
check_range $file $objsz $objsz 62
check_range $file $(($objsz * 2)) $objsz 61

echo "  Copy single object to the beginning:"
echo "    aaaa|bbbb|aaaa => bbbb|bbbb|aaaa"
$XFS_IO_PROG -c "copy_range -s $objsz -d 0 -l $objsz $file" "$file"
check_range $file 0 $(($objsz * 2)) 62
check_range $file $(($objsz * 2)) $objsz 61

echo "  Copy single object to the middle:"
echo "    bbbb|bbbb|aaaa => bbbb|aaaa|aaaa"
$XFS_IO_PROG -c "copy_range -s $(($objsz * 2)) -d $objsz -l $objsz $file" "$file"
check_range $file 0 $objsz 62
check_range $file $objsz $(($objsz * 2)) 61

cp $backup $file
echo "  Cross object boundary (no full object copy)"
echo "    aaaa|bbbb|cccc => aaaa|bbaa|aacc"
$XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz + $halfobj)) -l $objsz $file" "$file"
check_range $file 0 $objsz 61
check_range $file $objsz $halfobj 62
check_range $file $(($objsz + $halfobj)) $objsz 61
check_range $file $(($objsz * 2 + $halfobj)) $halfobj 63

cp $backup $file
echo "    aaaa|bbbb|cccc => aaaa|bbaa|bbcc"
$XFS_IO_PROG -c "copy_range -s $halfobj -d $(($objsz + $halfobj)) -l $objsz $file" "$file"
check_range $file 0 $objsz 61
check_range $file $objsz $halfobj 62
check_range $file $(($objsz + $halfobj)) $halfobj 61
check_range $file $(($objsz * 2)) $halfobj 62
check_range $file $(($objsz * 2 + $halfobj)) $halfobj 63

cp $backup $file
echo "    aaaa|bbbb|cccc => aaaa|bbbb|aabb"
$XFS_IO_PROG -c "copy_range -s $halfobj -d $(($objsz * 2)) -l $objsz $file" "$file"
check_range $file 0 $objsz 61
check_range $file $objsz $objsz 62
check_range $file $(($objsz * 2)) $halfobj 61
check_range $file $(($objsz * 2 + $halfobj)) $halfobj 62

#success, all done
status=0
exit