Bug Summary

File:xlators/cluster/afr/src/afr-lk-common.c
Location:line 2016, column 9
Description:Access to field 'flags' results in a dereference of a null pointer (loaded from variable 'fdctx')

Annotated Source Code

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#include "dict.h"
12#include "byte-order.h"
13#include "common-utils.h"
14
15#include "afr.h"
16#include "afr-transaction.h"
17
18#include <signal.h>
19
20
21#define LOCKED_NO0x0 0x0 /* no lock held */
22#define LOCKED_YES0x1 0x1 /* for DATA, METADATA, ENTRY and higher_path */
23#define LOCKED_LOWER0x2 0x2 /* for lower path */
24
25#define AFR_TRACE_INODELK_IN(frame, this, params ...)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, params
...); } while (0);
\
26 do { \
27 afr_private_t *_priv = this->private; \
28 if (!_priv->inodelk_trace) \
29 break; \
30 afr_trace_inodelk_in (frame, this, params); \
31 } while (0);
32
33#define AFR_TRACE_INODELK_OUT(frame, this, params ...)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_out (frame, this, params
...); } while (0);
\
34 do { \
35 afr_private_t *_priv = this->private; \
36 if (!_priv->inodelk_trace) \
37 break; \
38 afr_trace_inodelk_out (frame, this, params); \
39 } while (0);
40
41#define AFR_TRACE_ENTRYLK_IN(frame, this, params ...)do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, params
...); } while (0);
\
42 do { \
43 afr_private_t *_priv = this->private; \
44 if (!_priv->entrylk_trace) \
45 break; \
46 afr_trace_entrylk_in (frame, this, params); \
47 } while (0);
48
49#define AFR_TRACE_ENTRYLK_OUT(frame, this, params ...)do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, params
...); } while (0);
\
50 do { \
51 afr_private_t *_priv = this->private; \
52 if (!_priv->entrylk_trace) \
53 break; \
54 afr_trace_entrylk_out (frame, this, params); \
55 } while (0);
56
57int
58afr_entry_lockee_cmp (const void *l1, const void *l2)
59{
60 const afr_entry_lockee_t *r1 = l1;
61 const afr_entry_lockee_t *r2 = l2;
62 int ret = 0;
63
64 ret = uuid_compare (r1->loc.gfid, r2->loc.gfid);
65 /*Entrylks with NULL basename are the 'smallest'*/
66 if (ret == 0) {
67 if (!r1->basename)
68 return -1;
69 if (!r2->basename)
70 return 1;
71 ret = strcmp (r1->basename, r2->basename);
72 }
73
74 if (ret <= 0)
75 return -1;
76 else
77 return 1;
78
79}
80
81int afr_lock_blocking (call_frame_t *frame, xlator_t *this, int child_index);
82
83static int
84afr_copy_locked_nodes (call_frame_t *frame, xlator_t *this);
85
86static uint64_t afr_lock_number = 1;
87
88static uint64_t
89get_afr_lock_number ()
90{
91 return (++afr_lock_number);
92}
93
94int
95afr_set_lock_number (call_frame_t *frame, xlator_t *this)
96{
97 afr_local_t *local = NULL((void*)0);
98 afr_internal_lock_t *int_lock = NULL((void*)0);
99
100 local = frame->local;
101 int_lock = &local->internal_lock;
102
103 int_lock->lock_number = get_afr_lock_number ();
104
105 return 0;
106}
107
108void
109afr_set_lk_owner (call_frame_t *frame, xlator_t *this, void *lk_owner)
110{
111 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("Setting lk-owner=%llu", (unsigned long
long) (unsigned long)lk_owner); } while (0); _gf_log (this->
name, "afr-lk-common.c", __FUNCTION__, 113, GF_LOG_TRACE, "Setting lk-owner=%llu"
, (unsigned long long) (unsigned long)lk_owner); } while (0)
112 "Setting lk-owner=%llu",do { do { if (0) printf ("Setting lk-owner=%llu", (unsigned long
long) (unsigned long)lk_owner); } while (0); _gf_log (this->
name, "afr-lk-common.c", __FUNCTION__, 113, GF_LOG_TRACE, "Setting lk-owner=%llu"
, (unsigned long long) (unsigned long)lk_owner); } while (0)
113 (unsigned long long) (unsigned long)lk_owner)do { do { if (0) printf ("Setting lk-owner=%llu", (unsigned long
long) (unsigned long)lk_owner); } while (0); _gf_log (this->
name, "afr-lk-common.c", __FUNCTION__, 113, GF_LOG_TRACE, "Setting lk-owner=%llu"
, (unsigned long long) (unsigned long)lk_owner); } while (0)
;
114
115 set_lk_owner_from_ptr (&frame->root->lk_owner, lk_owner);
116}
117
118static int
119is_afr_lock_selfheal (afr_local_t *local)
120{
121 afr_internal_lock_t *int_lock = NULL((void*)0);
122 int ret = -1;
123
124 int_lock = &local->internal_lock;
125
126 switch (int_lock->selfheal_lk_type) {
127 case AFR_DATA_SELF_HEAL_LK:
128 case AFR_METADATA_SELF_HEAL_LK:
129 ret = 1;
130 break;
131 case AFR_ENTRY_SELF_HEAL_LK:
132 ret = 0;
133 break;
134 }
135
136 return ret;
137
138}
139
140int32_t
141internal_lock_count (call_frame_t *frame, xlator_t *this)
142{
143 afr_local_t *local = NULL((void*)0);
144 afr_private_t *priv = NULL((void*)0);
145 int32_t call_count = 0;
146 int i = 0;
147
148 local = frame->local;
149 priv = this->private;
150
151 for (i = 0; i < priv->child_count; i++) {
152 if (local->child_up[i])
153 ++call_count;
154 }
155
156 return call_count;
157}
158
159static void
160afr_print_inodelk (char *str, int size, int cmd,
161 struct gf_flock *flock, gf_lkowner_t *owner)
162{
163 char *cmd_str = NULL((void*)0);
164 char *type_str = NULL((void*)0);
165
166 switch (cmd) {
167#if F_GETLK12 != F_GETLK6412
168 case F_GETLK6412:
169#endif
170 case F_GETLK12:
171 cmd_str = "GETLK";
172 break;
173
174#if F_SETLK13 != F_SETLK6413
175 case F_SETLK6413:
176#endif
177 case F_SETLK13:
178 cmd_str = "SETLK";
179 break;
180
181#if F_SETLKW14 != F_SETLKW6414
182 case F_SETLKW6414:
183#endif
184 case F_SETLKW14:
185 cmd_str = "SETLKW";
186 break;
187
188 default:
189 cmd_str = "<null>";
190 break;
191 }
192
193 switch (flock->l_type) {
194 case F_RDLCK0:
195 type_str = "READ";
196 break;
197 case F_WRLCK1:
198 type_str = "WRITE";
199 break;
200 case F_UNLCK2:
201 type_str = "UNLOCK";
202 break;
203 default:
204 type_str = "UNKNOWN";
205 break;
206 }
207
208 snprintf (str, size, "lock=INODELK, cmd=%s, type=%s, "
209 "start=%llu, len=%llu, pid=%llu, lk-owner=%s",
210 cmd_str, type_str, (unsigned long long) flock->l_start,
211 (unsigned long long) flock->l_len,
212 (unsigned long long) flock->l_pid,
213 lkowner_utoa (owner));
214
215}
216
217static void
218afr_print_lockee (char *str, int size, loc_t *loc, fd_t *fd,
219 int child_index)
220{
221 snprintf (str, size, "path=%s, fd=%p, child=%d",
222 loc->path ? loc->path : "<nul>",
223 fd ? fd : NULL((void*)0),
224 child_index);
225}
226
227void
228afr_print_entrylk (char *str, int size, const char *basename,
229 gf_lkowner_t *owner)
230{
231 snprintf (str, size, "Basename=%s, lk-owner=%s",
232 basename ? basename : "<nul>",
233 lkowner_utoa (owner));
234}
235
236static void
237afr_print_verdict (int op_ret, int op_errno, char *str)
238{
239 if (op_ret < 0) {
240 if (op_errno == EAGAIN11)
241 strcpy (str, "EAGAIN");
242 else
243 strcpy (str, "FAILED");
244 }
245 else
246 strcpy (str, "GRANTED");
247}
248
249static void
250afr_set_lock_call_type (afr_lock_call_type_t lock_call_type,
251 char *lock_call_type_str,
252 afr_internal_lock_t *int_lock)
253{
254 switch (lock_call_type) {
255 case AFR_INODELK_TRANSACTION:
256 if (int_lock->transaction_lk_type == AFR_TRANSACTION_LK)
257 strcpy (lock_call_type_str, "AFR_INODELK_TRANSACTION");
258 else
259 strcpy (lock_call_type_str, "AFR_INODELK_SELFHEAL");
260 break;
261 case AFR_INODELK_NB_TRANSACTION:
262 if (int_lock->transaction_lk_type == AFR_TRANSACTION_LK)
263 strcpy (lock_call_type_str, "AFR_INODELK_NB_TRANSACTION");
264 else
265 strcpy (lock_call_type_str, "AFR_INODELK_NB_SELFHEAL");
266 break;
267 case AFR_ENTRYLK_TRANSACTION:
268 if (int_lock->transaction_lk_type == AFR_TRANSACTION_LK)
269 strcpy (lock_call_type_str, "AFR_ENTRYLK_TRANSACTION");
270 else
271 strcpy (lock_call_type_str, "AFR_ENTRYLK_SELFHEAL");
272 break;
273 case AFR_ENTRYLK_NB_TRANSACTION:
274 if (int_lock->transaction_lk_type == AFR_TRANSACTION_LK)
275 strcpy (lock_call_type_str, "AFR_ENTRYLK_NB_TRANSACTION");
276 else
277 strcpy (lock_call_type_str, "AFR_ENTRYLK_NB_SELFHEAL");
278 break;
279 default:
280 strcpy (lock_call_type_str, "UNKNOWN");
281 break;
282 }
283
284}
285
286static void
287afr_trace_inodelk_out (call_frame_t *frame, xlator_t *this,
288 afr_lock_call_type_t lock_call_type,
289 afr_lock_op_type_t lk_op_type, struct gf_flock *flock,
290 int op_ret, int op_errno, int32_t child_index)
291{
292 afr_internal_lock_t *int_lock = NULL((void*)0);
293 afr_local_t *local = NULL((void*)0);
294
295 char lockee[256];
296 char lock_call_type_str[256];
297 char verdict[16];
298
299 local = frame->local;
300 int_lock = &local->internal_lock;
301
302 afr_print_lockee (lockee, 256, &local->loc, local->fd, child_index);
303
304 afr_set_lock_call_type (lock_call_type, lock_call_type_str, int_lock);
305
306 afr_print_verdict (op_ret, op_errno, verdict);
307
308 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 313, GF_LOG_INFO, "[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0)
309 "[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}",do { do { if (0) printf ("[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 313, GF_LOG_INFO, "[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0)
310 lock_call_type_str,do { do { if (0) printf ("[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 313, GF_LOG_INFO, "[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0)
311 lk_op_type == AFR_LOCK_OP ? "LOCK REPLY" : "UNLOCK REPLY",do { do { if (0) printf ("[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 313, GF_LOG_INFO, "[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0)
312 verdict, lkowner_utoa (&frame->root->lk_owner), lockee,do { do { if (0) printf ("[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 313, GF_LOG_INFO, "[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0)
313 (unsigned long long) int_lock->lock_number)do { do { if (0) printf ("[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 313, GF_LOG_INFO, "[%s %s] [%s] lk-owner=%s Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lkowner_utoa (&frame->root
->lk_owner), lockee, (unsigned long long) int_lock->lock_number
); } while (0)
;
314
315}
316
317static void
318afr_trace_inodelk_in (call_frame_t *frame, xlator_t *this,
319 afr_lock_call_type_t lock_call_type,
320 afr_lock_op_type_t lk_op_type, struct gf_flock *flock,
321 int32_t cmd, int32_t child_index)
322{
323 afr_local_t *local = NULL((void*)0);
324 afr_internal_lock_t *int_lock = NULL((void*)0);
325
326 char lock[256];
327 char lockee[256];
328 char lock_call_type_str[256];
329
330 local = frame->local;
331 int_lock = &local->internal_lock;
332
333 afr_print_inodelk (lock, 256, cmd, flock, &frame->root->lk_owner);
334 afr_print_lockee (lockee, 256, &local->loc, local->fd, child_index);
335
336 afr_set_lock_call_type (lock_call_type, lock_call_type_str, int_lock);
337
338 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 343, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0)
339 "[%s %s] Lock={%s} Lockee={%s} Number={%llu}",do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 343, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0)
340 lock_call_type_str,do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 343, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0)
341 lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST" : "UNLOCK REQUEST",do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 343, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0)
342 lock, lockee,do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 343, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0)
343 (unsigned long long) int_lock->lock_number)do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 343, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number); } while (0)
;
344
345}
346
347static void
348afr_trace_entrylk_in (call_frame_t *frame, xlator_t *this,
349 afr_lock_call_type_t lock_call_type,
350 afr_lock_op_type_t lk_op_type, const char *basename,
351 int32_t cookie)
352{
353 afr_local_t *local = NULL((void*)0);
354 afr_internal_lock_t *int_lock = NULL((void*)0);
355 afr_private_t *priv = NULL((void*)0);
356 int child_index = 0;
357 int lockee_no = 0;
358
359 char lock[256];
360 char lockee[256];
361 char lock_call_type_str[256];
362
363 local = frame->local;
364 int_lock = &local->internal_lock;
365 priv = this->private;
366
367 if (!priv->entrylk_trace) {
368 return;
369 }
370 lockee_no = cookie / priv->child_count;
371 child_index = cookie % priv->child_count;
372
373 afr_print_entrylk (lock, 256, basename, &frame->root->lk_owner);
374 afr_print_lockee (lockee, 256, &int_lock->lockee[lockee_no].loc, local->fd,
375 child_index);
376
377 afr_set_lock_call_type (lock_call_type, lock_call_type_str, int_lock);
378
379 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 385, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0)
380 "[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}",do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 385, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0)
381 lock_call_type_str,do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 385, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0)
382 lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST" : "UNLOCK REQUEST",do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 385, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0)
383 lock, lockee,do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 385, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0)
384 (unsigned long long) int_lock->lock_number,do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 385, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0)
385 cookie)do { do { if (0) printf ("[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 385, GF_LOG_INFO, "[%s %s] Lock={%s} Lockee={%s} Number={%llu}, Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REQUEST"
: "UNLOCK REQUEST", lock, lockee, (unsigned long long) int_lock
->lock_number, cookie); } while (0)
;
386}
387
388static void
389afr_trace_entrylk_out (call_frame_t *frame, xlator_t *this,
390 afr_lock_call_type_t lock_call_type,
391 afr_lock_op_type_t lk_op_type, const char *basename,
392 int op_ret, int op_errno, int32_t cookie)
393{
394 afr_internal_lock_t *int_lock = NULL((void*)0);
395 afr_local_t *local = NULL((void*)0);
396 afr_private_t *priv = NULL((void*)0);
397 int lockee_no = 0;
398 int child_index = 0;
399
400 char lock[256];
401 char lockee[256];
402 char lock_call_type_str[256];
403 char verdict[16];
404
405 local = frame->local;
406 int_lock = &local->internal_lock;
407 priv = this->private;
408
409 if (!priv->entrylk_trace) {
410 return;
411 }
412 lockee_no = cookie / priv->child_count;
413 child_index = cookie % priv->child_count;
414
415 afr_print_entrylk (lock, 256, basename, &frame->root->lk_owner);
416 afr_print_lockee (lockee, 256, &int_lock->lockee[lockee_no].loc, local->fd,
417 child_index);
418
419 afr_set_lock_call_type (lock_call_type, lock_call_type_str, int_lock);
420
421 afr_print_verdict (op_ret, op_errno, verdict);
422
423 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0); _gf_log (this
->name, "afr-lk-common.c", __FUNCTION__, 430, GF_LOG_INFO,
"[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0)
424 "[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}",do { do { if (0) printf ("[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0); _gf_log (this
->name, "afr-lk-common.c", __FUNCTION__, 430, GF_LOG_INFO,
"[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0)
425 lock_call_type_str,do { do { if (0) printf ("[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0); _gf_log (this
->name, "afr-lk-common.c", __FUNCTION__, 430, GF_LOG_INFO,
"[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0)
426 lk_op_type == AFR_LOCK_OP ? "LOCK REPLY" : "UNLOCK REPLY",do { do { if (0) printf ("[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0); _gf_log (this
->name, "afr-lk-common.c", __FUNCTION__, 430, GF_LOG_INFO,
"[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0)
427 verdict,do { do { if (0) printf ("[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0); _gf_log (this
->name, "afr-lk-common.c", __FUNCTION__, 430, GF_LOG_INFO,
"[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0)
428 lock, lockee,do { do { if (0) printf ("[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0); _gf_log (this
->name, "afr-lk-common.c", __FUNCTION__, 430, GF_LOG_INFO,
"[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0)
429 (unsigned long long) int_lock->lock_number,do { do { if (0) printf ("[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0); _gf_log (this
->name, "afr-lk-common.c", __FUNCTION__, 430, GF_LOG_INFO,
"[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0)
430 cookie)do { do { if (0) printf ("[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0); _gf_log (this
->name, "afr-lk-common.c", __FUNCTION__, 430, GF_LOG_INFO,
"[%s %s] [%s] Lock={%s} Lockee={%s} Number={%llu} Cookie={%d}"
, lock_call_type_str, lk_op_type == AFR_LOCK_OP ? "LOCK REPLY"
: "UNLOCK REPLY", verdict, lock, lockee, (unsigned long long
) int_lock->lock_number, cookie); } while (0)
;
431
432}
433
434static int
435transaction_lk_op (afr_local_t *local)
436{
437 afr_internal_lock_t *int_lock = NULL((void*)0);
438 int ret = -1;
439
440 int_lock = &local->internal_lock;
441
442 if (int_lock->transaction_lk_type == AFR_TRANSACTION_LK) {
443 gf_log (THIS->name, GF_LOG_DEBUG,do { do { if (0) printf ("lk op is for a transaction"); } while
(0); _gf_log ((*__glusterfs_this_location())->name, "afr-lk-common.c"
, __FUNCTION__, 444, GF_LOG_DEBUG, "lk op is for a transaction"
); } while (0)
444 "lk op is for a transaction")do { do { if (0) printf ("lk op is for a transaction"); } while
(0); _gf_log ((*__glusterfs_this_location())->name, "afr-lk-common.c"
, __FUNCTION__, 444, GF_LOG_DEBUG, "lk op is for a transaction"
); } while (0)
;
445 ret = 1;
446 }
447 else if (int_lock->transaction_lk_type == AFR_SELFHEAL_LK) {
448 gf_log (THIS->name, GF_LOG_DEBUG,do { do { if (0) printf ("lk op is for a self heal"); } while
(0); _gf_log ((*__glusterfs_this_location())->name, "afr-lk-common.c"
, __FUNCTION__, 449, GF_LOG_DEBUG, "lk op is for a self heal"
); } while (0)
449 "lk op is for a self heal")do { do { if (0) printf ("lk op is for a self heal"); } while
(0); _gf_log ((*__glusterfs_this_location())->name, "afr-lk-common.c"
, __FUNCTION__, 449, GF_LOG_DEBUG, "lk op is for a self heal"
); } while (0)
;
450
451 ret = 0;
452 }
453
454 if (ret == -1)
455 gf_log (THIS->name, GF_LOG_DEBUG,do { do { if (0) printf ("lk op is not set"); } while (0); _gf_log
((*__glusterfs_this_location())->name, "afr-lk-common.c",
__FUNCTION__, 456, GF_LOG_DEBUG, "lk op is not set"); } while
(0)
456 "lk op is not set")do { do { if (0) printf ("lk op is not set"); } while (0); _gf_log
((*__glusterfs_this_location())->name, "afr-lk-common.c",
__FUNCTION__, 456, GF_LOG_DEBUG, "lk op is not set"); } while
(0)
;
457
458 return ret;
459
460}
461
462static int
463is_afr_lock_transaction (afr_local_t *local)
464{
465 int ret = 0;
466
467 switch (local->transaction.type) {
468 case AFR_DATA_TRANSACTION:
469 case AFR_METADATA_TRANSACTION:
470 ret = 1;
471 break;
472
473 case AFR_ENTRY_RENAME_TRANSACTION:
474 case AFR_ENTRY_TRANSACTION:
475 ret = 0;
476 break;
477
478 }
479
480 return ret;
481}
482
483int
484afr_init_entry_lockee (afr_entry_lockee_t *lockee, afr_local_t *local,
485 loc_t *loc, char *basename, int child_count)
486{
487 int ret = -1;
488
489 loc_copy (&lockee->loc, loc);
490 lockee->basename = (basename)? gf_strdup (basename): NULL((void*)0);
491 if (basename && !lockee->basename)
492 goto out;
493
494 lockee->locked_count = 0;
495 lockee->locked_nodes = GF_CALLOC (child_count,__gf_calloc (child_count, sizeof (*lockee->locked_nodes), gf_afr_mt_afr_node_character
)
496 sizeof (*lockee->locked_nodes),__gf_calloc (child_count, sizeof (*lockee->locked_nodes), gf_afr_mt_afr_node_character
)
497 gf_afr_mt_afr_node_character)__gf_calloc (child_count, sizeof (*lockee->locked_nodes), gf_afr_mt_afr_node_character
)
;
498
499 if (!lockee->locked_nodes)
500 goto out;
501
502 ret = 0;
503out:
504 return ret;
505
506}
507
508void
509afr_entry_lockee_cleanup (afr_internal_lock_t *int_lock)
510{
511 int i = 0;
512
513 for (i = 0; i < int_lock->lockee_count; i++) {
514 loc_wipe (&int_lock->lockee[i].loc);
515 if (int_lock->lockee[i].basename)
516 GF_FREE (int_lock->lockee[i].basename)__gf_free (int_lock->lockee[i].basename);
517 if (int_lock->lockee[i].locked_nodes)
518 GF_FREE (int_lock->lockee[i].locked_nodes)__gf_free (int_lock->lockee[i].locked_nodes);
519 }
520
521 return;
522}
523
524static int
525initialize_entrylk_variables (call_frame_t *frame, xlator_t *this)
526{
527 afr_local_t *local = NULL((void*)0);
528 afr_internal_lock_t *int_lock = NULL((void*)0);
529 afr_private_t *priv = NULL((void*)0);
530
531 int i = 0;
532
533 priv = this->private;
534 local = frame->local;
535 int_lock = &local->internal_lock;
536
537 int_lock->entrylk_lock_count = 0;
538 int_lock->lock_op_ret = -1;
539 int_lock->lock_op_errno = 0;
540
541 for (i = 0; i < AFR_LOCKEE_COUNT_MAX3; i++) {
542 if (!int_lock->lockee[i].locked_nodes)
543 break;
544 int_lock->lockee[i].locked_count = 0;
545 memset (int_lock->lockee[i].locked_nodes, 0,
546 sizeof (*int_lock->lockee[i].locked_nodes) *
547 priv->child_count);
548 }
549
550 return 0;
551}
552
553static int
554initialize_inodelk_variables (call_frame_t *frame, xlator_t *this)
555{
556 afr_local_t *local = NULL((void*)0);
557 afr_internal_lock_t *int_lock = NULL((void*)0);
558 afr_private_t *priv = NULL((void*)0);
559 int i = 0;
560
561 priv = this->private;
562 local = frame->local;
563 int_lock = &local->internal_lock;
564
565 int_lock->inodelk_lock_count = 0;
566 int_lock->lock_op_ret = -1;
567 int_lock->lock_op_errno = 0;
568
569 for (i = 0; i < priv->child_count; i++) {
570 int_lock->inode_locked_nodes[i] = 0;
571 }
572
573 return 0;
574}
575
576loc_t *
577lower_path (loc_t *l1, const char *b1, loc_t *l2, const char *b2)
578{
579 int ret = 0;
580
581 ret = uuid_compare (l1->inode->gfid, l2->inode->gfid);
582
583 if (ret == 0)
584 ret = strcmp (b1, b2);
585
586 if (ret <= 0)
587 return l1;
588 else
589 return l2;
590}
591
592int
593afr_lockee_locked_nodes_count (afr_internal_lock_t *int_lock)
594{
595 int call_count = 0;
596 int i = 0;
597
598 for (i = 0; i < int_lock->lockee_count; i++)
599 call_count += int_lock->lockee[i].locked_count;
600
601 return call_count;
602}
603
604int
605afr_locked_nodes_count (unsigned char *locked_nodes, int child_count)
606
607{
608 int i = 0;
609 int call_count = 0;
610
611 for (i = 0; i < child_count; i++) {
612 if (locked_nodes[i] & LOCKED_YES0x1)
613 call_count++;
614 }
615
616 return call_count;
617}
618
619/* FIXME: What if UNLOCK fails */
620static int32_t
621afr_unlock_common_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
622 int32_t op_ret, int32_t op_errno, dict_t *xdata)
623{
624 afr_local_t *local = NULL((void*)0);
625 afr_internal_lock_t *int_lock = NULL((void*)0);
626 int call_count = 0;
627
628 local = frame->local;
629 int_lock = &local->internal_lock;
630
631 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
632 {
633 call_count = --int_lock->lk_call_count;
634 }
635 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
636
637 if (call_count == 0) {
638 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("All internal locks unlocked"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 639, GF_LOG_TRACE, "All internal locks unlocked"); } while (
0)
639 "All internal locks unlocked")do { do { if (0) printf ("All internal locks unlocked"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 639, GF_LOG_TRACE, "All internal locks unlocked"); } while (
0)
;
640 int_lock->lock_cbk (frame, this);
641 }
642
643 return 0;
644}
645
646static int32_t
647afr_unlock_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
648 int32_t op_ret, int32_t op_errno, dict_t *xdata)
649{
650 afr_local_t *local = NULL((void*)0);
651 afr_internal_lock_t *int_lock = NULL((void*)0);
652 int32_t child_index = (long)cookie;
653
654 local = frame->local;
655 int_lock = &local->internal_lock;
656
657 AFR_TRACE_INODELK_OUT (frame, this, AFR_INODELK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_out (frame, this, AFR_INODELK_TRANSACTION
, AFR_UNLOCK_OP, ((void*)0), op_ret, op_errno, child_index); }
while (0);
658 AFR_UNLOCK_OP, NULL, op_ret,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_out (frame, this, AFR_INODELK_TRANSACTION
, AFR_UNLOCK_OP, ((void*)0), op_ret, op_errno, child_index); }
while (0);
659 op_errno, child_index)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_out (frame, this, AFR_INODELK_TRANSACTION
, AFR_UNLOCK_OP, ((void*)0), op_ret, op_errno, child_index); }
while (0);
;
660
661 if (op_ret < 0 && op_errno != ENOTCONN107 && op_errno != EBADFD77) {
662 gf_log (this->name, GF_LOG_INFO, "%s: unlock failed on %d "do { do { if (0) printf ("%s: unlock failed on %d " "unlock by %s"
, local->loc.path, child_index, lkowner_utoa (&frame->
root->lk_owner)); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 664, GF_LOG_INFO, "%s: unlock failed on %d " "unlock by %s"
, local->loc.path, child_index, lkowner_utoa (&frame->
root->lk_owner)); } while (0)
663 "unlock by %s", local->loc.path, child_index,do { do { if (0) printf ("%s: unlock failed on %d " "unlock by %s"
, local->loc.path, child_index, lkowner_utoa (&frame->
root->lk_owner)); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 664, GF_LOG_INFO, "%s: unlock failed on %d " "unlock by %s"
, local->loc.path, child_index, lkowner_utoa (&frame->
root->lk_owner)); } while (0)
664 lkowner_utoa (&frame->root->lk_owner))do { do { if (0) printf ("%s: unlock failed on %d " "unlock by %s"
, local->loc.path, child_index, lkowner_utoa (&frame->
root->lk_owner)); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 664, GF_LOG_INFO, "%s: unlock failed on %d " "unlock by %s"
, local->loc.path, child_index, lkowner_utoa (&frame->
root->lk_owner)); } while (0)
;
665 }
666
667
668 int_lock->inode_locked_nodes[child_index] &= LOCKED_NO0x0;
669 if (local->transaction.eager_lock)
670 local->transaction.eager_lock[child_index] = 0;
671
672 afr_unlock_common_cbk (frame, cookie, this, op_ret, op_errno, xdata);
673
674 return 0;
675
676}
677
678static int
679afr_unlock_inodelk (call_frame_t *frame, xlator_t *this)
680{
681 afr_internal_lock_t *int_lock = NULL((void*)0);
682 afr_local_t *local = NULL((void*)0);
683 afr_private_t *priv = NULL((void*)0);
684 struct gf_flock flock = {0,};
685 struct gf_flock full_flock = {0,};
686 struct gf_flock *flock_use = NULL((void*)0);
687 int call_count = 0;
688 int i = 0;
689 int piggyback = 0;
690 afr_fd_ctx_t *fd_ctx = NULL((void*)0);
691
692
693 local = frame->local;
694 int_lock = &local->internal_lock;
695 priv = this->private;
696
697 flock.l_start = int_lock->lk_flock.l_start;
698 flock.l_len = int_lock->lk_flock.l_len;
699 flock.l_type = F_UNLCK2;
700
701 full_flock.l_type = F_UNLCK2;
702 call_count = afr_locked_nodes_count (int_lock->inode_locked_nodes,
703 priv->child_count);
704
705 int_lock->lk_call_count = call_count;
706
707 if (!call_count) {
708 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("No internal locks unlocked"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 709, GF_LOG_TRACE, "No internal locks unlocked"); } while (
0)
709 "No internal locks unlocked")do { do { if (0) printf ("No internal locks unlocked"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 709, GF_LOG_TRACE, "No internal locks unlocked"); } while (
0)
;
710 int_lock->lock_cbk (frame, this);
711 goto out;
712 }
713
714 if (local->fd)
715 fd_ctx = afr_fd_ctx_get (local->fd, this);
716
717 for (i = 0; i < priv->child_count; i++) {
718 if ((int_lock->inode_locked_nodes[i] & LOCKED_YES0x1)
719 != LOCKED_YES0x1)
720 continue;
721
722 if (local->fd) {
723 flock_use = &flock;
724 if (!local->transaction.eager_lock[i]) {
725 goto wind;
726 }
727
728 piggyback = 0;
729
730 LOCK (&local->fd->lock)pthread_spin_lock (&local->fd->lock);
731 {
732 if (fd_ctx->lock_piggyback[i]) {
733 fd_ctx->lock_piggyback[i]--;
734 piggyback = 1;
735 } else {
736 fd_ctx->lock_acquired[i]--;
737 }
738 }
739 UNLOCK (&local->fd->lock)pthread_spin_unlock (&local->fd->lock);
740
741 if (piggyback) {
742 afr_unlock_inodelk_cbk (frame, (void *) (long) i,
743 this, 1, 0, NULL((void*)0));
744 if (!--call_count)
745 break;
746 continue;
747 }
748
749 flock_use = &full_flock;
750 wind:
751 AFR_TRACE_INODELK_IN (frame, this,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_UNLOCK_OP, flock_use, 13, i); } while (0);
752 AFR_INODELK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_UNLOCK_OP, flock_use, 13, i); } while (0);
753 AFR_UNLOCK_OP, flock_use, F_SETLK,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_UNLOCK_OP, flock_use, 13, i); } while (0);
754 i)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_UNLOCK_OP, flock_use, 13, i); } while (0);
;
755
756 STACK_WIND_COOKIE (frame, afr_unlock_inodelk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 761,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
757 (void *) (long)i,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 761,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
758 priv->children[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 761,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
759 priv->children[i]->fops->finodelk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 761,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
760 this->name, local->fd,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 761,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
761 F_SETLK, flock_use, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 761,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
762
763 if (!--call_count)
764 break;
765
766 } else {
767 AFR_TRACE_INODELK_IN (frame, this,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_UNLOCK_OP, &flock, 13, i); } while (0);
768 AFR_INODELK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_UNLOCK_OP, &flock, 13, i); } while (0);
769 AFR_UNLOCK_OP, &flock, F_SETLK, i)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_UNLOCK_OP, &flock, 13, i); } while (0);
;
770
771 STACK_WIND_COOKIE (frame, afr_unlock_inodelk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 776,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
772 (void *) (long)i,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 776,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
773 priv->children[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 776,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
774 priv->children[i]->fops->inodelk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 776,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
775 this->name, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 776,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
776 F_SETLK, &flock, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 776,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_unlock_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long)i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_unlock_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_unlock_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
;
777
778 if (!--call_count)
779 break;
780 }
781 }
782out:
783 return 0;
784}
785
786static int32_t
787afr_unlock_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
788 int32_t op_ret, int32_t op_errno, dict_t *xdata)
789{
790 afr_local_t *local = NULL((void*)0);
791 afr_private_t *priv = NULL((void*)0);
792 afr_internal_lock_t *int_lock = NULL((void*)0);
793 int32_t child_index = 0;
794 int lockee_no = 0;
795
796 priv = this->private;
797 lockee_no = (int)((long) cookie) / priv->child_count;
798 child_index = (int) ((long) cookie) % priv->child_count;
799
800 local = frame->local;
801 int_lock = &local->internal_lock;
802
803 AFR_TRACE_ENTRYLK_OUT (frame, this, AFR_ENTRYLK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_UNLOCK_OP, int_lock->lockee[lockee_no].basename, op_ret
, op_errno, (int) ((long)cookie)); } while (0);
804 AFR_UNLOCK_OP,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_UNLOCK_OP, int_lock->lockee[lockee_no].basename, op_ret
, op_errno, (int) ((long)cookie)); } while (0);
805 int_lock->lockee[lockee_no].basename, op_ret,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_UNLOCK_OP, int_lock->lockee[lockee_no].basename, op_ret
, op_errno, (int) ((long)cookie)); } while (0);
806 op_errno, (int) ((long)cookie))do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_UNLOCK_OP, int_lock->lockee[lockee_no].basename, op_ret
, op_errno, (int) ((long)cookie)); } while (0);
;
807
808 if (op_ret < 0) {
809 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("%s: unlock failed on %d, reason: %s"
, local->loc.path, child_index, strerror (op_errno)); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 811, GF_LOG_ERROR, "%s: unlock failed on %d, reason: %s", local
->loc.path, child_index, strerror (op_errno)); } while (0)
810 "%s: unlock failed on %d, reason: %s",do { do { if (0) printf ("%s: unlock failed on %d, reason: %s"
, local->loc.path, child_index, strerror (op_errno)); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 811, GF_LOG_ERROR, "%s: unlock failed on %d, reason: %s", local
->loc.path, child_index, strerror (op_errno)); } while (0)
811 local->loc.path, child_index, strerror (op_errno))do { do { if (0) printf ("%s: unlock failed on %d, reason: %s"
, local->loc.path, child_index, strerror (op_errno)); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 811, GF_LOG_ERROR, "%s: unlock failed on %d, reason: %s", local
->loc.path, child_index, strerror (op_errno)); } while (0)
;
812 }
813
814 int_lock->lockee[lockee_no].locked_nodes[child_index] &= LOCKED_NO0x0;
815 afr_unlock_common_cbk (frame, cookie, this, op_ret, op_errno, NULL((void*)0));
816
817 return 0;
818}
819
820static int
821afr_unlock_entrylk (call_frame_t *frame, xlator_t *this)
822{
823 afr_internal_lock_t *int_lock = NULL((void*)0);
824 afr_local_t *local = NULL((void*)0);
825 afr_private_t *priv = NULL((void*)0);
826 int call_count = 0;
827 int index = 0;
828 int lockee_no = 0;
829 int copies = 0;
830 int i = -1;
831
832 local = frame->local;
833 int_lock = &local->internal_lock;
834 priv = this->private;
835 copies = priv->child_count;
836
837 call_count = afr_lockee_locked_nodes_count (int_lock);
838
839 int_lock->lk_call_count = call_count;
840
841 if (!call_count){
842 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("No internal locks unlocked"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 843, GF_LOG_TRACE, "No internal locks unlocked"); } while (
0)
843 "No internal locks unlocked")do { do { if (0) printf ("No internal locks unlocked"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 843, GF_LOG_TRACE, "No internal locks unlocked"); } while (
0)
;
844 int_lock->lock_cbk (frame, this);
845 goto out;
846 }
847
848 for (i = 0; i < int_lock->lockee_count * priv->child_count; i++) {
849 lockee_no = i / copies;
850 index = i % copies;
851 if (int_lock->lockee[lockee_no].locked_nodes[index] & LOCKED_YES0x1) {
852 AFR_TRACE_ENTRYLK_IN (frame, this, AFR_ENTRYLK_NB_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_UNLOCK_OP, int_lock->lockee[lockee_no].basename, i);
} while (0);
853 AFR_UNLOCK_OP,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_UNLOCK_OP, int_lock->lockee[lockee_no].basename, i);
} while (0);
854 int_lock->lockee[lockee_no].basename,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_UNLOCK_OP, int_lock->lockee[lockee_no].basename, i);
} while (0);
855 i)do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_UNLOCK_OP, int_lock->lockee[lockee_no].basename, i);
} while (0);
;
856
857 STACK_WIND_COOKIE (frame, afr_unlock_entrylk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 864,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_unlock_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_unlock_entrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { frame->ref_count++; _new->next = frame->
root->frames.next; _new->prev = &frame->root->
frames; if (frame->root->frames.next) frame->root->
frames.next->prev = _new; frame->root->frames.next =
_new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_unlock_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_UNLOCK, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
858 (void *) (long) i,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 864,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_unlock_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_unlock_entrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { frame->ref_count++; _new->next = frame->
root->frames.next; _new->prev = &frame->root->
frames; if (frame->root->frames.next) frame->root->
frames.next->prev = _new; frame->root->frames.next =
_new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_unlock_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_UNLOCK, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
859 priv->children[index],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 864,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_unlock_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_unlock_entrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { frame->ref_count++; _new->next = frame->
root->frames.next; _new->prev = &frame->root->
frames; if (frame->root->frames.next) frame->root->
frames.next->prev = _new; frame->root->frames.next =
_new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_unlock_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_UNLOCK, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
860 priv->children[index]->fops->entrylk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 864,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_unlock_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_unlock_entrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { frame->ref_count++; _new->next = frame->
root->frames.next; _new->prev = &frame->root->
frames; if (frame->root->frames.next) frame->root->
frames.next->prev = _new; frame->root->frames.next =
_new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_unlock_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_UNLOCK, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
861 this->name,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 864,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_unlock_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_unlock_entrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { frame->ref_count++; _new->next = frame->
root->frames.next; _new->prev = &frame->root->
frames; if (frame->root->frames.next) frame->root->
frames.next->prev = _new; frame->root->frames.next =
_new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_unlock_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_UNLOCK, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
862 &int_lock->lockee[lockee_no].loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 864,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_unlock_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_unlock_entrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { frame->ref_count++; _new->next = frame->
root->frames.next; _new->prev = &frame->root->
frames; if (frame->root->frames.next) frame->root->
frames.next->prev = _new; frame->root->frames.next =
_new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_unlock_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_UNLOCK, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
863 int_lock->lockee[lockee_no].basename,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 864,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_unlock_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_unlock_entrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { frame->ref_count++; _new->next = frame->
root->frames.next; _new->prev = &frame->root->
frames; if (frame->root->frames.next) frame->root->
frames.next->prev = _new; frame->root->frames.next =
_new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_unlock_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_UNLOCK, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
864 ENTRYLK_UNLOCK, ENTRYLK_WRLCK, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 864,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_unlock_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_unlock_entrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { frame->ref_count++; _new->next = frame->
root->frames.next; _new->prev = &frame->root->
frames; if (frame->root->frames.next) frame->root->
frames.next->prev = _new; frame->root->frames.next =
_new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_unlock_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_UNLOCK, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
865
866 if (!--call_count)
867 break;
868 }
869 }
870
871out:
872 return 0;
873
874}
875
876static int32_t
877afr_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
878 int32_t op_ret, int32_t op_errno, dict_t *xdata)
879{
880 afr_internal_lock_t *int_lock = NULL((void*)0);
881 afr_local_t *local = NULL((void*)0);
882 afr_private_t *priv = NULL((void*)0);
883 int cky = (long) cookie;
884 int child_index = 0;
885 int lockee_no = 0;
886
887 priv = this->private;
888 local = frame->local;
889 int_lock = &local->internal_lock;
890
891 child_index = ((int)cky) % priv->child_count;
892 lockee_no = ((int)cky) / priv->child_count;
893
894 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
895 {
896 if (op_ret == -1) {
897 if (op_errno == ENOSYS38) {
898 /* return ENOTSUP */
899 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("subvolume does not support locking. "
"please load features/locks xlator on server"); } while (0);
_gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 901
, GF_LOG_ERROR, "subvolume does not support locking. " "please load features/locks xlator on server"
); } while (0)
900 "subvolume does not support locking. "do { do { if (0) printf ("subvolume does not support locking. "
"please load features/locks xlator on server"); } while (0);
_gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 901
, GF_LOG_ERROR, "subvolume does not support locking. " "please load features/locks xlator on server"
); } while (0)
901 "please load features/locks xlator on server")do { do { if (0) printf ("subvolume does not support locking. "
"please load features/locks xlator on server"); } while (0);
_gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 901
, GF_LOG_ERROR, "subvolume does not support locking. " "please load features/locks xlator on server"
); } while (0)
;
902 local->op_ret = op_ret;
903 int_lock->lock_op_ret = op_ret;
904 }
905
906 local->op_errno = op_errno;
907 int_lock->lock_op_errno = op_errno;
908 }
909
910 int_lock->lk_attempted_count++;
911 }
912 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
913
914 if ((op_ret == -1) &&
915 (op_errno == ENOSYS38)) {
916 afr_unlock (frame, this);
917 } else {
918 if (op_ret == 0) {
919 if (local->transaction.type == AFR_ENTRY_TRANSACTION ||
920 local->transaction.type == AFR_ENTRY_RENAME_TRANSACTION) {
921 int_lock->lockee[lockee_no].locked_nodes[child_index] |= LOCKED_YES0x1;
922 int_lock->lockee[lockee_no].locked_count++;
923 int_lock->entrylk_lock_count++;
924 } else {
925 int_lock->locked_nodes[child_index] |= LOCKED_YES0x1;
926 int_lock->lock_count++;
927 }
928 }
929 afr_lock_blocking (frame, this, cky + 1);
930 }
931
932 return 0;
933}
934
935static int32_t
936afr_blocking_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
937 int32_t op_ret, int32_t op_errno, dict_t *xdata)
938{
939 AFR_TRACE_INODELK_OUT (frame, this, AFR_INODELK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_out (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, ((void*)0), op_ret, op_errno, (long) cookie); }
while (0);
940 AFR_LOCK_OP, NULL, op_ret,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_out (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, ((void*)0), op_ret, op_errno, (long) cookie); }
while (0);
941 op_errno, (long) cookie)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_out (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, ((void*)0), op_ret, op_errno, (long) cookie); }
while (0);
;
942
943 afr_lock_cbk (frame, cookie, this, op_ret, op_errno, xdata);
944 return 0;
945
946}
947
948static int32_t
949afr_blocking_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
950 int32_t op_ret, int32_t op_errno, dict_t *xdata)
951{
952 AFR_TRACE_ENTRYLK_OUT (frame, this, AFR_ENTRYLK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, ((void*)0), op_ret, op_errno, (long)cookie); }
while (0);
953 AFR_LOCK_OP, NULL, op_ret,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, ((void*)0), op_ret, op_errno, (long)cookie); }
while (0);
954 op_errno, (long)cookie)do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, ((void*)0), op_ret, op_errno, (long)cookie); }
while (0);
;
955
956 afr_lock_cbk (frame, cookie, this, op_ret, op_errno, xdata);
957 return 0;
958}
959
960static int
961afr_copy_locked_nodes (call_frame_t *frame, xlator_t *this)
962{
963 afr_internal_lock_t *int_lock = NULL((void*)0);
964 afr_local_t *local = NULL((void*)0);
965 afr_private_t *priv = NULL((void*)0);
966
967 priv = this->private;
968 local = frame->local;
969 int_lock = &local->internal_lock;
970
971 switch (local->transaction.type) {
972 case AFR_DATA_TRANSACTION:
973 case AFR_METADATA_TRANSACTION:
974 memcpy (int_lock->inode_locked_nodes,
975 int_lock->locked_nodes,
976 priv->child_count);
977 int_lock->inodelk_lock_count = int_lock->lock_count;
978 break;
979
980 case AFR_ENTRY_RENAME_TRANSACTION:
981 case AFR_ENTRY_TRANSACTION:
982 /*entrylk_count is being used in both non-blocking and blocking
983 * modes */
984 break;
985 }
986
987 return 0;
988
989}
990
991static inline gf_boolean_t
992afr_is_entrylk (afr_internal_lock_t *int_lock,
993 afr_transaction_type trans_type)
994{
995 gf_boolean_t is_entrylk = _gf_false;
996
997 if ((int_lock->transaction_lk_type == AFR_SELFHEAL_LK) &&
998 int_lock->selfheal_lk_type == AFR_ENTRY_SELF_HEAL_LK) {
999
1000 is_entrylk = _gf_true;
1001
1002 } else if ((int_lock->transaction_lk_type == AFR_TRANSACTION_LK) &&
1003 (trans_type == AFR_ENTRY_TRANSACTION ||
1004 trans_type == AFR_ENTRY_RENAME_TRANSACTION)) {
1005
1006 is_entrylk = _gf_true;
1007
1008 } else {
1009 is_entrylk = _gf_false;
1010 }
1011
1012 return is_entrylk;
1013}
1014
1015static gf_boolean_t
1016_is_lock_wind_needed (afr_local_t *local, int child_index)
1017{
1018 if (!local->child_up[child_index])
1019 return _gf_false;
1020
1021 return _gf_true;
1022}
1023
1024int
1025afr_lock_blocking (call_frame_t *frame, xlator_t *this, int cookie)
1026{
1027 afr_internal_lock_t *int_lock = NULL((void*)0);
1028 afr_local_t *local = NULL((void*)0);
1029 afr_private_t *priv = NULL((void*)0);
1030 struct gf_flock flock = {0,};
1031 uint64_t ctx = 0;
1032 int ret = 0;
1033 int child_index = 0;
1034 int lockee_no = 0;
1035 gf_boolean_t is_entrylk = _gf_false;
1036
1037 local = frame->local;
1038 int_lock = &local->internal_lock;
1039 priv = this->private;
1040 child_index = cookie % priv->child_count;
1041 lockee_no = cookie / priv->child_count;
1042
1043 flock.l_start = int_lock->lk_flock.l_start;
1044 flock.l_len = int_lock->lk_flock.l_len;
1045 flock.l_type = int_lock->lk_flock.l_type;
1046
1047 if (local->fd) {
1048 ret = fd_ctx_get (local->fd, this, &ctx);
1049
1050 if (ret < 0) {
1051 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("unable to get fd ctx for fd=%p", local
->fd); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1053, GF_LOG_INFO, "unable to get fd ctx for fd=%p"
, local->fd); } while (0)
1052 "unable to get fd ctx for fd=%p",do { do { if (0) printf ("unable to get fd ctx for fd=%p", local
->fd); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1053, GF_LOG_INFO, "unable to get fd ctx for fd=%p"
, local->fd); } while (0)
1053 local->fd)do { do { if (0) printf ("unable to get fd ctx for fd=%p", local
->fd); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1053, GF_LOG_INFO, "unable to get fd ctx for fd=%p"
, local->fd); } while (0)
;
1054
1055 local->op_ret = -1;
1056 int_lock->lock_op_ret = -1;
1057
1058 afr_copy_locked_nodes (frame, this);
1059
1060 afr_unlock (frame, this);
1061
1062 return 0;
1063 }
1064 }
1065
1066 if (int_lock->lk_expected_count == int_lock->lk_attempted_count) {
1067 is_entrylk = afr_is_entrylk (int_lock, local->transaction.type);
1068
1069 if ((is_entrylk && int_lock->entrylk_lock_count == 0) ||
1070 (!is_entrylk && int_lock->lock_count == 0)) {
1071 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("unable to lock on even one child");
} while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1072, GF_LOG_INFO, "unable to lock on even one child"); } while
(0)
1072 "unable to lock on even one child")do { do { if (0) printf ("unable to lock on even one child");
} while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1072, GF_LOG_INFO, "unable to lock on even one child"); } while
(0)
;
1073
1074 local->op_ret = -1;
1075 int_lock->lock_op_ret = -1;
1076
1077 afr_copy_locked_nodes (frame, this);
1078
1079 afr_unlock(frame, this);
1080
1081 return 0;
1082 }
1083 }
1084
1085 if (int_lock->lk_expected_count == int_lock->lk_attempted_count) {
1086 /* we're done locking */
1087
1088 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("we're done locking"); } while (0); _gf_log
(this->name, "afr-lk-common.c", __FUNCTION__, 1089, GF_LOG_DEBUG
, "we're done locking"); } while (0)
1089 "we're done locking")do { do { if (0) printf ("we're done locking"); } while (0); _gf_log
(this->name, "afr-lk-common.c", __FUNCTION__, 1089, GF_LOG_DEBUG
, "we're done locking"); } while (0)
;
1090
1091 afr_copy_locked_nodes (frame, this);
1092
1093 int_lock->lock_op_ret = 0;
1094 int_lock->lock_cbk (frame, this);
1095 return 0;
1096 }
1097
1098 if (!_is_lock_wind_needed (local, child_index)) {
1099 afr_lock_blocking (frame, this, cookie + 1);
1100 return 0;
1101 }
1102
1103 switch (local->transaction.type) {
1104 case AFR_DATA_TRANSACTION:
1105 case AFR_METADATA_TRANSACTION:
1106
1107 if (local->fd) {
1108 AFR_TRACE_INODELK_IN (frame, this,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, &flock, 14, child_index); } while (0);
1109 AFR_INODELK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, &flock, 14, child_index); } while (0);
1110 AFR_LOCK_OP, &flock, F_SETLKW,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, &flock, 14, child_index); } while (0);
1111 child_index)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, &flock, 14, child_index); } while (0);
;
1112
1113 STACK_WIND_COOKIE (frame, afr_blocking_inodelk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1118
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->finodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->finodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->finodelk_cbk =
afr_blocking_inodelk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->finodelk); priv->children[child_index]->fops->
finodelk (_new, priv->children[child_index], this->name
, local->fd, 14, &flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1114 (void *) (long) child_index,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1118
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->finodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->finodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->finodelk_cbk =
afr_blocking_inodelk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->finodelk); priv->children[child_index]->fops->
finodelk (_new, priv->children[child_index], this->name
, local->fd, 14, &flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1115 priv->children[child_index],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1118
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->finodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->finodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->finodelk_cbk =
afr_blocking_inodelk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->finodelk); priv->children[child_index]->fops->
finodelk (_new, priv->children[child_index], this->name
, local->fd, 14, &flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1116 priv->children[child_index]->fops->finodelk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1118
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->finodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->finodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->finodelk_cbk =
afr_blocking_inodelk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->finodelk); priv->children[child_index]->fops->
finodelk (_new, priv->children[child_index], this->name
, local->fd, 14, &flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1117 this->name, local->fd,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1118
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->finodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->finodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->finodelk_cbk =
afr_blocking_inodelk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->finodelk); priv->children[child_index]->fops->
finodelk (_new, priv->children[child_index], this->name
, local->fd, 14, &flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1118 F_SETLKW, &flock, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1118
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->finodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->finodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->finodelk_cbk =
afr_blocking_inodelk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->finodelk); priv->children[child_index]->fops->
finodelk (_new, priv->children[child_index], this->name
, local->fd, 14, &flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1119
1120 } else {
1121 AFR_TRACE_INODELK_IN (frame, this,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, &flock, 14, child_index); } while (0);
1122 AFR_INODELK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, &flock, 14, child_index); } while (0);
1123 AFR_LOCK_OP, &flock, F_SETLKW,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, &flock, 14, child_index); } while (0);
1124 child_index)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_TRANSACTION
, AFR_LOCK_OP, &flock, 14, child_index); } while (0);
;
1125
1126 STACK_WIND_COOKIE (frame, afr_blocking_inodelk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1131
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->inodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->inodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->inodelk_cbk = afr_blocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->inodelk); priv->children
[child_index]->fops->inodelk (_new, priv->children[child_index
], this->name, &local->loc, 14, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1127 (void *) (long) child_index,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1131
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->inodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->inodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->inodelk_cbk = afr_blocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->inodelk); priv->children
[child_index]->fops->inodelk (_new, priv->children[child_index
], this->name, &local->loc, 14, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1128 priv->children[child_index],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1131
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->inodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->inodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->inodelk_cbk = afr_blocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->inodelk); priv->children
[child_index]->fops->inodelk (_new, priv->children[child_index
], this->name, &local->loc, 14, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1129 priv->children[child_index]->fops->inodelk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1131
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->inodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->inodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->inodelk_cbk = afr_blocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->inodelk); priv->children
[child_index]->fops->inodelk (_new, priv->children[child_index
], this->name, &local->loc, 14, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1130 this->name, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1131
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->inodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->inodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->inodelk_cbk = afr_blocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->inodelk); priv->children
[child_index]->fops->inodelk (_new, priv->children[child_index
], this->name, &local->loc, 14, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1131 F_SETLKW, &flock, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1131
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->inodelk_cbk) tmp_cbk
= afr_blocking_inodelk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->inodelk"
; _new->unwind_to = "afr_blocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->inodelk_cbk = afr_blocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->inodelk); priv->children
[child_index]->fops->inodelk (_new, priv->children[child_index
], this->name, &local->loc, 14, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
1132 }
1133
1134 break;
1135
1136 case AFR_ENTRY_RENAME_TRANSACTION:
1137 case AFR_ENTRY_TRANSACTION:
1138 /*Accounting for child_index increments on 'down'
1139 *and 'fd-less' children */
1140
1141 if (local->fd) {
1142 AFR_TRACE_ENTRYLK_IN (frame, this, AFR_ENTRYLK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, cookie
); } while (0);
1143 AFR_LOCK_OP,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, cookie
); } while (0);
1144 int_lock->lockee[lockee_no].basename,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, cookie
); } while (0);
1145 cookie)do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, cookie
); } while (0);
;
1146
1147 STACK_WIND_COOKIE (frame, afr_blocking_entrylk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1153
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->fentrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->fentrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->fentrylk_cbk =
afr_blocking_entrylk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->fentrylk); priv->children[child_index]->fops->
fentrylk (_new, priv->children[child_index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1148 (void *) (long) cookie,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1153
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->fentrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->fentrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->fentrylk_cbk =
afr_blocking_entrylk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->fentrylk); priv->children[child_index]->fops->
fentrylk (_new, priv->children[child_index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1149 priv->children[child_index],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1153
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->fentrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->fentrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->fentrylk_cbk =
afr_blocking_entrylk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->fentrylk); priv->children[child_index]->fops->
fentrylk (_new, priv->children[child_index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1150 priv->children[child_index]->fops->fentrylk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1153
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->fentrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->fentrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->fentrylk_cbk =
afr_blocking_entrylk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->fentrylk); priv->children[child_index]->fops->
fentrylk (_new, priv->children[child_index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1151 this->name, local->fd,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1153
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->fentrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->fentrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->fentrylk_cbk =
afr_blocking_entrylk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->fentrylk); priv->children[child_index]->fops->
fentrylk (_new, priv->children[child_index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1152 int_lock->lockee[lockee_no].basename,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1153
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->fentrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->fentrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->fentrylk_cbk =
afr_blocking_entrylk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->fentrylk); priv->children[child_index]->fops->
fentrylk (_new, priv->children[child_index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1153 ENTRYLK_LOCK, ENTRYLK_WRLCK, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1153
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->fentrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->fentrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->fentrylk_cbk =
afr_blocking_entrylk_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[child_index
]; if (priv->children[child_index]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[child_index]->
fops->fentrylk); priv->children[child_index]->fops->
fentrylk (_new, priv->children[child_index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
;
1154 } else {
1155 AFR_TRACE_ENTRYLK_IN (frame, this,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, local->transaction.basename, child_index); }
while (0);
1156 AFR_ENTRYLK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, local->transaction.basename, child_index); }
while (0);
1157 AFR_LOCK_OP, local->transaction.basename,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, local->transaction.basename, child_index); }
while (0);
1158 child_index)do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, local->transaction.basename, child_index); }
while (0);
;
1159
1160 STACK_WIND_COOKIE (frame, afr_blocking_entrylk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1167
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->entrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->entrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->entrylk_cbk = afr_blocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->entrylk); priv->children
[child_index]->fops->entrylk (_new, priv->children[child_index
], this->name, &int_lock->lockee[lockee_no].loc, int_lock
->lockee[lockee_no].basename, ENTRYLK_LOCK, ENTRYLK_WRLCK,
((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1161 (void *) (long) cookie,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1167
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->entrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->entrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->entrylk_cbk = afr_blocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->entrylk); priv->children
[child_index]->fops->entrylk (_new, priv->children[child_index
], this->name, &int_lock->lockee[lockee_no].loc, int_lock
->lockee[lockee_no].basename, ENTRYLK_LOCK, ENTRYLK_WRLCK,
((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1162 priv->children[child_index],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1167
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->entrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->entrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->entrylk_cbk = afr_blocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->entrylk); priv->children
[child_index]->fops->entrylk (_new, priv->children[child_index
], this->name, &int_lock->lockee[lockee_no].loc, int_lock
->lockee[lockee_no].basename, ENTRYLK_LOCK, ENTRYLK_WRLCK,
((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1163 priv->children[child_index]->fops->entrylk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1167
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->entrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->entrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->entrylk_cbk = afr_blocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->entrylk); priv->children
[child_index]->fops->entrylk (_new, priv->children[child_index
], this->name, &int_lock->lockee[lockee_no].loc, int_lock
->lockee[lockee_no].basename, ENTRYLK_LOCK, ENTRYLK_WRLCK,
((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1164 this->name,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1167
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->entrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->entrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->entrylk_cbk = afr_blocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->entrylk); priv->children
[child_index]->fops->entrylk (_new, priv->children[child_index
], this->name, &int_lock->lockee[lockee_no].loc, int_lock
->lockee[lockee_no].basename, ENTRYLK_LOCK, ENTRYLK_WRLCK,
((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1165 &int_lock->lockee[lockee_no].loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1167
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->entrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->entrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->entrylk_cbk = afr_blocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->entrylk); priv->children
[child_index]->fops->entrylk (_new, priv->children[child_index
], this->name, &int_lock->lockee[lockee_no].loc, int_lock
->lockee[lockee_no].basename, ENTRYLK_LOCK, ENTRYLK_WRLCK,
((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1166 int_lock->lockee[lockee_no].basename,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1167
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->entrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->entrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->entrylk_cbk = afr_blocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->entrylk); priv->children
[child_index]->fops->entrylk (_new, priv->children[child_index
], this->name, &int_lock->lockee[lockee_no].loc, int_lock
->lockee[lockee_no].basename, ENTRYLK_LOCK, ENTRYLK_WRLCK,
((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1167 ENTRYLK_LOCK, ENTRYLK_WRLCK, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1167
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->entrylk_cbk) tmp_cbk
= afr_blocking_entrylk_cbk; _new->root = frame->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) cookie; _new->wind_from = __FUNCTION__; _new->
wind_to = "priv->children[child_index]->fops->entrylk"
; _new->unwind_to = "afr_blocking_entrylk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->entrylk_cbk = afr_blocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->entrylk); priv->children
[child_index]->fops->entrylk (_new, priv->children[child_index
], this->name, &int_lock->lockee[lockee_no].loc, int_lock
->lockee[lockee_no].basename, ENTRYLK_LOCK, ENTRYLK_WRLCK,
((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
;
1168 }
1169
1170 break;
1171 }
1172
1173 return 0;
1174}
1175
1176int32_t
1177afr_blocking_lock (call_frame_t *frame, xlator_t *this)
1178{
1179 afr_internal_lock_t *int_lock = NULL((void*)0);
1180 afr_local_t *local = NULL((void*)0);
1181 afr_private_t *priv = NULL((void*)0);
1182 int up_count = 0;
1183
1184 priv = this->private;
1185 local = frame->local;
1186 int_lock = &local->internal_lock;
1187
1188 switch (local->transaction.type) {
1189 case AFR_DATA_TRANSACTION:
1190 case AFR_METADATA_TRANSACTION:
1191 initialize_inodelk_variables (frame, this);
1192 break;
1193
1194 case AFR_ENTRY_RENAME_TRANSACTION:
1195 case AFR_ENTRY_TRANSACTION:
1196 up_count = afr_up_children_count (local->child_up,
1197 priv->child_count);
1198 int_lock->lk_call_count = int_lock->lk_expected_count
1199 = (int_lock->lockee_count *
1200 up_count);
1201 initialize_entrylk_variables (frame, this);
1202 break;
1203 }
1204
1205 afr_lock_blocking (frame, this, 0);
1206
1207 return 0;
1208}
1209
1210static int32_t
1211afr_nonblocking_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1212 int32_t op_ret, int32_t op_errno, dict_t *xdata)
1213{
1214 afr_internal_lock_t *int_lock = NULL((void*)0);
1215 afr_local_t *local = NULL((void*)0);
1216 int call_count = 0;
1217 int child_index = (long) cookie;
1218 int copies = 0;
1219 int index = 0;
1220 int lockee_no = 0;
1221 afr_private_t *priv = NULL((void*)0);
1222
1223 priv = this->private;
1224
1225 copies = priv->child_count;
1226 index = child_index % copies;
1227 lockee_no = child_index / copies;
1228
1229 local = frame->local;
1230 int_lock = &local->internal_lock;
1231
1232 AFR_TRACE_ENTRYLK_OUT (frame, this, AFR_ENTRYLK_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, op_ret
, op_errno, (long) cookie); } while (0);
1233 AFR_LOCK_OP,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, op_ret
, op_errno, (long) cookie); } while (0);
1234 int_lock->lockee[lockee_no].basename, op_ret,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, op_ret
, op_errno, (long) cookie); } while (0);
1235 op_errno, (long) cookie)do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_out (frame, this, AFR_ENTRYLK_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, op_ret
, op_errno, (long) cookie); } while (0);
;
1236
1237 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
1238 {
1239 if (op_ret < 0 ) {
1240 if (op_errno == ENOSYS38) {
1241 /* return ENOTSUP */
1242 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("subvolume does not support locking. "
"please load features/locks xlator on server"); } while (0);
_gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1244
, GF_LOG_ERROR, "subvolume does not support locking. " "please load features/locks xlator on server"
); } while (0)
1243 "subvolume does not support locking. "do { do { if (0) printf ("subvolume does not support locking. "
"please load features/locks xlator on server"); } while (0);
_gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1244
, GF_LOG_ERROR, "subvolume does not support locking. " "please load features/locks xlator on server"
); } while (0)
1244 "please load features/locks xlator on server")do { do { if (0) printf ("subvolume does not support locking. "
"please load features/locks xlator on server"); } while (0);
_gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1244
, GF_LOG_ERROR, "subvolume does not support locking. " "please load features/locks xlator on server"
); } while (0)
;
1245 local->op_ret = op_ret;
1246 int_lock->lock_op_ret = op_ret;
1247
1248 int_lock->lock_op_errno = op_errno;
1249 local->op_errno = op_errno;
1250 }
1251 } else if (op_ret == 0) {
1252 int_lock->lockee[lockee_no].locked_nodes[index] |= \
1253 LOCKED_YES0x1;
1254 int_lock->lockee[lockee_no].locked_count++;
1255 int_lock->entrylk_lock_count++;
1256 }
1257
1258 call_count = --int_lock->lk_call_count;
1259 }
1260 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
1261
1262 if (call_count == 0) {
1263 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("Last locking reply received"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1264, GF_LOG_TRACE, "Last locking reply received"); } while
(0)
1264 "Last locking reply received")do { do { if (0) printf ("Last locking reply received"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1264, GF_LOG_TRACE, "Last locking reply received"); } while
(0)
;
1265 /* all locks successful. Proceed to call FOP */
1266 if (int_lock->entrylk_lock_count ==
1267 int_lock->lk_expected_count) {
1268 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("All servers locked. Calling the cbk"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1269, GF_LOG_TRACE, "All servers locked. Calling the cbk");
} while (0)
1269 "All servers locked. Calling the cbk")do { do { if (0) printf ("All servers locked. Calling the cbk"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1269, GF_LOG_TRACE, "All servers locked. Calling the cbk");
} while (0)
;
1270 int_lock->lock_op_ret = 0;
1271 int_lock->lock_cbk (frame, this);
1272 }
1273 /* Not all locks were successful. Unlock and try locking
1274 again, this time with serially blocking locks */
1275 else {
1276 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 1278, GF_LOG_TRACE, "%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0)
1277 "%d servers locked. Trying again with blocking calls",do { do { if (0) printf ("%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 1278, GF_LOG_TRACE, "%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0)
1278 int_lock->lock_count)do { do { if (0) printf ("%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 1278, GF_LOG_TRACE, "%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0)
;
1279
1280 afr_unlock(frame, this);
1281 }
1282 }
1283
1284 return 0;
1285}
1286
1287int
1288afr_nonblocking_entrylk (call_frame_t *frame, xlator_t *this)
1289{
1290 afr_internal_lock_t *int_lock = NULL((void*)0);
1291 afr_local_t *local = NULL((void*)0);
1292 afr_private_t *priv = NULL((void*)0);
1293 afr_fd_ctx_t *fd_ctx = NULL((void*)0);
1294 int copies = 0;
1295 int index = 0;
1296 int lockee_no = 0;
1297 int32_t call_count = 0;
1298 int i = 0;
1299
1300 local = frame->local;
1301 int_lock = &local->internal_lock;
1302 priv = this->private;
1303
1304 copies = priv->child_count;
1305 initialize_entrylk_variables (frame, this);
1306
1307 if (local->fd) {
1308 fd_ctx = afr_fd_ctx_get (local->fd, this);
1309 if (!fd_ctx) {
1310 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("unable to get fd ctx for fd=%p", local
->fd); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1312, GF_LOG_INFO, "unable to get fd ctx for fd=%p"
, local->fd); } while (0)
1311 "unable to get fd ctx for fd=%p",do { do { if (0) printf ("unable to get fd ctx for fd=%p", local
->fd); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1312, GF_LOG_INFO, "unable to get fd ctx for fd=%p"
, local->fd); } while (0)
1312 local->fd)do { do { if (0) printf ("unable to get fd ctx for fd=%p", local
->fd); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1312, GF_LOG_INFO, "unable to get fd ctx for fd=%p"
, local->fd); } while (0)
;
1313
1314 local->op_ret = -1;
1315 int_lock->lock_op_ret = -1;
1316 local->op_errno = EINVAL22;
1317 int_lock->lock_op_errno = EINVAL22;
1318
1319 return -1;
1320 }
1321
1322 call_count = int_lock->lockee_count * internal_lock_count (frame, this);
1323 int_lock->lk_call_count = call_count;
1324 int_lock->lk_expected_count = call_count;
1325
1326 if (!call_count) {
1327 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("fd not open on any subvolumes. aborting."
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1328, GF_LOG_INFO, "fd not open on any subvolumes. aborting."
); } while (0)
1328 "fd not open on any subvolumes. aborting.")do { do { if (0) printf ("fd not open on any subvolumes. aborting."
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1328, GF_LOG_INFO, "fd not open on any subvolumes. aborting."
); } while (0)
;
1329 afr_unlock (frame, this);
1330 goto out;
1331 }
1332
1333 /* Send non-blocking entrylk calls only on up children
1334 and where the fd has been opened */
1335 for (i = 0; i < int_lock->lockee_count*priv->child_count; i++) {
1336 index = i%copies;
1337 lockee_no = i/copies;
1338 if (local->child_up[index]) {
1339 AFR_TRACE_ENTRYLK_IN (frame, this, AFR_ENTRYLK_NB_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, i); }
while (0);
1340 AFR_LOCK_OP,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, i); }
while (0);
1341 int_lock->lockee[lockee_no].basename,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, i); }
while (0);
1342 i)do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, i); }
while (0);
;
1343
1344 STACK_WIND_COOKIE (frame, afr_nonblocking_entrylk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1351
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->fentrylk_cbk) tmp_cbk
= afr_nonblocking_entrylk_cbk; _new->root = frame->root
; _new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->fentrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->fentrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->fentrylk); priv->children[index]->
fops->fentrylk (_new, priv->children[index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK_NB
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1345 (void *) (long) i,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1351
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->fentrylk_cbk) tmp_cbk
= afr_nonblocking_entrylk_cbk; _new->root = frame->root
; _new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->fentrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->fentrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->fentrylk); priv->children[index]->
fops->fentrylk (_new, priv->children[index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK_NB
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1346 priv->children[index],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1351
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->fentrylk_cbk) tmp_cbk
= afr_nonblocking_entrylk_cbk; _new->root = frame->root
; _new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->fentrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->fentrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->fentrylk); priv->children[index]->
fops->fentrylk (_new, priv->children[index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK_NB
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1347 priv->children[index]->fops->fentrylk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1351
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->fentrylk_cbk) tmp_cbk
= afr_nonblocking_entrylk_cbk; _new->root = frame->root
; _new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->fentrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->fentrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->fentrylk); priv->children[index]->
fops->fentrylk (_new, priv->children[index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK_NB
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1348 this->name, local->fd,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1351
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->fentrylk_cbk) tmp_cbk
= afr_nonblocking_entrylk_cbk; _new->root = frame->root
; _new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->fentrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->fentrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->fentrylk); priv->children[index]->
fops->fentrylk (_new, priv->children[index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK_NB
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1349 int_lock->lockee[lockee_no].basename,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1351
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->fentrylk_cbk) tmp_cbk
= afr_nonblocking_entrylk_cbk; _new->root = frame->root
; _new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->fentrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->fentrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->fentrylk); priv->children[index]->
fops->fentrylk (_new, priv->children[index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK_NB
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1350 ENTRYLK_LOCK_NB, ENTRYLK_WRLCK,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1351
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->fentrylk_cbk) tmp_cbk
= afr_nonblocking_entrylk_cbk; _new->root = frame->root
; _new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->fentrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->fentrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->fentrylk); priv->children[index]->
fops->fentrylk (_new, priv->children[index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK_NB
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1351 NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1351
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->fentrylk_cbk) tmp_cbk
= afr_nonblocking_entrylk_cbk; _new->root = frame->root
; _new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->fentrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->fentrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->fentrylk); priv->children[index]->
fops->fentrylk (_new, priv->children[index], this->name
, local->fd, int_lock->lockee[lockee_no].basename, ENTRYLK_LOCK_NB
, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
;
1352 if (!--call_count)
1353 break;
1354 }
1355 }
1356 } else {
1357 call_count = int_lock->lockee_count * internal_lock_count (frame, this);
1358 int_lock->lk_call_count = call_count;
1359 int_lock->lk_expected_count = call_count;
1360
1361 for (i = 0; i < int_lock->lockee_count*priv->child_count; i++) {
1362 index = i%copies;
1363 lockee_no = i/copies;
1364 if (local->child_up[index]) {
1365 AFR_TRACE_ENTRYLK_IN (frame, this, AFR_ENTRYLK_NB_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, i); }
while (0);
1366 AFR_LOCK_OP,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, i); }
while (0);
1367 int_lock->lockee[lockee_no].basename,do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, i); }
while (0);
1368 i)do { afr_private_t *_priv = this->private; if (!_priv->
entrylk_trace) break; afr_trace_entrylk_in (frame, this, AFR_ENTRYLK_NB_TRANSACTION
, AFR_LOCK_OP, int_lock->lockee[lockee_no].basename, i); }
while (0);
;
1369
1370 STACK_WIND_COOKIE (frame, afr_nonblocking_entrylk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1377
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_nonblocking_entrylk_cbk; _new->root = frame->root;
_new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_LOCK_NB, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1371 (void *) (long) i,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1377
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_nonblocking_entrylk_cbk; _new->root = frame->root;
_new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_LOCK_NB, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1372 priv->children[index],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1377
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_nonblocking_entrylk_cbk; _new->root = frame->root;
_new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_LOCK_NB, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1373 priv->children[index]->fops->entrylk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1377
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_nonblocking_entrylk_cbk; _new->root = frame->root;
_new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_LOCK_NB, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1374 this->name, &int_lock->lockee[lockee_no].loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1377
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_nonblocking_entrylk_cbk; _new->root = frame->root;
_new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_LOCK_NB, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1375 int_lock->lockee[lockee_no].basename,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1377
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_nonblocking_entrylk_cbk; _new->root = frame->root;
_new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_LOCK_NB, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1376 ENTRYLK_LOCK_NB, ENTRYLK_WRLCK,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1377
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_nonblocking_entrylk_cbk; _new->root = frame->root;
_new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_LOCK_NB, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1377 NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1377
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[index]->fops->entrylk_cbk) tmp_cbk =
afr_nonblocking_entrylk_cbk; _new->root = frame->root;
_new->this = priv->children[index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = (void *
) (long) i; _new->wind_from = __FUNCTION__; _new->wind_to
= "priv->children[index]->fops->entrylk"; _new->
unwind_to = "afr_nonblocking_entrylk_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[index]->fops->entrylk_cbk = afr_nonblocking_entrylk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[index]; if (priv->children[index]->
ctx->measure_latency) gf_latency_begin (_new, priv->children
[index]->fops->entrylk); priv->children[index]->fops
->entrylk (_new, priv->children[index], this->name, &
int_lock->lockee[lockee_no].loc, int_lock->lockee[lockee_no
].basename, ENTRYLK_LOCK_NB, ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1378
1379 if (!--call_count)
1380 break;
1381 }
1382 }
1383 }
1384out:
1385 return 0;
1386}
1387
1388int32_t
1389afr_nonblocking_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1390 int32_t op_ret, int32_t op_errno, dict_t *xdata)
1391{
1392 afr_internal_lock_t *int_lock = NULL((void*)0);
1393 afr_local_t *local = NULL((void*)0);
1394 int call_count = 0;
1395 int child_index = (long) cookie;
1396 afr_fd_ctx_t *fd_ctx = NULL((void*)0);
1397
1398
1399 local = frame->local;
1400 int_lock = &local->internal_lock;
1401
1402 AFR_TRACE_INODELK_OUT (frame, this, AFR_INODELK_NB_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_out (frame, this, AFR_INODELK_NB_TRANSACTION
, AFR_LOCK_OP, ((void*)0), op_ret, op_errno, (long) cookie); }
while (0);
1403 AFR_LOCK_OP, NULL, op_ret,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_out (frame, this, AFR_INODELK_NB_TRANSACTION
, AFR_LOCK_OP, ((void*)0), op_ret, op_errno, (long) cookie); }
while (0);
1404 op_errno, (long) cookie)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_out (frame, this, AFR_INODELK_NB_TRANSACTION
, AFR_LOCK_OP, ((void*)0), op_ret, op_errno, (long) cookie); }
while (0);
;
1405
1406 if (local->fd)
1407 fd_ctx = afr_fd_ctx_get (local->fd, this);
1408
1409 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
1410 {
1411 if (op_ret < 0) {
1412 if (op_errno == ENOSYS38) {
1413 /* return ENOTSUP */
1414 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("subvolume does not support locking. "
"please load features/locks xlator on " "server"); } while (
0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1417
, GF_LOG_ERROR, "subvolume does not support locking. " "please load features/locks xlator on "
"server"); } while (0)
1415 "subvolume does not support locking. "do { do { if (0) printf ("subvolume does not support locking. "
"please load features/locks xlator on " "server"); } while (
0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1417
, GF_LOG_ERROR, "subvolume does not support locking. " "please load features/locks xlator on "
"server"); } while (0)
1416 "please load features/locks xlator on "do { do { if (0) printf ("subvolume does not support locking. "
"please load features/locks xlator on " "server"); } while (
0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1417
, GF_LOG_ERROR, "subvolume does not support locking. " "please load features/locks xlator on "
"server"); } while (0)
1417 "server")do { do { if (0) printf ("subvolume does not support locking. "
"please load features/locks xlator on " "server"); } while (
0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1417
, GF_LOG_ERROR, "subvolume does not support locking. " "please load features/locks xlator on "
"server"); } while (0)
;
1418 local->op_ret = op_ret;
1419 int_lock->lock_op_ret = op_ret;
1420 int_lock->lock_op_errno = op_errno;
1421 local->op_errno = op_errno;
1422 }
1423 if (local->transaction.eager_lock)
1424 local->transaction.eager_lock[child_index] = 0;
1425 } else {
1426 int_lock->inode_locked_nodes[child_index]
1427 |= LOCKED_YES0x1;
1428 int_lock->inodelk_lock_count++;
1429
1430 if (local->transaction.eager_lock &&
1431 local->transaction.eager_lock[child_index] &&
1432 local->fd) {
1433 /* piggybacked */
1434 if (op_ret == 1) {
1435 /* piggybacked */
1436 } else if (op_ret == 0) {
1437 /* lock acquired from server */
1438 fd_ctx->lock_acquired[child_index]++;
1439 }
1440 }
1441 }
1442
1443 call_count = --int_lock->lk_call_count;
1444 }
1445 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
1446
1447 if (call_count == 0) {
1448 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("Last inode locking reply received")
; } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1449, GF_LOG_TRACE, "Last inode locking reply received"); }
while (0)
1449 "Last inode locking reply received")do { do { if (0) printf ("Last inode locking reply received")
; } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1449, GF_LOG_TRACE, "Last inode locking reply received"); }
while (0)
;
1450 /* all locks successful. Proceed to call FOP */
1451 if (int_lock->inodelk_lock_count ==
1452 int_lock->lk_expected_count) {
1453 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("All servers locked. Calling the cbk"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1454, GF_LOG_TRACE, "All servers locked. Calling the cbk");
} while (0)
1454 "All servers locked. Calling the cbk")do { do { if (0) printf ("All servers locked. Calling the cbk"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1454, GF_LOG_TRACE, "All servers locked. Calling the cbk");
} while (0)
;
1455 int_lock->lock_op_ret = 0;
1456 int_lock->lock_cbk (frame, this);
1457 }
1458 /* Not all locks were successful. Unlock and try locking
1459 again, this time with serially blocking locks */
1460 else {
1461 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 1463, GF_LOG_TRACE, "%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0)
1462 "%d servers locked. Trying again with blocking calls",do { do { if (0) printf ("%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 1463, GF_LOG_TRACE, "%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0)
1463 int_lock->lock_count)do { do { if (0) printf ("%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0); _gf_log (this->name
, "afr-lk-common.c", __FUNCTION__, 1463, GF_LOG_TRACE, "%d servers locked. Trying again with blocking calls"
, int_lock->lock_count); } while (0)
;
1464
1465 afr_unlock(frame, this);
1466 }
1467 }
1468
1469 return 0;
1470}
1471
1472int
1473afr_nonblocking_inodelk (call_frame_t *frame, xlator_t *this)
1474{
1475 afr_internal_lock_t *int_lock = NULL((void*)0);
1476 afr_local_t *local = NULL((void*)0);
1477 afr_private_t *priv = NULL((void*)0);
1478 afr_fd_ctx_t *fd_ctx = NULL((void*)0);
1479 int32_t call_count = 0;
1480 int i = 0;
1481 int ret = 0;
1482 struct gf_flock flock = {0,};
1483 struct gf_flock full_flock = {0,};
1484 struct gf_flock *flock_use = NULL((void*)0);
1485 int piggyback = 0;
1486
1487 local = frame->local;
1488 int_lock = &local->internal_lock;
1489 priv = this->private;
1490
1491 flock.l_start = int_lock->lk_flock.l_start;
1492 flock.l_len = int_lock->lk_flock.l_len;
1493 flock.l_type = int_lock->lk_flock.l_type;
1494
1495 full_flock.l_type = int_lock->lk_flock.l_type;
1496
1497 initialize_inodelk_variables (frame, this);
1498
1499 if (local->fd) {
1500 fd_ctx = afr_fd_ctx_get (local->fd, this);
1501 if (!fd_ctx) {
1502 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("unable to get fd ctx for fd=%p", local
->fd); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1504, GF_LOG_INFO, "unable to get fd ctx for fd=%p"
, local->fd); } while (0)
1503 "unable to get fd ctx for fd=%p",do { do { if (0) printf ("unable to get fd ctx for fd=%p", local
->fd); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1504, GF_LOG_INFO, "unable to get fd ctx for fd=%p"
, local->fd); } while (0)
1504 local->fd)do { do { if (0) printf ("unable to get fd ctx for fd=%p", local
->fd); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1504, GF_LOG_INFO, "unable to get fd ctx for fd=%p"
, local->fd); } while (0)
;
1505
1506 local->op_ret = -1;
1507 int_lock->lock_op_ret = -1;
1508 local->op_errno = EINVAL22;
1509 int_lock->lock_op_errno = EINVAL22;
1510
1511 ret = -1;
1512 goto out;
1513 }
1514
1515 call_count = internal_lock_count (frame, this);
1516 int_lock->lk_call_count = call_count;
1517 int_lock->lk_expected_count = call_count;
1518
1519 if (!call_count) {
1520 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("fd not open on any subvolumes. aborting."
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1521, GF_LOG_INFO, "fd not open on any subvolumes. aborting."
); } while (0)
1521 "fd not open on any subvolumes. aborting.")do { do { if (0) printf ("fd not open on any subvolumes. aborting."
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1521, GF_LOG_INFO, "fd not open on any subvolumes. aborting."
); } while (0)
;
1522 afr_unlock (frame, this);
1523 goto out;
1524 }
1525
1526 /* Send non-blocking inodelk calls only on up children
1527 and where the fd has been opened */
1528 for (i = 0; i < priv->child_count; i++) {
1529 if (!local->child_up[i])
1530 continue;
1531
1532 flock_use = &flock;
1533 if (!local->transaction.eager_lock_on) {
1534 goto wind;
1535 }
1536
1537 piggyback = 0;
1538 local->transaction.eager_lock[i] = 1;
1539
1540 afr_set_delayed_post_op (frame, this);
1541
1542 LOCK (&local->fd->lock)pthread_spin_lock (&local->fd->lock);
1543 {
1544 if (fd_ctx->lock_acquired[i]) {
1545 fd_ctx->lock_piggyback[i]++;
1546 piggyback = 1;
1547 }
1548 }
1549 UNLOCK (&local->fd->lock)pthread_spin_unlock (&local->fd->lock);
1550
1551 if (piggyback) {
1552 /* (op_ret == 1) => indicate piggybacked lock */
1553 afr_nonblocking_inodelk_cbk (frame, (void *) (long) i,
1554 this, 1, 0, NULL((void*)0));
1555 if (!--call_count)
1556 break;
1557 continue;
1558 }
1559 flock_use = &full_flock;
1560 wind:
1561 AFR_TRACE_INODELK_IN (frame, this,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_NB_TRANSACTION
, AFR_LOCK_OP, flock_use, 13, i); } while (0);
1562 AFR_INODELK_NB_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_NB_TRANSACTION
, AFR_LOCK_OP, flock_use, 13, i); } while (0);
1563 AFR_LOCK_OP, flock_use, F_SETLK, i)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_NB_TRANSACTION
, AFR_LOCK_OP, flock_use, 13, i); } while (0);
;
1564
1565 STACK_WIND_COOKIE (frame, afr_nonblocking_inodelk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1570
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
1566 (void *) (long) i,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1570
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
1567 priv->children[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1570
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
1568 priv->children[i]->fops->finodelk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1570
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
1569 this->name, local->fd,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1570
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
1570 F_SETLK, flock_use, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1570
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->finodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->finodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->finodelk); priv->children[i]->fops->finodelk
(_new, priv->children[i], this->name, local->fd, 13
, flock_use, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
1571
1572 if (!--call_count)
1573 break;
1574 }
1575 } else {
1576 call_count = internal_lock_count (frame, this);
1577 int_lock->lk_call_count = call_count;
1578 int_lock->lk_expected_count = call_count;
1579
1580 for (i = 0; i < priv->child_count; i++) {
1581 if (!local->child_up[i])
1582 continue;
1583 AFR_TRACE_INODELK_IN (frame, this,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_NB_TRANSACTION
, AFR_LOCK_OP, &flock, 13, i); } while (0);
1584 AFR_INODELK_NB_TRANSACTION,do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_NB_TRANSACTION
, AFR_LOCK_OP, &flock, 13, i); } while (0);
1585 AFR_LOCK_OP, &flock, F_SETLK, i)do { afr_private_t *_priv = this->private; if (!_priv->
inodelk_trace) break; afr_trace_inodelk_in (frame, this, AFR_INODELK_NB_TRANSACTION
, AFR_LOCK_OP, &flock, 13, i); } while (0);
;
1586
1587 STACK_WIND_COOKIE (frame, afr_nonblocking_inodelk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1592
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
1588 (void *) (long) i,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1592
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
1589 priv->children[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1592
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
1590 priv->children[i]->fops->inodelk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1592
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
1591 this->name, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1592
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
1592 F_SETLK, &flock, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1592
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_nonblocking_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->inodelk"
; _new->unwind_to = "afr_nonblocking_inodelk_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[i]->fops->inodelk_cbk = afr_nonblocking_inodelk_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (priv->children[i]->ctx->
measure_latency) gf_latency_begin (_new, priv->children[i]
->fops->inodelk); priv->children[i]->fops->inodelk
(_new, priv->children[i], this->name, &local->loc
, 13, &flock, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
;
1593
1594 if (!--call_count)
1595 break;
1596 }
1597 }
1598out:
1599 return ret;
1600}
1601
1602int32_t
1603afr_unlock (call_frame_t *frame, xlator_t *this)
1604{
1605 afr_local_t *local = NULL((void*)0);
1606
1607 local = frame->local;
1608
1609 if (transaction_lk_op (local)) {
1610 if (is_afr_lock_transaction (local))
1611 afr_unlock_inodelk (frame, this);
1612 else
1613 afr_unlock_entrylk (frame, this);
1614
1615 } else {
1616 if (is_afr_lock_selfheal (local))
1617 afr_unlock_inodelk (frame, this);
1618 else
1619 afr_unlock_entrylk (frame, this);
1620 }
1621
1622 return 0;
1623}
1624
1625int
1626afr_mark_locked_nodes (xlator_t *this, fd_t *fd,
1627 unsigned char *locked_nodes)
1628{
1629 afr_private_t *priv = NULL((void*)0);
1630 afr_fd_ctx_t *fdctx = NULL((void*)0);
1631 uint64_t tmp = 0;
1632 int ret = 0;
1633
1634 priv = this->private;
1635
1636 ret = afr_fd_ctx_set (this, fd);
1637 if (ret)
1638 goto out;
1639
1640 ret = fd_ctx_get (fd, this, &tmp);
1641 if (ret) {
1642 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("failed to get the fd ctx"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1643, GF_LOG_INFO, "failed to get the fd ctx"); } while (0)
1643 "failed to get the fd ctx")do { do { if (0) printf ("failed to get the fd ctx"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1643, GF_LOG_INFO, "failed to get the fd ctx"); } while (0)
;
1644 goto out;
1645 }
1646 fdctx = (afr_fd_ctx_t *) (long) tmp;
1647
1648 GF_ASSERT (fdctx->locked_on)do { if (!(fdctx->locked_on)) { do { do { if (0) printf ("Assertion failed: "
"fdctx->locked_on"); } while (0); _gf_log_callingfn ("", "afr-lk-common.c"
, __FUNCTION__, 1648, GF_LOG_ERROR, "Assertion failed: " "fdctx->locked_on"
); } while (0); } } while (0)
;
1649
1650 memcpy (fdctx->locked_on, locked_nodes,
1651 priv->child_count);
1652
1653out:
1654 return ret;
1655}
1656
1657static int
1658__is_fd_saved (xlator_t *this, fd_t *fd)
1659{
1660 afr_locked_fd_t *locked_fd = NULL((void*)0);
1661 afr_private_t *priv = NULL((void*)0);
1662 int found = 0;
1663
1664 priv = this->private;
1665
1666 list_for_each_entry (locked_fd, &priv->saved_fds, list)for (locked_fd = ((typeof(*locked_fd) *)((char *)((&priv->
saved_fds)->next)-(unsigned long)(&((typeof(*locked_fd
) *)0)->list))); &locked_fd->list != (&priv->
saved_fds); locked_fd = ((typeof(*locked_fd) *)((char *)(locked_fd
->list.next)-(unsigned long)(&((typeof(*locked_fd) *)0
)->list))))
{
1667 if (locked_fd->fd == fd) {
1668 found = 1;
1669 break;
1670 }
1671 }
1672
1673 return found;
1674}
1675
1676static int
1677__afr_save_locked_fd (xlator_t *this, fd_t *fd)
1678{
1679 afr_private_t *priv = NULL((void*)0);
1680 afr_locked_fd_t *locked_fd = NULL((void*)0);
1681 int ret = 0;
1682
1683 priv = this->private;
1684
1685 locked_fd = GF_CALLOC (1, sizeof (*locked_fd),__gf_calloc (1, sizeof (*locked_fd), gf_afr_mt_locked_fd)
1686 gf_afr_mt_locked_fd)__gf_calloc (1, sizeof (*locked_fd), gf_afr_mt_locked_fd);
1687 if (!locked_fd) {
1688 ret = -1;
1689 goto out;
1690 }
1691
1692 locked_fd->fd = fd;
1693 INIT_LIST_HEAD (&locked_fd->list)do { (&locked_fd->list)->next = (&locked_fd->
list)->prev = &locked_fd->list; } while (0)
;
1694
1695 list_add_tail (&locked_fd->list, &priv->saved_fds);
1696
1697out:
1698 return ret;
1699}
1700
1701int
1702afr_save_locked_fd (xlator_t *this, fd_t *fd)
1703{
1704 afr_private_t *priv = NULL((void*)0);
1705 int ret = 0;
1706
1707 priv = this->private;
1708
1709 pthread_mutex_lock (&priv->mutex);
1710 {
1711 if (__is_fd_saved (this, fd)) {
1712 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("fd=%p already saved", fd); } while (
0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1713
, GF_LOG_DEBUG, "fd=%p already saved", fd); } while (0)
1713 "fd=%p already saved", fd)do { do { if (0) printf ("fd=%p already saved", fd); } while (
0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1713
, GF_LOG_DEBUG, "fd=%p already saved", fd); } while (0)
;
1714 goto unlock;
1715 }
1716
1717 ret = __afr_save_locked_fd (this, fd);
1718 if (ret) {
1719 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("fd=%p could not be saved", fd); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1720, GF_LOG_INFO, "fd=%p could not be saved", fd); } while
(0)
1720 "fd=%p could not be saved", fd)do { do { if (0) printf ("fd=%p could not be saved", fd); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1720, GF_LOG_INFO, "fd=%p could not be saved", fd); } while
(0)
;
1721 goto unlock;
1722 }
1723 }
1724unlock:
1725 pthread_mutex_unlock (&priv->mutex);
1726
1727 return ret;
1728}
1729
1730static int
1731afr_lock_recovery_cleanup (call_frame_t *frame, xlator_t *this)
1732{
1733 afr_local_t *local = NULL((void*)0);
1734 afr_locked_fd_t *locked_fd = NULL((void*)0);
1735
1736 local = frame->local;
1737
1738 locked_fd = local->locked_fd;
1739
1740 STACK_DESTROY (frame->root);
1741 afr_local_cleanup (local, this);
1742
1743 afr_save_locked_fd (this, locked_fd->fd);
1744
1745 return 0;
1746
1747}
1748
1749static int
1750afr_get_source_lock_recovery (xlator_t *this, fd_t *fd)
1751{
1752 afr_fd_ctx_t *fdctx = NULL((void*)0);
1753 afr_private_t *priv = NULL((void*)0);
1754 uint64_t tmp = 0;
1755 int i = 0;
1756 int source_child = -1;
1757 int ret = 0;
1758
1759 priv = this->private;
1760
1761 ret = fd_ctx_get (fd, this, &tmp);
1762 if (ret)
1763 goto out;
1764
1765 fdctx = (afr_fd_ctx_t *) (long) tmp;
1766
1767 for (i = 0; i < priv->child_count; i++) {
1768 if (fdctx->locked_on[i]) {
1769 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Found lock recovery source=%d", i);
} while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1770, GF_LOG_DEBUG, "Found lock recovery source=%d", i); } while
(0)
1770 "Found lock recovery source=%d", i)do { do { if (0) printf ("Found lock recovery source=%d", i);
} while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1770, GF_LOG_DEBUG, "Found lock recovery source=%d", i); } while
(0)
;
1771 source_child = i;
1772 break;
1773 }
1774 }
1775
1776out:
1777 return source_child;
1778
1779}
1780
1781int32_t
1782afr_get_locks_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1783 int32_t op_ret, int32_t op_errno, struct gf_flock *lock,
1784 dict_t *xdata);
1785int32_t
1786afr_recover_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1787 int32_t op_ret, int32_t op_errno, struct gf_flock *lock,
1788 dict_t *xdata)
1789{
1790 afr_local_t *local = NULL((void*)0);
1791 afr_private_t *priv = NULL((void*)0);
1792 int32_t source_child = 0;
1793 struct gf_flock flock = {0,};
1794
1795 local = frame->local;
1796 priv = this->private;
1797
1798 if (op_ret) {
1799 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("lock recovery failed"); } while (0)
; _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1800
, GF_LOG_INFO, "lock recovery failed"); } while (0)
1800 "lock recovery failed")do { do { if (0) printf ("lock recovery failed"); } while (0)
; _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1800
, GF_LOG_INFO, "lock recovery failed"); } while (0)
;
1801 goto cleanup;
1802 }
1803
1804 source_child = local->source_child;
1805
1806 memcpy (&flock, lock, sizeof (*lock));
1807
1808 STACK_WIND_COOKIE (frame, afr_get_locks_fd_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1812
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[source_child]->fops->lk_cbk) tmp_cbk
= afr_get_locks_fd_cbk; _new->root = frame->root; _new
->this = priv->children[source_child]; _new->ret = (
ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie =
(void *) (long) source_child; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[source_child]->fops->lk"
; _new->unwind_to = "afr_get_locks_fd_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[source_child]->fops->lk_cbk = afr_get_locks_fd_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[source_child]; if (priv->children[
source_child]->ctx->measure_latency) gf_latency_begin (
_new, priv->children[source_child]->fops->lk); priv->
children[source_child]->fops->lk (_new, priv->children
[source_child], local->fd, F_GETLK_FD, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1809 (void *) (long) source_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1812
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[source_child]->fops->lk_cbk) tmp_cbk
= afr_get_locks_fd_cbk; _new->root = frame->root; _new
->this = priv->children[source_child]; _new->ret = (
ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie =
(void *) (long) source_child; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[source_child]->fops->lk"
; _new->unwind_to = "afr_get_locks_fd_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[source_child]->fops->lk_cbk = afr_get_locks_fd_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[source_child]; if (priv->children[
source_child]->ctx->measure_latency) gf_latency_begin (
_new, priv->children[source_child]->fops->lk); priv->
children[source_child]->fops->lk (_new, priv->children
[source_child], local->fd, F_GETLK_FD, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1810 priv->children[source_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1812
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[source_child]->fops->lk_cbk) tmp_cbk
= afr_get_locks_fd_cbk; _new->root = frame->root; _new
->this = priv->children[source_child]; _new->ret = (
ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie =
(void *) (long) source_child; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[source_child]->fops->lk"
; _new->unwind_to = "afr_get_locks_fd_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[source_child]->fops->lk_cbk = afr_get_locks_fd_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[source_child]; if (priv->children[
source_child]->ctx->measure_latency) gf_latency_begin (
_new, priv->children[source_child]->fops->lk); priv->
children[source_child]->fops->lk (_new, priv->children
[source_child], local->fd, F_GETLK_FD, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1811 priv->children[source_child]->fops->lk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1812
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[source_child]->fops->lk_cbk) tmp_cbk
= afr_get_locks_fd_cbk; _new->root = frame->root; _new
->this = priv->children[source_child]; _new->ret = (
ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie =
(void *) (long) source_child; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[source_child]->fops->lk"
; _new->unwind_to = "afr_get_locks_fd_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[source_child]->fops->lk_cbk = afr_get_locks_fd_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[source_child]; if (priv->children[
source_child]->ctx->measure_latency) gf_latency_begin (
_new, priv->children[source_child]->fops->lk); priv->
children[source_child]->fops->lk (_new, priv->children
[source_child], local->fd, F_GETLK_FD, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1812 local->fd, F_GETLK_FD, &flock, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1812
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[source_child]->fops->lk_cbk) tmp_cbk
= afr_get_locks_fd_cbk; _new->root = frame->root; _new
->this = priv->children[source_child]; _new->ret = (
ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie =
(void *) (long) source_child; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[source_child]->fops->lk"
; _new->unwind_to = "afr_get_locks_fd_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[source_child]->fops->lk_cbk = afr_get_locks_fd_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[source_child]; if (priv->children[
source_child]->ctx->measure_latency) gf_latency_begin (
_new, priv->children[source_child]->fops->lk); priv->
children[source_child]->fops->lk (_new, priv->children
[source_child], local->fd, F_GETLK_FD, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
1813
1814 return 0;
1815
1816cleanup:
1817 afr_lock_recovery_cleanup (frame, this);
1818 return 0;
1819}
1820
1821int
1822afr_recover_lock (call_frame_t *frame, xlator_t *this,
1823 struct gf_flock *flock)
1824{
1825 afr_local_t *local = NULL((void*)0);
1826 afr_private_t *priv = NULL((void*)0);
1827 int32_t lock_recovery_child = 0;
1828
1829 priv = this->private;
1830 local = frame->local;
1831
1832 lock_recovery_child = local->lock_recovery_child;
1833
1834 frame->root->lk_owner = flock->l_owner;
1835
1836 STACK_WIND_COOKIE (frame, afr_recover_lock_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1840
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[lock_recovery_child]->fops->lk_cbk)
tmp_cbk = afr_recover_lock_cbk; _new->root = frame->root
; _new->this = priv->children[lock_recovery_child]; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) lock_recovery_child; _new->wind_from
= __FUNCTION__; _new->wind_to = "priv->children[lock_recovery_child]->fops->lk"
; _new->unwind_to = "afr_recover_lock_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[lock_recovery_child]->fops->lk_cbk
= afr_recover_lock_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[lock_recovery_child
]; if (priv->children[lock_recovery_child]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[lock_recovery_child
]->fops->lk); priv->children[lock_recovery_child]->
fops->lk (_new, priv->children[lock_recovery_child], local
->fd, 13, flock, ((void*)0)); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
1837 (void *) (long) lock_recovery_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1840
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[lock_recovery_child]->fops->lk_cbk)
tmp_cbk = afr_recover_lock_cbk; _new->root = frame->root
; _new->this = priv->children[lock_recovery_child]; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) lock_recovery_child; _new->wind_from
= __FUNCTION__; _new->wind_to = "priv->children[lock_recovery_child]->fops->lk"
; _new->unwind_to = "afr_recover_lock_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[lock_recovery_child]->fops->lk_cbk
= afr_recover_lock_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[lock_recovery_child
]; if (priv->children[lock_recovery_child]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[lock_recovery_child
]->fops->lk); priv->children[lock_recovery_child]->
fops->lk (_new, priv->children[lock_recovery_child], local
->fd, 13, flock, ((void*)0)); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
1838 priv->children[lock_recovery_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1840
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[lock_recovery_child]->fops->lk_cbk)
tmp_cbk = afr_recover_lock_cbk; _new->root = frame->root
; _new->this = priv->children[lock_recovery_child]; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) lock_recovery_child; _new->wind_from
= __FUNCTION__; _new->wind_to = "priv->children[lock_recovery_child]->fops->lk"
; _new->unwind_to = "afr_recover_lock_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[lock_recovery_child]->fops->lk_cbk
= afr_recover_lock_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[lock_recovery_child
]; if (priv->children[lock_recovery_child]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[lock_recovery_child
]->fops->lk); priv->children[lock_recovery_child]->
fops->lk (_new, priv->children[lock_recovery_child], local
->fd, 13, flock, ((void*)0)); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
1839 priv->children[lock_recovery_child]->fops->lk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1840
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[lock_recovery_child]->fops->lk_cbk)
tmp_cbk = afr_recover_lock_cbk; _new->root = frame->root
; _new->this = priv->children[lock_recovery_child]; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) lock_recovery_child; _new->wind_from
= __FUNCTION__; _new->wind_to = "priv->children[lock_recovery_child]->fops->lk"
; _new->unwind_to = "afr_recover_lock_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[lock_recovery_child]->fops->lk_cbk
= afr_recover_lock_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[lock_recovery_child
]; if (priv->children[lock_recovery_child]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[lock_recovery_child
]->fops->lk); priv->children[lock_recovery_child]->
fops->lk (_new, priv->children[lock_recovery_child], local
->fd, 13, flock, ((void*)0)); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
1840 local->fd, F_SETLK, flock, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1840
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[lock_recovery_child]->fops->lk_cbk)
tmp_cbk = afr_recover_lock_cbk; _new->root = frame->root
; _new->this = priv->children[lock_recovery_child]; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) lock_recovery_child; _new->wind_from
= __FUNCTION__; _new->wind_to = "priv->children[lock_recovery_child]->fops->lk"
; _new->unwind_to = "afr_recover_lock_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[lock_recovery_child]->fops->lk_cbk
= afr_recover_lock_cbk; old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[lock_recovery_child
]; if (priv->children[lock_recovery_child]->ctx->measure_latency
) gf_latency_begin (_new, priv->children[lock_recovery_child
]->fops->lk); priv->children[lock_recovery_child]->
fops->lk (_new, priv->children[lock_recovery_child], local
->fd, 13, flock, ((void*)0)); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
;
1841
1842 return 0;
1843}
1844
1845static int
1846is_afr_lock_eol (struct gf_flock *lock)
1847{
1848 int ret = 0;
1849
1850 if ((lock->l_type == GF_LK_EOL))
1851 ret = 1;
1852
1853 return ret;
1854}
1855
1856int32_t
1857afr_get_locks_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1858 int32_t op_ret, int32_t op_errno, struct gf_flock *lock,
1859 dict_t *xdata)
1860{
1861 if (op_ret) {
1862 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("Failed to get locks on fd"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1863, GF_LOG_INFO, "Failed to get locks on fd"); } while (0
)
1863 "Failed to get locks on fd")do { do { if (0) printf ("Failed to get locks on fd"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1863, GF_LOG_INFO, "Failed to get locks on fd"); } while (0
)
;
1864 goto cleanup;
1865 }
1866
1867 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Got a lock on fd"); } while (0); _gf_log
(this->name, "afr-lk-common.c", __FUNCTION__, 1868, GF_LOG_DEBUG
, "Got a lock on fd"); } while (0)
1868 "Got a lock on fd")do { do { if (0) printf ("Got a lock on fd"); } while (0); _gf_log
(this->name, "afr-lk-common.c", __FUNCTION__, 1868, GF_LOG_DEBUG
, "Got a lock on fd"); } while (0)
;
1869
1870 if (is_afr_lock_eol (lock)) {
1871 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("Reached EOL on locks on fd"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1872, GF_LOG_INFO, "Reached EOL on locks on fd"); } while (
0)
1872 "Reached EOL on locks on fd")do { do { if (0) printf ("Reached EOL on locks on fd"); } while
(0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1872, GF_LOG_INFO, "Reached EOL on locks on fd"); } while (
0)
;
1873 goto cleanup;
1874 }
1875
1876 afr_recover_lock (frame, this, lock);
1877
1878 return 0;
1879
1880cleanup:
1881 afr_lock_recovery_cleanup (frame, this);
1882
1883 return 0;
1884}
1885
1886static int
1887afr_lock_recovery (call_frame_t *frame, xlator_t *this)
1888{
1889 afr_local_t *local = NULL((void*)0);
1890 afr_private_t *priv = NULL((void*)0);
1891 fd_t *fd = NULL((void*)0);
1892 int ret = 0;
1893 int32_t source_child = 0;
1894 struct gf_flock flock = {0,};
1895
1896 priv = this->private;
1897 local = frame->local;
1898
1899 fd = local->fd;
1900
1901 source_child = afr_get_source_lock_recovery (this, fd);
1902 if (source_child < 0) {
1903 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Could not recover locks due to lock "
"split brain"); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1905, GF_LOG_ERROR, "Could not recover locks due to lock "
"split brain"); } while (0)
1904 "Could not recover locks due to lock "do { do { if (0) printf ("Could not recover locks due to lock "
"split brain"); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1905, GF_LOG_ERROR, "Could not recover locks due to lock "
"split brain"); } while (0)
1905 "split brain")do { do { if (0) printf ("Could not recover locks due to lock "
"split brain"); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 1905, GF_LOG_ERROR, "Could not recover locks due to lock "
"split brain"); } while (0)
;
1906 ret = -1;
1907 goto out;
1908 }
1909
1910 local->source_child = source_child;
1911
1912 /* the flock can be zero filled as we're querying incrementally
1913 the locks held on the fd.
1914 */
1915 STACK_WIND_COOKIE (frame, afr_get_locks_fd_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1919
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[source_child]->fops->lk_cbk) tmp_cbk
= afr_get_locks_fd_cbk; _new->root = frame->root; _new
->this = priv->children[source_child]; _new->ret = (
ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie =
(void *) (long) source_child; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[source_child]->fops->lk"
; _new->unwind_to = "afr_get_locks_fd_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[source_child]->fops->lk_cbk = afr_get_locks_fd_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[source_child]; if (priv->children[
source_child]->ctx->measure_latency) gf_latency_begin (
_new, priv->children[source_child]->fops->lk); priv->
children[source_child]->fops->lk (_new, priv->children
[source_child], local->fd, F_GETLK_FD, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1916 (void *) (long) source_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1919
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[source_child]->fops->lk_cbk) tmp_cbk
= afr_get_locks_fd_cbk; _new->root = frame->root; _new
->this = priv->children[source_child]; _new->ret = (
ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie =
(void *) (long) source_child; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[source_child]->fops->lk"
; _new->unwind_to = "afr_get_locks_fd_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[source_child]->fops->lk_cbk = afr_get_locks_fd_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[source_child]; if (priv->children[
source_child]->ctx->measure_latency) gf_latency_begin (
_new, priv->children[source_child]->fops->lk); priv->
children[source_child]->fops->lk (_new, priv->children
[source_child], local->fd, F_GETLK_FD, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1917 priv->children[source_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1919
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[source_child]->fops->lk_cbk) tmp_cbk
= afr_get_locks_fd_cbk; _new->root = frame->root; _new
->this = priv->children[source_child]; _new->ret = (
ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie =
(void *) (long) source_child; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[source_child]->fops->lk"
; _new->unwind_to = "afr_get_locks_fd_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[source_child]->fops->lk_cbk = afr_get_locks_fd_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[source_child]; if (priv->children[
source_child]->ctx->measure_latency) gf_latency_begin (
_new, priv->children[source_child]->fops->lk); priv->
children[source_child]->fops->lk (_new, priv->children
[source_child], local->fd, F_GETLK_FD, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1918 priv->children[source_child]->fops->lk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1919
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[source_child]->fops->lk_cbk) tmp_cbk
= afr_get_locks_fd_cbk; _new->root = frame->root; _new
->this = priv->children[source_child]; _new->ret = (
ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie =
(void *) (long) source_child; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[source_child]->fops->lk"
; _new->unwind_to = "afr_get_locks_fd_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[source_child]->fops->lk_cbk = afr_get_locks_fd_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[source_child]; if (priv->children[
source_child]->ctx->measure_latency) gf_latency_begin (
_new, priv->children[source_child]->fops->lk); priv->
children[source_child]->fops->lk (_new, priv->children
[source_child], local->fd, F_GETLK_FD, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1919 local->fd, F_GETLK_FD, &flock, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 1919
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[source_child]->fops->lk_cbk) tmp_cbk
= afr_get_locks_fd_cbk; _new->root = frame->root; _new
->this = priv->children[source_child]; _new->ret = (
ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie =
(void *) (long) source_child; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[source_child]->fops->lk"
; _new->unwind_to = "afr_get_locks_fd_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[source_child]->fops->lk_cbk = afr_get_locks_fd_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[source_child]; if (priv->children[
source_child]->ctx->measure_latency) gf_latency_begin (
_new, priv->children[source_child]->fops->lk); priv->
children[source_child]->fops->lk (_new, priv->children
[source_child], local->fd, F_GETLK_FD, &flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
1920
1921out:
1922 return ret;
1923}
1924
1925
1926static int
1927afr_mark_fd_opened (xlator_t *this, fd_t *fd, int32_t child_index)
1928{
1929 afr_fd_ctx_t *fdctx = NULL((void*)0);
1930 uint64_t tmp = 0;
1931 int ret = 0;
1932
1933 ret = fd_ctx_get (fd, this, &tmp);
1934 if (ret)
1935 goto out;
1936
1937 fdctx = (afr_fd_ctx_t *) (long) tmp;
1938
1939 fdctx->opened_on[child_index] = AFR_FD_OPENED;
1940
1941out:
1942 return ret;
1943}
1944
1945int32_t
1946afr_lock_recovery_preopen_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1947 int32_t op_ret, int32_t op_errno, fd_t *fd,
1948 dict_t *xdata)
1949{
1950 int32_t child_index = (long )cookie;
1951 int ret = 0;
1952
1953 if (op_ret) {
1954 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("Reopen during lock-recovery failed"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1955, GF_LOG_INFO, "Reopen during lock-recovery failed"); }
while (0)
1955 "Reopen during lock-recovery failed")do { do { if (0) printf ("Reopen during lock-recovery failed"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1955, GF_LOG_INFO, "Reopen during lock-recovery failed"); }
while (0)
;
1956 goto cleanup;
1957 }
1958
1959 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Open succeeded => proceed to recover locks"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1960, GF_LOG_DEBUG, "Open succeeded => proceed to recover locks"
); } while (0)
1960 "Open succeeded => proceed to recover locks")do { do { if (0) printf ("Open succeeded => proceed to recover locks"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 1960, GF_LOG_DEBUG, "Open succeeded => proceed to recover locks"
); } while (0)
;
1961
1962 ret = afr_lock_recovery (frame, this);
1963 if (ret) {
1964 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("Lock recovery failed"); } while (0)
; _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1965
, GF_LOG_INFO, "Lock recovery failed"); } while (0)
1965 "Lock recovery failed")do { do { if (0) printf ("Lock recovery failed"); } while (0)
; _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1965
, GF_LOG_INFO, "Lock recovery failed"); } while (0)
;
1966 goto cleanup;
1967 }
1968
1969 ret = afr_mark_fd_opened (this, fd, child_index);
1970 if (ret) {
1971 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("Marking fd open failed"); } while (
0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1972
, GF_LOG_INFO, "Marking fd open failed"); } while (0)
1972 "Marking fd open failed")do { do { if (0) printf ("Marking fd open failed"); } while (
0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__, 1972
, GF_LOG_INFO, "Marking fd open failed"); } while (0)
;
1973 goto cleanup;
1974 }
1975
1976 return 0;
1977
1978cleanup:
1979 afr_lock_recovery_cleanup (frame, this);
1980 return 0;
1981}
1982
1983static int
1984afr_lock_recovery_preopen (call_frame_t *frame, xlator_t *this)
1985{
1986 afr_private_t *priv = NULL((void*)0);
1987 afr_local_t *local = NULL((void*)0);
1988 uint64_t tmp = 0;
1989 afr_fd_ctx_t *fdctx = NULL((void*)0);
1990 loc_t loc = {0,};
1991 int32_t child_index = 0;
1992 int ret = 0;
1993
1994 priv = this->private;
1995 local = frame->local;
1996
1997 GF_ASSERT (local && local->fd)do { if (!(local && local->fd)) { do { do { if (0)
printf ("Assertion failed: " "local && local->fd"
); } while (0); _gf_log_callingfn ("", "afr-lk-common.c", __FUNCTION__
, 1997, GF_LOG_ERROR, "Assertion failed: " "local && local->fd"
); } while (0); } } while (0)
;
1998
1999 ret = fd_ctx_get (local->fd, this, &tmp);
2000 if (ret)
8
Assuming 'ret' is 0
9
Taking false branch
2001 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to get the context of fd"
, uuid_utoa (local->fd->inode->gfid)); } while (0); _gf_log
(this->name, "afr-lk-common.c", __FUNCTION__, 2003, GF_LOG_WARNING
, "%s: failed to get the context of fd", uuid_utoa (local->
fd->inode->gfid)); } while (0)
2002 "%s: failed to get the context of fd",do { do { if (0) printf ("%s: failed to get the context of fd"
, uuid_utoa (local->fd->inode->gfid)); } while (0); _gf_log
(this->name, "afr-lk-common.c", __FUNCTION__, 2003, GF_LOG_WARNING
, "%s: failed to get the context of fd", uuid_utoa (local->
fd->inode->gfid)); } while (0)
2003 uuid_utoa (local->fd->inode->gfid))do { do { if (0) printf ("%s: failed to get the context of fd"
, uuid_utoa (local->fd->inode->gfid)); } while (0); _gf_log
(this->name, "afr-lk-common.c", __FUNCTION__, 2003, GF_LOG_WARNING
, "%s: failed to get the context of fd", uuid_utoa (local->
fd->inode->gfid)); } while (0)
;
2004 fdctx = (afr_fd_ctx_t *) (long) tmp;
10
Value assigned to 'fdctx'
2005 /* TODO: instead we should return from the function */
2006 GF_ASSERT (fdctx)do { if (!(fdctx)) { do { do { if (0) printf ("Assertion failed: "
"fdctx"); } while (0); _gf_log_callingfn ("", "afr-lk-common.c"
, __FUNCTION__, 2006, GF_LOG_ERROR, "Assertion failed: " "fdctx"
); } while (0); } } while (0)
;
11
Within the expansion of the macro 'GF_ASSERT':
a
Assuming 'fdctx' is null
2007
2008 child_index = local->lock_recovery_child;
2009
2010 inode_path (local->fd->inode, NULL((void*)0), (char **)&loc.path);
2011 loc.name = strrchr (loc.path, '/');
2012 loc.inode = inode_ref (local->fd->inode);
2013 loc.parent = inode_parent (local->fd->inode, 0, NULL((void*)0));
2014
2015
2016 STACK_WIND_COOKIE (frame, afr_lock_recovery_preopen_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 2020
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->open_cbk) tmp_cbk
= afr_lock_recovery_preopen_cbk; _new->root = frame->root
; _new->this = priv->children[child_index]; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= (void *)(long) child_index; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[child_index]->fops->open"
; _new->unwind_to = "afr_lock_recovery_preopen_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->open_cbk = afr_lock_recovery_preopen_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->open); priv->children[child_index
]->fops->open (_new, priv->children[child_index], &
loc, fdctx->flags, local->fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
12
Within the expansion of the macro 'STACK_WIND_COOKIE':
a
Assuming '_new' is non-null
b
Access to field 'flags' results in a dereference of a null pointer (loaded from variable 'fdctx')
2017 (void *)(long) child_index,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 2020
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->open_cbk) tmp_cbk
= afr_lock_recovery_preopen_cbk; _new->root = frame->root
; _new->this = priv->children[child_index]; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= (void *)(long) child_index; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[child_index]->fops->open"
; _new->unwind_to = "afr_lock_recovery_preopen_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->open_cbk = afr_lock_recovery_preopen_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->open); priv->children[child_index
]->fops->open (_new, priv->children[child_index], &
loc, fdctx->flags, local->fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2018 priv->children[child_index],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 2020
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->open_cbk) tmp_cbk
= afr_lock_recovery_preopen_cbk; _new->root = frame->root
; _new->this = priv->children[child_index]; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= (void *)(long) child_index; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[child_index]->fops->open"
; _new->unwind_to = "afr_lock_recovery_preopen_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->open_cbk = afr_lock_recovery_preopen_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->open); priv->children[child_index
]->fops->open (_new, priv->children[child_index], &
loc, fdctx->flags, local->fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2019 priv->children[child_index]->fops->open,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 2020
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->open_cbk) tmp_cbk
= afr_lock_recovery_preopen_cbk; _new->root = frame->root
; _new->this = priv->children[child_index]; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= (void *)(long) child_index; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[child_index]->fops->open"
; _new->unwind_to = "afr_lock_recovery_preopen_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->open_cbk = afr_lock_recovery_preopen_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->open); priv->children[child_index
]->fops->open (_new, priv->children[child_index], &
loc, fdctx->flags, local->fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2020 &loc, fdctx->flags, local->fd, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "afr-lk-common.c", __FUNCTION__, 2020
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( priv->children[child_index]->fops->open_cbk) tmp_cbk
= afr_lock_recovery_preopen_cbk; _new->root = frame->root
; _new->this = priv->children[child_index]; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= (void *)(long) child_index; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[child_index]->fops->open"
; _new->unwind_to = "afr_lock_recovery_preopen_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { frame->ref_count++; _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; } pthread_spin_unlock (&frame->root->stack_lock
); priv->children[child_index]->fops->open_cbk = afr_lock_recovery_preopen_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[child_index]; if (priv->children[child_index
]->ctx->measure_latency) gf_latency_begin (_new, priv->
children[child_index]->fops->open); priv->children[child_index
]->fops->open (_new, priv->children[child_index], &
loc, fdctx->flags, local->fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2021
2022 return 0;
2023}
2024
2025static int
2026is_fd_opened (fd_t *fd, int32_t child_index)
2027{
2028 afr_fd_ctx_t *fdctx = NULL((void*)0);
2029 uint64_t tmp = 0;
2030 int ret = 0;
2031
2032 ret = fd_ctx_get (fd, THIS(*__glusterfs_this_location()), &tmp);
2033 if (ret)
2034 goto out;
2035
2036 fdctx = (afr_fd_ctx_t *) (long) tmp;
2037
2038 if (fdctx->opened_on[child_index] == AFR_FD_OPENED)
2039 ret = 1;
2040
2041out:
2042 return ret;
2043}
2044
2045int
2046afr_attempt_lock_recovery (xlator_t *this, int32_t child_index)
2047{
2048 call_frame_t *frame = NULL((void*)0);
2049 afr_private_t *priv = NULL((void*)0);
2050 afr_local_t *local = NULL((void*)0);
2051 afr_locked_fd_t *locked_fd = NULL((void*)0);
2052 afr_locked_fd_t *tmp = NULL((void*)0);
2053 int ret = -1;
2054 struct list_head locks_list = {0,};
2055 int32_t op_errno = 0;
2056
2057
2058 priv = this->private;
2059
2060 if (list_empty (&priv->saved_fds))
1
Taking false branch
2061 goto out;
2062
2063 frame = create_frame (this, this->ctx->pool);
2064 if (!frame) {
2
Assuming 'frame' is non-null
3
Taking false branch
2065 ret = -1;
2066 goto out;
2067 }
2068
2069 AFR_LOCAL_ALLOC_OR_GOTO (frame->local, out)do { frame->local = mem_get0 ((*__glusterfs_this_location(
))->local_pool); if (!frame->local) { do { do { if (0) printf
("out of memory :("); } while (0); _gf_log (this->name, "afr-lk-common.c"
, __FUNCTION__, 2069, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
2070 local = frame->local;
2071 ret = afr_local_init (local, priv, &op_errno);
2072 if (ret < 0) {
4
Assuming 'ret' is >= 0
5
Taking false branch
2073 ret = -1;
2074 goto out;
2075 }
2076
2077 frame->local = local;
2078
2079 INIT_LIST_HEAD (&locks_list)do { (&locks_list)->next = (&locks_list)->prev =
&locks_list; } while (0)
;
2080
2081 pthread_mutex_lock (&priv->mutex);
2082 {
2083 list_splice_init (&priv->saved_fds, &locks_list);
2084 }
2085 pthread_mutex_unlock (&priv->mutex);
2086
2087 list_for_each_entry_safe (locked_fd, tmp,for (locked_fd = ((typeof(*locked_fd) *)((char *)((&locks_list
)->next)-(unsigned long)(&((typeof(*locked_fd) *)0)->
list))), tmp = ((typeof(*locked_fd) *)((char *)(locked_fd->
list.next)-(unsigned long)(&((typeof(*locked_fd) *)0)->
list))); &locked_fd->list != (&locks_list); locked_fd
= tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->list.next)-(
unsigned long)(&((typeof(*tmp) *)0)->list))))
2088 &locks_list, list)for (locked_fd = ((typeof(*locked_fd) *)((char *)((&locks_list
)->next)-(unsigned long)(&((typeof(*locked_fd) *)0)->
list))), tmp = ((typeof(*locked_fd) *)((char *)(locked_fd->
list.next)-(unsigned long)(&((typeof(*locked_fd) *)0)->
list))); &locked_fd->list != (&locks_list); locked_fd
= tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->list.next)-(
unsigned long)(&((typeof(*tmp) *)0)->list))))
{
2089
2090 list_del_init (&locked_fd->list);
2091
2092 local->fd = fd_ref (locked_fd->fd);
2093 local->lock_recovery_child = child_index;
2094 local->locked_fd = locked_fd;
2095
2096 if (!is_fd_opened (locked_fd->fd, child_index)) {
6
Taking true branch
2097 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("attempting open before lock " "recovery"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 2099, GF_LOG_DEBUG, "attempting open before lock " "recovery"
); } while (0)
2098 "attempting open before lock "do { do { if (0) printf ("attempting open before lock " "recovery"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 2099, GF_LOG_DEBUG, "attempting open before lock " "recovery"
); } while (0)
2099 "recovery")do { do { if (0) printf ("attempting open before lock " "recovery"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 2099, GF_LOG_DEBUG, "attempting open before lock " "recovery"
); } while (0)
;
2100 afr_lock_recovery_preopen (frame, this);
7
Calling 'afr_lock_recovery_preopen'
2101 } else {
2102 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("attempting lock recovery " "without a preopen"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 2104, GF_LOG_DEBUG, "attempting lock recovery " "without a preopen"
); } while (0)
2103 "attempting lock recovery "do { do { if (0) printf ("attempting lock recovery " "without a preopen"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 2104, GF_LOG_DEBUG, "attempting lock recovery " "without a preopen"
); } while (0)
2104 "without a preopen")do { do { if (0) printf ("attempting lock recovery " "without a preopen"
); } while (0); _gf_log (this->name, "afr-lk-common.c", __FUNCTION__
, 2104, GF_LOG_DEBUG, "attempting lock recovery " "without a preopen"
); } while (0)
;
2105 afr_lock_recovery (frame, this);
2106 }
2107 }
2108
2109out:
2110 if ((ret < 0) && frame)
2111 AFR_STACK_DESTROY (frame)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); __local = frame->local; __this = frame->this;
frame->local = ((void*)0); STACK_DESTROY (frame->root)
; if (__local) { afr_local_cleanup (__local, __this); mem_put
(__local); } } while (0);
;
2112 return ret;
2113}
2114
2115void
2116afr_lk_transfer_datalock (call_frame_t *dst, call_frame_t *src,
2117 unsigned int child_count)
2118{
2119 afr_local_t *dst_local = NULL((void*)0);
2120 afr_local_t *src_local = NULL((void*)0);
2121 afr_internal_lock_t *dst_lock = NULL((void*)0);
2122 afr_internal_lock_t *src_lock = NULL((void*)0);
2123
2124 dst_local = dst->local;
2125 dst_lock = &dst_local->internal_lock;
2126 src_local = src->local;
2127 src_lock = &src_local->internal_lock;
2128 if (src_lock->inode_locked_nodes) {
2129 memcpy (dst_lock->inode_locked_nodes,
2130 src_lock->inode_locked_nodes,
2131 sizeof (*dst_lock->inode_locked_nodes) * child_count);
2132 memset (src_lock->inode_locked_nodes, 0,
2133 sizeof (*src_lock->inode_locked_nodes) * child_count);
2134 }
2135
2136 dst_lock->transaction_lk_type = src_lock->transaction_lk_type;
2137 dst_lock->selfheal_lk_type = src_lock->selfheal_lk_type;
2138 dst_lock->inodelk_lock_count = src_lock->inodelk_lock_count;
2139 src_lock->inodelk_lock_count = 0;
2140}