blob: 0273d84994c0927d145e28f371f6374fda90175b (
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
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#!/usr/bin/env bash
set -ex
function get_block_name_prefix() {
rbd info --format=json $1 | python3 -c "import sys, json; print(json.load(sys.stdin)['block_name_prefix'])"
}
function do_pwrite() {
local spec=$1
local old_byte=$2
local new_byte=$3
local dev
dev=$(sudo rbd map $spec)
cmp <(dd if=/dev/zero bs=1M count=10 | tr \\000 \\$old_byte) $dev
xfs_io -c "pwrite -b 1M -S $new_byte 0 10M" $dev
sudo rbd unmap $dev
}
function do_cmp() {
local spec=$1
local byte=$2
local dev
dev=$(sudo rbd map $spec)
cmp <(dd if=/dev/zero bs=1M count=10 | tr \\000 \\$byte) $dev
sudo rbd unmap $dev
}
function gen_child_specs() {
local i=$1
local child_specs="foo/img$i-clone1 foo/img$i-clone2 foo/ns1/img$i-clone1 foo/ns1/img$i-clone2"
if [[ $i -ge 3 ]]; then
child_specs="$child_specs foo/ns2/img$i-clone1 foo/ns2/img$i-clone2"
fi
echo $child_specs
}
ceph osd pool create foo 12
rbd pool init foo
ceph osd pool create bar 12
rbd pool init bar
ceph osd set-require-min-compat-client nautilus
rbd namespace create foo/ns1
rbd namespace create foo/ns2
SPECS=(foo/img1 foo/img2 foo/ns1/img3 foo/ns1/img4)
COUNT=1
for spec in "${SPECS[@]}"; do
if [[ $spec =~ img1|img3 ]]; then
rbd create --size 10 $spec
else
rbd create --size 10 --data-pool bar $spec
fi
do_pwrite $spec 000 $(printf %03d $COUNT)
rbd snap create $spec@snap
COUNT=$((COUNT + 1))
done
for i in {1..4}; do
for child_spec in $(gen_child_specs $i); do
if [[ $child_spec =~ clone1 ]]; then
rbd clone ${SPECS[i - 1]}@snap $child_spec
else
rbd clone --data-pool bar ${SPECS[i - 1]}@snap $child_spec
fi
do_pwrite $child_spec $(printf %03d $i) $(printf %03d $COUNT)
COUNT=$((COUNT + 1))
done
done
[[ $(rados -p foo ls | grep -c $(get_block_name_prefix foo/img1)) -eq 3 ]]
[[ $(rados -p bar ls | grep -c $(get_block_name_prefix foo/img2)) -eq 3 ]]
[[ $(rados -p foo -N ns1 ls | grep -c $(get_block_name_prefix foo/ns1/img3)) -eq 3 ]]
[[ $(rados -p bar -N ns1 ls | grep -c $(get_block_name_prefix foo/ns1/img4)) -eq 3 ]]
[[ $(rados -p foo ls | grep -c $(get_block_name_prefix foo/img1-clone1)) -eq 3 ]]
[[ $(rados -p bar ls | grep -c $(get_block_name_prefix foo/img1-clone2)) -eq 3 ]]
[[ $(rados -p foo -N ns1 ls | grep -c $(get_block_name_prefix foo/ns1/img1-clone1)) -eq 3 ]]
[[ $(rados -p bar -N ns1 ls | grep -c $(get_block_name_prefix foo/ns1/img1-clone2)) -eq 3 ]]
[[ $(rados -p foo ls | grep -c $(get_block_name_prefix foo/img2-clone1)) -eq 3 ]]
[[ $(rados -p bar ls | grep -c $(get_block_name_prefix foo/img2-clone2)) -eq 3 ]]
[[ $(rados -p foo -N ns1 ls | grep -c $(get_block_name_prefix foo/ns1/img2-clone1)) -eq 3 ]]
[[ $(rados -p bar -N ns1 ls | grep -c $(get_block_name_prefix foo/ns1/img2-clone2)) -eq 3 ]]
[[ $(rados -p foo ls | grep -c $(get_block_name_prefix foo/img3-clone1)) -eq 3 ]]
[[ $(rados -p bar ls | grep -c $(get_block_name_prefix foo/img3-clone2)) -eq 3 ]]
[[ $(rados -p foo -N ns1 ls | grep -c $(get_block_name_prefix foo/ns1/img3-clone1)) -eq 3 ]]
[[ $(rados -p bar -N ns1 ls | grep -c $(get_block_name_prefix foo/ns1/img3-clone2)) -eq 3 ]]
[[ $(rados -p foo -N ns2 ls | grep -c $(get_block_name_prefix foo/ns2/img3-clone1)) -eq 3 ]]
[[ $(rados -p bar -N ns2 ls | grep -c $(get_block_name_prefix foo/ns2/img3-clone2)) -eq 3 ]]
[[ $(rados -p foo ls | grep -c $(get_block_name_prefix foo/img4-clone1)) -eq 3 ]]
[[ $(rados -p bar ls | grep -c $(get_block_name_prefix foo/img4-clone2)) -eq 3 ]]
[[ $(rados -p foo -N ns1 ls | grep -c $(get_block_name_prefix foo/ns1/img4-clone1)) -eq 3 ]]
[[ $(rados -p bar -N ns1 ls | grep -c $(get_block_name_prefix foo/ns1/img4-clone2)) -eq 3 ]]
[[ $(rados -p foo -N ns2 ls | grep -c $(get_block_name_prefix foo/ns2/img4-clone1)) -eq 3 ]]
[[ $(rados -p bar -N ns2 ls | grep -c $(get_block_name_prefix foo/ns2/img4-clone2)) -eq 3 ]]
COUNT=1
for spec in "${SPECS[@]}"; do
do_cmp $spec $(printf %03d $COUNT)
COUNT=$((COUNT + 1))
done
for i in {1..4}; do
for child_spec in $(gen_child_specs $i); do
do_cmp $child_spec $(printf %03d $COUNT)
COUNT=$((COUNT + 1))
done
done
echo OK
|