File: | xlators/protocol/client/src/client-handshake.c |
Location: | line 1221, column 13 |
Description: | Branch condition evaluates to a garbage value |
1 | /* | |||
2 | Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> | |||
3 | This file is part of GlusterFS. | |||
4 | ||||
5 | This file is licensed to you under your choice of the GNU Lesser | |||
6 | General Public License, version 3 or any later version (LGPLv3 or | |||
7 | later), or the GNU General Public License, version 2 (GPLv2), in all | |||
8 | cases as published by the Free Software Foundation. | |||
9 | */ | |||
10 | ||||
11 | #ifndef _CONFIG_H | |||
12 | #define _CONFIG_H | |||
13 | #include "config.h" | |||
14 | #endif | |||
15 | ||||
16 | #include "fd-lk.h" | |||
17 | #include "client.h" | |||
18 | #include "xlator.h" | |||
19 | #include "defaults.h" | |||
20 | #include "glusterfs.h" | |||
21 | #include "statedump.h" | |||
22 | #include "compat-errno.h" | |||
23 | ||||
24 | #include "glusterfs3.h" | |||
25 | #include "portmap-xdr.h" | |||
26 | #include "rpc-common-xdr.h" | |||
27 | ||||
28 | #define CLIENT_REOPEN_MAX_ATTEMPTS1024 1024 | |||
29 | extern rpc_clnt_prog_t clnt3_3_fop_prog; | |||
30 | extern rpc_clnt_prog_t clnt_pmap_prog; | |||
31 | ||||
32 | int client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, | |||
33 | void *myframe); | |||
34 | ||||
35 | int client_set_lk_version_cbk (struct rpc_req *req, struct iovec *iov, | |||
36 | int count, void *myframe); | |||
37 | ||||
38 | int client_set_lk_version (xlator_t *this); | |||
39 | ||||
40 | typedef struct client_fd_lk_local { | |||
41 | int ref; | |||
42 | gf_boolean_t error; | |||
43 | gf_lock_t lock; | |||
44 | clnt_fd_ctx_t *fdctx; | |||
45 | }clnt_fd_lk_local_t; | |||
46 | ||||
47 | /* Handshake */ | |||
48 | ||||
49 | void | |||
50 | rpc_client_ping_timer_expired (void *data) | |||
51 | { | |||
52 | rpc_transport_t *trans = NULL((void*)0); | |||
53 | rpc_clnt_connection_t *conn = NULL((void*)0); | |||
54 | int disconnect = 0; | |||
55 | int transport_activity = 0; | |||
56 | struct timeval timeout = {0, }; | |||
57 | struct timeval current = {0, }; | |||
58 | struct rpc_clnt *clnt = NULL((void*)0); | |||
59 | xlator_t *this = NULL((void*)0); | |||
60 | clnt_conf_t *conf = NULL((void*)0); | |||
61 | ||||
62 | this = data; | |||
63 | ||||
64 | if (!this || !this->private) { | |||
65 | gf_log (THIS->name, GF_LOG_WARNING, "xlator initialization not done")do { do { if (0) printf ("xlator initialization not done"); } while (0); _gf_log ((*__glusterfs_this_location())->name, "client-handshake.c", __FUNCTION__, 65, GF_LOG_WARNING, "xlator initialization not done" ); } while (0); | |||
66 | goto out; | |||
67 | } | |||
68 | ||||
69 | conf = this->private; | |||
70 | ||||
71 | clnt = conf->rpc; | |||
72 | if (!clnt) { | |||
73 | gf_log (this->name, GF_LOG_WARNING, "rpc not initialized")do { do { if (0) printf ("rpc not initialized"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 73 , GF_LOG_WARNING, "rpc not initialized"); } while (0); | |||
74 | goto out; | |||
75 | } | |||
76 | ||||
77 | conn = &clnt->conn; | |||
78 | trans = conn->trans; | |||
79 | ||||
80 | if (!trans) { | |||
81 | gf_log (this->name, GF_LOG_WARNING, "transport not initialized")do { do { if (0) printf ("transport not initialized"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 81, GF_LOG_WARNING, "transport not initialized"); } while ( 0); | |||
82 | goto out; | |||
83 | } | |||
84 | ||||
85 | pthread_mutex_lock (&conn->lock); | |||
86 | { | |||
87 | if (conn->ping_timer) | |||
88 | gf_timer_call_cancel (this->ctx, | |||
89 | conn->ping_timer); | |||
90 | gettimeofday (¤t, NULL((void*)0)); | |||
91 | ||||
92 | if (((current.tv_sec - conn->last_received.tv_sec) < | |||
93 | conf->opt.ping_timeout) | |||
94 | || ((current.tv_sec - conn->last_sent.tv_sec) < | |||
95 | conf->opt.ping_timeout)) { | |||
96 | transport_activity = 1; | |||
97 | } | |||
98 | ||||
99 | if (transport_activity) { | |||
100 | gf_log (trans->name, GF_LOG_TRACE,do { do { if (0) printf ("ping timer expired but transport activity " "detected - not bailing transport"); } while (0); _gf_log (trans ->name, "client-handshake.c", __FUNCTION__, 102, GF_LOG_TRACE , "ping timer expired but transport activity " "detected - not bailing transport" ); } while (0) | |||
101 | "ping timer expired but transport activity "do { do { if (0) printf ("ping timer expired but transport activity " "detected - not bailing transport"); } while (0); _gf_log (trans ->name, "client-handshake.c", __FUNCTION__, 102, GF_LOG_TRACE , "ping timer expired but transport activity " "detected - not bailing transport" ); } while (0) | |||
102 | "detected - not bailing transport")do { do { if (0) printf ("ping timer expired but transport activity " "detected - not bailing transport"); } while (0); _gf_log (trans ->name, "client-handshake.c", __FUNCTION__, 102, GF_LOG_TRACE , "ping timer expired but transport activity " "detected - not bailing transport" ); } while (0); | |||
103 | timeout.tv_sec = conf->opt.ping_timeout; | |||
104 | timeout.tv_usec = 0; | |||
105 | ||||
106 | conn->ping_timer = | |||
107 | gf_timer_call_after (this->ctx, timeout, | |||
108 | rpc_client_ping_timer_expired, | |||
109 | (void *) this); | |||
110 | if (conn->ping_timer == NULL((void*)0)) | |||
111 | gf_log (trans->name, GF_LOG_WARNING,do { do { if (0) printf ("unable to setup ping timer"); } while (0); _gf_log (trans->name, "client-handshake.c", __FUNCTION__ , 112, GF_LOG_WARNING, "unable to setup ping timer"); } while (0) | |||
112 | "unable to setup ping timer")do { do { if (0) printf ("unable to setup ping timer"); } while (0); _gf_log (trans->name, "client-handshake.c", __FUNCTION__ , 112, GF_LOG_WARNING, "unable to setup ping timer"); } while (0); | |||
113 | ||||
114 | } else { | |||
115 | conn->ping_started = 0; | |||
116 | conn->ping_timer = NULL((void*)0); | |||
117 | disconnect = 1; | |||
118 | } | |||
119 | } | |||
120 | pthread_mutex_unlock (&conn->lock); | |||
121 | ||||
122 | if (disconnect) { | |||
123 | gf_log (trans->name, GF_LOG_CRITICAL,do { do { if (0) printf ("server %s has not responded in the last %d " "seconds, disconnecting.", conn->trans->peerinfo.identifier , conf->opt.ping_timeout); } while (0); _gf_log (trans-> name, "client-handshake.c", __FUNCTION__, 127, GF_LOG_CRITICAL , "server %s has not responded in the last %d " "seconds, disconnecting." , conn->trans->peerinfo.identifier, conf->opt.ping_timeout ); } while (0) | |||
124 | "server %s has not responded in the last %d "do { do { if (0) printf ("server %s has not responded in the last %d " "seconds, disconnecting.", conn->trans->peerinfo.identifier , conf->opt.ping_timeout); } while (0); _gf_log (trans-> name, "client-handshake.c", __FUNCTION__, 127, GF_LOG_CRITICAL , "server %s has not responded in the last %d " "seconds, disconnecting." , conn->trans->peerinfo.identifier, conf->opt.ping_timeout ); } while (0) | |||
125 | "seconds, disconnecting.",do { do { if (0) printf ("server %s has not responded in the last %d " "seconds, disconnecting.", conn->trans->peerinfo.identifier , conf->opt.ping_timeout); } while (0); _gf_log (trans-> name, "client-handshake.c", __FUNCTION__, 127, GF_LOG_CRITICAL , "server %s has not responded in the last %d " "seconds, disconnecting." , conn->trans->peerinfo.identifier, conf->opt.ping_timeout ); } while (0) | |||
126 | conn->trans->peerinfo.identifier,do { do { if (0) printf ("server %s has not responded in the last %d " "seconds, disconnecting.", conn->trans->peerinfo.identifier , conf->opt.ping_timeout); } while (0); _gf_log (trans-> name, "client-handshake.c", __FUNCTION__, 127, GF_LOG_CRITICAL , "server %s has not responded in the last %d " "seconds, disconnecting." , conn->trans->peerinfo.identifier, conf->opt.ping_timeout ); } while (0) | |||
127 | conf->opt.ping_timeout)do { do { if (0) printf ("server %s has not responded in the last %d " "seconds, disconnecting.", conn->trans->peerinfo.identifier , conf->opt.ping_timeout); } while (0); _gf_log (trans-> name, "client-handshake.c", __FUNCTION__, 127, GF_LOG_CRITICAL , "server %s has not responded in the last %d " "seconds, disconnecting." , conn->trans->peerinfo.identifier, conf->opt.ping_timeout ); } while (0); | |||
128 | ||||
129 | rpc_transport_disconnect (conn->trans); | |||
130 | } | |||
131 | ||||
132 | out: | |||
133 | return; | |||
134 | } | |||
135 | ||||
136 | void | |||
137 | client_start_ping (void *data) | |||
138 | { | |||
139 | xlator_t *this = NULL((void*)0); | |||
140 | clnt_conf_t *conf = NULL((void*)0); | |||
141 | rpc_clnt_connection_t *conn = NULL((void*)0); | |||
142 | int32_t ret = -1; | |||
143 | struct timeval timeout = {0, }; | |||
144 | call_frame_t *frame = NULL((void*)0); | |||
145 | int frame_count = 0; | |||
146 | ||||
147 | this = data; | |||
148 | if (!this || !this->private) { | |||
149 | gf_log (THIS->name, GF_LOG_WARNING, "xlator not initialized")do { do { if (0) printf ("xlator not initialized"); } while ( 0); _gf_log ((*__glusterfs_this_location())->name, "client-handshake.c" , __FUNCTION__, 149, GF_LOG_WARNING, "xlator not initialized" ); } while (0); | |||
150 | goto fail; | |||
151 | } | |||
152 | ||||
153 | conf = this->private; | |||
154 | if (!conf->rpc) { | |||
155 | gf_log (this->name, GF_LOG_WARNING, "rpc not initialized")do { do { if (0) printf ("rpc not initialized"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 155 , GF_LOG_WARNING, "rpc not initialized"); } while (0); | |||
156 | goto fail; | |||
157 | } | |||
158 | conn = &conf->rpc->conn; | |||
159 | ||||
160 | if (conf->opt.ping_timeout == 0) { | |||
161 | gf_log (this->name, GF_LOG_INFO, "ping timeout is 0, returning")do { do { if (0) printf ("ping timeout is 0, returning"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 161, GF_LOG_INFO, "ping timeout is 0, returning"); } while ( 0); | |||
162 | return; | |||
163 | } | |||
164 | ||||
165 | pthread_mutex_lock (&conn->lock); | |||
166 | { | |||
167 | if (conn->ping_timer) | |||
168 | gf_timer_call_cancel (this->ctx, conn->ping_timer); | |||
169 | ||||
170 | conn->ping_timer = NULL((void*)0); | |||
171 | conn->ping_started = 0; | |||
172 | ||||
173 | if (conn->saved_frames) | |||
174 | /* treat the case where conn->saved_frames is NULL | |||
175 | as no pending frames */ | |||
176 | frame_count = conn->saved_frames->count; | |||
177 | ||||
178 | if ((frame_count == 0) || !conn->connected) { | |||
179 | /* using goto looked ugly here, | |||
180 | * hence getting out this way */ | |||
181 | /* unlock */ | |||
182 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("returning as transport is already disconnected" " OR there are no frames (%d || %d)", frame_count, !conn-> connected); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 185, GF_LOG_DEBUG, "returning as transport is already disconnected" " OR there are no frames (%d || %d)", frame_count, !conn-> connected); } while (0) | |||
183 | "returning as transport is already disconnected"do { do { if (0) printf ("returning as transport is already disconnected" " OR there are no frames (%d || %d)", frame_count, !conn-> connected); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 185, GF_LOG_DEBUG, "returning as transport is already disconnected" " OR there are no frames (%d || %d)", frame_count, !conn-> connected); } while (0) | |||
184 | " OR there are no frames (%d || %d)",do { do { if (0) printf ("returning as transport is already disconnected" " OR there are no frames (%d || %d)", frame_count, !conn-> connected); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 185, GF_LOG_DEBUG, "returning as transport is already disconnected" " OR there are no frames (%d || %d)", frame_count, !conn-> connected); } while (0) | |||
185 | frame_count, !conn->connected)do { do { if (0) printf ("returning as transport is already disconnected" " OR there are no frames (%d || %d)", frame_count, !conn-> connected); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 185, GF_LOG_DEBUG, "returning as transport is already disconnected" " OR there are no frames (%d || %d)", frame_count, !conn-> connected); } while (0); | |||
186 | ||||
187 | pthread_mutex_unlock (&conn->lock); | |||
188 | return; | |||
189 | } | |||
190 | ||||
191 | if (frame_count < 0) { | |||
192 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("saved_frames->count is %""ll" "d" , conn->saved_frames->count); } while (0); _gf_log (this ->name, "client-handshake.c", __FUNCTION__, 194, GF_LOG_WARNING , "saved_frames->count is %""ll" "d", conn->saved_frames ->count); } while (0) | |||
193 | "saved_frames->count is %"PRId64,do { do { if (0) printf ("saved_frames->count is %""ll" "d" , conn->saved_frames->count); } while (0); _gf_log (this ->name, "client-handshake.c", __FUNCTION__, 194, GF_LOG_WARNING , "saved_frames->count is %""ll" "d", conn->saved_frames ->count); } while (0) | |||
194 | conn->saved_frames->count)do { do { if (0) printf ("saved_frames->count is %""ll" "d" , conn->saved_frames->count); } while (0); _gf_log (this ->name, "client-handshake.c", __FUNCTION__, 194, GF_LOG_WARNING , "saved_frames->count is %""ll" "d", conn->saved_frames ->count); } while (0); | |||
195 | conn->saved_frames->count = 0; | |||
196 | } | |||
197 | ||||
198 | timeout.tv_sec = conf->opt.ping_timeout; | |||
199 | timeout.tv_usec = 0; | |||
200 | ||||
201 | conn->ping_timer = | |||
202 | gf_timer_call_after (this->ctx, timeout, | |||
203 | rpc_client_ping_timer_expired, | |||
204 | (void *) this); | |||
205 | ||||
206 | if (conn->ping_timer == NULL((void*)0)) { | |||
207 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("unable to setup ping timer"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 208, GF_LOG_WARNING, "unable to setup ping timer"); } while (0) | |||
208 | "unable to setup ping timer")do { do { if (0) printf ("unable to setup ping timer"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 208, GF_LOG_WARNING, "unable to setup ping timer"); } while (0); | |||
209 | } else { | |||
210 | conn->ping_started = 1; | |||
211 | } | |||
212 | } | |||
213 | pthread_mutex_unlock (&conn->lock); | |||
214 | ||||
215 | frame = create_frame (this, this->ctx->pool); | |||
216 | if (!frame) | |||
217 | goto fail; | |||
218 | ||||
219 | ret = client_submit_request (this, NULL((void*)0), frame, conf->handshake, | |||
220 | GF_HNDSK_PING, client_ping_cbk, NULL((void*)0), | |||
221 | NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0), (xdrproc_t)NULL((void*)0)); | |||
222 | if (ret) { | |||
223 | gf_log (THIS->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to start ping timer"); } while (0); _gf_log ((*__glusterfs_this_location())->name, "client-handshake.c" , __FUNCTION__, 224, GF_LOG_ERROR, "failed to start ping timer" ); } while (0) | |||
224 | "failed to start ping timer")do { do { if (0) printf ("failed to start ping timer"); } while (0); _gf_log ((*__glusterfs_this_location())->name, "client-handshake.c" , __FUNCTION__, 224, GF_LOG_ERROR, "failed to start ping timer" ); } while (0); | |||
225 | } | |||
226 | ||||
227 | return; | |||
228 | ||||
229 | fail: | |||
230 | if (frame) { | |||
231 | STACK_DESTROY (frame->root); | |||
232 | } | |||
233 | ||||
234 | return; | |||
235 | } | |||
236 | ||||
237 | ||||
238 | int | |||
239 | client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, | |||
240 | void *myframe) | |||
241 | { | |||
242 | xlator_t *this = NULL((void*)0); | |||
243 | rpc_clnt_connection_t *conn = NULL((void*)0); | |||
244 | struct timeval timeout = {0, }; | |||
245 | call_frame_t *frame = NULL((void*)0); | |||
246 | clnt_conf_t *conf = NULL((void*)0); | |||
247 | ||||
248 | if (!myframe) { | |||
249 | gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("frame with the request is NULL"); } while (0); _gf_log ((*__glusterfs_this_location())->name, "client-handshake.c", __FUNCTION__, 250, GF_LOG_WARNING, "frame with the request is NULL" ); } while (0) | |||
250 | "frame with the request is NULL")do { do { if (0) printf ("frame with the request is NULL"); } while (0); _gf_log ((*__glusterfs_this_location())->name, "client-handshake.c", __FUNCTION__, 250, GF_LOG_WARNING, "frame with the request is NULL" ); } while (0); | |||
251 | goto out; | |||
252 | } | |||
253 | frame = myframe; | |||
254 | this = frame->this; | |||
255 | if (!this || !this->private) { | |||
256 | gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("xlator private is not set"); } while (0); _gf_log ((*__glusterfs_this_location())->name, "client-handshake.c" , __FUNCTION__, 257, GF_LOG_WARNING, "xlator private is not set" ); } while (0) | |||
257 | "xlator private is not set")do { do { if (0) printf ("xlator private is not set"); } while (0); _gf_log ((*__glusterfs_this_location())->name, "client-handshake.c" , __FUNCTION__, 257, GF_LOG_WARNING, "xlator private is not set" ); } while (0); | |||
258 | goto out; | |||
259 | } | |||
260 | ||||
261 | conf = this->private; | |||
262 | conn = &conf->rpc->conn; | |||
263 | ||||
264 | pthread_mutex_lock (&conn->lock); | |||
265 | { | |||
266 | if (req->rpc_status == -1) { | |||
267 | if (conn->ping_timer != NULL((void*)0)) { | |||
268 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("socket or ib related error"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 269, GF_LOG_WARNING, "socket or ib related error"); } while (0) | |||
269 | "socket or ib related error")do { do { if (0) printf ("socket or ib related error"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 269, GF_LOG_WARNING, "socket or ib related error"); } while (0); | |||
270 | gf_timer_call_cancel (this->ctx, | |||
271 | conn->ping_timer); | |||
272 | conn->ping_timer = NULL((void*)0); | |||
273 | } else { | |||
274 | /* timer expired and transport bailed out */ | |||
275 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("timer must have expired"); } while ( 0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 276, GF_LOG_WARNING, "timer must have expired"); } while (0 ) | |||
276 | "timer must have expired")do { do { if (0) printf ("timer must have expired"); } while ( 0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 276, GF_LOG_WARNING, "timer must have expired"); } while (0 ); | |||
277 | } | |||
278 | ||||
279 | goto unlock; | |||
280 | } | |||
281 | ||||
282 | ||||
283 | timeout.tv_sec = conf->opt.ping_timeout; | |||
284 | timeout.tv_usec = 0; | |||
285 | ||||
286 | gf_timer_call_cancel (this->ctx, | |||
287 | conn->ping_timer); | |||
288 | ||||
289 | conn->ping_timer = | |||
290 | gf_timer_call_after (this->ctx, timeout, | |||
291 | client_start_ping, (void *)this); | |||
292 | ||||
293 | if (conn->ping_timer == NULL((void*)0)) | |||
294 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set the ping timer"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 295, GF_LOG_WARNING, "failed to set the ping timer"); } while (0) | |||
295 | "failed to set the ping timer")do { do { if (0) printf ("failed to set the ping timer"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 295, GF_LOG_WARNING, "failed to set the ping timer"); } while (0); | |||
296 | } | |||
297 | unlock: | |||
298 | pthread_mutex_unlock (&conn->lock); | |||
299 | out: | |||
300 | if (frame) | |||
301 | STACK_DESTROY (frame->root); | |||
302 | return 0; | |||
303 | } | |||
304 | ||||
305 | ||||
306 | int | |||
307 | client3_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, | |||
308 | void *myframe) | |||
309 | { | |||
310 | gf_getspec_rsp rsp = {0,}; | |||
311 | call_frame_t *frame = NULL((void*)0); | |||
312 | int ret = 0; | |||
313 | ||||
314 | frame = myframe; | |||
315 | ||||
316 | if (!frame || !frame->this) { | |||
317 | gf_log (THIS->name, GF_LOG_ERROR, "frame not found with the request, "do { do { if (0) printf ("frame not found with the request, " "returning EINVAL"); } while (0); _gf_log ((*__glusterfs_this_location ())->name, "client-handshake.c", __FUNCTION__, 318, GF_LOG_ERROR , "frame not found with the request, " "returning EINVAL"); } while (0) | |||
318 | "returning EINVAL")do { do { if (0) printf ("frame not found with the request, " "returning EINVAL"); } while (0); _gf_log ((*__glusterfs_this_location ())->name, "client-handshake.c", __FUNCTION__, 318, GF_LOG_ERROR , "frame not found with the request, " "returning EINVAL"); } while (0); | |||
319 | rsp.op_ret = -1; | |||
320 | rsp.op_errno = EINVAL22; | |||
321 | goto out; | |||
322 | } | |||
323 | if (-1 == req->rpc_status) { | |||
324 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("received RPC status error, returning ENOTCONN" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 325, GF_LOG_WARNING, "received RPC status error, returning ENOTCONN" ); } while (0) | |||
325 | "received RPC status error, returning ENOTCONN")do { do { if (0) printf ("received RPC status error, returning ENOTCONN" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 325, GF_LOG_WARNING, "received RPC status error, returning ENOTCONN" ); } while (0); | |||
326 | rsp.op_ret = -1; | |||
327 | rsp.op_errno = ENOTCONN107; | |||
328 | goto out; | |||
329 | } | |||
330 | ||||
331 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_getspec_rsp); | |||
332 | if (ret < 0) { | |||
333 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("XDR decoding failed, returning EINVAL" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 334, GF_LOG_ERROR, "XDR decoding failed, returning EINVAL" ); } while (0) | |||
334 | "XDR decoding failed, returning EINVAL")do { do { if (0) printf ("XDR decoding failed, returning EINVAL" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 334, GF_LOG_ERROR, "XDR decoding failed, returning EINVAL" ); } while (0); | |||
335 | rsp.op_ret = -1; | |||
336 | rsp.op_errno = EINVAL22; | |||
337 | goto out; | |||
338 | } | |||
339 | ||||
340 | if (-1 == rsp.op_ret) { | |||
341 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to get the 'volume file' from server" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 342, GF_LOG_WARNING, "failed to get the 'volume file' from server" ); } while (0) | |||
342 | "failed to get the 'volume file' from server")do { do { if (0) printf ("failed to get the 'volume file' from server" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 342, GF_LOG_WARNING, "failed to get the 'volume file' from server" ); } while (0); | |||
343 | goto out; | |||
344 | } | |||
345 | ||||
346 | out: | |||
347 | CLIENT_STACK_UNWIND (getspec, frame, rsp.op_ret, rsp.op_errno,do { clnt_local_t *__local = frame->local; frame->local = ((void*)0); do { fop_getspec_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if ( !frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "client-handshake.c", __FUNCTION__, 348, GF_LOG_CRITICAL , "!frame"); } while (0); break; } fn = (fop_getspec_cbk_t )frame ->ret; _parent = frame->parent; pthread_spin_lock (& frame->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, rsp .op_ret, rsp.op_errno, rsp.spec); (*__glusterfs_this_location ()) = old_THIS; } while (0); client_local_wipe (__local); } while (0) | |||
348 | rsp.spec)do { clnt_local_t *__local = frame->local; frame->local = ((void*)0); do { fop_getspec_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if ( !frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "client-handshake.c", __FUNCTION__, 348, GF_LOG_CRITICAL , "!frame"); } while (0); break; } fn = (fop_getspec_cbk_t )frame ->ret; _parent = frame->parent; pthread_spin_lock (& frame->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, rsp .op_ret, rsp.op_errno, rsp.spec); (*__glusterfs_this_location ()) = old_THIS; } while (0); client_local_wipe (__local); } while (0); | |||
349 | ||||
350 | /* Don't use 'GF_FREE', this is allocated by libc */ | |||
351 | free (rsp.spec); | |||
352 | ||||
353 | return 0; | |||
354 | } | |||
355 | ||||
356 | int32_t client3_getspec (call_frame_t *frame, xlator_t *this, void *data) | |||
357 | { | |||
358 | clnt_conf_t *conf = NULL((void*)0); | |||
359 | clnt_args_t *args = NULL((void*)0); | |||
360 | gf_getspec_req req = {0,}; | |||
361 | int op_errno = ESTALE116; | |||
362 | int ret = 0; | |||
363 | ||||
364 | if (!frame || !this || !data) | |||
365 | goto unwind; | |||
366 | ||||
367 | args = data; | |||
368 | conf = this->private; | |||
369 | req.flags = args->flags; | |||
370 | req.key = (char *)args->name; | |||
371 | ||||
372 | ret = client_submit_request (this, &req, frame, conf->handshake, | |||
373 | GF_HNDSK_GETSPEC, client3_getspec_cbk, | |||
374 | NULL((void*)0), NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0), | |||
375 | (xdrproc_t)xdr_gf_getspec_req); | |||
376 | ||||
377 | if (ret) { | |||
378 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to send the request"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 379, GF_LOG_WARNING, "failed to send the request"); } while (0) | |||
379 | "failed to send the request")do { do { if (0) printf ("failed to send the request"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 379, GF_LOG_WARNING, "failed to send the request"); } while (0); | |||
380 | } | |||
381 | ||||
382 | return 0; | |||
383 | unwind: | |||
384 | CLIENT_STACK_UNWIND (getspec, frame, -1, op_errno, NULL)do { clnt_local_t *__local = frame->local; frame->local = ((void*)0); do { fop_getspec_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if ( !frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "client-handshake.c", __FUNCTION__, 384, GF_LOG_CRITICAL , "!frame"); } while (0); break; } fn = (fop_getspec_cbk_t )frame ->ret; _parent = frame->parent; pthread_spin_lock (& frame->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); client_local_wipe (__local); } while (0); | |||
385 | return 0; | |||
386 | ||||
387 | } | |||
388 | ||||
389 | int | |||
390 | client_notify_parents_child_up (xlator_t *this) | |||
391 | { | |||
392 | clnt_conf_t *conf = NULL((void*)0); | |||
393 | int ret = 0; | |||
394 | ||||
395 | conf = this->private; | |||
396 | ret = default_notify (this, GF_EVENT_CHILD_UP, NULL((void*)0)); | |||
397 | if (ret) | |||
398 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("notify of CHILD_UP failed"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 399, GF_LOG_INFO, "notify of CHILD_UP failed"); } while (0) | |||
399 | "notify of CHILD_UP failed")do { do { if (0) printf ("notify of CHILD_UP failed"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 399, GF_LOG_INFO, "notify of CHILD_UP failed"); } while (0); | |||
400 | ||||
401 | conf->last_sent_event = GF_EVENT_CHILD_UP; | |||
402 | return 0; | |||
403 | } | |||
404 | ||||
405 | int | |||
406 | clnt_fd_lk_reacquire_failed (xlator_t *this, clnt_fd_ctx_t *fdctx, | |||
407 | clnt_conf_t *conf) | |||
408 | { | |||
409 | int ret = -1; | |||
410 | ||||
411 | GF_VALIDATE_OR_GOTO ("client", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("client", "client-handshake.c", __FUNCTION__, 411, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
412 | GF_VALIDATE_OR_GOTO (this->name, conf, out)do { if (!conf) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conf"); } while (0); _gf_log_callingfn (this->name, "client-handshake.c", __FUNCTION__, 412, GF_LOG_ERROR , "invalid argument: " "conf"); } while (0); goto out; } } while (0); | |||
413 | GF_VALIDATE_OR_GOTO (this->name, fdctx, out)do { if (!fdctx) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "fdctx"); } while (0); _gf_log_callingfn (this->name, "client-handshake.c", __FUNCTION__, 413, GF_LOG_ERROR , "invalid argument: " "fdctx"); } while (0); goto out; } } while (0); | |||
414 | ||||
415 | pthread_mutex_lock (&conf->lock); | |||
416 | { | |||
417 | fdctx->remote_fd = -1; | |||
418 | fdctx->lk_heal_state = GF_LK_HEAL_DONE; | |||
419 | } | |||
420 | pthread_mutex_unlock (&conf->lock); | |||
421 | ||||
422 | ret = 0; | |||
423 | out: | |||
424 | return ret; | |||
425 | } | |||
426 | ||||
427 | int | |||
428 | client_set_lk_version_cbk (struct rpc_req *req, struct iovec *iov, | |||
429 | int count, void *myframe) | |||
430 | { | |||
431 | int32_t ret = -1; | |||
432 | call_frame_t *fr = NULL((void*)0); | |||
433 | gf_set_lk_ver_rsp rsp = {0,}; | |||
434 | ||||
435 | fr = (call_frame_t *) myframe; | |||
436 | GF_VALIDATE_OR_GOTO ("client", fr, out)do { if (!fr) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fr"); } while (0); _gf_log_callingfn ("client", "client-handshake.c", __FUNCTION__, 436, GF_LOG_ERROR , "invalid argument: " "fr"); } while (0); goto out; } } while (0); | |||
437 | ||||
438 | if (req->rpc_status == -1) { | |||
439 | gf_log (fr->this->name, GF_LOG_WARNING,do { do { if (0) printf ("received RPC status error"); } while (0); _gf_log (fr->this->name, "client-handshake.c", __FUNCTION__ , 440, GF_LOG_WARNING, "received RPC status error"); } while ( 0) | |||
440 | "received RPC status error")do { do { if (0) printf ("received RPC status error"); } while (0); _gf_log (fr->this->name, "client-handshake.c", __FUNCTION__ , 440, GF_LOG_WARNING, "received RPC status error"); } while ( 0); | |||
441 | goto out; | |||
442 | } | |||
443 | ||||
444 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_set_lk_ver_rsp); | |||
445 | if (ret < 0) | |||
446 | gf_log (fr->this->name, GF_LOG_WARNING,do { do { if (0) printf ("xdr decoding failed"); } while (0); _gf_log (fr->this->name, "client-handshake.c", __FUNCTION__ , 447, GF_LOG_WARNING, "xdr decoding failed"); } while (0) | |||
447 | "xdr decoding failed")do { do { if (0) printf ("xdr decoding failed"); } while (0); _gf_log (fr->this->name, "client-handshake.c", __FUNCTION__ , 447, GF_LOG_WARNING, "xdr decoding failed"); } while (0); | |||
448 | else | |||
449 | gf_log (fr->this->name, GF_LOG_INFO,do { do { if (0) printf ("Server lk version = %d", rsp.lk_ver ); } while (0); _gf_log (fr->this->name, "client-handshake.c" , __FUNCTION__, 450, GF_LOG_INFO, "Server lk version = %d", rsp .lk_ver); } while (0) | |||
450 | "Server lk version = %d", rsp.lk_ver)do { do { if (0) printf ("Server lk version = %d", rsp.lk_ver ); } while (0); _gf_log (fr->this->name, "client-handshake.c" , __FUNCTION__, 450, GF_LOG_INFO, "Server lk version = %d", rsp .lk_ver); } while (0); | |||
451 | ||||
452 | ret = 0; | |||
453 | out: | |||
454 | if (fr) | |||
455 | STACK_DESTROY (fr->root); | |||
456 | ||||
457 | return ret; | |||
458 | } | |||
459 | ||||
460 | //TODO: Check for all released fdctx and destroy them | |||
461 | int | |||
462 | client_set_lk_version (xlator_t *this) | |||
463 | { | |||
464 | int ret = -1; | |||
465 | clnt_conf_t *conf = NULL((void*)0); | |||
466 | call_frame_t *frame = NULL((void*)0); | |||
467 | gf_set_lk_ver_req req = {0, }; | |||
468 | ||||
469 | GF_VALIDATE_OR_GOTO ("client", this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("client", "client-handshake.c", __FUNCTION__, 469, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto err; } } while (0); | |||
470 | ||||
471 | conf = (clnt_conf_t *) this->private; | |||
472 | ||||
473 | req.lk_ver = client_get_lk_ver (conf); | |||
474 | ret = gf_asprintf (&req.uid, "%s-%s-%d", | |||
475 | this->ctx->process_uuid, this->name, | |||
476 | this->graph->id); | |||
477 | if (ret == -1) | |||
478 | goto err; | |||
479 | ||||
480 | frame = create_frame (this, this->ctx->pool); | |||
481 | if (!frame) { | |||
482 | ret = -1; | |||
483 | goto out; | |||
484 | } | |||
485 | ||||
486 | gf_log (this->name, GF_LOG_DEBUG, "Sending SET_LK_VERSION")do { do { if (0) printf ("Sending SET_LK_VERSION"); } while ( 0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 486, GF_LOG_DEBUG, "Sending SET_LK_VERSION"); } while (0); | |||
487 | ||||
488 | ret = client_submit_request (this, &req, frame, | |||
489 | conf->handshake, | |||
490 | GF_HNDSK_SET_LK_VER, | |||
491 | client_set_lk_version_cbk, | |||
492 | NULL((void*)0), NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0), | |||
493 | (xdrproc_t)xdr_gf_set_lk_ver_req); | |||
494 | out: | |||
495 | GF_FREE (req.uid)__gf_free (req.uid); | |||
496 | return ret; | |||
497 | err: | |||
498 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Failed to send SET_LK_VERSION to server" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 499, GF_LOG_WARNING, "Failed to send SET_LK_VERSION to server" ); } while (0) | |||
499 | "Failed to send SET_LK_VERSION to server")do { do { if (0) printf ("Failed to send SET_LK_VERSION to server" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 499, GF_LOG_WARNING, "Failed to send SET_LK_VERSION to server" ); } while (0); | |||
500 | ||||
501 | return ret; | |||
502 | } | |||
503 | ||||
504 | int | |||
505 | client_fd_lk_count (fd_lk_ctx_t *lk_ctx) | |||
506 | { | |||
507 | int count = 0; | |||
508 | fd_lk_ctx_node_t *fd_lk = NULL((void*)0); | |||
509 | ||||
510 | GF_VALIDATE_OR_GOTO ("client", lk_ctx, err)do { if (!lk_ctx) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "lk_ctx"); } while (0); _gf_log_callingfn ("client", "client-handshake.c", __FUNCTION__, 510, GF_LOG_ERROR , "invalid argument: " "lk_ctx"); } while (0); goto err; } } while (0); | |||
511 | ||||
512 | LOCK (&lk_ctx->lock)pthread_spin_lock (&lk_ctx->lock); | |||
513 | { | |||
514 | list_for_each_entry (fd_lk, &lk_ctx->lk_list, next)for (fd_lk = ((typeof(*fd_lk) *)((char *)((&lk_ctx->lk_list )->next)-(unsigned long)(&((typeof(*fd_lk) *)0)->next ))); &fd_lk->next != (&lk_ctx->lk_list); fd_lk = ((typeof(*fd_lk) *)((char *)(fd_lk->next.next)-(unsigned long )(&((typeof(*fd_lk) *)0)->next)))) | |||
515 | count++; | |||
516 | } | |||
517 | UNLOCK (&lk_ctx->lock)pthread_spin_unlock (&lk_ctx->lock); | |||
518 | ||||
519 | return count; | |||
520 | err: | |||
521 | return -1; | |||
522 | } | |||
523 | ||||
524 | clnt_fd_lk_local_t * | |||
525 | clnt_fd_lk_local_ref (xlator_t *this, clnt_fd_lk_local_t *local) | |||
526 | { | |||
527 | GF_VALIDATE_OR_GOTO (this->name, local, out)do { if (!local) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "local"); } while (0); _gf_log_callingfn (this->name, "client-handshake.c", __FUNCTION__, 527, GF_LOG_ERROR , "invalid argument: " "local"); } while (0); goto out; } } while (0); | |||
528 | ||||
529 | LOCK (&local->lock)pthread_spin_lock (&local->lock); | |||
530 | { | |||
531 | local->ref++; | |||
532 | } | |||
533 | UNLOCK (&local->lock)pthread_spin_unlock (&local->lock); | |||
534 | out: | |||
535 | return local; | |||
536 | } | |||
537 | ||||
538 | int | |||
539 | clnt_fd_lk_local_unref (xlator_t *this, clnt_fd_lk_local_t *local) | |||
540 | { | |||
541 | int ref = -1; | |||
542 | ||||
543 | GF_VALIDATE_OR_GOTO (this->name, local, out)do { if (!local) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "local"); } while (0); _gf_log_callingfn (this->name, "client-handshake.c", __FUNCTION__, 543, GF_LOG_ERROR , "invalid argument: " "local"); } while (0); goto out; } } while (0); | |||
544 | ||||
545 | LOCK (&local->lock)pthread_spin_lock (&local->lock); | |||
546 | { | |||
547 | ref = --local->ref; | |||
548 | } | |||
549 | UNLOCK (&local->lock)pthread_spin_unlock (&local->lock); | |||
550 | ||||
551 | if (ref == 0) { | |||
552 | LOCK_DESTROY (&local->lock)pthread_spin_destroy (&local->lock); | |||
553 | GF_FREE (local)__gf_free (local); | |||
554 | } | |||
555 | out: | |||
556 | return ref; | |||
557 | } | |||
558 | ||||
559 | clnt_fd_lk_local_t * | |||
560 | clnt_fd_lk_local_create (clnt_fd_ctx_t *fdctx) | |||
561 | { | |||
562 | clnt_fd_lk_local_t *local = NULL((void*)0); | |||
563 | ||||
564 | local = GF_CALLOC (1, sizeof (clnt_fd_lk_local_t),__gf_calloc (1, sizeof (clnt_fd_lk_local_t), gf_client_mt_clnt_fd_lk_local_t ) | |||
565 | gf_client_mt_clnt_fd_lk_local_t)__gf_calloc (1, sizeof (clnt_fd_lk_local_t), gf_client_mt_clnt_fd_lk_local_t ); | |||
566 | if (!local) | |||
567 | goto out; | |||
568 | ||||
569 | local->ref = 1; | |||
570 | local->error = _gf_false; | |||
571 | local->fdctx = fdctx; | |||
572 | ||||
573 | LOCK_INIT (&local->lock)pthread_spin_init (&local->lock, 0); | |||
574 | out: | |||
575 | return local; | |||
576 | } | |||
577 | ||||
578 | void | |||
579 | clnt_mark_fd_bad (clnt_conf_t *conf, clnt_fd_ctx_t *fdctx) | |||
580 | { | |||
581 | pthread_mutex_lock (&conf->lock); | |||
582 | { | |||
583 | fdctx->remote_fd = -1; | |||
584 | } | |||
585 | pthread_mutex_unlock (&conf->lock); | |||
586 | } | |||
587 | ||||
588 | int | |||
589 | clnt_release_reopen_fd_cbk (struct rpc_req *req, struct iovec *iov, | |||
590 | int count, void *myframe) | |||
591 | { | |||
592 | xlator_t *this = NULL((void*)0); | |||
593 | call_frame_t *frame = NULL((void*)0); | |||
594 | clnt_conf_t *conf = NULL((void*)0); | |||
595 | clnt_fd_ctx_t *fdctx = NULL((void*)0); | |||
596 | ||||
597 | frame = myframe; | |||
598 | this = frame->this; | |||
599 | fdctx = (clnt_fd_ctx_t *) frame->local; | |||
600 | conf = (clnt_conf_t *) this->private; | |||
601 | ||||
602 | clnt_fd_lk_reacquire_failed (this, fdctx, conf); | |||
603 | ||||
604 | fdctx->reopen_done (fdctx, this); | |||
605 | ||||
606 | frame->local = NULL((void*)0); | |||
607 | STACK_DESTROY (frame->root); | |||
608 | ||||
609 | return 0; | |||
610 | } | |||
611 | ||||
612 | int | |||
613 | clnt_release_reopen_fd (xlator_t *this, clnt_fd_ctx_t *fdctx) | |||
614 | { | |||
615 | int ret = -1; | |||
616 | clnt_conf_t *conf = NULL((void*)0); | |||
617 | call_frame_t *frame = NULL((void*)0); | |||
618 | gfs3_release_req req = {{0,},}; | |||
619 | ||||
620 | conf = (clnt_conf_t *) this->private; | |||
621 | ||||
622 | frame = create_frame (this, this->ctx->pool); | |||
623 | if (!frame) | |||
624 | goto out; | |||
625 | ||||
626 | frame->local = (void *) fdctx; | |||
627 | req.fd = fdctx->remote_fd; | |||
628 | ||||
629 | ret = client_submit_request (this, &req, frame, conf->fops, | |||
630 | GFS3_OP_RELEASE, | |||
631 | clnt_release_reopen_fd_cbk, NULL((void*)0), | |||
632 | NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0), | |||
633 | (xdrproc_t)xdr_gfs3_releasedir_req); | |||
634 | return 0; | |||
635 | out: | |||
636 | if (ret) { | |||
637 | clnt_fd_lk_reacquire_failed (this, fdctx, conf); | |||
638 | fdctx->reopen_done (fdctx, this); | |||
639 | if (frame) { | |||
640 | frame->local = NULL((void*)0); | |||
641 | STACK_DESTROY (frame->root); | |||
642 | } | |||
643 | } | |||
644 | return 0; | |||
645 | } | |||
646 | ||||
647 | int | |||
648 | clnt_reacquire_lock_error (xlator_t *this, clnt_fd_ctx_t *fdctx, | |||
649 | clnt_conf_t *conf) | |||
650 | { | |||
651 | int32_t ret = -1; | |||
652 | ||||
653 | GF_VALIDATE_OR_GOTO ("client", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("client", "client-handshake.c", __FUNCTION__, 653, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
654 | GF_VALIDATE_OR_GOTO (this->name, fdctx, out)do { if (!fdctx) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "fdctx"); } while (0); _gf_log_callingfn (this->name, "client-handshake.c", __FUNCTION__, 654, GF_LOG_ERROR , "invalid argument: " "fdctx"); } while (0); goto out; } } while (0); | |||
655 | GF_VALIDATE_OR_GOTO (this->name, conf, out)do { if (!conf) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conf"); } while (0); _gf_log_callingfn (this->name, "client-handshake.c", __FUNCTION__, 655, GF_LOG_ERROR , "invalid argument: " "conf"); } while (0); goto out; } } while (0); | |||
656 | ||||
657 | clnt_release_reopen_fd (this, fdctx); | |||
658 | ||||
659 | ret = 0; | |||
660 | out: | |||
661 | return ret; | |||
662 | } | |||
663 | ||||
664 | gf_boolean_t | |||
665 | clnt_fd_lk_local_error_status (xlator_t *this, | |||
666 | clnt_fd_lk_local_t *local) | |||
667 | { | |||
668 | gf_boolean_t error = _gf_false; | |||
669 | ||||
670 | LOCK (&local->lock)pthread_spin_lock (&local->lock); | |||
671 | { | |||
672 | error = local->error; | |||
673 | } | |||
674 | UNLOCK (&local->lock)pthread_spin_unlock (&local->lock); | |||
675 | ||||
676 | return error; | |||
677 | } | |||
678 | ||||
679 | int | |||
680 | clnt_fd_lk_local_mark_error (xlator_t *this, | |||
681 | clnt_fd_lk_local_t *local) | |||
682 | { | |||
683 | int32_t ret = -1; | |||
684 | clnt_conf_t *conf = NULL((void*)0); | |||
685 | gf_boolean_t error = _gf_false; | |||
686 | ||||
687 | GF_VALIDATE_OR_GOTO ("client", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("client", "client-handshake.c", __FUNCTION__, 687, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
688 | GF_VALIDATE_OR_GOTO (this->name, local, out)do { if (!local) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "local"); } while (0); _gf_log_callingfn (this->name, "client-handshake.c", __FUNCTION__, 688, GF_LOG_ERROR , "invalid argument: " "local"); } while (0); goto out; } } while (0); | |||
689 | ||||
690 | conf = (clnt_conf_t *) this->private; | |||
691 | ||||
692 | LOCK (&local->lock)pthread_spin_lock (&local->lock); | |||
693 | { | |||
694 | error = local->error; | |||
695 | local->error = _gf_true; | |||
696 | } | |||
697 | UNLOCK (&local->lock)pthread_spin_unlock (&local->lock); | |||
698 | ||||
699 | if (!error) | |||
700 | clnt_reacquire_lock_error (this, local->fdctx, conf); | |||
701 | ret = 0; | |||
702 | out: | |||
703 | return ret; | |||
704 | } | |||
705 | ||||
706 | int | |||
707 | client_reacquire_lock_cbk (struct rpc_req *req, struct iovec *iov, | |||
708 | int count, void *myframe) | |||
709 | { | |||
710 | int32_t ret = -1; | |||
711 | xlator_t *this = NULL((void*)0); | |||
712 | gfs3_lk_rsp rsp = {0,}; | |||
713 | call_frame_t *frame = NULL((void*)0); | |||
714 | clnt_conf_t *conf = NULL((void*)0); | |||
715 | clnt_fd_ctx_t *fdctx = NULL((void*)0); | |||
716 | clnt_fd_lk_local_t *local = NULL((void*)0); | |||
717 | struct gf_flock lock = {0,}; | |||
718 | ||||
719 | frame = (call_frame_t *) myframe; | |||
720 | this = frame->this; | |||
721 | local = (clnt_fd_lk_local_t *) frame->local; | |||
722 | conf = (clnt_conf_t *) this->private; | |||
723 | ||||
724 | if (req->rpc_status == -1) { | |||
725 | gf_log ("client", GF_LOG_WARNING,do { do { if (0) printf ("request failed at rpc"); } while (0 ); _gf_log ("client", "client-handshake.c", __FUNCTION__, 726 , GF_LOG_WARNING, "request failed at rpc"); } while (0) | |||
726 | "request failed at rpc")do { do { if (0) printf ("request failed at rpc"); } while (0 ); _gf_log ("client", "client-handshake.c", __FUNCTION__, 726 , GF_LOG_WARNING, "request failed at rpc"); } while (0); | |||
727 | goto out; | |||
728 | } | |||
729 | ||||
730 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_lk_rsp); | |||
731 | if (ret < 0) { | |||
732 | gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed")do { do { if (0) printf ("XDR decoding failed"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 732 , GF_LOG_ERROR, "XDR decoding failed"); } while (0); | |||
733 | goto out; | |||
734 | } | |||
735 | ||||
736 | if (rsp.op_ret == -1) { | |||
737 | gf_log (this->name, GF_LOG_ERROR, "lock request failed")do { do { if (0) printf ("lock request failed"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 737 , GF_LOG_ERROR, "lock request failed"); } while (0); | |||
738 | ret = -1; | |||
739 | goto out; | |||
740 | } | |||
741 | ||||
742 | fdctx = local->fdctx; | |||
743 | ||||
744 | gf_proto_flock_to_flock (&rsp.flock, &lock); | |||
745 | ||||
746 | gf_log (this->name, GF_LOG_DEBUG, "%s type lock reacquired on file "do { do { if (0) printf ("%s type lock reacquired on file " "with gfid %s from %" "ll" "u" " to %""ll" "u", lock.l_type == 2 ? "F_UNLCK" : (lock .l_type == 0 ? "F_RDLCK" : "F_WRLCK"), uuid_utoa (fdctx->gfid ), lock.l_start, lock.l_start + lock.l_len); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 749, GF_LOG_DEBUG , "%s type lock reacquired on file " "with gfid %s from %""ll" "u" " to %""ll" "u", lock.l_type == 2 ? "F_UNLCK" : (lock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), uuid_utoa (fdctx->gfid), lock .l_start, lock.l_start + lock.l_len); } while (0) | |||
747 | "with gfid %s from %"PRIu64 " to %"PRIu64,do { do { if (0) printf ("%s type lock reacquired on file " "with gfid %s from %" "ll" "u" " to %""ll" "u", lock.l_type == 2 ? "F_UNLCK" : (lock .l_type == 0 ? "F_RDLCK" : "F_WRLCK"), uuid_utoa (fdctx->gfid ), lock.l_start, lock.l_start + lock.l_len); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 749, GF_LOG_DEBUG , "%s type lock reacquired on file " "with gfid %s from %""ll" "u" " to %""ll" "u", lock.l_type == 2 ? "F_UNLCK" : (lock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), uuid_utoa (fdctx->gfid), lock .l_start, lock.l_start + lock.l_len); } while (0) | |||
748 | get_lk_type (lock.l_type), uuid_utoa (fdctx->gfid),do { do { if (0) printf ("%s type lock reacquired on file " "with gfid %s from %" "ll" "u" " to %""ll" "u", lock.l_type == 2 ? "F_UNLCK" : (lock .l_type == 0 ? "F_RDLCK" : "F_WRLCK"), uuid_utoa (fdctx->gfid ), lock.l_start, lock.l_start + lock.l_len); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 749, GF_LOG_DEBUG , "%s type lock reacquired on file " "with gfid %s from %""ll" "u" " to %""ll" "u", lock.l_type == 2 ? "F_UNLCK" : (lock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), uuid_utoa (fdctx->gfid), lock .l_start, lock.l_start + lock.l_len); } while (0) | |||
749 | lock.l_start, lock.l_start + lock.l_len)do { do { if (0) printf ("%s type lock reacquired on file " "with gfid %s from %" "ll" "u" " to %""ll" "u", lock.l_type == 2 ? "F_UNLCK" : (lock .l_type == 0 ? "F_RDLCK" : "F_WRLCK"), uuid_utoa (fdctx->gfid ), lock.l_start, lock.l_start + lock.l_len); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 749, GF_LOG_DEBUG , "%s type lock reacquired on file " "with gfid %s from %""ll" "u" " to %""ll" "u", lock.l_type == 2 ? "F_UNLCK" : (lock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), uuid_utoa (fdctx->gfid), lock .l_start, lock.l_start + lock.l_len); } while (0); | |||
750 | ||||
751 | if (!clnt_fd_lk_local_error_status (this, local) && | |||
752 | clnt_fd_lk_local_unref (this, local) == 0) { | |||
753 | pthread_mutex_lock (&conf->lock); | |||
754 | { | |||
755 | fdctx->lk_heal_state = GF_LK_HEAL_DONE; | |||
756 | } | |||
757 | pthread_mutex_unlock (&conf->lock); | |||
758 | ||||
759 | fdctx->reopen_done (fdctx, this); | |||
760 | } | |||
761 | ||||
762 | ret = 0; | |||
763 | out: | |||
764 | if (ret < 0) { | |||
765 | clnt_fd_lk_local_mark_error (this, local); | |||
766 | ||||
767 | clnt_fd_lk_local_unref (this, local); | |||
768 | } | |||
769 | ||||
770 | frame->local = NULL((void*)0); | |||
771 | STACK_DESTROY (frame->root); | |||
772 | ||||
773 | return ret; | |||
774 | } | |||
775 | ||||
776 | int | |||
777 | _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) | |||
778 | { | |||
779 | int32_t ret = -1; | |||
780 | int32_t gf_cmd = 0; | |||
781 | int32_t gf_type = 0; | |||
782 | gfs3_lk_req req = {{0,},}; | |||
783 | struct gf_flock flock = {0,}; | |||
784 | fd_lk_ctx_t *lk_ctx = NULL((void*)0); | |||
785 | clnt_fd_lk_local_t *local = NULL((void*)0); | |||
786 | fd_lk_ctx_node_t *fd_lk = NULL((void*)0); | |||
787 | call_frame_t *frame = NULL((void*)0); | |||
788 | clnt_conf_t *conf = NULL((void*)0); | |||
789 | ||||
790 | conf = (clnt_conf_t *) this->private; | |||
791 | lk_ctx = fdctx->lk_ctx; | |||
792 | ||||
793 | local = clnt_fd_lk_local_create (fdctx); | |||
794 | if (!local) { | |||
795 | gf_log (this->name, GF_LOG_WARNING, "clnt_fd_lk_local_create "do { do { if (0) printf ("clnt_fd_lk_local_create " "failed, aborting reacquring of locks on %s." , uuid_utoa (fdctx->gfid)); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 797, GF_LOG_WARNING , "clnt_fd_lk_local_create " "failed, aborting reacquring of locks on %s." , uuid_utoa (fdctx->gfid)); } while (0) | |||
796 | "failed, aborting reacquring of locks on %s.",do { do { if (0) printf ("clnt_fd_lk_local_create " "failed, aborting reacquring of locks on %s." , uuid_utoa (fdctx->gfid)); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 797, GF_LOG_WARNING , "clnt_fd_lk_local_create " "failed, aborting reacquring of locks on %s." , uuid_utoa (fdctx->gfid)); } while (0) | |||
797 | uuid_utoa (fdctx->gfid))do { do { if (0) printf ("clnt_fd_lk_local_create " "failed, aborting reacquring of locks on %s." , uuid_utoa (fdctx->gfid)); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 797, GF_LOG_WARNING , "clnt_fd_lk_local_create " "failed, aborting reacquring of locks on %s." , uuid_utoa (fdctx->gfid)); } while (0); | |||
798 | clnt_reacquire_lock_error (this, fdctx, conf); | |||
799 | goto out; | |||
800 | } | |||
801 | ||||
802 | list_for_each_entry (fd_lk, &lk_ctx->lk_list, next)for (fd_lk = ((typeof(*fd_lk) *)((char *)((&lk_ctx->lk_list )->next)-(unsigned long)(&((typeof(*fd_lk) *)0)->next ))); &fd_lk->next != (&lk_ctx->lk_list); fd_lk = ((typeof(*fd_lk) *)((char *)(fd_lk->next.next)-(unsigned long )(&((typeof(*fd_lk) *)0)->next)))) { | |||
803 | memcpy (&flock, &fd_lk->user_flock, | |||
804 | sizeof (struct gf_flock)); | |||
805 | ||||
806 | /* Always send F_SETLK even if the cmd was F_SETLKW */ | |||
807 | /* to avoid frame being blocked if lock cannot be granted. */ | |||
808 | ret = client_cmd_to_gf_cmd (F_SETLK13, &gf_cmd); | |||
809 | if (ret) { | |||
810 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("client_cmd_to_gf_cmd failed, " "aborting reacquiring of locks" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 812, GF_LOG_WARNING, "client_cmd_to_gf_cmd failed, " "aborting reacquiring of locks"); } while (0) | |||
811 | "client_cmd_to_gf_cmd failed, "do { do { if (0) printf ("client_cmd_to_gf_cmd failed, " "aborting reacquiring of locks" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 812, GF_LOG_WARNING, "client_cmd_to_gf_cmd failed, " "aborting reacquiring of locks"); } while (0) | |||
812 | "aborting reacquiring of locks")do { do { if (0) printf ("client_cmd_to_gf_cmd failed, " "aborting reacquiring of locks" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 812, GF_LOG_WARNING, "client_cmd_to_gf_cmd failed, " "aborting reacquiring of locks"); } while (0); | |||
813 | break; | |||
814 | } | |||
815 | ||||
816 | gf_type = client_type_to_gf_type (flock.l_type); | |||
817 | req.fd = fdctx->remote_fd; | |||
818 | req.cmd = gf_cmd; | |||
819 | req.type = gf_type; | |||
820 | (void) gf_proto_flock_from_flock (&req.flock, | |||
821 | &flock); | |||
822 | ||||
823 | memcpy (req.gfid, fdctx->gfid, 16); | |||
824 | ||||
825 | frame = create_frame (this, this->ctx->pool); | |||
826 | if (!frame) { | |||
827 | ret = -1; | |||
828 | break; | |||
829 | } | |||
830 | ||||
831 | frame->local = clnt_fd_lk_local_ref (this, local); | |||
832 | frame->root->lk_owner = fd_lk->user_flock.l_owner; | |||
833 | ||||
834 | ret = client_submit_request (this, &req, frame, | |||
835 | conf->fops, GFS3_OP_LK, | |||
836 | client_reacquire_lock_cbk, | |||
837 | NULL((void*)0), NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0), | |||
838 | (xdrproc_t)xdr_gfs3_lk_req); | |||
839 | if (ret) { | |||
840 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("reacquiring locks failed on file with gfid %s" , uuid_utoa (fdctx->gfid)); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 842, GF_LOG_WARNING , "reacquiring locks failed on file with gfid %s", uuid_utoa ( fdctx->gfid)); } while (0) | |||
841 | "reacquiring locks failed on file with gfid %s",do { do { if (0) printf ("reacquiring locks failed on file with gfid %s" , uuid_utoa (fdctx->gfid)); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 842, GF_LOG_WARNING , "reacquiring locks failed on file with gfid %s", uuid_utoa ( fdctx->gfid)); } while (0) | |||
842 | uuid_utoa (fdctx->gfid))do { do { if (0) printf ("reacquiring locks failed on file with gfid %s" , uuid_utoa (fdctx->gfid)); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 842, GF_LOG_WARNING , "reacquiring locks failed on file with gfid %s", uuid_utoa ( fdctx->gfid)); } while (0); | |||
843 | break; | |||
844 | } | |||
845 | ||||
846 | ret = 0; | |||
847 | frame = NULL((void*)0); | |||
848 | } | |||
849 | ||||
850 | if (local) | |||
851 | (void) clnt_fd_lk_local_unref (this, local); | |||
852 | out: | |||
853 | return ret; | |||
854 | } | |||
855 | ||||
856 | int | |||
857 | client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) | |||
858 | { | |||
859 | int32_t ret = -1; | |||
860 | fd_lk_ctx_t *lk_ctx = NULL((void*)0); | |||
861 | ||||
862 | GF_VALIDATE_OR_GOTO ("client", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("client", "client-handshake.c", __FUNCTION__, 862, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
863 | GF_VALIDATE_OR_GOTO (this->name, fdctx, out)do { if (!fdctx) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "fdctx"); } while (0); _gf_log_callingfn (this->name, "client-handshake.c", __FUNCTION__, 863, GF_LOG_ERROR , "invalid argument: " "fdctx"); } while (0); goto out; } } while (0); | |||
864 | ||||
865 | if (client_fd_lk_list_empty (fdctx->lk_ctx, _gf_false)) { | |||
866 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("fd lock list is empty"); } while (0 ); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 867, GF_LOG_DEBUG, "fd lock list is empty"); } while (0) | |||
867 | "fd lock list is empty")do { do { if (0) printf ("fd lock list is empty"); } while (0 ); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 867, GF_LOG_DEBUG, "fd lock list is empty"); } while (0); | |||
868 | fdctx->reopen_done (fdctx, this); | |||
869 | } else { | |||
870 | lk_ctx = fdctx->lk_ctx; | |||
871 | ||||
872 | LOCK (&lk_ctx->lock)pthread_spin_lock (&lk_ctx->lock); | |||
873 | { | |||
874 | (void) _client_reacquire_lock (this, fdctx); | |||
875 | } | |||
876 | UNLOCK (&lk_ctx->lock)pthread_spin_unlock (&lk_ctx->lock); | |||
877 | } | |||
878 | ret = 0; | |||
879 | out: | |||
880 | return ret; | |||
881 | } | |||
882 | ||||
883 | void | |||
884 | client_default_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this) | |||
885 | { | |||
886 | gf_log_callingfn (this->name, GF_LOG_WARNING,do { do { if (0) printf ("This function should never be called" ); } while (0); _gf_log_callingfn (this->name, "client-handshake.c" , __FUNCTION__, 887, GF_LOG_WARNING, "This function should never be called" ); } while (0) | |||
887 | "This function should never be called")do { do { if (0) printf ("This function should never be called" ); } while (0); _gf_log_callingfn (this->name, "client-handshake.c" , __FUNCTION__, 887, GF_LOG_WARNING, "This function should never be called" ); } while (0); | |||
888 | } | |||
889 | ||||
890 | void | |||
891 | client_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this) | |||
892 | { | |||
893 | clnt_conf_t *conf = NULL((void*)0); | |||
894 | gf_boolean_t destroy = _gf_false; | |||
895 | ||||
896 | conf = this->private; | |||
897 | ||||
898 | pthread_mutex_lock (&conf->lock); | |||
899 | { | |||
900 | fdctx->reopen_attempts = 0; | |||
901 | if (!fdctx->released) | |||
902 | list_add_tail (&fdctx->sfd_pos, &conf->saved_fds); | |||
903 | else | |||
904 | destroy = _gf_true; | |||
905 | fdctx->reopen_done = client_default_reopen_done; | |||
906 | } | |||
907 | pthread_mutex_unlock (&conf->lock); | |||
908 | ||||
909 | if (destroy) | |||
910 | client_fdctx_destroy (this, fdctx); | |||
911 | } | |||
912 | ||||
913 | void | |||
914 | client_child_up_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this) | |||
915 | { | |||
916 | clnt_conf_t *conf = NULL((void*)0); | |||
917 | uint64_t fd_count = 0; | |||
918 | ||||
919 | conf = this->private; | |||
920 | ||||
921 | LOCK (&conf->rec_lock)pthread_spin_lock (&conf->rec_lock); | |||
922 | { | |||
923 | fd_count = --(conf->reopen_fd_count); | |||
924 | } | |||
925 | UNLOCK (&conf->rec_lock)pthread_spin_unlock (&conf->rec_lock); | |||
926 | ||||
927 | client_reopen_done (fdctx, this); | |||
928 | if (fd_count == 0) { | |||
929 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("last fd open'd/lock-self-heal'd - notifying CHILD-UP" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 930, GF_LOG_INFO, "last fd open'd/lock-self-heal'd - notifying CHILD-UP" ); } while (0) | |||
930 | "last fd open'd/lock-self-heal'd - notifying CHILD-UP")do { do { if (0) printf ("last fd open'd/lock-self-heal'd - notifying CHILD-UP" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 930, GF_LOG_INFO, "last fd open'd/lock-self-heal'd - notifying CHILD-UP" ); } while (0); | |||
931 | client_set_lk_version (this); | |||
932 | client_notify_parents_child_up (this); | |||
933 | } | |||
934 | } | |||
935 | ||||
936 | int | |||
937 | client3_3_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, | |||
938 | void *myframe) | |||
939 | { | |||
940 | int32_t ret = -1; | |||
941 | gfs3_open_rsp rsp = {0,}; | |||
942 | gf_boolean_t attempt_lock_recovery = _gf_false; | |||
943 | clnt_local_t *local = NULL((void*)0); | |||
944 | clnt_conf_t *conf = NULL((void*)0); | |||
945 | clnt_fd_ctx_t *fdctx = NULL((void*)0); | |||
946 | call_frame_t *frame = NULL((void*)0); | |||
947 | xlator_t *this = NULL((void*)0); | |||
948 | ||||
949 | frame = myframe; | |||
950 | this = frame->this; | |||
951 | conf = this->private; | |||
952 | local = frame->local; | |||
953 | fdctx = local->fdctx; | |||
954 | ||||
955 | if (-1 == req->rpc_status) { | |||
956 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("received RPC status error, returning ENOTCONN" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 957, GF_LOG_WARNING, "received RPC status error, returning ENOTCONN" ); } while (0) | |||
957 | "received RPC status error, returning ENOTCONN")do { do { if (0) printf ("received RPC status error, returning ENOTCONN" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 957, GF_LOG_WARNING, "received RPC status error, returning ENOTCONN" ); } while (0); | |||
958 | rsp.op_ret = -1; | |||
959 | rsp.op_errno = ENOTCONN107; | |||
960 | goto out; | |||
961 | } | |||
962 | ||||
963 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_open_rsp); | |||
964 | if (ret < 0) { | |||
965 | gf_log (frame->this->name, GF_LOG_ERROR, "XDR decoding failed")do { do { if (0) printf ("XDR decoding failed"); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__ , 965, GF_LOG_ERROR, "XDR decoding failed"); } while (0); | |||
966 | rsp.op_ret = -1; | |||
967 | rsp.op_errno = EINVAL22; | |||
968 | goto out; | |||
969 | } | |||
970 | ||||
971 | if (rsp.op_ret < 0) { | |||
972 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("reopen on %s failed (%s)", local-> loc.path, strerror (rsp.op_errno)); } while (0); _gf_log (frame ->this->name, "client-handshake.c", __FUNCTION__, 974, GF_LOG_WARNING , "reopen on %s failed (%s)", local->loc.path, strerror (rsp .op_errno)); } while (0) | |||
973 | "reopen on %s failed (%s)",do { do { if (0) printf ("reopen on %s failed (%s)", local-> loc.path, strerror (rsp.op_errno)); } while (0); _gf_log (frame ->this->name, "client-handshake.c", __FUNCTION__, 974, GF_LOG_WARNING , "reopen on %s failed (%s)", local->loc.path, strerror (rsp .op_errno)); } while (0) | |||
974 | local->loc.path, strerror (rsp.op_errno))do { do { if (0) printf ("reopen on %s failed (%s)", local-> loc.path, strerror (rsp.op_errno)); } while (0); _gf_log (frame ->this->name, "client-handshake.c", __FUNCTION__, 974, GF_LOG_WARNING , "reopen on %s failed (%s)", local->loc.path, strerror (rsp .op_errno)); } while (0); | |||
975 | } else { | |||
976 | gf_log (frame->this->name, GF_LOG_DEBUG,do { do { if (0) printf ("reopen on %s succeeded (remote-fd = %" "ll" "d"")", local->loc.path, rsp.fd); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__ , 978, GF_LOG_DEBUG, "reopen on %s succeeded (remote-fd = %""ll" "d"")", local->loc.path, rsp.fd); } while (0) | |||
977 | "reopen on %s succeeded (remote-fd = %"PRId64")",do { do { if (0) printf ("reopen on %s succeeded (remote-fd = %" "ll" "d"")", local->loc.path, rsp.fd); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__ , 978, GF_LOG_DEBUG, "reopen on %s succeeded (remote-fd = %""ll" "d"")", local->loc.path, rsp.fd); } while (0) | |||
978 | local->loc.path, rsp.fd)do { do { if (0) printf ("reopen on %s succeeded (remote-fd = %" "ll" "d"")", local->loc.path, rsp.fd); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__ , 978, GF_LOG_DEBUG, "reopen on %s succeeded (remote-fd = %""ll" "d"")", local->loc.path, rsp.fd); } while (0); | |||
979 | } | |||
980 | ||||
981 | if (rsp.op_ret == -1) { | |||
982 | ret = -1; | |||
983 | goto out; | |||
984 | } | |||
985 | ||||
986 | pthread_mutex_lock (&conf->lock); | |||
987 | { | |||
988 | fdctx->remote_fd = rsp.fd; | |||
989 | if (!fdctx->released) { | |||
990 | if (conf->lk_heal && | |||
991 | !client_fd_lk_list_empty (fdctx->lk_ctx, | |||
992 | _gf_false)) { | |||
993 | attempt_lock_recovery = _gf_true; | |||
994 | fdctx->lk_heal_state = GF_LK_HEAL_IN_PROGRESS; | |||
995 | } | |||
996 | } | |||
997 | } | |||
998 | pthread_mutex_unlock (&conf->lock); | |||
999 | ||||
1000 | ret = 0; | |||
1001 | ||||
1002 | if (attempt_lock_recovery) { | |||
1003 | /* Delay decrementing the reopen fd count untill all the | |||
1004 | locks corresponding to this fd are acquired.*/ | |||
1005 | gf_log (this->name, GF_LOG_DEBUG, "acquiring locks "do { do { if (0) printf ("acquiring locks " "on %s", local-> loc.path); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1006, GF_LOG_DEBUG, "acquiring locks " "on %s" , local->loc.path); } while (0) | |||
1006 | "on %s", local->loc.path)do { do { if (0) printf ("acquiring locks " "on %s", local-> loc.path); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1006, GF_LOG_DEBUG, "acquiring locks " "on %s" , local->loc.path); } while (0); | |||
1007 | ret = client_reacquire_lock (frame->this, local->fdctx); | |||
1008 | if (ret) { | |||
1009 | clnt_reacquire_lock_error (this, local->fdctx, conf); | |||
1010 | gf_log (this->name, GF_LOG_WARNING, "acquiring locks "do { do { if (0) printf ("acquiring locks " "failed on %s", local ->loc.path); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1011, GF_LOG_WARNING, "acquiring locks " "failed on %s" , local->loc.path); } while (0) | |||
1011 | "failed on %s", local->loc.path)do { do { if (0) printf ("acquiring locks " "failed on %s", local ->loc.path); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1011, GF_LOG_WARNING, "acquiring locks " "failed on %s" , local->loc.path); } while (0); | |||
1012 | } | |||
1013 | } | |||
1014 | ||||
1015 | out: | |||
1016 | if (!attempt_lock_recovery) | |||
1017 | fdctx->reopen_done (fdctx, this); | |||
1018 | ||||
1019 | frame->local = NULL((void*)0); | |||
1020 | STACK_DESTROY (frame->root); | |||
1021 | ||||
1022 | client_local_wipe (local); | |||
1023 | ||||
1024 | return 0; | |||
1025 | } | |||
1026 | ||||
1027 | int | |||
1028 | client3_3_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, | |||
1029 | void *myframe) | |||
1030 | { | |||
1031 | int32_t ret = -1; | |||
1032 | gfs3_open_rsp rsp = {0,}; | |||
1033 | clnt_local_t *local = NULL((void*)0); | |||
1034 | clnt_conf_t *conf = NULL((void*)0); | |||
1035 | clnt_fd_ctx_t *fdctx = NULL((void*)0); | |||
1036 | call_frame_t *frame = NULL((void*)0); | |||
1037 | ||||
1038 | frame = myframe; | |||
1039 | local = frame->local; | |||
1040 | fdctx = local->fdctx; | |||
1041 | conf = frame->this->private; | |||
1042 | ||||
1043 | ||||
1044 | if (-1 == req->rpc_status) { | |||
1045 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("received RPC status error, returning ENOTCONN" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1046, GF_LOG_WARNING, "received RPC status error, returning ENOTCONN" ); } while (0) | |||
1046 | "received RPC status error, returning ENOTCONN")do { do { if (0) printf ("received RPC status error, returning ENOTCONN" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1046, GF_LOG_WARNING, "received RPC status error, returning ENOTCONN" ); } while (0); | |||
1047 | rsp.op_ret = -1; | |||
1048 | rsp.op_errno = ENOTCONN107; | |||
1049 | goto out; | |||
1050 | } | |||
1051 | ||||
1052 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_opendir_rsp); | |||
1053 | if (ret < 0) { | |||
1054 | gf_log (frame->this->name, GF_LOG_ERROR, "XDR decoding failed")do { do { if (0) printf ("XDR decoding failed"); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__ , 1054, GF_LOG_ERROR, "XDR decoding failed"); } while (0); | |||
1055 | rsp.op_ret = -1; | |||
1056 | rsp.op_errno = EINVAL22; | |||
1057 | goto out; | |||
1058 | } | |||
1059 | ||||
1060 | if (rsp.op_ret < 0) { | |||
1061 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("reopendir on %s failed (%s)", local ->loc.path, strerror (rsp.op_errno)); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__ , 1063, GF_LOG_WARNING, "reopendir on %s failed (%s)", local-> loc.path, strerror (rsp.op_errno)); } while (0) | |||
1062 | "reopendir on %s failed (%s)",do { do { if (0) printf ("reopendir on %s failed (%s)", local ->loc.path, strerror (rsp.op_errno)); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__ , 1063, GF_LOG_WARNING, "reopendir on %s failed (%s)", local-> loc.path, strerror (rsp.op_errno)); } while (0) | |||
1063 | local->loc.path, strerror (rsp.op_errno))do { do { if (0) printf ("reopendir on %s failed (%s)", local ->loc.path, strerror (rsp.op_errno)); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__ , 1063, GF_LOG_WARNING, "reopendir on %s failed (%s)", local-> loc.path, strerror (rsp.op_errno)); } while (0); | |||
1064 | } else { | |||
1065 | gf_log (frame->this->name, GF_LOG_INFO,do { do { if (0) printf ("reopendir on %s succeeded (fd = %""ll" "d"")", local->loc.path, rsp.fd); } while (0); _gf_log (frame ->this->name, "client-handshake.c", __FUNCTION__, 1067, GF_LOG_INFO, "reopendir on %s succeeded (fd = %""ll" "d"")", local->loc.path, rsp.fd); } while (0) | |||
1066 | "reopendir on %s succeeded (fd = %"PRId64")",do { do { if (0) printf ("reopendir on %s succeeded (fd = %""ll" "d"")", local->loc.path, rsp.fd); } while (0); _gf_log (frame ->this->name, "client-handshake.c", __FUNCTION__, 1067, GF_LOG_INFO, "reopendir on %s succeeded (fd = %""ll" "d"")", local->loc.path, rsp.fd); } while (0) | |||
1067 | local->loc.path, rsp.fd)do { do { if (0) printf ("reopendir on %s succeeded (fd = %""ll" "d"")", local->loc.path, rsp.fd); } while (0); _gf_log (frame ->this->name, "client-handshake.c", __FUNCTION__, 1067, GF_LOG_INFO, "reopendir on %s succeeded (fd = %""ll" "d"")", local->loc.path, rsp.fd); } while (0); | |||
1068 | } | |||
1069 | ||||
1070 | if (-1 == rsp.op_ret) { | |||
1071 | ret = -1; | |||
1072 | goto out; | |||
1073 | } | |||
1074 | ||||
1075 | pthread_mutex_lock (&conf->lock); | |||
1076 | { | |||
1077 | fdctx->remote_fd = rsp.fd; | |||
1078 | } | |||
1079 | pthread_mutex_unlock (&conf->lock); | |||
1080 | ||||
1081 | out: | |||
1082 | fdctx->reopen_done (fdctx, frame->this); | |||
1083 | ||||
1084 | frame->local = NULL((void*)0); | |||
1085 | STACK_DESTROY (frame->root); | |||
1086 | client_local_wipe (local); | |||
1087 | ||||
1088 | return 0; | |||
1089 | } | |||
1090 | ||||
1091 | static int | |||
1092 | protocol_client_reopendir (clnt_fd_ctx_t *fdctx, xlator_t *this) | |||
1093 | { | |||
1094 | int ret = -1; | |||
1095 | gfs3_opendir_req req = {{0,},}; | |||
1096 | clnt_local_t *local = NULL((void*)0); | |||
1097 | call_frame_t *frame = NULL((void*)0); | |||
1098 | clnt_conf_t *conf = NULL((void*)0); | |||
1099 | ||||
1100 | conf = this->private; | |||
1101 | ||||
1102 | local = mem_get0 (this->local_pool); | |||
1103 | if (!local) { | |||
1104 | ret = -1; | |||
1105 | goto out; | |||
1106 | } | |||
1107 | local->fdctx = fdctx; | |||
1108 | ||||
1109 | uuid_copy (local->loc.gfid, fdctx->gfid); | |||
1110 | ret = loc_path (&local->loc, NULL((void*)0)); | |||
1111 | if (ret < 0) | |||
1112 | goto out; | |||
1113 | ||||
1114 | frame = create_frame (this, this->ctx->pool); | |||
1115 | if (!frame) { | |||
1116 | ret = -1; | |||
1117 | goto out; | |||
1118 | } | |||
1119 | ||||
1120 | memcpy (req.gfid, fdctx->gfid, 16); | |||
1121 | ||||
1122 | gf_log (frame->this->name, GF_LOG_DEBUG,do { do { if (0) printf ("attempting reopen on %s", local-> loc.path); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1123, GF_LOG_DEBUG, "attempting reopen on %s" , local->loc.path); } while (0) | |||
1123 | "attempting reopen on %s", local->loc.path)do { do { if (0) printf ("attempting reopen on %s", local-> loc.path); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1123, GF_LOG_DEBUG, "attempting reopen on %s" , local->loc.path); } while (0); | |||
1124 | ||||
1125 | frame->local = local; | |||
1126 | ||||
1127 | ret = client_submit_request (this, &req, frame, conf->fops, | |||
1128 | GFS3_OP_OPENDIR, | |||
1129 | client3_3_reopendir_cbk, NULL((void*)0), | |||
1130 | NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0), | |||
1131 | (xdrproc_t)xdr_gfs3_opendir_req); | |||
1132 | if (ret) { | |||
1133 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to send the re-opendir request" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1134, GF_LOG_ERROR, "failed to send the re-opendir request" ); } while (0) | |||
1134 | "failed to send the re-opendir request")do { do { if (0) printf ("failed to send the re-opendir request" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1134, GF_LOG_ERROR, "failed to send the re-opendir request" ); } while (0); | |||
1135 | } | |||
1136 | ||||
1137 | return 0; | |||
1138 | ||||
1139 | out: | |||
1140 | if (frame) { | |||
1141 | frame->local = NULL((void*)0); | |||
1142 | STACK_DESTROY (frame->root); | |||
1143 | } | |||
1144 | ||||
1145 | if (local) | |||
1146 | client_local_wipe (local); | |||
1147 | ||||
1148 | fdctx->reopen_done (fdctx, this); | |||
1149 | ||||
1150 | return 0; | |||
1151 | ||||
1152 | } | |||
1153 | ||||
1154 | static int | |||
1155 | protocol_client_reopenfile (clnt_fd_ctx_t *fdctx, xlator_t *this) | |||
1156 | { | |||
1157 | int ret = -1; | |||
1158 | gfs3_open_req req = {{0,},}; | |||
1159 | clnt_local_t *local = NULL((void*)0); | |||
1160 | call_frame_t *frame = NULL((void*)0); | |||
1161 | clnt_conf_t *conf = NULL((void*)0); | |||
1162 | ||||
1163 | conf = this->private; | |||
1164 | ||||
1165 | frame = create_frame (this, this->ctx->pool); | |||
1166 | if (!frame) { | |||
1167 | ret = -1; | |||
1168 | goto out; | |||
1169 | } | |||
1170 | ||||
1171 | local = mem_get0 (this->local_pool); | |||
1172 | if (!local) { | |||
1173 | ret = -1; | |||
1174 | goto out; | |||
1175 | } | |||
1176 | ||||
1177 | local->fdctx = fdctx; | |||
1178 | uuid_copy (local->loc.gfid, fdctx->gfid); | |||
1179 | ret = loc_path (&local->loc, NULL((void*)0)); | |||
1180 | if (ret < 0) | |||
1181 | goto out; | |||
1182 | ||||
1183 | frame->local = local; | |||
1184 | ||||
1185 | memcpy (req.gfid, fdctx->gfid, 16); | |||
1186 | req.flags = gf_flags_from_flags (fdctx->flags); | |||
1187 | req.flags = req.flags & (~(O_TRUNC01000|O_CREAT0100|O_EXCL0200)); | |||
1188 | ||||
1189 | gf_log (frame->this->name, GF_LOG_DEBUG,do { do { if (0) printf ("attempting reopen on %s", local-> loc.path); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1190, GF_LOG_DEBUG, "attempting reopen on %s" , local->loc.path); } while (0) | |||
1190 | "attempting reopen on %s", local->loc.path)do { do { if (0) printf ("attempting reopen on %s", local-> loc.path); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1190, GF_LOG_DEBUG, "attempting reopen on %s" , local->loc.path); } while (0); | |||
1191 | ||||
1192 | ret = client_submit_request (this, &req, frame, conf->fops, | |||
1193 | GFS3_OP_OPEN, client3_3_reopen_cbk, NULL((void*)0), | |||
1194 | NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0), | |||
1195 | (xdrproc_t)xdr_gfs3_open_req); | |||
1196 | if (ret) { | |||
1197 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to send the re-open request" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1198, GF_LOG_ERROR, "failed to send the re-open request" ); } while (0) | |||
1198 | "failed to send the re-open request")do { do { if (0) printf ("failed to send the re-open request" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1198, GF_LOG_ERROR, "failed to send the re-open request" ); } while (0); | |||
1199 | } | |||
1200 | ||||
1201 | return 0; | |||
1202 | ||||
1203 | out: | |||
1204 | if (frame) { | |||
1205 | frame->local = NULL((void*)0); | |||
1206 | STACK_DESTROY (frame->root); | |||
1207 | } | |||
1208 | ||||
1209 | if (local) | |||
1210 | client_local_wipe (local); | |||
1211 | ||||
1212 | fdctx->reopen_done (fdctx, this); | |||
1213 | ||||
1214 | return 0; | |||
1215 | ||||
1216 | } | |||
1217 | ||||
1218 | static void | |||
1219 | protocol_client_reopen (clnt_fd_ctx_t *fdctx, xlator_t *this) | |||
1220 | { | |||
1221 | if (fdctx->is_dir) | |||
| ||||
1222 | protocol_client_reopendir (fdctx, this); | |||
1223 | else | |||
1224 | protocol_client_reopenfile (fdctx, this); | |||
1225 | } | |||
1226 | ||||
1227 | gf_boolean_t | |||
1228 | __is_fd_reopen_in_progress (clnt_fd_ctx_t *fdctx) | |||
1229 | { | |||
1230 | if (fdctx->reopen_done == client_default_reopen_done) | |||
1231 | return _gf_false; | |||
1232 | return _gf_true; | |||
1233 | } | |||
1234 | ||||
1235 | void | |||
1236 | client_attempt_reopen (fd_t *fd, xlator_t *this) | |||
1237 | { | |||
1238 | clnt_conf_t *conf = NULL((void*)0); | |||
1239 | clnt_fd_ctx_t *fdctx = NULL((void*)0); | |||
1240 | gf_boolean_t reopen = _gf_false; | |||
1241 | ||||
1242 | if (!fd || !this) | |||
1243 | goto out; | |||
1244 | ||||
1245 | conf = this->private; | |||
1246 | pthread_mutex_lock (&conf->lock); | |||
1247 | { | |||
1248 | fdctx = this_fd_get_ctx (fd, this); | |||
1249 | if (!fdctx) | |||
1250 | goto unlock; | |||
1251 | if (__is_fd_reopen_in_progress (fdctx)) | |||
1252 | goto unlock; | |||
1253 | if (fdctx->remote_fd != -1) | |||
1254 | goto unlock; | |||
1255 | ||||
1256 | if (fdctx->reopen_attempts == CLIENT_REOPEN_MAX_ATTEMPTS1024) { | |||
1257 | reopen = _gf_true; | |||
1258 | fdctx->reopen_done = client_reopen_done; | |||
1259 | list_del_init (&fdctx->sfd_pos); | |||
1260 | } else { | |||
1261 | fdctx->reopen_attempts++; | |||
1262 | } | |||
1263 | } | |||
1264 | unlock: | |||
1265 | pthread_mutex_unlock (&conf->lock); | |||
1266 | if (reopen) | |||
1267 | protocol_client_reopen (fdctx, this); | |||
1268 | out: | |||
1269 | return; | |||
1270 | } | |||
1271 | ||||
1272 | int | |||
1273 | client_post_handshake (call_frame_t *frame, xlator_t *this) | |||
1274 | { | |||
1275 | clnt_conf_t *conf = NULL((void*)0); | |||
1276 | clnt_fd_ctx_t *tmp = NULL((void*)0); | |||
1277 | clnt_fd_ctx_t *fdctx = NULL((void*)0); | |||
1278 | struct list_head reopen_head; | |||
1279 | ||||
1280 | int count = 0; | |||
1281 | ||||
1282 | if (!this || !this->private) | |||
1283 | goto out; | |||
1284 | ||||
1285 | conf = this->private; | |||
1286 | INIT_LIST_HEAD (&reopen_head)do { (&reopen_head)->next = (&reopen_head)->prev = &reopen_head; } while (0); | |||
1287 | ||||
1288 | pthread_mutex_lock (&conf->lock); | |||
1289 | { | |||
1290 | list_for_each_entry_safe (fdctx, tmp, &conf->saved_fds,for (fdctx = ((typeof(*fdctx) *)((char *)((&conf->saved_fds )->next)-(unsigned long)(&((typeof(*fdctx) *)0)->sfd_pos ))), tmp = ((typeof(*fdctx) *)((char *)(fdctx->sfd_pos.next )-(unsigned long)(&((typeof(*fdctx) *)0)->sfd_pos))); & fdctx->sfd_pos != (&conf->saved_fds); fdctx = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->sfd_pos.next)-(unsigned long)(&((typeof(*tmp) *)0)->sfd_pos)))) | |||
1291 | sfd_pos)for (fdctx = ((typeof(*fdctx) *)((char *)((&conf->saved_fds )->next)-(unsigned long)(&((typeof(*fdctx) *)0)->sfd_pos ))), tmp = ((typeof(*fdctx) *)((char *)(fdctx->sfd_pos.next )-(unsigned long)(&((typeof(*fdctx) *)0)->sfd_pos))); & fdctx->sfd_pos != (&conf->saved_fds); fdctx = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->sfd_pos.next)-(unsigned long)(&((typeof(*tmp) *)0)->sfd_pos)))) { | |||
1292 | if (fdctx->remote_fd != -1) | |||
1293 | continue; | |||
1294 | ||||
1295 | fdctx->reopen_done = client_child_up_reopen_done; | |||
1296 | list_del_init (&fdctx->sfd_pos); | |||
1297 | list_add_tail (&fdctx->sfd_pos, &reopen_head); | |||
1298 | count++; | |||
1299 | } | |||
1300 | } | |||
1301 | pthread_mutex_unlock (&conf->lock); | |||
1302 | ||||
1303 | /* Delay notifying CHILD_UP to parents | |||
1304 | until all locks are recovered */ | |||
1305 | if (count > 0) { | |||
1306 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("%d fds open - Delaying child_up until they are re-opened" , count); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1308, GF_LOG_INFO, "%d fds open - Delaying child_up until they are re-opened" , count); } while (0) | |||
1307 | "%d fds open - Delaying child_up until they are re-opened",do { do { if (0) printf ("%d fds open - Delaying child_up until they are re-opened" , count); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1308, GF_LOG_INFO, "%d fds open - Delaying child_up until they are re-opened" , count); } while (0) | |||
1308 | count)do { do { if (0) printf ("%d fds open - Delaying child_up until they are re-opened" , count); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1308, GF_LOG_INFO, "%d fds open - Delaying child_up until they are re-opened" , count); } while (0); | |||
1309 | client_save_number_fds (conf, count); | |||
1310 | ||||
1311 | list_for_each_entry_safe (fdctx, tmp, &reopen_head, sfd_pos)for (fdctx = ((typeof(*fdctx) *)((char *)((&reopen_head)-> next)-(unsigned long)(&((typeof(*fdctx) *)0)->sfd_pos) )), tmp = ((typeof(*fdctx) *)((char *)(fdctx->sfd_pos.next )-(unsigned long)(&((typeof(*fdctx) *)0)->sfd_pos))); & fdctx->sfd_pos != (&reopen_head); fdctx = tmp, tmp = ( (typeof(*tmp) *)((char *)(tmp->sfd_pos.next)-(unsigned long )(&((typeof(*tmp) *)0)->sfd_pos)))) { | |||
1312 | list_del_init (&fdctx->sfd_pos); | |||
1313 | ||||
1314 | protocol_client_reopen (fdctx, this); | |||
1315 | } | |||
1316 | } else { | |||
1317 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("No fds to open - notifying all parents child up" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1318, GF_LOG_DEBUG, "No fds to open - notifying all parents child up" ); } while (0) | |||
1318 | "No fds to open - notifying all parents child up")do { do { if (0) printf ("No fds to open - notifying all parents child up" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1318, GF_LOG_DEBUG, "No fds to open - notifying all parents child up" ); } while (0); | |||
1319 | client_set_lk_version (this); | |||
1320 | client_notify_parents_child_up (this); | |||
1321 | } | |||
1322 | out: | |||
1323 | return 0; | |||
1324 | } | |||
1325 | ||||
1326 | int | |||
1327 | client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) | |||
1328 | { | |||
1329 | call_frame_t *frame = NULL((void*)0); | |||
1330 | clnt_conf_t *conf = NULL((void*)0); | |||
1331 | xlator_t *this = NULL((void*)0); | |||
1332 | dict_t *reply = NULL((void*)0); | |||
1333 | char *process_uuid = NULL((void*)0); | |||
1334 | char *remote_error = NULL((void*)0); | |||
1335 | char *remote_subvol = NULL((void*)0); | |||
1336 | gf_setvolume_rsp rsp = {0,}; | |||
1337 | int ret = 0; | |||
1338 | int32_t op_ret = 0; | |||
1339 | int32_t op_errno = 0; | |||
1340 | gf_boolean_t auth_fail = _gf_false; | |||
1341 | uint32_t lk_ver = 0; | |||
1342 | ||||
1343 | frame = myframe; | |||
1344 | this = frame->this; | |||
1345 | conf = this->private; | |||
1346 | ||||
1347 | if (-1 == req->rpc_status) { | |||
| ||||
1348 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("received RPC status error"); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__, 1349, GF_LOG_WARNING, "received RPC status error" ); } while (0) | |||
1349 | "received RPC status error")do { do { if (0) printf ("received RPC status error"); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__, 1349, GF_LOG_WARNING, "received RPC status error" ); } while (0); | |||
1350 | op_ret = -1; | |||
1351 | goto out; | |||
1352 | } | |||
1353 | ||||
1354 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_setvolume_rsp); | |||
1355 | if (ret < 0) { | |||
1356 | gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed")do { do { if (0) printf ("XDR decoding failed"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1356 , GF_LOG_ERROR, "XDR decoding failed"); } while (0); | |||
1357 | op_ret = -1; | |||
1358 | goto out; | |||
1359 | } | |||
1360 | op_ret = rsp.op_ret; | |||
1361 | op_errno = gf_error_to_errno (rsp.op_errno); | |||
1362 | if (-1 == rsp.op_ret) { | |||
1363 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set the volume (%s)", (op_errno )? strerror (op_errno) : "--"); } while (0); _gf_log (frame-> this->name, "client-handshake.c", __FUNCTION__, 1365, GF_LOG_WARNING , "failed to set the volume (%s)", (op_errno)? strerror (op_errno ) : "--"); } while (0) | |||
1364 | "failed to set the volume (%s)",do { do { if (0) printf ("failed to set the volume (%s)", (op_errno )? strerror (op_errno) : "--"); } while (0); _gf_log (frame-> this->name, "client-handshake.c", __FUNCTION__, 1365, GF_LOG_WARNING , "failed to set the volume (%s)", (op_errno)? strerror (op_errno ) : "--"); } while (0) | |||
1365 | (op_errno)? strerror (op_errno) : "--")do { do { if (0) printf ("failed to set the volume (%s)", (op_errno )? strerror (op_errno) : "--"); } while (0); _gf_log (frame-> this->name, "client-handshake.c", __FUNCTION__, 1365, GF_LOG_WARNING , "failed to set the volume (%s)", (op_errno)? strerror (op_errno ) : "--"); } while (0); | |||
1366 | } | |||
1367 | ||||
1368 | reply = dict_new (); | |||
1369 | if (!reply) | |||
1370 | goto out; | |||
1371 | ||||
1372 | if (rsp.dict.dict_len) { | |||
1373 | ret = dict_unserialize (rsp.dict.dict_val, | |||
1374 | rsp.dict.dict_len, &reply); | |||
1375 | if (ret < 0) { | |||
1376 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to unserialize buffer to dict" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1377, GF_LOG_WARNING, "failed to unserialize buffer to dict" ); } while (0) | |||
1377 | "failed to unserialize buffer to dict")do { do { if (0) printf ("failed to unserialize buffer to dict" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1377, GF_LOG_WARNING, "failed to unserialize buffer to dict" ); } while (0); | |||
1378 | goto out; | |||
1379 | } | |||
1380 | } | |||
1381 | ||||
1382 | ret = dict_get_str (reply, "ERROR", &remote_error); | |||
1383 | if (ret < 0) { | |||
1384 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to get ERROR string from reply dict" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1385, GF_LOG_WARNING, "failed to get ERROR string from reply dict" ); } while (0) | |||
1385 | "failed to get ERROR string from reply dict")do { do { if (0) printf ("failed to get ERROR string from reply dict" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1385, GF_LOG_WARNING, "failed to get ERROR string from reply dict" ); } while (0); | |||
1386 | } | |||
1387 | ||||
1388 | ret = dict_get_str (reply, "process-uuid", &process_uuid); | |||
1389 | if (ret < 0) { | |||
1390 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to get 'process-uuid' from reply dict" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1391, GF_LOG_WARNING, "failed to get 'process-uuid' from reply dict" ); } while (0) | |||
1391 | "failed to get 'process-uuid' from reply dict")do { do { if (0) printf ("failed to get 'process-uuid' from reply dict" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1391, GF_LOG_WARNING, "failed to get 'process-uuid' from reply dict" ); } while (0); | |||
1392 | } | |||
1393 | ||||
1394 | if (op_ret < 0) { | |||
1395 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("SETVOLUME on remote-host failed: %s" , remote_error ? remote_error : strerror (op_errno)); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1397, GF_LOG_ERROR, "SETVOLUME on remote-host failed: %s", remote_error ? remote_error : strerror (op_errno)); } while (0) | |||
1396 | "SETVOLUME on remote-host failed: %s",do { do { if (0) printf ("SETVOLUME on remote-host failed: %s" , remote_error ? remote_error : strerror (op_errno)); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1397, GF_LOG_ERROR, "SETVOLUME on remote-host failed: %s", remote_error ? remote_error : strerror (op_errno)); } while (0) | |||
1397 | remote_error ? remote_error : strerror (op_errno))do { do { if (0) printf ("SETVOLUME on remote-host failed: %s" , remote_error ? remote_error : strerror (op_errno)); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1397, GF_LOG_ERROR, "SETVOLUME on remote-host failed: %s", remote_error ? remote_error : strerror (op_errno)); } while (0); | |||
1398 | errno(*__errno_location ()) = op_errno; | |||
1399 | if (remote_error && | |||
1400 | (strcmp ("Authentication failed", remote_error) == 0)) { | |||
1401 | auth_fail = _gf_true; | |||
1402 | op_ret = 0; | |||
1403 | } | |||
1404 | if (op_errno == ESTALE116) { | |||
1405 | ret = default_notify (this, GF_EVENT_VOLFILE_MODIFIED, NULL((void*)0)); | |||
1406 | if (ret) | |||
1407 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("notify of VOLFILE_MODIFIED failed") ; } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1408, GF_LOG_INFO, "notify of VOLFILE_MODIFIED failed"); } while (0) | |||
1408 | "notify of VOLFILE_MODIFIED failed")do { do { if (0) printf ("notify of VOLFILE_MODIFIED failed") ; } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1408, GF_LOG_INFO, "notify of VOLFILE_MODIFIED failed"); } while (0); | |||
1409 | conf->last_sent_event = GF_EVENT_VOLFILE_MODIFIED; | |||
1410 | } | |||
1411 | goto out; | |||
1412 | } | |||
1413 | ||||
1414 | ret = dict_get_str (this->options, "remote-subvolume", | |||
1415 | &remote_subvol); | |||
1416 | if (ret || !remote_subvol) { | |||
1417 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to find key 'remote-subvolume' in the options" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1418, GF_LOG_WARNING, "failed to find key 'remote-subvolume' in the options" ); } while (0) | |||
1418 | "failed to find key 'remote-subvolume' in the options")do { do { if (0) printf ("failed to find key 'remote-subvolume' in the options" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1418, GF_LOG_WARNING, "failed to find key 'remote-subvolume' in the options" ); } while (0); | |||
1419 | goto out; | |||
1420 | } | |||
1421 | ||||
1422 | ret = dict_get_uint32 (reply, "clnt-lk-version", &lk_ver); | |||
1423 | if (ret) { | |||
1424 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to find key 'clnt-lk-version' in the options" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1425, GF_LOG_WARNING, "failed to find key 'clnt-lk-version' in the options" ); } while (0) | |||
1425 | "failed to find key 'clnt-lk-version' in the options")do { do { if (0) printf ("failed to find key 'clnt-lk-version' in the options" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1425, GF_LOG_WARNING, "failed to find key 'clnt-lk-version' in the options" ); } while (0); | |||
1426 | goto out; | |||
1427 | } | |||
1428 | ||||
1429 | gf_log (this->name, GF_LOG_DEBUG, "clnt-lk-version = %d, "do { do { if (0) printf ("clnt-lk-version = %d, " "server-lk-version = %d" , client_get_lk_ver (conf), lk_ver); } while (0); _gf_log (this ->name, "client-handshake.c", __FUNCTION__, 1430, GF_LOG_DEBUG , "clnt-lk-version = %d, " "server-lk-version = %d", client_get_lk_ver (conf), lk_ver); } while (0) | |||
1430 | "server-lk-version = %d", client_get_lk_ver (conf), lk_ver)do { do { if (0) printf ("clnt-lk-version = %d, " "server-lk-version = %d" , client_get_lk_ver (conf), lk_ver); } while (0); _gf_log (this ->name, "client-handshake.c", __FUNCTION__, 1430, GF_LOG_DEBUG , "clnt-lk-version = %d, " "server-lk-version = %d", client_get_lk_ver (conf), lk_ver); } while (0); | |||
1431 | /* TODO: currently setpeer path is broken */ | |||
1432 | /* | |||
1433 | if (process_uuid && req->conn && | |||
1434 | !strcmp (this->ctx->process_uuid, process_uuid)) { | |||
1435 | rpc_transport_t *peer_trans = NULL; | |||
1436 | uint64_t peertrans_int = 0; | |||
1437 | ||||
1438 | ret = dict_get_uint64 (reply, "transport-ptr", | |||
1439 | &peertrans_int); | |||
1440 | if (ret) | |||
1441 | goto out; | |||
1442 | ||||
1443 | gf_log (this->name, GF_LOG_WARNING, | |||
1444 | "attaching to the local volume '%s'", | |||
1445 | remote_subvol); | |||
1446 | ||||
1447 | peer_trans = (void *) (long) (peertrans_int); | |||
1448 | ||||
1449 | rpc_transport_setpeer (req->conn->trans, peer_trans); | |||
1450 | } | |||
1451 | */ | |||
1452 | ||||
1453 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("Connected to %s, attached to remote volume '%s'." , conf->rpc->conn.trans->peerinfo.identifier, remote_subvol ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1456, GF_LOG_INFO, "Connected to %s, attached to remote volume '%s'." , conf->rpc->conn.trans->peerinfo.identifier, remote_subvol ); } while (0) | |||
1454 | "Connected to %s, attached to remote volume '%s'.",do { do { if (0) printf ("Connected to %s, attached to remote volume '%s'." , conf->rpc->conn.trans->peerinfo.identifier, remote_subvol ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1456, GF_LOG_INFO, "Connected to %s, attached to remote volume '%s'." , conf->rpc->conn.trans->peerinfo.identifier, remote_subvol ); } while (0) | |||
1455 | conf->rpc->conn.trans->peerinfo.identifier,do { do { if (0) printf ("Connected to %s, attached to remote volume '%s'." , conf->rpc->conn.trans->peerinfo.identifier, remote_subvol ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1456, GF_LOG_INFO, "Connected to %s, attached to remote volume '%s'." , conf->rpc->conn.trans->peerinfo.identifier, remote_subvol ); } while (0) | |||
1456 | remote_subvol)do { do { if (0) printf ("Connected to %s, attached to remote volume '%s'." , conf->rpc->conn.trans->peerinfo.identifier, remote_subvol ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1456, GF_LOG_INFO, "Connected to %s, attached to remote volume '%s'." , conf->rpc->conn.trans->peerinfo.identifier, remote_subvol ); } while (0); | |||
1457 | ||||
1458 | rpc_clnt_set_connected (&conf->rpc->conn); | |||
1459 | ||||
1460 | op_ret = 0; | |||
1461 | conf->connecting = 0; | |||
1462 | conf->connected = 1; | |||
1463 | ||||
1464 | conf->need_different_port = 0; | |||
1465 | ||||
1466 | if (lk_ver != client_get_lk_ver (conf)) { | |||
1467 | gf_log (this->name, GF_LOG_INFO, "Server and Client "do { do { if (0) printf ("Server and Client " "lk-version numbers are not same, reopening the fds" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1468, GF_LOG_INFO, "Server and Client " "lk-version numbers are not same, reopening the fds" ); } while (0) | |||
1468 | "lk-version numbers are not same, reopening the fds")do { do { if (0) printf ("Server and Client " "lk-version numbers are not same, reopening the fds" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1468, GF_LOG_INFO, "Server and Client " "lk-version numbers are not same, reopening the fds" ); } while (0); | |||
1469 | client_mark_fd_bad (this); | |||
1470 | client_post_handshake (frame, frame->this); | |||
1471 | } else { | |||
1472 | /*TODO: Traverse the saved fd list, and send | |||
1473 | release to the server on fd's that were closed | |||
1474 | during grace period */ | |||
1475 | gf_log (this->name, GF_LOG_INFO, "Server and Client "do { do { if (0) printf ("Server and Client " "lk-version numbers are same, no need to " "reopen the fds"); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1477, GF_LOG_INFO, "Server and Client " "lk-version numbers are same, no need to " "reopen the fds"); } while (0) | |||
1476 | "lk-version numbers are same, no need to "do { do { if (0) printf ("Server and Client " "lk-version numbers are same, no need to " "reopen the fds"); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1477, GF_LOG_INFO, "Server and Client " "lk-version numbers are same, no need to " "reopen the fds"); } while (0) | |||
1477 | "reopen the fds")do { do { if (0) printf ("Server and Client " "lk-version numbers are same, no need to " "reopen the fds"); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1477, GF_LOG_INFO, "Server and Client " "lk-version numbers are same, no need to " "reopen the fds"); } while (0); | |||
1478 | } | |||
1479 | ||||
1480 | out: | |||
1481 | if (auth_fail) { | |||
1482 | gf_log (this->name, GF_LOG_INFO, "sending AUTH_FAILED event")do { do { if (0) printf ("sending AUTH_FAILED event"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1482, GF_LOG_INFO, "sending AUTH_FAILED event"); } while (0 ); | |||
1483 | ret = default_notify (this, GF_EVENT_AUTH_FAILED, NULL((void*)0)); | |||
1484 | if (ret) | |||
1485 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("notify of AUTH_FAILED failed"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1486, GF_LOG_INFO, "notify of AUTH_FAILED failed"); } while (0) | |||
1486 | "notify of AUTH_FAILED failed")do { do { if (0) printf ("notify of AUTH_FAILED failed"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1486, GF_LOG_INFO, "notify of AUTH_FAILED failed"); } while (0); | |||
1487 | conf->connecting = 0; | |||
1488 | conf->connected = 0; | |||
1489 | conf->last_sent_event = GF_EVENT_AUTH_FAILED; | |||
1490 | ret = -1; | |||
1491 | } | |||
1492 | if (-1 == op_ret) { | |||
1493 | /* Let the connection/re-connection happen in | |||
1494 | * background, for now, don't hang here, | |||
1495 | * tell the parents that i am all ok.. | |||
1496 | */ | |||
1497 | gf_log (this->name, GF_LOG_INFO, "sending CHILD_CONNECTING event")do { do { if (0) printf ("sending CHILD_CONNECTING event"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1497, GF_LOG_INFO, "sending CHILD_CONNECTING event"); } while (0); | |||
1498 | ret = default_notify (this, GF_EVENT_CHILD_CONNECTING, NULL((void*)0)); | |||
1499 | if (ret) | |||
1500 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("notify of CHILD_CONNECTING failed") ; } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1501, GF_LOG_INFO, "notify of CHILD_CONNECTING failed"); } while (0) | |||
1501 | "notify of CHILD_CONNECTING failed")do { do { if (0) printf ("notify of CHILD_CONNECTING failed") ; } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1501, GF_LOG_INFO, "notify of CHILD_CONNECTING failed"); } while (0); | |||
1502 | conf->last_sent_event = GF_EVENT_CHILD_CONNECTING; | |||
1503 | conf->connecting= 1; | |||
1504 | ret = 0; | |||
1505 | } | |||
1506 | ||||
1507 | free (rsp.dict.dict_val); | |||
1508 | ||||
1509 | STACK_DESTROY (frame->root); | |||
1510 | ||||
1511 | if (reply) | |||
1512 | dict_unref (reply); | |||
1513 | ||||
1514 | return ret; | |||
1515 | } | |||
1516 | ||||
1517 | int | |||
1518 | client_setvolume (xlator_t *this, struct rpc_clnt *rpc) | |||
1519 | { | |||
1520 | int ret = 0; | |||
1521 | gf_setvolume_req req = {{0,},}; | |||
1522 | call_frame_t *fr = NULL((void*)0); | |||
1523 | char *process_uuid_xl = NULL((void*)0); | |||
1524 | clnt_conf_t *conf = NULL((void*)0); | |||
1525 | dict_t *options = NULL((void*)0); | |||
1526 | ||||
1527 | options = this->options; | |||
1528 | conf = this->private; | |||
1529 | ||||
1530 | if (conf->fops) { | |||
1531 | ret = dict_set_int32 (options, "fops-version", | |||
1532 | conf->fops->prognum); | |||
1533 | if (ret < 0) { | |||
1534 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to set version-fops(%d) in handshake msg" , conf->fops->prognum); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 1536, GF_LOG_ERROR, "failed to set version-fops(%d) in handshake msg", conf-> fops->prognum); } while (0) | |||
1535 | "failed to set version-fops(%d) in handshake msg",do { do { if (0) printf ("failed to set version-fops(%d) in handshake msg" , conf->fops->prognum); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 1536, GF_LOG_ERROR, "failed to set version-fops(%d) in handshake msg", conf-> fops->prognum); } while (0) | |||
1536 | conf->fops->prognum)do { do { if (0) printf ("failed to set version-fops(%d) in handshake msg" , conf->fops->prognum); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 1536, GF_LOG_ERROR, "failed to set version-fops(%d) in handshake msg", conf-> fops->prognum); } while (0); | |||
1537 | goto fail; | |||
1538 | } | |||
1539 | } | |||
1540 | ||||
1541 | if (conf->mgmt) { | |||
1542 | ret = dict_set_int32 (options, "mgmt-version", conf->mgmt->prognum); | |||
1543 | if (ret < 0) { | |||
1544 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to set version-mgmt(%d) in handshake msg" , conf->mgmt->prognum); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 1546, GF_LOG_ERROR, "failed to set version-mgmt(%d) in handshake msg", conf-> mgmt->prognum); } while (0) | |||
1545 | "failed to set version-mgmt(%d) in handshake msg",do { do { if (0) printf ("failed to set version-mgmt(%d) in handshake msg" , conf->mgmt->prognum); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 1546, GF_LOG_ERROR, "failed to set version-mgmt(%d) in handshake msg", conf-> mgmt->prognum); } while (0) | |||
1546 | conf->mgmt->prognum)do { do { if (0) printf ("failed to set version-mgmt(%d) in handshake msg" , conf->mgmt->prognum); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 1546, GF_LOG_ERROR, "failed to set version-mgmt(%d) in handshake msg", conf-> mgmt->prognum); } while (0); | |||
1547 | goto fail; | |||
1548 | } | |||
1549 | } | |||
1550 | ||||
1551 | /* With multiple graphs possible in the same process, we need a | |||
1552 | field to bring the uniqueness. Graph-ID should be enough to get the | |||
1553 | job done | |||
1554 | */ | |||
1555 | ret = gf_asprintf (&process_uuid_xl, "%s-%s-%d", | |||
1556 | this->ctx->process_uuid, this->name, | |||
1557 | this->graph->id); | |||
1558 | if (-1 == ret) { | |||
1559 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("asprintf failed while setting process_uuid" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1560, GF_LOG_ERROR, "asprintf failed while setting process_uuid" ); } while (0) | |||
1560 | "asprintf failed while setting process_uuid")do { do { if (0) printf ("asprintf failed while setting process_uuid" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1560, GF_LOG_ERROR, "asprintf failed while setting process_uuid" ); } while (0); | |||
1561 | goto fail; | |||
1562 | } | |||
1563 | ||||
1564 | ret = dict_set_dynstr (options, "process-uuid", process_uuid_xl); | |||
1565 | if (ret < 0) { | |||
1566 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to set process-uuid(%s) in handshake msg" , process_uuid_xl); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1568, GF_LOG_ERROR, "failed to set process-uuid(%s) in handshake msg" , process_uuid_xl); } while (0) | |||
1567 | "failed to set process-uuid(%s) in handshake msg",do { do { if (0) printf ("failed to set process-uuid(%s) in handshake msg" , process_uuid_xl); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1568, GF_LOG_ERROR, "failed to set process-uuid(%s) in handshake msg" , process_uuid_xl); } while (0) | |||
1568 | process_uuid_xl)do { do { if (0) printf ("failed to set process-uuid(%s) in handshake msg" , process_uuid_xl); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1568, GF_LOG_ERROR, "failed to set process-uuid(%s) in handshake msg" , process_uuid_xl); } while (0); | |||
1569 | goto fail; | |||
1570 | } | |||
1571 | ||||
1572 | ret = dict_set_str (options, "client-version", PACKAGE_VERSION"3git"); | |||
1573 | if (ret < 0) { | |||
1574 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set client-version(%s) in handshake msg" , "3git"); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1576, GF_LOG_WARNING, "failed to set client-version(%s) in handshake msg" , "3git"); } while (0) | |||
1575 | "failed to set client-version(%s) in handshake msg",do { do { if (0) printf ("failed to set client-version(%s) in handshake msg" , "3git"); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1576, GF_LOG_WARNING, "failed to set client-version(%s) in handshake msg" , "3git"); } while (0) | |||
1576 | PACKAGE_VERSION)do { do { if (0) printf ("failed to set client-version(%s) in handshake msg" , "3git"); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1576, GF_LOG_WARNING, "failed to set client-version(%s) in handshake msg" , "3git"); } while (0); | |||
1577 | } | |||
1578 | ||||
1579 | if (this->ctx->cmd_args.volfile_server) { | |||
1580 | if (this->ctx->cmd_args.volfile_id) { | |||
1581 | ret = dict_set_str (options, "volfile-key", | |||
1582 | this->ctx->cmd_args.volfile_id); | |||
1583 | if (ret) | |||
1584 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to set 'volfile-key'"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1585, GF_LOG_ERROR, "failed to set 'volfile-key'"); } while (0) | |||
1585 | "failed to set 'volfile-key'")do { do { if (0) printf ("failed to set 'volfile-key'"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1585, GF_LOG_ERROR, "failed to set 'volfile-key'"); } while (0); | |||
1586 | } | |||
1587 | ret = dict_set_uint32 (options, "volfile-checksum", | |||
1588 | this->graph->volfile_checksum); | |||
1589 | if (ret) | |||
1590 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to set 'volfile-checksum'"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1591, GF_LOG_ERROR, "failed to set 'volfile-checksum'"); } while (0) | |||
1591 | "failed to set 'volfile-checksum'")do { do { if (0) printf ("failed to set 'volfile-checksum'"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1591, GF_LOG_ERROR, "failed to set 'volfile-checksum'"); } while (0); | |||
1592 | } | |||
1593 | ||||
1594 | ret = dict_set_int16 (options, "clnt-lk-version", | |||
1595 | client_get_lk_ver (conf)); | |||
1596 | if (ret < 0) { | |||
1597 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set clnt-lk-version(%""u" ") in handshake msg", client_get_lk_ver (conf)); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1599 , GF_LOG_WARNING, "failed to set clnt-lk-version(%""u"") in handshake msg" , client_get_lk_ver (conf)); } while (0) | |||
1598 | "failed to set clnt-lk-version(%"PRIu32") in handshake msg",do { do { if (0) printf ("failed to set clnt-lk-version(%""u" ") in handshake msg", client_get_lk_ver (conf)); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1599 , GF_LOG_WARNING, "failed to set clnt-lk-version(%""u"") in handshake msg" , client_get_lk_ver (conf)); } while (0) | |||
1599 | client_get_lk_ver (conf))do { do { if (0) printf ("failed to set clnt-lk-version(%""u" ") in handshake msg", client_get_lk_ver (conf)); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1599 , GF_LOG_WARNING, "failed to set clnt-lk-version(%""u"") in handshake msg" , client_get_lk_ver (conf)); } while (0); | |||
1600 | } | |||
1601 | ||||
1602 | ret = dict_serialized_length (options); | |||
1603 | if (ret < 0) { | |||
1604 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to get serialized length of dict" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1605, GF_LOG_ERROR, "failed to get serialized length of dict" ); } while (0) | |||
1605 | "failed to get serialized length of dict")do { do { if (0) printf ("failed to get serialized length of dict" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1605, GF_LOG_ERROR, "failed to get serialized length of dict" ); } while (0); | |||
1606 | ret = -1; | |||
1607 | goto fail; | |||
1608 | } | |||
1609 | req.dict.dict_len = ret; | |||
1610 | req.dict.dict_val = GF_CALLOC (1, req.dict.dict_len,__gf_calloc (1, req.dict.dict_len, gf_client_mt_clnt_req_buf_t ) | |||
1611 | gf_client_mt_clnt_req_buf_t)__gf_calloc (1, req.dict.dict_len, gf_client_mt_clnt_req_buf_t ); | |||
1612 | ret = dict_serialize (options, req.dict.dict_val); | |||
1613 | if (ret < 0) { | |||
1614 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to serialize dictionary"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1615, GF_LOG_ERROR, "failed to serialize dictionary"); } while (0) | |||
1615 | "failed to serialize dictionary")do { do { if (0) printf ("failed to serialize dictionary"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1615, GF_LOG_ERROR, "failed to serialize dictionary"); } while (0); | |||
1616 | goto fail; | |||
1617 | } | |||
1618 | ||||
1619 | fr = create_frame (this, this->ctx->pool); | |||
1620 | if (!fr) | |||
1621 | goto fail; | |||
1622 | ||||
1623 | ret = client_submit_request (this, &req, fr, conf->handshake, | |||
1624 | GF_HNDSK_SETVOLUME, client_setvolume_cbk, | |||
1625 | NULL((void*)0), NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0), | |||
1626 | (xdrproc_t)xdr_gf_setvolume_req); | |||
1627 | ||||
1628 | fail: | |||
1629 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); | |||
1630 | ||||
1631 | return ret; | |||
1632 | } | |||
1633 | ||||
1634 | int | |||
1635 | select_server_supported_programs (xlator_t *this, gf_prog_detail *prog) | |||
1636 | { | |||
1637 | gf_prog_detail *trav = NULL((void*)0); | |||
1638 | clnt_conf_t *conf = NULL((void*)0); | |||
1639 | int ret = -1; | |||
1640 | ||||
1641 | if (!this || !prog) { | |||
1642 | gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("xlator not found OR RPC program not found" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "client-handshake.c", __FUNCTION__, 1643, GF_LOG_WARNING, "xlator not found OR RPC program not found" ); } while (0) | |||
1643 | "xlator not found OR RPC program not found")do { do { if (0) printf ("xlator not found OR RPC program not found" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "client-handshake.c", __FUNCTION__, 1643, GF_LOG_WARNING, "xlator not found OR RPC program not found" ); } while (0); | |||
1644 | goto out; | |||
1645 | } | |||
1646 | ||||
1647 | conf = this->private; | |||
1648 | trav = prog; | |||
1649 | ||||
1650 | while (trav) { | |||
1651 | /* Select 'programs' */ | |||
1652 | if ((clnt3_3_fop_prog.prognum == trav->prognum) && | |||
1653 | (clnt3_3_fop_prog.progver == trav->progver)) { | |||
1654 | conf->fops = &clnt3_3_fop_prog; | |||
1655 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("Using Program %s, Num (%""ll" "d""), " "Version (%""ll" "d"")", trav->progname, trav->prognum , trav->progver); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1658, GF_LOG_INFO, "Using Program %s, Num (%" "ll" "d""), " "Version (%""ll" "d"")", trav->progname, trav ->prognum, trav->progver); } while (0) | |||
1656 | "Using Program %s, Num (%"PRId64"), "do { do { if (0) printf ("Using Program %s, Num (%""ll" "d""), " "Version (%""ll" "d"")", trav->progname, trav->prognum , trav->progver); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1658, GF_LOG_INFO, "Using Program %s, Num (%" "ll" "d""), " "Version (%""ll" "d"")", trav->progname, trav ->prognum, trav->progver); } while (0) | |||
1657 | "Version (%"PRId64")",do { do { if (0) printf ("Using Program %s, Num (%""ll" "d""), " "Version (%""ll" "d"")", trav->progname, trav->prognum , trav->progver); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1658, GF_LOG_INFO, "Using Program %s, Num (%" "ll" "d""), " "Version (%""ll" "d"")", trav->progname, trav ->prognum, trav->progver); } while (0) | |||
1658 | trav->progname, trav->prognum, trav->progver)do { do { if (0) printf ("Using Program %s, Num (%""ll" "d""), " "Version (%""ll" "d"")", trav->progname, trav->prognum , trav->progver); } while (0); _gf_log (this->name, "client-handshake.c" , __FUNCTION__, 1658, GF_LOG_INFO, "Using Program %s, Num (%" "ll" "d""), " "Version (%""ll" "d"")", trav->progname, trav ->prognum, trav->progver); } while (0); | |||
1659 | ret = 0; | |||
1660 | } | |||
1661 | if (ret) { | |||
1662 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("%s (%""ll" "d"") not supported", trav ->progname, trav->progver); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 1664, GF_LOG_TRACE, "%s (%""ll" "d"") not supported", trav->progname, trav-> progver); } while (0) | |||
1663 | "%s (%"PRId64") not supported", trav->progname,do { do { if (0) printf ("%s (%""ll" "d"") not supported", trav ->progname, trav->progver); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 1664, GF_LOG_TRACE, "%s (%""ll" "d"") not supported", trav->progname, trav-> progver); } while (0) | |||
1664 | trav->progver)do { do { if (0) printf ("%s (%""ll" "d"") not supported", trav ->progname, trav->progver); } while (0); _gf_log (this-> name, "client-handshake.c", __FUNCTION__, 1664, GF_LOG_TRACE, "%s (%""ll" "d"") not supported", trav->progname, trav-> progver); } while (0); | |||
1665 | } | |||
1666 | trav = trav->next; | |||
1667 | } | |||
1668 | ||||
1669 | out: | |||
1670 | return ret; | |||
1671 | } | |||
1672 | ||||
1673 | ||||
1674 | int | |||
1675 | server_has_portmap (xlator_t *this, gf_prog_detail *prog) | |||
1676 | { | |||
1677 | gf_prog_detail *trav = NULL((void*)0); | |||
1678 | int ret = -1; | |||
1679 | ||||
1680 | if (!this || !prog) { | |||
1681 | gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("xlator not found OR RPC program not found" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "client-handshake.c", __FUNCTION__, 1682, GF_LOG_WARNING, "xlator not found OR RPC program not found" ); } while (0) | |||
1682 | "xlator not found OR RPC program not found")do { do { if (0) printf ("xlator not found OR RPC program not found" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "client-handshake.c", __FUNCTION__, 1682, GF_LOG_WARNING, "xlator not found OR RPC program not found" ); } while (0); | |||
1683 | goto out; | |||
1684 | } | |||
1685 | ||||
1686 | trav = prog; | |||
1687 | ||||
1688 | while (trav) { | |||
1689 | if ((trav->prognum == GLUSTER_PMAP_PROGRAM34123456) && | |||
1690 | (trav->progver == GLUSTER_PMAP_VERSION1)) { | |||
1691 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("detected portmapper on server"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1692, GF_LOG_DEBUG, "detected portmapper on server"); } while (0) | |||
1692 | "detected portmapper on server")do { do { if (0) printf ("detected portmapper on server"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1692, GF_LOG_DEBUG, "detected portmapper on server"); } while (0); | |||
1693 | ret = 0; | |||
1694 | break; | |||
1695 | } | |||
1696 | trav = trav->next; | |||
1697 | } | |||
1698 | ||||
1699 | out: | |||
1700 | return ret; | |||
1701 | } | |||
1702 | ||||
1703 | ||||
1704 | int | |||
1705 | client_query_portmap_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) | |||
1706 | { | |||
1707 | struct pmap_port_by_brick_rsp rsp = {0,}; | |||
1708 | call_frame_t *frame = NULL((void*)0); | |||
1709 | clnt_conf_t *conf = NULL((void*)0); | |||
1710 | int ret = -1; | |||
1711 | struct rpc_clnt_config config = {0, }; | |||
1712 | xlator_t *this = NULL((void*)0); | |||
1713 | ||||
1714 | frame = myframe; | |||
1715 | if (!frame || !frame->this || !frame->this->private) { | |||
1716 | gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("frame not found with rpc request"); } while (0); _gf_log ((*__glusterfs_this_location())->name , "client-handshake.c", __FUNCTION__, 1717, GF_LOG_WARNING, "frame not found with rpc request" ); } while (0) | |||
1717 | "frame not found with rpc request")do { do { if (0) printf ("frame not found with rpc request"); } while (0); _gf_log ((*__glusterfs_this_location())->name , "client-handshake.c", __FUNCTION__, 1717, GF_LOG_WARNING, "frame not found with rpc request" ); } while (0); | |||
1718 | goto out; | |||
1719 | } | |||
1720 | this = frame->this; | |||
1721 | conf = frame->this->private; | |||
1722 | ||||
1723 | if (-1 == req->rpc_status) { | |||
1724 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("received RPC status error, try again later" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1725, GF_LOG_WARNING, "received RPC status error, try again later" ); } while (0) | |||
1725 | "received RPC status error, try again later")do { do { if (0) printf ("received RPC status error, try again later" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1725, GF_LOG_WARNING, "received RPC status error, try again later" ); } while (0); | |||
1726 | goto out; | |||
1727 | } | |||
1728 | ||||
1729 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_pmap_port_by_brick_rsp); | |||
1730 | if (ret < 0) { | |||
1731 | gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed")do { do { if (0) printf ("XDR decoding failed"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1731 , GF_LOG_ERROR, "XDR decoding failed"); } while (0); | |||
1732 | goto out; | |||
1733 | } | |||
1734 | ||||
1735 | if (-1 == rsp.op_ret) { | |||
1736 | ret = -1; | |||
1737 | gf_log (this->name, ((!conf->portmap_err_logged) ?do { do { if (0) printf ("failed to get the port number for remote subvolume. " "Please run 'gluster volume status' on server to see " "if brick process is running." ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1741, ((!conf->portmap_err_logged) ? GF_LOG_ERROR : GF_LOG_DEBUG), "failed to get the port number for remote subvolume. " "Please run 'gluster volume status' on server to see " "if brick process is running." ); } while (0) | |||
1738 | GF_LOG_ERROR : GF_LOG_DEBUG),do { do { if (0) printf ("failed to get the port number for remote subvolume. " "Please run 'gluster volume status' on server to see " "if brick process is running." ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1741, ((!conf->portmap_err_logged) ? GF_LOG_ERROR : GF_LOG_DEBUG), "failed to get the port number for remote subvolume. " "Please run 'gluster volume status' on server to see " "if brick process is running." ); } while (0) | |||
1739 | "failed to get the port number for remote subvolume. "do { do { if (0) printf ("failed to get the port number for remote subvolume. " "Please run 'gluster volume status' on server to see " "if brick process is running." ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1741, ((!conf->portmap_err_logged) ? GF_LOG_ERROR : GF_LOG_DEBUG), "failed to get the port number for remote subvolume. " "Please run 'gluster volume status' on server to see " "if brick process is running." ); } while (0) | |||
1740 | "Please run 'gluster volume status' on server to see "do { do { if (0) printf ("failed to get the port number for remote subvolume. " "Please run 'gluster volume status' on server to see " "if brick process is running." ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1741, ((!conf->portmap_err_logged) ? GF_LOG_ERROR : GF_LOG_DEBUG), "failed to get the port number for remote subvolume. " "Please run 'gluster volume status' on server to see " "if brick process is running." ); } while (0) | |||
1741 | "if brick process is running.")do { do { if (0) printf ("failed to get the port number for remote subvolume. " "Please run 'gluster volume status' on server to see " "if brick process is running." ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1741, ((!conf->portmap_err_logged) ? GF_LOG_ERROR : GF_LOG_DEBUG), "failed to get the port number for remote subvolume. " "Please run 'gluster volume status' on server to see " "if brick process is running." ); } while (0); | |||
1742 | conf->portmap_err_logged = 1; | |||
1743 | goto out; | |||
1744 | } | |||
1745 | ||||
1746 | conf->portmap_err_logged = 0; | |||
1747 | ||||
1748 | config.remote_port = rsp.port; | |||
1749 | rpc_clnt_reconfig (conf->rpc, &config); | |||
1750 | ||||
1751 | conf->skip_notify = 1; | |||
1752 | conf->quick_reconnect = 1; | |||
1753 | ||||
1754 | out: | |||
1755 | if (frame) | |||
1756 | STACK_DESTROY (frame->root); | |||
1757 | ||||
1758 | if (conf) { | |||
1759 | /* Need this to connect the same transport on different port */ | |||
1760 | /* ie, glusterd to glusterfsd */ | |||
1761 | rpc_transport_disconnect (conf->rpc->conn.trans); | |||
1762 | } | |||
1763 | ||||
1764 | return ret; | |||
1765 | } | |||
1766 | ||||
1767 | ||||
1768 | int | |||
1769 | client_query_portmap (xlator_t *this, struct rpc_clnt *rpc) | |||
1770 | { | |||
1771 | int ret = -1; | |||
1772 | pmap_port_by_brick_req req = {0,}; | |||
1773 | call_frame_t *fr = NULL((void*)0); | |||
1774 | clnt_conf_t *conf = NULL((void*)0); | |||
1775 | dict_t *options = NULL((void*)0); | |||
1776 | char *remote_subvol = NULL((void*)0); | |||
1777 | char *xprt = NULL((void*)0); | |||
1778 | char brick_name[PATH_MAX4096] = {0,}; | |||
1779 | ||||
1780 | options = this->options; | |||
1781 | conf = this->private; | |||
1782 | ||||
1783 | ret = dict_get_str (options, "remote-subvolume", &remote_subvol); | |||
1784 | if (ret < 0) { | |||
1785 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("remote-subvolume not set in volfile" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1786, GF_LOG_ERROR, "remote-subvolume not set in volfile" ); } while (0) | |||
1786 | "remote-subvolume not set in volfile")do { do { if (0) printf ("remote-subvolume not set in volfile" ); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__, 1786, GF_LOG_ERROR, "remote-subvolume not set in volfile" ); } while (0); | |||
1787 | goto fail; | |||
1788 | } | |||
1789 | ||||
1790 | req.brick = remote_subvol; | |||
1791 | ||||
1792 | /* FIXME: Dirty work around */ | |||
1793 | if (!dict_get_str (options, "transport-type", &xprt)) { | |||
1794 | /* This logic is required only in case of 'rdma' client | |||
1795 | transport-type and the volume is of 'tcp,rdma' | |||
1796 | transport type. */ | |||
1797 | if (!strcmp (xprt, "rdma")) { | |||
1798 | if (!conf->need_different_port) { | |||
1799 | snprintf (brick_name, PATH_MAX4096, "%s.rdma", | |||
1800 | remote_subvol); | |||
1801 | req.brick = brick_name; | |||
1802 | conf->need_different_port = 1; | |||
1803 | conf->skip_notify = 1; | |||
1804 | } else { | |||
1805 | conf->need_different_port = 0; | |||
1806 | conf->skip_notify = 0; | |||
1807 | } | |||
1808 | } | |||
1809 | } | |||
1810 | ||||
1811 | fr = create_frame (this, this->ctx->pool); | |||
1812 | if (!fr) { | |||
1813 | ret = -1; | |||
1814 | goto fail; | |||
1815 | } | |||
1816 | ||||
1817 | ret = client_submit_request (this, &req, fr, &clnt_pmap_prog, | |||
1818 | GF_PMAP_PORTBYBRICK, | |||
1819 | client_query_portmap_cbk, | |||
1820 | NULL((void*)0), NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0), | |||
1821 | (xdrproc_t)xdr_pmap_port_by_brick_req); | |||
1822 | ||||
1823 | fail: | |||
1824 | return ret; | |||
1825 | } | |||
1826 | ||||
1827 | ||||
1828 | int | |||
1829 | client_dump_version_cbk (struct rpc_req *req, struct iovec *iov, int count, | |||
1830 | void *myframe) | |||
1831 | { | |||
1832 | gf_dump_rsp rsp = {0,}; | |||
1833 | gf_prog_detail *trav = NULL((void*)0); | |||
1834 | gf_prog_detail *next = NULL((void*)0); | |||
1835 | call_frame_t *frame = NULL((void*)0); | |||
1836 | clnt_conf_t *conf = NULL((void*)0); | |||
1837 | int ret = 0; | |||
1838 | ||||
1839 | frame = myframe; | |||
1840 | conf = frame->this->private; | |||
1841 | ||||
1842 | if (-1 == req->rpc_status) { | |||
1843 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("received RPC status error"); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__, 1844, GF_LOG_WARNING, "received RPC status error" ); } while (0) | |||
1844 | "received RPC status error")do { do { if (0) printf ("received RPC status error"); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__, 1844, GF_LOG_WARNING, "received RPC status error" ); } while (0); | |||
1845 | goto out; | |||
1846 | } | |||
1847 | ||||
1848 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_dump_rsp); | |||
1849 | if (ret < 0) { | |||
1850 | gf_log (frame->this->name, GF_LOG_ERROR, "XDR decoding failed")do { do { if (0) printf ("XDR decoding failed"); } while (0); _gf_log (frame->this->name, "client-handshake.c", __FUNCTION__ , 1850, GF_LOG_ERROR, "XDR decoding failed"); } while (0); | |||
1851 | goto out; | |||
1852 | } | |||
1853 | if (-1 == rsp.op_ret) { | |||
1854 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to get the 'versions' from server" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1855, GF_LOG_WARNING, "failed to get the 'versions' from server" ); } while (0) | |||
1855 | "failed to get the 'versions' from server")do { do { if (0) printf ("failed to get the 'versions' from server" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1855, GF_LOG_WARNING, "failed to get the 'versions' from server" ); } while (0); | |||
1856 | goto out; | |||
1857 | } | |||
1858 | ||||
1859 | if (server_has_portmap (frame->this, rsp.prog) == 0) { | |||
1860 | ret = client_query_portmap (frame->this, conf->rpc); | |||
1861 | goto out; | |||
1862 | } | |||
1863 | ||||
1864 | /* Check for the proper version string */ | |||
1865 | /* Reply in "Name:Program-Number:Program-Version,..." format */ | |||
1866 | ret = select_server_supported_programs (frame->this, rsp.prog); | |||
1867 | if (ret) { | |||
1868 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("server doesn't support the version" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1869, GF_LOG_ERROR, "server doesn't support the version" ); } while (0) | |||
1869 | "server doesn't support the version")do { do { if (0) printf ("server doesn't support the version" ); } while (0); _gf_log (frame->this->name, "client-handshake.c" , __FUNCTION__, 1869, GF_LOG_ERROR, "server doesn't support the version" ); } while (0); | |||
1870 | goto out; | |||
1871 | } | |||
1872 | ||||
1873 | client_setvolume (frame->this, conf->rpc); | |||
1874 | ||||
1875 | out: | |||
1876 | /* don't use GF_FREE, buffer was allocated by libc */ | |||
1877 | if (rsp.prog) { | |||
1878 | trav = rsp.prog; | |||
1879 | while (trav) { | |||
1880 | next = trav->next; | |||
1881 | free (trav->progname); | |||
1882 | free (trav); | |||
1883 | trav = next; | |||
1884 | } | |||
1885 | } | |||
1886 | ||||
1887 | STACK_DESTROY (frame->root); | |||
1888 | ||||
1889 | if (ret != 0) | |||
1890 | rpc_transport_disconnect (conf->rpc->conn.trans); | |||
1891 | ||||
1892 | return ret; | |||
1893 | } | |||
1894 | ||||
1895 | int | |||
1896 | client_handshake (xlator_t *this, struct rpc_clnt *rpc) | |||
1897 | { | |||
1898 | call_frame_t *frame = NULL((void*)0); | |||
1899 | clnt_conf_t *conf = NULL((void*)0); | |||
1900 | gf_dump_req req = {0,}; | |||
1901 | int ret = 0; | |||
1902 | ||||
1903 | conf = this->private; | |||
1904 | if (!conf->handshake) { | |||
1905 | gf_log (this->name, GF_LOG_WARNING, "handshake program not found")do { do { if (0) printf ("handshake program not found"); } while (0); _gf_log (this->name, "client-handshake.c", __FUNCTION__ , 1905, GF_LOG_WARNING, "handshake program not found"); } while (0); | |||
1906 | goto out; | |||
1907 | } | |||
1908 | ||||
1909 | frame = create_frame (this, this->ctx->pool); | |||
1910 | if (!frame) | |||
1911 | goto out; | |||
1912 | ||||
1913 | req.gfs_id = 0xbabe; | |||
1914 | ret = client_submit_request (this, &req, frame, conf->dump, | |||
1915 | GF_DUMP_DUMP, client_dump_version_cbk, | |||
1916 | NULL((void*)0), NULL((void*)0), 0, NULL((void*)0), 0, | |||
1917 | NULL((void*)0), (xdrproc_t)xdr_gf_dump_req); | |||
1918 | ||||
1919 | out: | |||
1920 | return ret; | |||
1921 | } | |||
1922 | ||||
1923 | char *clnt_handshake_procs[GF_HNDSK_MAXVALUE] = { | |||
1924 | [GF_HNDSK_NULL] = "NULL", | |||
1925 | [GF_HNDSK_SETVOLUME] = "SETVOLUME", | |||
1926 | [GF_HNDSK_GETSPEC] = "GETSPEC", | |||
1927 | [GF_HNDSK_PING] = "PING", | |||
1928 | [GF_HNDSK_SET_LK_VER] = "SET_LK_VER" | |||
1929 | }; | |||
1930 | ||||
1931 | rpc_clnt_prog_t clnt_handshake_prog = { | |||
1932 | .progname = "GlusterFS Handshake", | |||
1933 | .prognum = GLUSTER_HNDSK_PROGRAM14398633, | |||
1934 | .progver = GLUSTER_HNDSK_VERSION2, | |||
1935 | .procnames = clnt_handshake_procs, | |||
1936 | }; | |||
1937 | ||||
1938 | char *clnt_dump_proc[GF_DUMP_MAXVALUE] = { | |||
1939 | [GF_DUMP_NULL] = "NULL", | |||
1940 | [GF_DUMP_DUMP] = "DUMP", | |||
1941 | }; | |||
1942 | ||||
1943 | rpc_clnt_prog_t clnt_dump_prog = { | |||
1944 | .progname = "GF-DUMP", | |||
1945 | .prognum = GLUSTER_DUMP_PROGRAM123451501, | |||
1946 | .progver = GLUSTER_DUMP_VERSION1, | |||
1947 | .procnames = clnt_dump_proc, | |||
1948 | }; | |||
1949 | ||||
1950 | char *clnt_pmap_procs[GF_PMAP_MAXVALUE] = { | |||
1951 | [GF_PMAP_PORTBYBRICK] = "PORTBYBRICK", | |||
1952 | }; | |||
1953 | ||||
1954 | rpc_clnt_prog_t clnt_pmap_prog = { | |||
1955 | .progname = "PORTMAP", | |||
1956 | .prognum = GLUSTER_PMAP_PROGRAM34123456, | |||
1957 | .progver = GLUSTER_PMAP_VERSION1, | |||
1958 | .procnames = clnt_pmap_procs, | |||
1959 | }; |