glusterfs

Форк
0
/
bug-1088231.t 
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

8
cleanup;
9

10
TEST glusterd
11
TEST pidof glusterd
12
TEST $CLI volume create $V0  $H0:$B0/${V0}{0,1}
13
TEST $CLI volume set $V0 cluster.randomize-hash-range-by-gfid on
14
TEST $CLI volume start $V0
15
TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0
16
TEST 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

29
gfid_with_hyphen=`getfattr -n glusterfs.gfid.string $M0/a 2>/dev/null \
30
                  | grep glusterfs.gfid.string | cut -d '"' -f 2`
31

32
TEST 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.
36
TEST umount $M0
37
TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0
38

39
TEST 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
65
echo `get_layout  $B0/$V0"0"/a`
66
echo `get_layout  $B0/$V0"1"/a`
67
layout_b0_s=`get_layout $B0/$V0"0"/a  | cut -c19-26`
68
layout_b0_e=`get_layout $B0/$V0"0"/a  | cut -c27-34`
69
layout_b1_s=`get_layout $B0/$V0"1"/a  | cut -c19-26`
70
layout_b1_e=`get_layout $B0/$V0"1"/a  | cut -c27-34`
71

72

73
##Add 0X to perform Hex arithematic
74
layout_b0_s="0x"$layout_b0_s
75
layout_b0_e="0x"$layout_b0_e
76
layout_b1_s="0x"$layout_b1_s
77
layout_b1_e="0x"$layout_b1_e
78

79

80
## Logic of converting starting layout "0" to "Max_value of layout + 1"
81
comp1=$(($layout_b0_s + 0))
82
if [ "$comp1" == "0" ];then
83
	comp1=4294967296
84
fi
85

86
comp2=$(($layout_b1_s + 0))
87
if [ "$comp2" == "0" ];then
88
	comp2=4294967296
89
fi
90

91
diff1=$(($layout_b0_e + 1))
92
diff2=$(($layout_b1_e + 1))
93

94

95
healed=0
96

97
if [ "$comp1" == "$diff1" ] && [ "$comp2" == "$diff2" ]; then
98
   healed=$(($healed + 1))
99
fi
100

101
if [ "$comp1" == "$diff2" ] && [ "$comp2" == "$diff1" ]; then
102
	healed=$(($healed + 1))
103
fi
104

105
TEST [ $healed == 1 ]
106

107
cleanup
108

109
TEST glusterd
110
TEST pidof glusterd
111
TEST $CLI volume create $V0  $H0:$B0/${V0}{0,1}
112
TEST $CLI volume set $V0 cluster.randomize-hash-range-by-gfid on
113
TEST $CLI volume start $V0
114
TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0
115
TEST mkdir $M0/a
116

117
gfid_with_hyphen=`getfattr -n glusterfs.gfid.string $M0/a 2>/dev/null \
118
                  | grep glusterfs.gfid.string | cut -d '"' -f 2`
119

120
TEST setfattr -x trusted.glusterfs.dht $B0/$V0"0"/a
121
TEST 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.
125
TEST umount $M0
126
TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0
127

128
TEST stat $M0/.gfid/$gfid_with_hyphen
129

130
##Extract Layout
131

132
layout_b0_s=`get_layout $B0/$V0"0"/a  | cut -c19-26`
133
layout_b0_e=`get_layout $B0/$V0"0"/a  | cut -c27-34`
134
layout_b1_s=`get_layout $B0/$V0"1"/a  | cut -c19-26`
135
layout_b1_e=`get_layout $B0/$V0"1"/a  | cut -c27-34`
136

137

138
##Add 0X to perform Hex arithematic
139
layout_b0_s="0x"$layout_b0_s
140
layout_b0_e="0x"$layout_b0_e
141
layout_b1_s="0x"$layout_b1_s
142
layout_b1_e="0x"$layout_b1_e
143

144

145

146
## Logic of converting starting layout "0" to "Max_value of layout + 1"
147
comp1=$(($layout_b0_s + 0))
148
if [ "$comp1" == "0" ];then
149
        comp1=4294967296
150
fi
151

152
comp2=$(($layout_b1_s + 0))
153
if [ "$comp2" == "0" ];then
154
        comp2=4294967296
155
fi
156

157
diff1=$(($layout_b0_e + 1))
158
diff2=$(($layout_b1_e + 1))
159

160

161
healed=0
162

163
if [ "$comp1" == "$diff1" ] && [ "$comp2" == "$diff2" ]; then
164
   healed=$(($healed + 1))
165
fi
166

167
if [ "$comp1" == "$diff2" ] && [ "$comp2" == "$diff1" ]; then
168
        healed=$(($healed + 1))
169
fi
170

171
TEST [ $healed == 1 ]
172
cleanup
173

174

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.