glusterfs
172 строки · 4.8 Кб
1#!/bin/bash
2. $(dirname $0)/../../include.rc
3. $(dirname $0)/../../volume.rc
4. $(dirname $0)/../../fileio.rc
5. $(dirname $0)/../../dht.rc
6
7
8cleanup;
9
10TEST glusterd
11TEST pidof glusterd
12TEST $CLI volume create $V0 $H0:$B0/${V0}{0,1}
13TEST $CLI volume set $V0 cluster.randomize-hash-range-by-gfid on
14TEST $CLI volume start $V0
15TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0
16TEST mkdir $M0/a
17
18
19## Bug Description: In case of dht_discover code path, which is triggered
20## when lookup done is nameless lookup, at the end of the lookup, even if
21## it finds that self-heal is needed to fix-the layout it wont heal because
22## healing code path is not added under nameless lookup.
23
24## What to test: With Patch, Even in case of nameless lookup, if layout
25## needs to be fixed, the it will be fixed wherever lookup is successful
26## and it will not create any directory for subvols having ENOENT as it is
27## nameless lookup.
28
29gfid_with_hyphen=`getfattr -n glusterfs.gfid.string $M0/a 2>/dev/null \
30| grep glusterfs.gfid.string | cut -d '"' -f 2`
31
32TEST setfattr -x trusted.glusterfs.dht $B0/$V0"0"/a
33
34## new healing code don't attempt healing if inode is already
35## populated. So, unmount and remount before we do stat.
36TEST umount $M0
37TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0
38
39TEST stat $M0/.gfid/$gfid_with_hyphen
40
41## Assuming that we have two bricks, we can have two permutations of layout
42## Case 1: Brick - A Brick - B
43## 0 - 50 51-100
44##
45## Case 2: Brick - A Brick - B
46## 51 - 100 0 - 50
47##
48## To ensure layout is assigned properly, the following tests should be
49## performed.
50##
51## Case 1: Layout_b0_s = 0; Layout_b0_e = 50, Layout_b1_s=51,
52## Layout_b1_e = 100;
53##
54## layout_b1_s = layout_b0_e + 1;
55## layout_b0_s = layout_b1_e + 1; but b0_s is 0, so change to 101
56## then compare
57## Case 2: Layout_b0_s = 51, Layout_b0_e = 100, Layout_b1_s=0,
58## Layout_b1_e = 51
59##
60## layout_b0_s = Layout_b1_e + 1;
61## layout_b1_s = Layout_b0_e + 1; but b1_s is 0, so chage to 101.
62
63
64##Extract Layout
65echo `get_layout $B0/$V0"0"/a`
66echo `get_layout $B0/$V0"1"/a`
67layout_b0_s=`get_layout $B0/$V0"0"/a | cut -c19-26`
68layout_b0_e=`get_layout $B0/$V0"0"/a | cut -c27-34`
69layout_b1_s=`get_layout $B0/$V0"1"/a | cut -c19-26`
70layout_b1_e=`get_layout $B0/$V0"1"/a | cut -c27-34`
71
72
73##Add 0X to perform Hex arithematic
74layout_b0_s="0x"$layout_b0_s
75layout_b0_e="0x"$layout_b0_e
76layout_b1_s="0x"$layout_b1_s
77layout_b1_e="0x"$layout_b1_e
78
79
80## Logic of converting starting layout "0" to "Max_value of layout + 1"
81comp1=$(($layout_b0_s + 0))
82if [ "$comp1" == "0" ];then
83comp1=4294967296
84fi
85
86comp2=$(($layout_b1_s + 0))
87if [ "$comp2" == "0" ];then
88comp2=4294967296
89fi
90
91diff1=$(($layout_b0_e + 1))
92diff2=$(($layout_b1_e + 1))
93
94
95healed=0
96
97if [ "$comp1" == "$diff1" ] && [ "$comp2" == "$diff2" ]; then
98healed=$(($healed + 1))
99fi
100
101if [ "$comp1" == "$diff2" ] && [ "$comp2" == "$diff1" ]; then
102healed=$(($healed + 1))
103fi
104
105TEST [ $healed == 1 ]
106
107cleanup
108
109TEST glusterd
110TEST pidof glusterd
111TEST $CLI volume create $V0 $H0:$B0/${V0}{0,1}
112TEST $CLI volume set $V0 cluster.randomize-hash-range-by-gfid on
113TEST $CLI volume start $V0
114TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0
115TEST mkdir $M0/a
116
117gfid_with_hyphen=`getfattr -n glusterfs.gfid.string $M0/a 2>/dev/null \
118| grep glusterfs.gfid.string | cut -d '"' -f 2`
119
120TEST setfattr -x trusted.glusterfs.dht $B0/$V0"0"/a
121TEST setfattr -x trusted.glusterfs.dht $B0/$V0"1"/a
122
123## new healing code don't attempt healing if inode is already
124## populated. So, unmount and remount before we do stat.
125TEST umount $M0
126TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0
127
128TEST stat $M0/.gfid/$gfid_with_hyphen
129
130##Extract Layout
131
132layout_b0_s=`get_layout $B0/$V0"0"/a | cut -c19-26`
133layout_b0_e=`get_layout $B0/$V0"0"/a | cut -c27-34`
134layout_b1_s=`get_layout $B0/$V0"1"/a | cut -c19-26`
135layout_b1_e=`get_layout $B0/$V0"1"/a | cut -c27-34`
136
137
138##Add 0X to perform Hex arithematic
139layout_b0_s="0x"$layout_b0_s
140layout_b0_e="0x"$layout_b0_e
141layout_b1_s="0x"$layout_b1_s
142layout_b1_e="0x"$layout_b1_e
143
144
145
146## Logic of converting starting layout "0" to "Max_value of layout + 1"
147comp1=$(($layout_b0_s + 0))
148if [ "$comp1" == "0" ];then
149comp1=4294967296
150fi
151
152comp2=$(($layout_b1_s + 0))
153if [ "$comp2" == "0" ];then
154comp2=4294967296
155fi
156
157diff1=$(($layout_b0_e + 1))
158diff2=$(($layout_b1_e + 1))
159
160
161healed=0
162
163if [ "$comp1" == "$diff1" ] && [ "$comp2" == "$diff2" ]; then
164healed=$(($healed + 1))
165fi
166
167if [ "$comp1" == "$diff2" ] && [ "$comp2" == "$diff1" ]; then
168healed=$(($healed + 1))
169fi
170
171TEST [ $healed == 1 ]
172cleanup
173
174