Bug Summary

File:xlators/cluster/afr/src/./afr-common.c
Location:line 3877, column 25
Description:Value stored to 'up_children' is never read

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 <libgen.h>
12#include <unistd.h>
13#include <fnmatch.h>
14#include <sys/time.h>
15#include <stdlib.h>
16#include <signal.h>
17
18#ifndef _CONFIG_H
19#define _CONFIG_H
20#include "config.h"
21#endif
22
23#include "glusterfs.h"
24#include "afr.h"
25#include "dict.h"
26#include "xlator.h"
27#include "hashfn.h"
28#include "logging.h"
29#include "stack.h"
30#include "list.h"
31#include "call-stub.h"
32#include "defaults.h"
33#include "common-utils.h"
34#include "compat-errno.h"
35#include "compat.h"
36#include "byte-order.h"
37#include "statedump.h"
38#include "inode.h"
39
40#include "fd.h"
41
42#include "afr-inode-read.h"
43#include "afr-inode-write.h"
44#include "afr-dir-read.h"
45#include "afr-dir-write.h"
46#include "afr-transaction.h"
47#include "afr-self-heal.h"
48#include "afr-self-heal-common.h"
49#include "afr-self-heald.h"
50#include "pump.h"
51
52#define AFR_ICTX_OPENDIR_DONE_MASK0x0000000100000000ULL 0x0000000100000000ULL
53#define AFR_ICTX_READ_CHILD_MASK0x00000000FFFFFFFFULL 0x00000000FFFFFFFFULL
54
55int
56afr_lookup_done_success_action (call_frame_t *frame, xlator_t *this,
57 gf_boolean_t fail_conflict);
58void
59afr_children_copy (int32_t *dst, int32_t *src, unsigned int child_count)
60{
61 int i = 0;
62
63 for (i = 0; i < child_count; i++)
64 dst[i] = src[i];
65}
66
67void
68afr_xattr_req_prepare (xlator_t *this, dict_t *xattr_req, const char *path)
69{
70 int i = 0;
71 afr_private_t *priv = NULL((void*)0);
72 int ret = 0;
73
74 priv = this->private;
75
76 for (i = 0; i < priv->child_count; i++) {
77 ret = dict_set_uint64 (xattr_req, priv->pending_key[i],
78 3 * sizeof(int32_t));
79 if (ret < 0)
80 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: Unable to set dict value for %s"
, path, priv->pending_key[i]); } while (0); _gf_log (this->
name, "./afr-common.c", __FUNCTION__, 82, GF_LOG_WARNING, "%s: Unable to set dict value for %s"
, path, priv->pending_key[i]); } while (0)
81 "%s: Unable to set dict value for %s",do { do { if (0) printf ("%s: Unable to set dict value for %s"
, path, priv->pending_key[i]); } while (0); _gf_log (this->
name, "./afr-common.c", __FUNCTION__, 82, GF_LOG_WARNING, "%s: Unable to set dict value for %s"
, path, priv->pending_key[i]); } while (0)
82 path, priv->pending_key[i])do { do { if (0) printf ("%s: Unable to set dict value for %s"
, path, priv->pending_key[i]); } while (0); _gf_log (this->
name, "./afr-common.c", __FUNCTION__, 82, GF_LOG_WARNING, "%s: Unable to set dict value for %s"
, path, priv->pending_key[i]); } while (0)
;
83 /* 3 = data+metadata+entry */
84 }
85 ret = dict_set_int32 (xattr_req, GF_GFIDLESS_LOOKUP"gfidless-lookup", 1);
86 if (ret) {
87 gf_log (this->name, GF_LOG_DEBUG, "%s: failed to set gfidless "do { do { if (0) printf ("%s: failed to set gfidless " "lookup"
, path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 88, GF_LOG_DEBUG, "%s: failed to set gfidless "
"lookup", path); } while (0)
88 "lookup", path)do { do { if (0) printf ("%s: failed to set gfidless " "lookup"
, path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 88, GF_LOG_DEBUG, "%s: failed to set gfidless "
"lookup", path); } while (0)
;
89 }
90}
91
92int
93afr_lookup_xattr_req_prepare (afr_local_t *local, xlator_t *this,
94 dict_t *xattr_req, loc_t *loc, void **gfid_req)
95{
96 int ret = -ENOMEM12;
97
98 GF_ASSERT (gfid_req)do { if (!(gfid_req)) { do { do { if (0) printf ("Assertion failed: "
"gfid_req"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 98, GF_LOG_ERROR, "Assertion failed: " "gfid_req"
); } while (0); } } while (0)
;
99
100 *gfid_req = NULL((void*)0);
101 local->xattr_req = dict_new ();
102 if (!local->xattr_req)
103 goto out;
104 if (xattr_req)
105 dict_copy (xattr_req, local->xattr_req);
106
107 afr_xattr_req_prepare (this, local->xattr_req, loc->path);
108 ret = dict_set_uint64 (local->xattr_req, GLUSTERFS_INODELK_COUNT"glusterfs.inodelk-count", 0);
109 if (ret < 0) {
110 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: Unable to set dict value for %s"
, loc->path, "glusterfs.inodelk-count"); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 112, GF_LOG_WARNING
, "%s: Unable to set dict value for %s", loc->path, "glusterfs.inodelk-count"
); } while (0)
111 "%s: Unable to set dict value for %s",do { do { if (0) printf ("%s: Unable to set dict value for %s"
, loc->path, "glusterfs.inodelk-count"); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 112, GF_LOG_WARNING
, "%s: Unable to set dict value for %s", loc->path, "glusterfs.inodelk-count"
); } while (0)
112 loc->path, GLUSTERFS_INODELK_COUNT)do { do { if (0) printf ("%s: Unable to set dict value for %s"
, loc->path, "glusterfs.inodelk-count"); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 112, GF_LOG_WARNING
, "%s: Unable to set dict value for %s", loc->path, "glusterfs.inodelk-count"
); } while (0)
;
113 }
114 ret = dict_set_uint64 (local->xattr_req, GLUSTERFS_ENTRYLK_COUNT"glusterfs.entrylk-count", 0);
115 if (ret < 0) {
116 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: Unable to set dict value for %s"
, loc->path, "glusterfs.entrylk-count"); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 118, GF_LOG_WARNING
, "%s: Unable to set dict value for %s", loc->path, "glusterfs.entrylk-count"
); } while (0)
117 "%s: Unable to set dict value for %s",do { do { if (0) printf ("%s: Unable to set dict value for %s"
, loc->path, "glusterfs.entrylk-count"); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 118, GF_LOG_WARNING
, "%s: Unable to set dict value for %s", loc->path, "glusterfs.entrylk-count"
); } while (0)
118 loc->path, GLUSTERFS_ENTRYLK_COUNT)do { do { if (0) printf ("%s: Unable to set dict value for %s"
, loc->path, "glusterfs.entrylk-count"); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 118, GF_LOG_WARNING
, "%s: Unable to set dict value for %s", loc->path, "glusterfs.entrylk-count"
); } while (0)
;
119 }
120
121 ret = dict_set_uint32 (local->xattr_req, GLUSTERFS_PARENT_ENTRYLK"glusterfs.parent-entrylk", 0);
122 if (ret < 0) {
123 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: Unable to set dict value for %s"
, loc->path, "glusterfs.parent-entrylk"); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 125, GF_LOG_WARNING
, "%s: Unable to set dict value for %s", loc->path, "glusterfs.parent-entrylk"
); } while (0)
124 "%s: Unable to set dict value for %s",do { do { if (0) printf ("%s: Unable to set dict value for %s"
, loc->path, "glusterfs.parent-entrylk"); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 125, GF_LOG_WARNING
, "%s: Unable to set dict value for %s", loc->path, "glusterfs.parent-entrylk"
); } while (0)
125 loc->path, GLUSTERFS_PARENT_ENTRYLK)do { do { if (0) printf ("%s: Unable to set dict value for %s"
, loc->path, "glusterfs.parent-entrylk"); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 125, GF_LOG_WARNING
, "%s: Unable to set dict value for %s", loc->path, "glusterfs.parent-entrylk"
); } while (0)
;
126 }
127
128 ret = dict_get_ptr (local->xattr_req, "gfid-req", gfid_req);
129 if (ret) {
130 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s: failed to get the gfid from dict"
, loc->path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 131, GF_LOG_DEBUG, "%s: failed to get the gfid from dict"
, loc->path); } while (0)
131 "%s: failed to get the gfid from dict", loc->path)do { do { if (0) printf ("%s: failed to get the gfid from dict"
, loc->path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 131, GF_LOG_DEBUG, "%s: failed to get the gfid from dict"
, loc->path); } while (0)
;
132 *gfid_req = NULL((void*)0);
133 } else {
134 if (loc->parent != NULL((void*)0))
135 dict_del (local->xattr_req, "gfid-req");
136 }
137 ret = 0;
138out:
139 return ret;
140}
141
142void
143afr_lookup_save_gfid (uuid_t dst, void* new, const loc_t *loc)
144{
145 inode_t *inode = NULL((void*)0);
146
147 inode = loc->inode;
148 if (inode && !uuid_is_null (inode->gfid))
149 uuid_copy (dst, inode->gfid);
150 else if (!uuid_is_null (loc->gfid))
151 uuid_copy (dst, loc->gfid);
152 else if (new && !uuid_is_null (new))
153 uuid_copy (dst, new);
154}
155
156int
157afr_errno_count (int32_t *children, int *child_errno,
158 unsigned int child_count, int32_t op_errno)
159{
160 int i = 0;
161 int errno_count = 0;
162 int child = 0;
163
164 for (i = 0; i < child_count; i++) {
165 if (children) {
166 child = children[i];
167 if (child == -1)
168 break;
169 } else {
170 child = i;
171 }
172 if (child_errno[child] == op_errno)
173 errno_count++;
174 }
175 return errno_count;
176}
177
178int32_t
179afr_set_dict_gfid (dict_t *dict, uuid_t gfid)
180{
181 int ret = 0;
182 uuid_t *pgfid = NULL((void*)0);
183
184 GF_ASSERT (gfid)do { if (!(gfid)) { do { do { if (0) printf ("Assertion failed: "
"gfid"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 184, GF_LOG_ERROR, "Assertion failed: " "gfid"
); } while (0); } } while (0)
;
185
186 pgfid = GF_CALLOC (1, sizeof (uuid_t), gf_common_mt_char)__gf_calloc (1, sizeof (uuid_t), gf_common_mt_char);
187 if (!pgfid) {
188 ret = -1;
189 goto out;
190 }
191
192 uuid_copy (*pgfid, gfid);
193
194 ret = dict_set_dynptr (dict, "gfid-req", pgfid, sizeof (uuid_t));
195 if (ret)
196 gf_log (THIS->name, GF_LOG_ERROR, "gfid set failed")do { do { if (0) printf ("gfid set failed"); } while (0); _gf_log
((*__glusterfs_this_location())->name, "./afr-common.c", __FUNCTION__
, 196, GF_LOG_ERROR, "gfid set failed"); } while (0)
;
197
198out:
199 if (ret && pgfid)
200 GF_FREE (pgfid)__gf_free (pgfid);
201
202 return ret;
203}
204
205void
206afr_inode_ctx_destroy (afr_inode_ctx_t *ctx)
207{
208 if (!ctx)
209 return;
210 GF_FREE (ctx->fresh_children)__gf_free (ctx->fresh_children);
211 GF_FREE (ctx)__gf_free (ctx);
212}
213
214afr_inode_ctx_t*
215__afr_inode_ctx_get (inode_t *inode, xlator_t *this)
216{
217 int ret = 0;
218 uint64_t ctx_addr = 0;
219 afr_inode_ctx_t *ctx = NULL((void*)0);
220 afr_private_t *priv = NULL((void*)0);
221
222 priv = this->private;
223 ret = __inode_ctx_get (inode, this, &ctx_addr)__inode_ctx_get2(inode,this,&ctx_addr,0);
224 if (ret < 0)
225 ctx_addr = 0;
226 if (ctx_addr != 0) {
227 ctx = (afr_inode_ctx_t*) (long) ctx_addr;
228 goto out;
229 }
230 ctx = GF_CALLOC (1, sizeof (*ctx),__gf_calloc (1, sizeof (*ctx), gf_afr_mt_inode_ctx_t)
231 gf_afr_mt_inode_ctx_t)__gf_calloc (1, sizeof (*ctx), gf_afr_mt_inode_ctx_t);
232 if (!ctx)
233 goto fail;
234 ctx->fresh_children = GF_CALLOC (priv->child_count,__gf_calloc (priv->child_count, sizeof (*ctx->fresh_children
), gf_afr_mt_int32_t)
235 sizeof (*ctx->fresh_children),__gf_calloc (priv->child_count, sizeof (*ctx->fresh_children
), gf_afr_mt_int32_t)
236 gf_afr_mt_int32_t)__gf_calloc (priv->child_count, sizeof (*ctx->fresh_children
), gf_afr_mt_int32_t)
;
237 if (!ctx->fresh_children)
238 goto fail;
239 ret = __inode_ctx_put (inode, this, (uint64_t)ctx);
240 if (ret) {
241 gf_log_callingfn (this->name, GF_LOG_ERROR, "failed to "do { do { if (0) printf ("failed to " "set the inode ctx (%s)"
, uuid_utoa (inode->gfid)); } while (0); _gf_log_callingfn
(this->name, "./afr-common.c", __FUNCTION__, 243, GF_LOG_ERROR
, "failed to " "set the inode ctx (%s)", uuid_utoa (inode->
gfid)); } while (0)
242 "set the inode ctx (%s)",do { do { if (0) printf ("failed to " "set the inode ctx (%s)"
, uuid_utoa (inode->gfid)); } while (0); _gf_log_callingfn
(this->name, "./afr-common.c", __FUNCTION__, 243, GF_LOG_ERROR
, "failed to " "set the inode ctx (%s)", uuid_utoa (inode->
gfid)); } while (0)
243 uuid_utoa (inode->gfid))do { do { if (0) printf ("failed to " "set the inode ctx (%s)"
, uuid_utoa (inode->gfid)); } while (0); _gf_log_callingfn
(this->name, "./afr-common.c", __FUNCTION__, 243, GF_LOG_ERROR
, "failed to " "set the inode ctx (%s)", uuid_utoa (inode->
gfid)); } while (0)
;
244 goto fail;
245 }
246
247out:
248 return ctx;
249
250fail:
251 afr_inode_ctx_destroy (ctx);
252 return NULL((void*)0);
253}
254
255afr_inode_ctx_t*
256afr_inode_ctx_get (inode_t *inode, xlator_t *this)
257{
258 afr_inode_ctx_t *ctx = NULL((void*)0);
259
260 LOCK (&inode->lock)pthread_spin_lock (&inode->lock);
261 {
262 ctx = __afr_inode_ctx_get (inode, this);
263 }
264 UNLOCK (&inode->lock)pthread_spin_unlock (&inode->lock);
265 return ctx;
266}
267
268void
269afr_inode_get_ctx_params (xlator_t *this, inode_t *inode,
270 afr_inode_params_t *params)
271{
272 GF_ASSERT (inode)do { if (!(inode)) { do { do { if (0) printf ("Assertion failed: "
"inode"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 272, GF_LOG_ERROR, "Assertion failed: " "inode"
); } while (0); } } while (0)
;
273 GF_ASSERT (params)do { if (!(params)) { do { do { if (0) printf ("Assertion failed: "
"params"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 273, GF_LOG_ERROR, "Assertion failed: " "params"
); } while (0); } } while (0)
;
274
275 afr_inode_ctx_t *ctx = NULL((void*)0);
276 afr_private_t *priv = NULL((void*)0);
277 int i = 0;
278 int32_t read_child = -1;
279 int32_t *fresh_children = NULL((void*)0);
280
281 priv = this->private;
282 LOCK (&inode->lock)pthread_spin_lock (&inode->lock);
283 {
284 ctx = __afr_inode_ctx_get (inode, this);
285 if (!ctx)
286 goto unlock;
287 switch (params->op) {
288 case AFR_INODE_GET_READ_CTX:
289 fresh_children = params->u.read_ctx.children;
290 read_child = (int32_t)(ctx->masks &
291 AFR_ICTX_READ_CHILD_MASK0x00000000FFFFFFFFULL);
292 params->u.read_ctx.read_child = read_child;
293 if (!fresh_children)
294 goto unlock;
295 for (i = 0; i < priv->child_count; i++)
296 fresh_children[i] = ctx->fresh_children[i];
297 break;
298 case AFR_INODE_GET_OPENDIR_DONE:
299 params->u.value = _gf_false;
300 if (ctx->masks & AFR_ICTX_OPENDIR_DONE_MASK0x0000000100000000ULL)
301 params->u.value = _gf_true;
302 break;
303 default:
304 GF_ASSERT (0)do { if (!(0)) { do { do { if (0) printf ("Assertion failed: "
"0"); } while (0); _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__
, 304, GF_LOG_ERROR, "Assertion failed: " "0"); } while (0); }
} while (0)
;
305 break;
306 }
307 }
308unlock:
309 UNLOCK (&inode->lock)pthread_spin_unlock (&inode->lock);
310}
311
312gf_boolean_t
313afr_is_split_brain (xlator_t *this, inode_t *inode)
314{
315 afr_inode_ctx_t *ctx = NULL((void*)0);
316 gf_boolean_t spb = _gf_false;
317
318 ctx = afr_inode_ctx_get (inode, this);
319 if (!ctx)
320 goto out;
321 if ((ctx->mdata_spb == SPB) || (ctx->data_spb == SPB))
322 spb = _gf_true;
323out:
324 return spb;
325}
326
327gf_boolean_t
328afr_is_opendir_done (xlator_t *this, inode_t *inode)
329{
330 afr_inode_params_t params = {0};
331
332 params.op = AFR_INODE_GET_OPENDIR_DONE;
333 afr_inode_get_ctx_params (this, inode, &params);
334 return params.u.value;
335}
336
337int32_t
338afr_inode_get_read_ctx (xlator_t *this, inode_t *inode, int32_t *fresh_children)
339{
340 afr_inode_params_t params = {0};
341
342 params.op = AFR_INODE_GET_READ_CTX;
343 params.u.read_ctx.children = fresh_children;
344 afr_inode_get_ctx_params (this, inode, &params);
345 return params.u.read_ctx.read_child;
346}
347
348void
349afr_inode_ctx_set_read_child (afr_inode_ctx_t *ctx, int32_t read_child)
350{
351 uint64_t remaining_mask = 0;
352 uint64_t mask = 0;
353
354 remaining_mask = (~AFR_ICTX_READ_CHILD_MASK0x00000000FFFFFFFFULL & ctx->masks);
355 mask = (AFR_ICTX_READ_CHILD_MASK0x00000000FFFFFFFFULL & read_child);
356 ctx->masks = remaining_mask | mask;
357}
358
359void
360afr_inode_ctx_set_read_ctx (afr_inode_ctx_t *ctx, int32_t read_child,
361 int32_t *fresh_children, int32_t child_count)
362{
363 int i = 0;
364
365 afr_inode_ctx_set_read_child (ctx, read_child);
366 for (i = 0; i < child_count; i++) {
367 if (fresh_children)
368 ctx->fresh_children[i] = fresh_children[i];
369 else
370 ctx->fresh_children[i] = -1;
371 }
372}
373
374void
375afr_inode_ctx_rm_stale_children (afr_inode_ctx_t *ctx, int32_t *stale_children,
376 int32_t child_count)
377{
378 int i = 0;
379 int32_t read_child = -1;
380
381 GF_ASSERT (stale_children)do { if (!(stale_children)) { do { do { if (0) printf ("Assertion failed: "
"stale_children"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 381, GF_LOG_ERROR, "Assertion failed: " "stale_children"
); } while (0); } } while (0)
;
382 for (i = 0; i < child_count; i++) {
383 if (stale_children[i] == -1)
384 break;
385 afr_children_rm_child (ctx->fresh_children,
386 stale_children[i], child_count);
387 }
388 read_child = (int32_t)(ctx->masks & AFR_ICTX_READ_CHILD_MASK0x00000000FFFFFFFFULL);
389 if (!afr_is_child_present (ctx->fresh_children, child_count,
390 read_child))
391 afr_inode_ctx_set_read_child (ctx, ctx->fresh_children[0]);
392}
393
394void
395afr_inode_ctx_set_opendir_done (afr_inode_ctx_t *ctx)
396{
397 uint64_t remaining_mask = 0;
398 uint64_t mask = 0;
399
400 remaining_mask = (~AFR_ICTX_OPENDIR_DONE_MASK0x0000000100000000ULL & ctx->masks);
401 mask = (0xFFFFFFFFFFFFFFFFULL & AFR_ICTX_OPENDIR_DONE_MASK0x0000000100000000ULL);
402 ctx->masks = remaining_mask | mask;
403}
404
405void
406afr_inode_set_ctx_params (xlator_t *this, inode_t *inode,
407 afr_inode_params_t *params)
408{
409 GF_ASSERT (inode)do { if (!(inode)) { do { do { if (0) printf ("Assertion failed: "
"inode"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 409, GF_LOG_ERROR, "Assertion failed: " "inode"
); } while (0); } } while (0)
;
410 GF_ASSERT (params)do { if (!(params)) { do { do { if (0) printf ("Assertion failed: "
"params"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 410, GF_LOG_ERROR, "Assertion failed: " "params"
); } while (0); } } while (0)
;
411
412 afr_inode_ctx_t *ctx = NULL((void*)0);
413 afr_private_t *priv = NULL((void*)0);
414 int32_t read_child = -1;
415 int32_t *fresh_children = NULL((void*)0);
416 int32_t *stale_children = NULL((void*)0);
417
418 priv = this->private;
419 LOCK (&inode->lock)pthread_spin_lock (&inode->lock);
420 {
421 ctx = __afr_inode_ctx_get (inode, this);
422 if (!ctx)
423 goto unlock;
424 switch (params->op) {
425 case AFR_INODE_SET_READ_CTX:
426 read_child = params->u.read_ctx.read_child;
427 fresh_children = params->u.read_ctx.children;
428 afr_inode_ctx_set_read_ctx (ctx, read_child,
429 fresh_children,
430 priv->child_count);
431 break;
432 case AFR_INODE_RM_STALE_CHILDREN:
433 stale_children = params->u.read_ctx.children;
434 afr_inode_ctx_rm_stale_children (ctx,
435 stale_children,
436 priv->child_count);
437 break;
438 case AFR_INODE_SET_OPENDIR_DONE:
439 afr_inode_ctx_set_opendir_done (ctx);
440 break;
441 default:
442 GF_ASSERT (0)do { if (!(0)) { do { do { if (0) printf ("Assertion failed: "
"0"); } while (0); _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__
, 442, GF_LOG_ERROR, "Assertion failed: " "0"); } while (0); }
} while (0)
;
443 break;
444 }
445 }
446unlock:
447 UNLOCK (&inode->lock)pthread_spin_unlock (&inode->lock);
448}
449
450void
451afr_set_split_brain (xlator_t *this, inode_t *inode, afr_spb_state_t mdata_spb,
452 afr_spb_state_t data_spb)
453{
454 afr_inode_ctx_t *ctx = NULL((void*)0);
455
456 ctx = afr_inode_ctx_get (inode, this);
457 if (mdata_spb != DONT_KNOW)
458 ctx->mdata_spb = mdata_spb;
459 if (data_spb != DONT_KNOW)
460 ctx->data_spb = data_spb;
461}
462
463void
464afr_set_opendir_done (xlator_t *this, inode_t *inode)
465{
466 afr_inode_params_t params = {0};
467
468 params.op = AFR_INODE_SET_OPENDIR_DONE;
469 afr_inode_set_ctx_params (this, inode, &params);
470}
471
472void
473afr_inode_set_read_ctx (xlator_t *this, inode_t *inode, int32_t read_child,
474 int32_t *fresh_children)
475{
476 afr_inode_params_t params = {0};
477 afr_private_t *priv = NULL((void*)0);
478
479 priv = this->private;
480 GF_ASSERT (read_child >= 0)do { if (!(read_child >= 0)) { do { do { if (0) printf ("Assertion failed: "
"read_child >= 0"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 480, GF_LOG_ERROR, "Assertion failed: " "read_child >= 0"
); } while (0); } } while (0)
;
481 GF_ASSERT (fresh_children)do { if (!(fresh_children)) { do { do { if (0) printf ("Assertion failed: "
"fresh_children"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 481, GF_LOG_ERROR, "Assertion failed: " "fresh_children"
); } while (0); } } while (0)
;
482 GF_ASSERT (afr_is_child_present (fresh_children, priv->child_count,do { if (!(afr_is_child_present (fresh_children, priv->child_count
, read_child))) { do { do { if (0) printf ("Assertion failed: "
"afr_is_child_present (fresh_children, priv->child_count, read_child)"
); } while (0); _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__
, 483, GF_LOG_ERROR, "Assertion failed: " "afr_is_child_present (fresh_children, priv->child_count, read_child)"
); } while (0); } } while (0)
483 read_child))do { if (!(afr_is_child_present (fresh_children, priv->child_count
, read_child))) { do { do { if (0) printf ("Assertion failed: "
"afr_is_child_present (fresh_children, priv->child_count, read_child)"
); } while (0); _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__
, 483, GF_LOG_ERROR, "Assertion failed: " "afr_is_child_present (fresh_children, priv->child_count, read_child)"
); } while (0); } } while (0)
;
484
485 params.op = AFR_INODE_SET_READ_CTX;
486 params.u.read_ctx.read_child = read_child;
487 params.u.read_ctx.children = fresh_children;
488 afr_inode_set_ctx_params (this, inode, &params);
489}
490
491void
492afr_inode_rm_stale_children (xlator_t *this, inode_t *inode,
493 int32_t *stale_children)
494{
495 afr_inode_params_t params = {0};
496
497 GF_ASSERT (stale_children)do { if (!(stale_children)) { do { do { if (0) printf ("Assertion failed: "
"stale_children"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 497, GF_LOG_ERROR, "Assertion failed: " "stale_children"
); } while (0); } } while (0)
;
498
499 params.op = AFR_INODE_RM_STALE_CHILDREN;
500 params.u.read_ctx.children = stale_children;
501 afr_inode_set_ctx_params (this, inode, &params);
502}
503
504gf_boolean_t
505afr_is_source_child (int32_t *sources, int32_t child_count, int32_t child)
506{
507 gf_boolean_t source_xattrs = _gf_false;
508
509 GF_ASSERT (child < child_count)do { if (!(child < child_count)) { do { do { if (0) printf
("Assertion failed: " "child < child_count"); } while (0)
; _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__, 509,
GF_LOG_ERROR, "Assertion failed: " "child < child_count")
; } while (0); } } while (0)
;
510
511 if ((child >= 0) && (child < child_count) &&
512 sources[child]) {
513 source_xattrs = _gf_true;
514 }
515 return source_xattrs;
516}
517
518gf_boolean_t
519afr_is_child_present (int32_t *success_children, int32_t child_count,
520 int32_t child)
521{
522 gf_boolean_t success_child = _gf_false;
523 int i = 0;
524
525 GF_ASSERT (child < child_count)do { if (!(child < child_count)) { do { do { if (0) printf
("Assertion failed: " "child < child_count"); } while (0)
; _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__, 525,
GF_LOG_ERROR, "Assertion failed: " "child < child_count")
; } while (0); } } while (0)
;
526
527 for (i = 0; i < child_count; i++) {
528 if (success_children[i] == -1)
529 break;
530 if (child == success_children[i]) {
531 success_child = _gf_true;
532 break;
533 }
534 }
535 return success_child;
536}
537
538gf_boolean_t
539afr_is_read_child (int32_t *success_children, int32_t *sources,
540 int32_t child_count, int32_t child)
541{
542 gf_boolean_t success_child = _gf_false;
543 gf_boolean_t source = _gf_false;
544
545 if (child < 0) {
546 return _gf_false;
547 }
548
549 GF_ASSERT (success_children)do { if (!(success_children)) { do { do { if (0) printf ("Assertion failed: "
"success_children"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 549, GF_LOG_ERROR, "Assertion failed: " "success_children"
); } while (0); } } while (0)
;
550 GF_ASSERT (child_count > 0)do { if (!(child_count > 0)) { do { do { if (0) printf ("Assertion failed: "
"child_count > 0"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 550, GF_LOG_ERROR, "Assertion failed: " "child_count > 0"
); } while (0); } } while (0)
;
551
552 success_child = afr_is_child_present (success_children, child_count,
553 child);
554 if (!success_child)
555 goto out;
556 if (NULL((void*)0) == sources) {
557 source = _gf_true;
558 goto out;
559 }
560 source = afr_is_source_child (sources, child_count, child);
561out:
562 return (success_child && source);
563}
564
565int32_t
566afr_hash_child (int32_t *success_children, int32_t child_count,
567 unsigned int hmode, uuid_t gfid)
568{
569 uuid_t gfid_copy = {0,};
570 pid_t pid;
571
572 if (!hmode) {
573 return -1;
574 }
575
576 if (gfid) {
577 uuid_copy(gfid_copy,gfid);
578 }
579 if (hmode > 1) {
580 /*
581 * Why getpid? Because it's one of the cheapest calls
582 * available - faster than gethostname etc. - and returns a
583 * constant-length value that's sure to be shorter than a UUID.
584 * It's still very unlikely to be the same across clients, so
585 * it still provides good mixing. We're not trying for
586 * perfection here. All we need is a low probability that
587 * multiple clients won't converge on the same subvolume.
588 */
589 pid = getpid();
590 memcpy (gfid_copy, &pid, sizeof(pid));
591 }
592
593 return SuperFastHash((char *)gfid_copy,
594 sizeof(gfid_copy)) % child_count;
595}
596
597/* If sources is NULL the xattrs are assumed to be of source for all
598 * success_children.
599 */
600int
601afr_select_read_child_from_policy (int32_t *success_children,
602 int32_t child_count, int32_t prev_read_child,
603 int32_t config_read_child, int32_t *sources,
604 unsigned int hmode, uuid_t gfid)
605{
606 int32_t read_child = -1;
607 int i = 0;
608
609 GF_ASSERT (success_children)do { if (!(success_children)) { do { do { if (0) printf ("Assertion failed: "
"success_children"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 609, GF_LOG_ERROR, "Assertion failed: " "success_children"
); } while (0); } } while (0)
;
610
611 read_child = config_read_child;
612 if (afr_is_read_child (success_children, sources, child_count,
613 read_child))
614 goto out;
615
616 read_child = prev_read_child;
617 if (afr_is_read_child (success_children, sources, child_count,
618 read_child))
619 goto out;
620
621 read_child = afr_hash_child (success_children, child_count,
622 hmode, gfid);
623 if (afr_is_read_child (success_children, sources, child_count,
624 read_child)) {
625 goto out;
626 }
627
628 for (i = 0; i < child_count; i++) {
629 read_child = success_children[i];
630 if (read_child < 0)
631 break;
632 if (afr_is_read_child (success_children, sources, child_count,
633 read_child))
634 goto out;
635 }
636 read_child = -1;
637
638out:
639 return read_child;
640}
641
642/* This function should be used when all the success_children are sources
643 */
644void
645afr_set_read_ctx_from_policy (xlator_t *this, inode_t *inode,
646 int32_t *fresh_children, int32_t prev_read_child,
647 int32_t config_read_child, uuid_t gfid)
648{
649 int read_child = -1;
650 afr_private_t *priv = NULL((void*)0);
651
652 priv = this->private;
653 read_child = afr_select_read_child_from_policy (fresh_children,
654 priv->child_count,
655 prev_read_child,
656 config_read_child,
657 NULL((void*)0),
658 priv->hash_mode, gfid);
659 if (read_child >= 0)
660 afr_inode_set_read_ctx (this, inode, read_child,
661 fresh_children);
662}
663
664/* afr_next_call_child ()
665 * This is a common function used by all the read-type fops
666 * This function should not be called with the inode's read_children array.
667 * The fop's handler should make a copy of the inode's read_children,
668 * preferred read_child into the local vars, because while this function is
669 * in execution there is a chance for inode's read_ctx to change.
670 */
671int32_t
672afr_next_call_child (int32_t *fresh_children, unsigned char *child_up,
673 size_t child_count, int32_t *last_index,
674 int32_t read_child)
675{
676 int next_index = 0;
677 int32_t next_call_child = -1;
678
679 GF_ASSERT (last_index)do { if (!(last_index)) { do { do { if (0) printf ("Assertion failed: "
"last_index"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 679, GF_LOG_ERROR, "Assertion failed: " "last_index"
); } while (0); } } while (0)
;
680
681 next_index = *last_index;
682retry:
683 next_index++;
684 if ((next_index >= child_count) ||
685 (fresh_children[next_index] == -1))
686 goto out;
687 if ((fresh_children[next_index] == read_child) ||
688 (!child_up[fresh_children[next_index]]))
689 goto retry;
690 *last_index = next_index;
691 next_call_child = fresh_children[next_index];
692out:
693 return next_call_child;
694}
695
696 /* This function should not be called with the inode's read_children array.
697 * The fop's handler should make a copy of the inode's read_children,
698 * preferred read_child into the local vars, because while this function is
699 * in execution there is a chance for inode's read_ctx to change.
700 */
701int32_t
702afr_get_call_child (xlator_t *this, unsigned char *child_up, int32_t read_child,
703 int32_t *fresh_children,
704 int32_t *call_child, int32_t *last_index)
705{
706 int ret = 0;
707 afr_private_t *priv = NULL((void*)0);
708 int i = 0;
709
710 GF_ASSERT (child_up)do { if (!(child_up)) { do { do { if (0) printf ("Assertion failed: "
"child_up"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 710, GF_LOG_ERROR, "Assertion failed: " "child_up"
); } while (0); } } while (0)
;
711 GF_ASSERT (call_child)do { if (!(call_child)) { do { do { if (0) printf ("Assertion failed: "
"call_child"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 711, GF_LOG_ERROR, "Assertion failed: " "call_child"
); } while (0); } } while (0)
;
712 GF_ASSERT (last_index)do { if (!(last_index)) { do { do { if (0) printf ("Assertion failed: "
"last_index"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 712, GF_LOG_ERROR, "Assertion failed: " "last_index"
); } while (0); } } while (0)
;
713 GF_ASSERT (fresh_children)do { if (!(fresh_children)) { do { do { if (0) printf ("Assertion failed: "
"fresh_children"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 713, GF_LOG_ERROR, "Assertion failed: " "fresh_children"
); } while (0); } } while (0)
;
714
715 if (read_child < 0) {
716 ret = -EIO5;
717 goto out;
718 }
719 priv = this->private;
720 *call_child = -1;
721 *last_index = -1;
722
723 if (child_up[read_child]) {
724 *call_child = read_child;
725 } else {
726 for (i = 0; i < priv->child_count; i++) {
727 if (fresh_children[i] == -1)
728 break;
729 if (child_up[fresh_children[i]]) {
730 *call_child = fresh_children[i];
731 ret = 0;
732 break;
733 }
734 }
735
736 if (*call_child == -1) {
737 ret = -ENOTCONN107;
738 goto out;
739 }
740
741 *last_index = i;
742 }
743out:
744 gf_log (this->name, GF_LOG_DEBUG, "Returning %d, call_child: %d, "do { do { if (0) printf ("Returning %d, call_child: %d, " "last_index: %d"
, ret, *call_child, *last_index); } while (0); _gf_log (this->
name, "./afr-common.c", __FUNCTION__, 745, GF_LOG_DEBUG, "Returning %d, call_child: %d, "
"last_index: %d", ret, *call_child, *last_index); } while (0
)
745 "last_index: %d", ret, *call_child, *last_index)do { do { if (0) printf ("Returning %d, call_child: %d, " "last_index: %d"
, ret, *call_child, *last_index); } while (0); _gf_log (this->
name, "./afr-common.c", __FUNCTION__, 745, GF_LOG_DEBUG, "Returning %d, call_child: %d, "
"last_index: %d", ret, *call_child, *last_index); } while (0
)
;
746 return ret;
747}
748
749void
750afr_reset_xattr (dict_t **xattr, unsigned int child_count)
751{
752 unsigned int i = 0;
753
754 if (!xattr)
755 goto out;
756 for (i = 0; i < child_count; i++) {
757 if (xattr[i]) {
758 dict_unref (xattr[i]);
759 xattr[i] = NULL((void*)0);
760 }
761 }
762out:
763 return;
764}
765
766void
767afr_xattr_array_destroy (dict_t **xattr, unsigned int child_count)
768{
769 afr_reset_xattr (xattr, child_count);
770 GF_FREE (xattr)__gf_free (xattr);
771}
772
773void
774afr_local_sh_cleanup (afr_local_t *local, xlator_t *this)
775{
776 afr_self_heal_t *sh = NULL((void*)0);
777 afr_private_t *priv = NULL((void*)0);
778
779 sh = &local->self_heal;
780 priv = this->private;
781
782 GF_FREE (sh->buf)__gf_free (sh->buf);
783
784 GF_FREE (sh->parentbufs)__gf_free (sh->parentbufs);
785
786 if (sh->inode)
787 inode_unref (sh->inode);
788
789 afr_xattr_array_destroy (sh->xattr, priv->child_count);
790
791 GF_FREE (sh->child_errno)__gf_free (sh->child_errno);
792
793 afr_matrix_cleanup (sh->pending_matrix, priv->child_count);
794 afr_matrix_cleanup (sh->delta_matrix, priv->child_count);
795
796 GF_FREE (sh->sources)__gf_free (sh->sources);
797
798 GF_FREE (sh->success)__gf_free (sh->success);
799
800 GF_FREE (sh->locked_nodes)__gf_free (sh->locked_nodes);
801
802 if (sh->healing_fd) {
803 fd_unref (sh->healing_fd);
804 sh->healing_fd = NULL((void*)0);
805 }
806
807 GF_FREE ((char *)sh->linkname)__gf_free ((char *)sh->linkname);
808
809 GF_FREE (sh->success_children)__gf_free (sh->success_children);
810
811 GF_FREE (sh->fresh_children)__gf_free (sh->fresh_children);
812
813 GF_FREE (sh->fresh_parent_dirs)__gf_free (sh->fresh_parent_dirs);
814
815 loc_wipe (&sh->parent_loc);
816 loc_wipe (&sh->lookup_loc);
817
818 GF_FREE (sh->checksum)__gf_free (sh->checksum);
819
820 GF_FREE (sh->write_needed)__gf_free (sh->write_needed);
821 if (sh->healing_fd)
822 fd_unref (sh->healing_fd);
823}
824
825
826void
827afr_local_transaction_cleanup (afr_local_t *local, xlator_t *this)
828{
829 afr_private_t * priv = NULL((void*)0);
830
831 priv = this->private;
832
833 afr_matrix_cleanup (local->pending, priv->child_count);
834 afr_matrix_cleanup (local->transaction.txn_changelog,
835 priv->child_count);
836
837 GF_FREE (local->internal_lock.locked_nodes)__gf_free (local->internal_lock.locked_nodes);
838
839 GF_FREE (local->internal_lock.inode_locked_nodes)__gf_free (local->internal_lock.inode_locked_nodes);
840
841 GF_FREE (local->internal_lock.lower_locked_nodes)__gf_free (local->internal_lock.lower_locked_nodes);
842
843 afr_entry_lockee_cleanup (&local->internal_lock);
844
845 GF_FREE (local->transaction.pre_op)__gf_free (local->transaction.pre_op);
846 GF_FREE (local->transaction.eager_lock)__gf_free (local->transaction.eager_lock);
847
848 GF_FREE (local->transaction.basename)__gf_free (local->transaction.__xpg_basename);
849 GF_FREE (local->transaction.new_basename)__gf_free (local->transaction.new_basename);
850
851 loc_wipe (&local->transaction.parent_loc);
852 loc_wipe (&local->transaction.new_parent_loc);
853
854 GF_FREE (local->transaction.postop_piggybacked)__gf_free (local->transaction.postop_piggybacked);
855}
856
857
858void
859afr_local_cleanup (afr_local_t *local, xlator_t *this)
860{
861 afr_private_t * priv = NULL((void*)0);
862
863 if (!local)
864 return;
865
866 afr_local_sh_cleanup (local, this);
867
868 afr_local_transaction_cleanup (local, this);
869
870 priv = this->private;
871
872 loc_wipe (&local->loc);
873 loc_wipe (&local->newloc);
874
875 if (local->fd)
876 fd_unref (local->fd);
877
878 if (local->xattr_req)
879 dict_unref (local->xattr_req);
880
881 if (local->dict)
882 dict_unref (local->dict);
883
884 GF_FREE(local->replies)__gf_free (local->replies);
885
886 GF_FREE (local->child_up)__gf_free (local->child_up);
887
888 GF_FREE (local->child_errno)__gf_free (local->child_errno);
889
890 GF_FREE (local->fresh_children)__gf_free (local->fresh_children);
891
892 { /* lookup */
893 if (local->cont.lookup.xattrs) {
894 afr_reset_xattr (local->cont.lookup.xattrs,
895 priv->child_count);
896 GF_FREE (local->cont.lookup.xattrs)__gf_free (local->cont.lookup.xattrs);
897 local->cont.lookup.xattrs = NULL((void*)0);
898 }
899
900 if (local->cont.lookup.xattr) {
901 dict_unref (local->cont.lookup.xattr);
902 }
903
904 if (local->cont.lookup.inode) {
905 inode_unref (local->cont.lookup.inode);
906 }
907
908 GF_FREE (local->cont.lookup.postparents)__gf_free (local->cont.lookup.postparents);
909
910 GF_FREE (local->cont.lookup.bufs)__gf_free (local->cont.lookup.bufs);
911
912 GF_FREE (local->cont.lookup.success_children)__gf_free (local->cont.lookup.success_children);
913
914 GF_FREE (local->cont.lookup.sources)__gf_free (local->cont.lookup.sources);
915 afr_matrix_cleanup (local->cont.lookup.pending_matrix,
916 priv->child_count);
917 }
918
919 { /* getxattr */
920 GF_FREE (local->cont.getxattr.name)__gf_free (local->cont.getxattr.name);
921 }
922
923 { /* lk */
924 GF_FREE (local->cont.lk.locked_nodes)__gf_free (local->cont.lk.locked_nodes);
925 }
926
927 { /* create */
928 if (local->cont.create.fd)
929 fd_unref (local->cont.create.fd);
930 if (local->cont.create.params)
931 dict_unref (local->cont.create.params);
932 }
933
934 { /* mknod */
935 if (local->cont.mknod.params)
936 dict_unref (local->cont.mknod.params);
937 }
938
939 { /* mkdir */
940 if (local->cont.mkdir.params)
941 dict_unref (local->cont.mkdir.params);
942 }
943
944 { /* symlink */
945 if (local->cont.symlink.params)
946 dict_unref (local->cont.symlink.params);
947 }
948
949 { /* writev */
950 GF_FREE (local->cont.writev.vector)__gf_free (local->cont.writev.vector);
951 }
952
953 { /* setxattr */
954 if (local->cont.setxattr.dict)
955 dict_unref (local->cont.setxattr.dict);
956 }
957
958 { /* fsetxattr */
959 if (local->cont.fsetxattr.dict)
960 dict_unref (local->cont.fsetxattr.dict);
961 }
962
963 { /* removexattr */
964 GF_FREE (local->cont.removexattr.name)__gf_free (local->cont.removexattr.name);
965 }
966 { /* xattrop */
967 if (local->cont.xattrop.xattr)
968 dict_unref (local->cont.xattrop.xattr);
969 }
970 { /* fxattrop */
971 if (local->cont.fxattrop.xattr)
972 dict_unref (local->cont.fxattrop.xattr);
973 }
974 { /* symlink */
975 GF_FREE (local->cont.symlink.linkpath)__gf_free (local->cont.symlink.linkpath);
976 }
977
978 { /* opendir */
979 GF_FREE (local->cont.opendir.checksum)__gf_free (local->cont.opendir.checksum);
980 }
981
982 { /* readdirp */
983 if (local->cont.readdir.dict)
984 dict_unref (local->cont.readdir.dict);
985 }
986
987 if (local->xdata_req)
988 dict_unref (local->xdata_req);
989
990 if (local->xdata_rsp)
991 dict_unref (local->xdata_rsp);
992}
993
994
995int
996afr_frame_return (call_frame_t *frame)
997{
998 afr_local_t *local = NULL((void*)0);
999 int call_count = 0;
1000
1001 local = frame->local;
1002
1003 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
1004 {
1005 call_count = --local->call_count;
1006 }
1007 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
1008
1009 return call_count;
1010}
1011
1012int
1013afr_set_elem_count_get (unsigned char *elems, int child_count)
1014{
1015 int i = 0;
1016 int ret = 0;
1017
1018 for (i = 0; i < child_count; i++)
1019 if (elems[i])
1020 ret++;
1021 return ret;
1022}
1023
1024/**
1025 * up_children_count - return the number of children that are up
1026 */
1027
1028unsigned int
1029afr_up_children_count (unsigned char *child_up, unsigned int child_count)
1030{
1031 return afr_set_elem_count_get (child_up, child_count);
1032}
1033
1034unsigned int
1035afr_locked_children_count (unsigned char *children, unsigned int child_count)
1036{
1037 return afr_set_elem_count_get (children, child_count);
1038}
1039
1040unsigned int
1041afr_pre_op_done_children_count (unsigned char *pre_op,
1042 unsigned int child_count)
1043{
1044 return afr_set_elem_count_get (pre_op, child_count);
1045}
1046
1047gf_boolean_t
1048afr_is_fresh_lookup (loc_t *loc, xlator_t *this)
1049{
1050 uint64_t ctx = 0;
1051 int32_t ret = 0;
1052
1053 GF_ASSERT (loc)do { if (!(loc)) { do { do { if (0) printf ("Assertion failed: "
"loc"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1053, GF_LOG_ERROR, "Assertion failed: " "loc"
); } while (0); } } while (0)
;
1054 GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: "
"this"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1054, GF_LOG_ERROR, "Assertion failed: " "this"
); } while (0); } } while (0)
;
1055 GF_ASSERT (loc->inode)do { if (!(loc->inode)) { do { do { if (0) printf ("Assertion failed: "
"loc->inode"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1055, GF_LOG_ERROR, "Assertion failed: " "loc->inode"
); } while (0); } } while (0)
;
1056
1057 ret = inode_ctx_get (loc->inode, this, &ctx)inode_ctx_get2(loc->inode,this,&ctx,0);
1058 if (0 == ret)
1059 return _gf_false;
1060 return _gf_true;
1061}
1062
1063void
1064afr_update_loc_gfids (loc_t *loc, struct iatt *buf, struct iatt *postparent)
1065{
1066 GF_ASSERT (loc)do { if (!(loc)) { do { do { if (0) printf ("Assertion failed: "
"loc"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1066, GF_LOG_ERROR, "Assertion failed: " "loc"
); } while (0); } } while (0)
;
1067 GF_ASSERT (buf)do { if (!(buf)) { do { do { if (0) printf ("Assertion failed: "
"buf"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1067, GF_LOG_ERROR, "Assertion failed: " "buf"
); } while (0); } } while (0)
;
1068
1069 uuid_copy (loc->gfid, buf->ia_gfid);
1070 if (postparent)
1071 uuid_copy (loc->pargfid, postparent->ia_gfid);
1072}
1073
1074int
1075afr_lookup_build_response_params (afr_local_t *local, xlator_t *this)
1076{
1077 struct iatt *buf = NULL((void*)0);
1078 struct iatt *postparent = NULL((void*)0);
1079 dict_t **xattr = NULL((void*)0);
1080 int32_t *success_children = NULL((void*)0);
1081 int32_t *sources = NULL((void*)0);
1082 afr_private_t *priv = NULL((void*)0);
1083 int32_t read_child = -1;
1084 int ret = 0;
1085 int i = 0;
1086
1087 GF_ASSERT (local)do { if (!(local)) { do { do { if (0) printf ("Assertion failed: "
"local"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1087, GF_LOG_ERROR, "Assertion failed: " "local"
); } while (0); } } while (0)
;
1088
1089 buf = &local->cont.lookup.buf;
1090 postparent = &local->cont.lookup.postparent;
1091 xattr = &local->cont.lookup.xattr;
1092 priv = this->private;
1093
1094 read_child = afr_inode_get_read_ctx (this, local->cont.lookup.inode,
1095 local->fresh_children);
1096 if (read_child < 0) {
1097 ret = -1;
1098 goto out;
1099 }
1100 success_children = local->cont.lookup.success_children;
1101 sources = local->cont.lookup.sources;
1102 memset (sources, 0, sizeof (*sources) * priv->child_count);
1103 afr_children_intersection_get (local->fresh_children, success_children,
1104 sources, priv->child_count);
1105 if (!sources[read_child]) {
1106 read_child = -1;
1107 for (i = 0; i < priv->child_count; i++) {
1108 if (sources[i]) {
1109 read_child = i;
1110 break;
1111 }
1112 }
1113 }
1114 if (read_child < 0) {
1115 ret = -1;
1116 goto out;
1117 }
1118 gf_log (this->name, GF_LOG_DEBUG, "Building lookup response from %d",do { do { if (0) printf ("Building lookup response from %d", read_child
); } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 1119, GF_LOG_DEBUG, "Building lookup response from %d", read_child
); } while (0)
1119 read_child)do { do { if (0) printf ("Building lookup response from %d", read_child
); } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 1119, GF_LOG_DEBUG, "Building lookup response from %d", read_child
); } while (0)
;
1120 if (!*xattr)
1121 *xattr = dict_ref (local->cont.lookup.xattrs[read_child]);
1122 *buf = local->cont.lookup.bufs[read_child];
1123 *postparent = local->cont.lookup.postparents[read_child];
1124
1125 if (IA_INVAL == local->cont.lookup.inode->ia_type) {
1126 /* fix for RT #602 */
1127 local->cont.lookup.inode->ia_type = buf->ia_type;
1128 }
1129out:
1130 return ret;
1131}
1132
1133static void
1134afr_lookup_update_lk_counts (afr_local_t *local, xlator_t *this,
1135 int child_index, dict_t *xattr)
1136{
1137 uint32_t inodelk_count = 0;
1138 uint32_t entrylk_count = 0;
1139 int ret = -1;
1140 uint32_t parent_entrylk = 0;
1141
1142 GF_ASSERT (local)do { if (!(local)) { do { do { if (0) printf ("Assertion failed: "
"local"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1142, GF_LOG_ERROR, "Assertion failed: " "local"
); } while (0); } } while (0)
;
1143 GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: "
"this"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1143, GF_LOG_ERROR, "Assertion failed: " "this"
); } while (0); } } while (0)
;
1144 GF_ASSERT (xattr)do { if (!(xattr)) { do { do { if (0) printf ("Assertion failed: "
"xattr"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1144, GF_LOG_ERROR, "Assertion failed: " "xattr"
); } while (0); } } while (0)
;
1145 GF_ASSERT (child_index >= 0)do { if (!(child_index >= 0)) { do { do { if (0) printf ("Assertion failed: "
"child_index >= 0"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1145, GF_LOG_ERROR, "Assertion failed: " "child_index >= 0"
); } while (0); } } while (0)
;
1146
1147 ret = dict_get_uint32 (xattr, GLUSTERFS_INODELK_COUNT"glusterfs.inodelk-count",
1148 &inodelk_count);
1149 if (ret == 0)
1150 local->inodelk_count += inodelk_count;
1151
1152 ret = dict_get_uint32 (xattr, GLUSTERFS_ENTRYLK_COUNT"glusterfs.entrylk-count",
1153 &entrylk_count);
1154 if (ret == 0)
1155 local->entrylk_count += entrylk_count;
1156 ret = dict_get_uint32 (xattr, GLUSTERFS_PARENT_ENTRYLK"glusterfs.parent-entrylk",
1157 &parent_entrylk);
1158 if (!ret)
1159 local->cont.lookup.parent_entrylk += parent_entrylk;
1160}
1161
1162/*
1163 * It's important to maintain a commutative property on do_*_self_heal and
1164 * found*; once set, they must not be cleared by a subsequent iteration or
1165 * call, so that they represent a logical OR of all iterations and calls
1166 * regardless of child/key order. That allows the caller to call us multiple
1167 * times without having to use a separate variable as a "reduce" accumulator.
1168 */
1169static void
1170afr_lookup_set_self_heal_params_by_xattr (afr_local_t *local, xlator_t *this,
1171 dict_t *xattr)
1172{
1173 afr_private_t *priv = NULL((void*)0);
1174 int i = 0;
1175 int ret = -1;
1176 void *pending_raw = NULL((void*)0);
1177 int32_t *pending = NULL((void*)0);
1178
1179 GF_ASSERT (local)do { if (!(local)) { do { do { if (0) printf ("Assertion failed: "
"local"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1179, GF_LOG_ERROR, "Assertion failed: " "local"
); } while (0); } } while (0)
;
1180 GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: "
"this"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1180, GF_LOG_ERROR, "Assertion failed: " "this"
); } while (0); } } while (0)
;
1181 GF_ASSERT (xattr)do { if (!(xattr)) { do { do { if (0) printf ("Assertion failed: "
"xattr"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1181, GF_LOG_ERROR, "Assertion failed: " "xattr"
); } while (0); } } while (0)
;
1182
1183 priv = this->private;
1184
1185 for (i = 0; i < priv->child_count; i++) {
1186 ret = dict_get_ptr (xattr, priv->pending_key[i],
1187 &pending_raw);
1188 if (ret != 0) {
1189 continue;
1190 }
1191 pending = pending_raw;
1192
1193 if (pending[AFR_METADATA_TRANSACTION]) {
1194 gf_log(this->name, GF_LOG_DEBUG,do { do { if (0) printf ("metadata self-heal is pending for %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1196, GF_LOG_DEBUG, "metadata self-heal is pending for %s."
, local->loc.path); } while (0)
1195 "metadata self-heal is pending for %s.",do { do { if (0) printf ("metadata self-heal is pending for %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1196, GF_LOG_DEBUG, "metadata self-heal is pending for %s."
, local->loc.path); } while (0)
1196 local->loc.path)do { do { if (0) printf ("metadata self-heal is pending for %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1196, GF_LOG_DEBUG, "metadata self-heal is pending for %s."
, local->loc.path); } while (0)
;
1197 local->self_heal.do_metadata_self_heal = _gf_true;
1198 }
1199
1200 if (pending[AFR_ENTRY_TRANSACTION]) {
1201 gf_log(this->name, GF_LOG_DEBUG,do { do { if (0) printf ("entry self-heal is pending for %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1203, GF_LOG_DEBUG, "entry self-heal is pending for %s."
, local->loc.path); } while (0)
1202 "entry self-heal is pending for %s.",do { do { if (0) printf ("entry self-heal is pending for %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1203, GF_LOG_DEBUG, "entry self-heal is pending for %s."
, local->loc.path); } while (0)
1203 local->loc.path)do { do { if (0) printf ("entry self-heal is pending for %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1203, GF_LOG_DEBUG, "entry self-heal is pending for %s."
, local->loc.path); } while (0)
;
1204 local->self_heal.do_entry_self_heal = _gf_true;
1205 }
1206
1207 if (pending[AFR_DATA_TRANSACTION]) {
1208 gf_log(this->name, GF_LOG_DEBUG,do { do { if (0) printf ("data self-heal is pending for %s.",
local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1210, GF_LOG_DEBUG, "data self-heal is pending for %s."
, local->loc.path); } while (0)
1209 "data self-heal is pending for %s.",do { do { if (0) printf ("data self-heal is pending for %s.",
local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1210, GF_LOG_DEBUG, "data self-heal is pending for %s."
, local->loc.path); } while (0)
1210 local->loc.path)do { do { if (0) printf ("data self-heal is pending for %s.",
local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1210, GF_LOG_DEBUG, "data self-heal is pending for %s."
, local->loc.path); } while (0)
;
1211 local->self_heal.do_data_self_heal = _gf_true;
1212 }
1213 }
1214}
1215
1216void
1217afr_lookup_check_set_metadata_split_brain (afr_local_t *local, xlator_t *this)
1218{
1219 int32_t *sources = NULL((void*)0);
1220 afr_private_t *priv = NULL((void*)0);
1221 int32_t subvol_status = 0;
1222 int32_t *success_children = NULL((void*)0);
1223 dict_t **xattrs = NULL((void*)0);
1224 struct iatt *bufs = NULL((void*)0);
1225 int32_t **pending_matrix = NULL((void*)0);
1226
1227 priv = this->private;
1228
1229 sources = GF_CALLOC (priv->child_count, sizeof (*sources),__gf_calloc (priv->child_count, sizeof (*sources), gf_afr_mt_int32_t
)
1230 gf_afr_mt_int32_t)__gf_calloc (priv->child_count, sizeof (*sources), gf_afr_mt_int32_t
)
;
1231 if (NULL((void*)0) == sources)
1232 goto out;
1233 success_children = local->cont.lookup.success_children;
1234 xattrs = local->cont.lookup.xattrs;
1235 bufs = local->cont.lookup.bufs;
1236 pending_matrix = local->cont.lookup.pending_matrix;
1237 afr_build_sources (this, xattrs, bufs, pending_matrix,
1238 sources, success_children, AFR_METADATA_TRANSACTION,
1239 &subvol_status, _gf_false);
1240 if (subvol_status & SPLIT_BRAIN)
1241 local->cont.lookup.possible_spb = _gf_true;
1242out:
1243 GF_FREE (sources)__gf_free (sources);
1244}
1245
1246static void
1247afr_detect_self_heal_by_iatt (afr_local_t *local, xlator_t *this,
1248 struct iatt *buf, struct iatt *lookup_buf)
1249{
1250 if (PERMISSION_DIFFERS (buf, lookup_buf)(st_mode_from_ia ((buf)->ia_prot, (buf)->ia_type) != st_mode_from_ia
((lookup_buf)->ia_prot, (lookup_buf)->ia_type))
) {
1251 /* mismatching permissions */
1252 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("permissions differ for %s ", local->
loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1253, GF_LOG_DEBUG, "permissions differ for %s "
, local->loc.path); } while (0)
1253 "permissions differ for %s ", local->loc.path)do { do { if (0) printf ("permissions differ for %s ", local->
loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1253, GF_LOG_DEBUG, "permissions differ for %s "
, local->loc.path); } while (0)
;
1254 local->self_heal.do_metadata_self_heal = _gf_true;
1255 }
1256
1257 if (OWNERSHIP_DIFFERS (buf, lookup_buf)(((buf)->ia_uid != (lookup_buf)->ia_uid) || ((buf)->
ia_gid != (lookup_buf)->ia_gid))
) {
1258 /* mismatching permissions */
1259 local->self_heal.do_metadata_self_heal = _gf_true;
1260 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("ownership differs for %s ", local->
loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1261, GF_LOG_DEBUG, "ownership differs for %s "
, local->loc.path); } while (0)
1261 "ownership differs for %s ", local->loc.path)do { do { if (0) printf ("ownership differs for %s ", local->
loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1261, GF_LOG_DEBUG, "ownership differs for %s "
, local->loc.path); } while (0)
;
1262 }
1263
1264 if (SIZE_DIFFERS (buf, lookup_buf)((buf)->ia_size != (lookup_buf)->ia_size)
1265 && IA_ISREG (buf->ia_type)(buf->ia_type == IA_IFREG)) {
1266 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("size differs for %s ", local->loc
.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1267, GF_LOG_DEBUG, "size differs for %s ", local
->loc.path); } while (0)
1267 "size differs for %s ", local->loc.path)do { do { if (0) printf ("size differs for %s ", local->loc
.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1267, GF_LOG_DEBUG, "size differs for %s ", local
->loc.path); } while (0)
;
1268 local->self_heal.do_data_self_heal = _gf_true;
1269 }
1270
1271 if (uuid_compare (buf->ia_gfid, lookup_buf->ia_gfid)) {
1272 /* mismatching gfid */
1273 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: gfid different on subvolume", local
->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1274, GF_LOG_WARNING, "%s: gfid different on subvolume"
, local->loc.path); } while (0)
1274 "%s: gfid different on subvolume", local->loc.path)do { do { if (0) printf ("%s: gfid different on subvolume", local
->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1274, GF_LOG_WARNING, "%s: gfid different on subvolume"
, local->loc.path); } while (0)
;
1275 }
1276}
1277
1278static void
1279afr_detect_self_heal_by_split_brain_status (afr_local_t *local, xlator_t *this)
1280{
1281 gf_boolean_t split_brain = _gf_false;
1282 afr_self_heal_t *sh = NULL((void*)0);
1283
1284 sh = &local->self_heal;
1285
1286 split_brain = afr_is_split_brain (this, local->cont.lookup.inode);
1287 split_brain = split_brain || local->cont.lookup.possible_spb;
1288 if ((local->success_count > 0) && split_brain &&
1289 IA_ISREG (local->cont.lookup.inode->ia_type)(local->cont.lookup.inode->ia_type == IA_IFREG)) {
1290 sh->force_confirm_spb = _gf_true;
1291 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("split brain detected during lookup of %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1293, GF_LOG_DEBUG, "split brain detected during lookup of %s."
, local->loc.path); } while (0)
1292 "split brain detected during lookup of %s.",do { do { if (0) printf ("split brain detected during lookup of %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1293, GF_LOG_DEBUG, "split brain detected during lookup of %s."
, local->loc.path); } while (0)
1293 local->loc.path)do { do { if (0) printf ("split brain detected during lookup of %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1293, GF_LOG_DEBUG, "split brain detected during lookup of %s."
, local->loc.path); } while (0)
;
1294 }
1295}
1296
1297static void
1298afr_detect_self_heal_by_lookup_status (afr_local_t *local, xlator_t *this)
1299{
1300 GF_ASSERT (local)do { if (!(local)) { do { do { if (0) printf ("Assertion failed: "
"local"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1300, GF_LOG_ERROR, "Assertion failed: " "local"
); } while (0); } } while (0)
;
1301 GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: "
"this"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1301, GF_LOG_ERROR, "Assertion failed: " "this"
); } while (0); } } while (0)
;
1302
1303 if ((local->success_count > 0) && (local->enoent_count > 0)) {
1304 local->self_heal.do_metadata_self_heal = _gf_true;
1305 local->self_heal.do_data_self_heal = _gf_true;
1306 local->self_heal.do_entry_self_heal = _gf_true;
1307 local->self_heal.do_gfid_self_heal = _gf_true;
1308 local->self_heal.do_missing_entry_self_heal = _gf_true;
1309 gf_log(this->name, GF_LOG_DEBUG,do { do { if (0) printf ("entries are missing in lookup of %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1311, GF_LOG_DEBUG, "entries are missing in lookup of %s."
, local->loc.path); } while (0)
1310 "entries are missing in lookup of %s.",do { do { if (0) printf ("entries are missing in lookup of %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1311, GF_LOG_DEBUG, "entries are missing in lookup of %s."
, local->loc.path); } while (0)
1311 local->loc.path)do { do { if (0) printf ("entries are missing in lookup of %s."
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1311, GF_LOG_DEBUG, "entries are missing in lookup of %s."
, local->loc.path); } while (0)
;
1312 }
1313
1314 return;
1315}
1316
1317gf_boolean_t
1318afr_can_self_heal_proceed (afr_self_heal_t *sh, afr_private_t *priv)
1319{
1320 GF_ASSERT (sh)do { if (!(sh)) { do { do { if (0) printf ("Assertion failed: "
"sh"); } while (0); _gf_log_callingfn ("", "./afr-common.c",
__FUNCTION__, 1320, GF_LOG_ERROR, "Assertion failed: " "sh")
; } while (0); } } while (0)
;
1321 GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: "
"priv"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1321, GF_LOG_ERROR, "Assertion failed: " "priv"
); } while (0); } } while (0)
;
1322
1323 if (sh->force_confirm_spb)
1324 return _gf_true;
1325 return (sh->do_gfid_self_heal
1326 || sh->do_missing_entry_self_heal
1327 || (afr_data_self_heal_enabled (priv->data_self_heal) &&
1328 sh->do_data_self_heal)
1329 || (priv->metadata_self_heal && sh->do_metadata_self_heal)
1330 || (priv->entry_self_heal && sh->do_entry_self_heal));
1331}
1332
1333afr_transaction_type
1334afr_transaction_type_get (ia_type_t ia_type)
1335{
1336 afr_transaction_type type = AFR_METADATA_TRANSACTION;
1337
1338 GF_ASSERT (ia_type != IA_INVAL)do { if (!(ia_type != IA_INVAL)) { do { do { if (0) printf ("Assertion failed: "
"ia_type != IA_INVAL"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1338, GF_LOG_ERROR, "Assertion failed: " "ia_type != IA_INVAL"
); } while (0); } } while (0)
;
1339
1340 if (IA_ISDIR (ia_type)(ia_type == IA_IFDIR)) {
1341 type = AFR_ENTRY_TRANSACTION;
1342 } else if (IA_ISREG (ia_type)(ia_type == IA_IFREG)) {
1343 type = AFR_DATA_TRANSACTION;
1344 }
1345 return type;
1346}
1347
1348int
1349afr_lookup_select_read_child (afr_local_t *local, xlator_t *this,
1350 int32_t *read_child)
1351{
1352 ia_type_t ia_type = IA_INVAL;
1353 int32_t source = -1;
1354 int ret = -1;
1355 dict_t **xattrs = NULL((void*)0);
1356 int32_t *success_children = NULL((void*)0);
1357 afr_transaction_type type = AFR_METADATA_TRANSACTION;
1358 uuid_t *gfid = NULL((void*)0);
1359
1360 GF_ASSERT (local)do { if (!(local)) { do { do { if (0) printf ("Assertion failed: "
"local"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1360, GF_LOG_ERROR, "Assertion failed: " "local"
); } while (0); } } while (0)
;
1361 GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: "
"this"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1361, GF_LOG_ERROR, "Assertion failed: " "this"
); } while (0); } } while (0)
;
1362 GF_ASSERT (local->success_count > 0)do { if (!(local->success_count > 0)) { do { do { if (0
) printf ("Assertion failed: " "local->success_count > 0"
); } while (0); _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__
, 1362, GF_LOG_ERROR, "Assertion failed: " "local->success_count > 0"
); } while (0); } } while (0)
;
1363
1364 success_children = local->cont.lookup.success_children;
1365 /*We can take the success_children[0] only because we already
1366 *handle the conflicting children other wise, we could select the
1367 *read_child based on wrong file type
1368 */
1369 ia_type = local->cont.lookup.bufs[success_children[0]].ia_type;
1370 type = afr_transaction_type_get (ia_type);
1371 xattrs = local->cont.lookup.xattrs;
1372 gfid = &local->cont.lookup.buf.ia_gfid;
1373 source = afr_lookup_select_read_child_by_txn_type (this, local, xattrs,
1374 type, *gfid);
1375 if (source < 0) {
1376 gf_log (this->name, GF_LOG_DEBUG, "failed to select source "do { do { if (0) printf ("failed to select source " "for %s",
local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1377, GF_LOG_DEBUG, "failed to select source "
"for %s", local->loc.path); } while (0)
1377 "for %s", local->loc.path)do { do { if (0) printf ("failed to select source " "for %s",
local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1377, GF_LOG_DEBUG, "failed to select source "
"for %s", local->loc.path); } while (0)
;
1378 goto out;
1379 }
1380
1381 gf_log (this->name, GF_LOG_DEBUG, "Source selected as %d for %s",do { do { if (0) printf ("Source selected as %d for %s", source
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1382, GF_LOG_DEBUG, "Source selected as %d for %s"
, source, local->loc.path); } while (0)
1382 source, local->loc.path)do { do { if (0) printf ("Source selected as %d for %s", source
, local->loc.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 1382, GF_LOG_DEBUG, "Source selected as %d for %s"
, source, local->loc.path); } while (0)
;
1383 *read_child = source;
1384 ret = 0;
1385out:
1386 return ret;
1387}
1388
1389static inline gf_boolean_t
1390afr_is_transaction_running (afr_local_t *local)
1391{
1392 GF_ASSERT (local->fop == GF_FOP_LOOKUP)do { if (!(local->fop == GF_FOP_LOOKUP)) { do { do { if (0
) printf ("Assertion failed: " "local->fop == GF_FOP_LOOKUP"
); } while (0); _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__
, 1392, GF_LOG_ERROR, "Assertion failed: " "local->fop == GF_FOP_LOOKUP"
); } while (0); } } while (0)
;
1393 return ((local->inodelk_count > 0) || (local->entrylk_count > 0));
1394}
1395
1396void
1397afr_launch_self_heal (call_frame_t *frame, xlator_t *this, inode_t *inode,
1398 gf_boolean_t background, ia_type_t ia_type, char *reason,
1399 void (*gfid_sh_success_cbk) (call_frame_t *sh_frame,
1400 xlator_t *this),
1401 int (*unwind) (call_frame_t *frame, xlator_t *this,
1402 int32_t op_ret, int32_t op_errno,
1403 int32_t sh_failed))
1404{
1405 afr_local_t *local = NULL((void*)0);
1406 char sh_type_str[256] = {0,};
1407 char *bg = "";
1408
1409 GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: "
"frame"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1409, GF_LOG_ERROR, "Assertion failed: " "frame"
); } while (0); } } while (0)
;
1410 GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: "
"this"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1410, GF_LOG_ERROR, "Assertion failed: " "this"
); } while (0); } } while (0)
;
1411 GF_ASSERT (inode)do { if (!(inode)) { do { do { if (0) printf ("Assertion failed: "
"inode"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1411, GF_LOG_ERROR, "Assertion failed: " "inode"
); } while (0); } } while (0)
;
1412 GF_ASSERT (ia_type != IA_INVAL)do { if (!(ia_type != IA_INVAL)) { do { do { if (0) printf ("Assertion failed: "
"ia_type != IA_INVAL"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1412, GF_LOG_ERROR, "Assertion failed: " "ia_type != IA_INVAL"
); } while (0); } } while (0)
;
1413
1414 local = frame->local;
1415 local->self_heal.background = background;
1416 local->self_heal.type = ia_type;
1417 local->self_heal.unwind = unwind;
1418 local->self_heal.gfid_sh_success_cbk = gfid_sh_success_cbk;
1419
1420 afr_self_heal_type_str_get (&local->self_heal,
1421 sh_type_str,
1422 sizeof (sh_type_str));
1423
1424 if (background)
1425 bg = "background";
1426 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s %s self-heal triggered. path: %s, reason: %s"
, bg, sh_type_str, local->loc.path, reason); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 1428, GF_LOG_DEBUG
, "%s %s self-heal triggered. path: %s, reason: %s", bg, sh_type_str
, local->loc.path, reason); } while (0)
1427 "%s %s self-heal triggered. path: %s, reason: %s", bg,do { do { if (0) printf ("%s %s self-heal triggered. path: %s, reason: %s"
, bg, sh_type_str, local->loc.path, reason); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 1428, GF_LOG_DEBUG
, "%s %s self-heal triggered. path: %s, reason: %s", bg, sh_type_str
, local->loc.path, reason); } while (0)
1428 sh_type_str, local->loc.path, reason)do { do { if (0) printf ("%s %s self-heal triggered. path: %s, reason: %s"
, bg, sh_type_str, local->loc.path, reason); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 1428, GF_LOG_DEBUG
, "%s %s self-heal triggered. path: %s, reason: %s", bg, sh_type_str
, local->loc.path, reason); } while (0)
;
1429
1430 afr_self_heal (frame, this, inode);
1431}
1432
1433unsigned int
1434afr_gfid_missing_count (const char *xlator_name, int32_t *success_children,
1435 struct iatt *bufs, unsigned int child_count,
1436 const char *path)
1437{
1438 unsigned int gfid_miss_count = 0;
1439 int i = 0;
1440 struct iatt *child1 = NULL((void*)0);
1441
1442 for (i = 0; i < child_count; i++) {
1443 if (success_children[i] == -1)
1444 break;
1445 child1 = &bufs[success_children[i]];
1446 if (uuid_is_null (child1->ia_gfid)) {
1447 gf_log (xlator_name, GF_LOG_DEBUG, "%s: gfid is null"do { do { if (0) printf ("%s: gfid is null" " on subvolume %d"
, path, success_children[i]); } while (0); _gf_log (xlator_name
, "./afr-common.c", __FUNCTION__, 1448, GF_LOG_DEBUG, "%s: gfid is null"
" on subvolume %d", path, success_children[i]); } while (0)
1448 " on subvolume %d", path, success_children[i])do { do { if (0) printf ("%s: gfid is null" " on subvolume %d"
, path, success_children[i]); } while (0); _gf_log (xlator_name
, "./afr-common.c", __FUNCTION__, 1448, GF_LOG_DEBUG, "%s: gfid is null"
" on subvolume %d", path, success_children[i]); } while (0)
;
1449 gfid_miss_count++;
1450 }
1451 }
1452
1453 return gfid_miss_count;
1454}
1455
1456static int
1457afr_lookup_gfid_missing_count (afr_local_t *local, xlator_t *this)
1458{
1459 int32_t *success_children = NULL((void*)0);
1460 afr_private_t *priv = NULL((void*)0);
1461 struct iatt *bufs = NULL((void*)0);
1462 int miss_count = 0;
1463
1464 priv = this->private;
1465 bufs = local->cont.lookup.bufs;
1466 success_children = local->cont.lookup.success_children;
1467
1468 miss_count = afr_gfid_missing_count (this->name, success_children,
1469 bufs, priv->child_count,
1470 local->loc.path);
1471 return miss_count;
1472}
1473
1474gf_boolean_t
1475afr_conflicting_iattrs (struct iatt *bufs, int32_t *success_children,
1476 unsigned int child_count, const char *path,
1477 const char *xlator_name)
1478{
1479 gf_boolean_t conflicting = _gf_false;
1480 int i = 0;
1481 struct iatt *child1 = NULL((void*)0);
1482 struct iatt *child2 = NULL((void*)0);
1483 uuid_t *gfid = NULL((void*)0);
1484
1485 for (i = 0; i < child_count; i++) {
1486 if (success_children[i] == -1)
1487 break;
1488 child1 = &bufs[success_children[i]];
1489 if ((!gfid) && (!uuid_is_null (child1->ia_gfid)))
1490 gfid = &child1->ia_gfid;
1491
1492 if (i == 0)
1493 continue;
1494
1495 child2 = &bufs[success_children[i-1]];
1496 if (FILETYPE_DIFFERS (child1, child2)((child1)->ia_type != (child2)->ia_type)) {
1497 gf_log (xlator_name, GF_LOG_WARNING, "%s: filetype "do { do { if (0) printf ("%s: filetype " "differs on subvolumes (%d, %d)"
, path, success_children[i-1], success_children[i]); } while (
0); _gf_log (xlator_name, "./afr-common.c", __FUNCTION__, 1499
, GF_LOG_WARNING, "%s: filetype " "differs on subvolumes (%d, %d)"
, path, success_children[i-1], success_children[i]); } while (
0)
1498 "differs on subvolumes (%d, %d)", path,do { do { if (0) printf ("%s: filetype " "differs on subvolumes (%d, %d)"
, path, success_children[i-1], success_children[i]); } while (
0); _gf_log (xlator_name, "./afr-common.c", __FUNCTION__, 1499
, GF_LOG_WARNING, "%s: filetype " "differs on subvolumes (%d, %d)"
, path, success_children[i-1], success_children[i]); } while (
0)
1499 success_children[i-1], success_children[i])do { do { if (0) printf ("%s: filetype " "differs on subvolumes (%d, %d)"
, path, success_children[i-1], success_children[i]); } while (
0); _gf_log (xlator_name, "./afr-common.c", __FUNCTION__, 1499
, GF_LOG_WARNING, "%s: filetype " "differs on subvolumes (%d, %d)"
, path, success_children[i-1], success_children[i]); } while (
0)
;
1500 conflicting = _gf_true;
1501 goto out;
1502 }
1503 if (!gfid || uuid_is_null (child1->ia_gfid))
1504 continue;
1505 if (uuid_compare (*gfid, child1->ia_gfid)) {
1506 gf_log (xlator_name, GF_LOG_WARNING, "%s: gfid differs"do { do { if (0) printf ("%s: gfid differs" " on subvolume %d"
, path, success_children[i]); } while (0); _gf_log (xlator_name
, "./afr-common.c", __FUNCTION__, 1507, GF_LOG_WARNING, "%s: gfid differs"
" on subvolume %d", path, success_children[i]); } while (0)
1507 " on subvolume %d", path, success_children[i])do { do { if (0) printf ("%s: gfid differs" " on subvolume %d"
, path, success_children[i]); } while (0); _gf_log (xlator_name
, "./afr-common.c", __FUNCTION__, 1507, GF_LOG_WARNING, "%s: gfid differs"
" on subvolume %d", path, success_children[i]); } while (0)
;
1508 conflicting = _gf_true;
1509 goto out;
1510 }
1511 }
1512out:
1513 return conflicting;
1514}
1515
1516/* afr_update_gfid_from_iatts: This function should be called only if the
1517 * iatts are not conflicting.
1518 */
1519void
1520afr_update_gfid_from_iatts (uuid_t uuid, struct iatt *bufs,
1521 int32_t *success_children, unsigned int child_count)
1522{
1523 uuid_t *gfid = NULL((void*)0);
1524 int i = 0;
1525 int child = 0;
1526
1527 for (i = 0; i < child_count; i++) {
1528 child = success_children[i];
1529 if (child == -1)
1530 break;
1531 if ((!gfid) && (!uuid_is_null (bufs[child].ia_gfid))) {
1532 gfid = &bufs[child].ia_gfid;
1533 } else if (gfid && (!uuid_is_null (bufs[child].ia_gfid))) {
1534 if (uuid_compare (*gfid, bufs[child].ia_gfid)) {
1535 GF_ASSERT (0)do { if (!(0)) { do { do { if (0) printf ("Assertion failed: "
"0"); } while (0); _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__
, 1535, GF_LOG_ERROR, "Assertion failed: " "0"); } while (0);
} } while (0)
;
1536 goto out;
1537 }
1538 }
1539 }
1540 if (gfid && (!uuid_is_null (*gfid)))
1541 uuid_copy (uuid, *gfid);
1542out:
1543 return;
1544}
1545
1546static gf_boolean_t
1547afr_lookup_conflicting_entries (afr_local_t *local, xlator_t *this)
1548{
1549 afr_private_t *priv = NULL((void*)0);
1550 gf_boolean_t conflict = _gf_false;
1551
1552 priv = this->private;
1553 conflict = afr_conflicting_iattrs (local->cont.lookup.bufs,
1554 local->cont.lookup.success_children,
1555 priv->child_count, local->loc.path,
1556 this->name);
1557 return conflict;
1558}
1559
1560gf_boolean_t
1561afr_open_only_data_self_heal (char *data_self_heal)
1562{
1563 return !strcmp (data_self_heal, "open");
1564}
1565
1566gf_boolean_t
1567afr_data_self_heal_enabled (char *data_self_heal)
1568{
1569 gf_boolean_t enabled = _gf_false;
1570
1571 if (gf_string2boolean (data_self_heal, &enabled) == -1) {
1572 enabled = !strcmp (data_self_heal, "open");
1573 GF_ASSERT (enabled)do { if (!(enabled)) { do { do { if (0) printf ("Assertion failed: "
"enabled"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1573, GF_LOG_ERROR, "Assertion failed: " "enabled"
); } while (0); } } while (0)
;
1574 }
1575
1576 return enabled;
1577}
1578
1579static void
1580afr_lookup_set_self_heal_params (afr_local_t *local, xlator_t *this)
1581{
1582 int i = 0;
1583 struct iatt *bufs = NULL((void*)0);
1584 dict_t **xattr = NULL((void*)0);
1585 afr_private_t *priv = NULL((void*)0);
1586 int32_t child1 = -1;
1587 int32_t child2 = -1;
1588 afr_self_heal_t *sh = NULL((void*)0);
1589
1590 priv = this->private;
1591 sh = &local->self_heal;
1592
1593 afr_detect_self_heal_by_lookup_status (local, this);
1594
1595 if (afr_lookup_gfid_missing_count (local, this))
1596 local->self_heal.do_gfid_self_heal = _gf_true;
1597
1598 if (_gf_true == afr_lookup_conflicting_entries (local, this))
1599 local->self_heal.do_missing_entry_self_heal = _gf_true;
1600 else
1601 afr_update_gfid_from_iatts (local->self_heal.sh_gfid_req,
1602 local->cont.lookup.bufs,
1603 local->cont.lookup.success_children,
1604 priv->child_count);
1605
1606 bufs = local->cont.lookup.bufs;
1607 for (i = 1; i < local->success_count; i++) {
1608 child1 = local->cont.lookup.success_children[i-1];
1609 child2 = local->cont.lookup.success_children[i];
1610 afr_detect_self_heal_by_iatt (local, this,
1611 &bufs[child1], &bufs[child2]);
1612 }
1613
1614 xattr = local->cont.lookup.xattrs;
1615 for (i = 0; i < local->success_count; i++) {
1616 child1 = local->cont.lookup.success_children[i];
1617 afr_lookup_set_self_heal_params_by_xattr (local, this,
1618 xattr[child1]);
1619 }
1620 if (afr_open_only_data_self_heal (priv->data_self_heal))
1621 sh->do_data_self_heal = _gf_false;
1622 if (sh->do_metadata_self_heal)
1623 afr_lookup_check_set_metadata_split_brain (local, this);
1624 afr_detect_self_heal_by_split_brain_status (local, this);
1625}
1626
1627int
1628afr_self_heal_lookup_unwind (call_frame_t *frame, xlator_t *this,
1629 int32_t op_ret, int32_t op_errno,
1630 int32_t sh_failed)
1631{
1632 afr_local_t *local = NULL((void*)0);
1633 int ret = -1;
1634 dict_t *xattr = NULL((void*)0);
1635 int32_t spb = 0;
1636
1637 local = frame->local;
1638
1639 if (op_ret == -1) {
1640 local->op_ret = -1;
1641 local->op_errno = afr_most_important_error(local->op_errno,
1642 op_errno, _gf_true);
1643
1644 goto out;
1645 } else {
1646 local->op_ret = 0;
1647 }
1648
1649 afr_lookup_done_success_action (frame, this, _gf_true);
1650 xattr = local->cont.lookup.xattr;
1651 if (xattr) {
1652 ret = dict_set_int32 (xattr, "sh-failed", sh_failed);
1653 if (ret)
1654 gf_log (this->name, GF_LOG_ERROR, "%s: Failed to set "do { do { if (0) printf ("%s: Failed to set " "sh-failed to %d"
, local->loc.path, sh_failed); } while (0); _gf_log (this->
name, "./afr-common.c", __FUNCTION__, 1655, GF_LOG_ERROR, "%s: Failed to set "
"sh-failed to %d", local->loc.path, sh_failed); } while (
0)
1655 "sh-failed to %d", local->loc.path, sh_failed)do { do { if (0) printf ("%s: Failed to set " "sh-failed to %d"
, local->loc.path, sh_failed); } while (0); _gf_log (this->
name, "./afr-common.c", __FUNCTION__, 1655, GF_LOG_ERROR, "%s: Failed to set "
"sh-failed to %d", local->loc.path, sh_failed); } while (
0)
;
1656
1657 if (local->self_heal.actual_sh_started == _gf_true &&
1658 sh_failed == 0) {
1659 ret = dict_set_int32 (xattr, "actual-sh-done", 1);
1660 if (ret)
1661 gf_log(this->name, GF_LOG_ERROR, "%s: Failed to"do { do { if (0) printf ("%s: Failed to" " set actual-sh-done to %d"
, local->loc.path, local->self_heal.actual_sh_started);
} while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 1664, GF_LOG_ERROR, "%s: Failed to" " set actual-sh-done to %d"
, local->loc.path, local->self_heal.actual_sh_started);
} while (0)
1662 " set actual-sh-done to %d",do { do { if (0) printf ("%s: Failed to" " set actual-sh-done to %d"
, local->loc.path, local->self_heal.actual_sh_started);
} while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 1664, GF_LOG_ERROR, "%s: Failed to" " set actual-sh-done to %d"
, local->loc.path, local->self_heal.actual_sh_started);
} while (0)
1663 local->loc.path,do { do { if (0) printf ("%s: Failed to" " set actual-sh-done to %d"
, local->loc.path, local->self_heal.actual_sh_started);
} while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 1664, GF_LOG_ERROR, "%s: Failed to" " set actual-sh-done to %d"
, local->loc.path, local->self_heal.actual_sh_started);
} while (0)
1664 local->self_heal.actual_sh_started)do { do { if (0) printf ("%s: Failed to" " set actual-sh-done to %d"
, local->loc.path, local->self_heal.actual_sh_started);
} while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 1664, GF_LOG_ERROR, "%s: Failed to" " set actual-sh-done to %d"
, local->loc.path, local->self_heal.actual_sh_started);
} while (0)
;
1665 }
1666
1667 if (local->loc.inode)
1668 spb = afr_is_split_brain (this, local->loc.inode);
1669 ret = dict_set_int32 (xattr, "split-brain", spb);
1670 }
1671out:
1672 AFR_STACK_UNWIND (lookup, frame, local->op_ret, local->op_errno,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 1675, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.lookup.inode,
&local->cont.lookup.buf, local->cont.lookup.xattr,
&local->cont.lookup.postparent); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
1673 local->cont.lookup.inode, &local->cont.lookup.buf,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 1675, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.lookup.inode,
&local->cont.lookup.buf, local->cont.lookup.xattr,
&local->cont.lookup.postparent); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
1674 local->cont.lookup.xattr,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 1675, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.lookup.inode,
&local->cont.lookup.buf, local->cont.lookup.xattr,
&local->cont.lookup.postparent); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
1675 &local->cont.lookup.postparent)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 1675, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.lookup.inode,
&local->cont.lookup.buf, local->cont.lookup.xattr,
&local->cont.lookup.postparent); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
1676
1677 return 0;
1678}
1679
1680//TODO: At the moment only lookup needs this, so not doing any checks, in the
1681// future we will have to do fop specific operations
1682void
1683afr_post_gfid_sh_success (call_frame_t *sh_frame, xlator_t *this)
1684{
1685 afr_local_t *local = NULL((void*)0);
1686 afr_local_t *sh_local = NULL((void*)0);
1687 afr_private_t *priv = NULL((void*)0);
1688 afr_self_heal_t *sh = NULL((void*)0);
1689 int i = 0;
1690 struct iatt *lookup_bufs = NULL((void*)0);
1691 struct iatt *lookup_parentbufs = NULL((void*)0);
1692
1693 sh_local = sh_frame->local;
1694 sh = &sh_local->self_heal;
1695 local = sh->orig_frame->local;
1696 lookup_bufs = local->cont.lookup.bufs;
1697 lookup_parentbufs = local->cont.lookup.postparents;
1698 priv = this->private;
1699
1700 memcpy (lookup_bufs, sh->buf, priv->child_count * sizeof (*sh->buf));
1701 memcpy (lookup_parentbufs, sh->parentbufs,
1702 priv->child_count * sizeof (*sh->parentbufs));
1703
1704 afr_reset_xattr (local->cont.lookup.xattrs, priv->child_count);
1705 if (local->cont.lookup.xattr) {
1706 dict_unref (local->cont.lookup.xattr);
1707 local->cont.lookup.xattr = NULL((void*)0);
1708 }
1709
1710 for (i = 0; i < priv->child_count; i++) {
1711 if (sh->xattr[i])
1712 local->cont.lookup.xattrs[i] = dict_ref (sh->xattr[i]);
1713 }
1714
1715 afr_reset_children (local->cont.lookup.success_children,
1716 priv->child_count);
1717 afr_children_copy (local->cont.lookup.success_children,
1718 sh->fresh_children, priv->child_count);
1719}
1720
1721static void
1722afr_lookup_perform_self_heal (call_frame_t *frame, xlator_t *this,
1723 gf_boolean_t *sh_launched)
1724{
1725 unsigned int up_count = 0;
1726 afr_private_t *priv = NULL((void*)0);
1727 afr_local_t *local = NULL((void*)0);
1728 char *reason = NULL((void*)0);
1729
1730 GF_ASSERT (sh_launched)do { if (!(sh_launched)) { do { do { if (0) printf ("Assertion failed: "
"sh_launched"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1730, GF_LOG_ERROR, "Assertion failed: " "sh_launched"
); } while (0); } } while (0)
;
1731 *sh_launched = _gf_false;
1732 priv = this->private;
1733 local = frame->local;
1734
1735 up_count = afr_up_children_count (local->child_up, priv->child_count);
1736 if (up_count == 1) {
1737 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Only 1 child up - do not attempt to detect self heal"
); } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 1738, GF_LOG_DEBUG, "Only 1 child up - do not attempt to detect self heal"
); } while (0)
1738 "Only 1 child up - do not attempt to detect self heal")do { do { if (0) printf ("Only 1 child up - do not attempt to detect self heal"
); } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 1738, GF_LOG_DEBUG, "Only 1 child up - do not attempt to detect self heal"
); } while (0)
;
1739 goto out;
1740 }
1741
1742 afr_lookup_set_self_heal_params (local, this);
1743 if (afr_can_self_heal_proceed (&local->self_heal, priv)) {
1744 if (afr_is_transaction_running (local))
1745 goto out;
1746
1747 reason = "lookup detected pending operations";
1748 afr_launch_self_heal (frame, this, local->cont.lookup.inode,
1749 _gf_true, local->cont.lookup.buf.ia_type,
1750 reason, afr_post_gfid_sh_success,
1751 afr_self_heal_lookup_unwind);
1752 *sh_launched = _gf_true;
1753 }
1754out:
1755 return;
1756}
1757
1758void
1759afr_get_fresh_children (int32_t *success_children, int32_t *sources,
1760 int32_t *fresh_children, unsigned int child_count)
1761{
1762 unsigned int i = 0;
1763 unsigned int j = 0;
1764
1765 GF_ASSERT (success_children)do { if (!(success_children)) { do { do { if (0) printf ("Assertion failed: "
"success_children"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1765, GF_LOG_ERROR, "Assertion failed: " "success_children"
); } while (0); } } while (0)
;
1766 GF_ASSERT (sources)do { if (!(sources)) { do { do { if (0) printf ("Assertion failed: "
"sources"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1766, GF_LOG_ERROR, "Assertion failed: " "sources"
); } while (0); } } while (0)
;
1767 GF_ASSERT (fresh_children)do { if (!(fresh_children)) { do { do { if (0) printf ("Assertion failed: "
"fresh_children"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1767, GF_LOG_ERROR, "Assertion failed: " "fresh_children"
); } while (0); } } while (0)
;
1768
1769 afr_reset_children (fresh_children, child_count);
1770 for (i = 0; i < child_count; i++) {
1771 if (success_children[i] == -1)
1772 break;
1773 if (afr_is_read_child (success_children, sources, child_count,
1774 success_children[i])) {
1775 fresh_children[j] = success_children[i];
1776 j++;
1777 }
1778 }
1779}
1780
1781static int
1782afr_lookup_set_read_ctx (afr_local_t *local, xlator_t *this, int32_t read_child)
1783{
1784 afr_private_t *priv = NULL((void*)0);
1785
1786 GF_ASSERT (read_child >= 0)do { if (!(read_child >= 0)) { do { do { if (0) printf ("Assertion failed: "
"read_child >= 0"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 1786, GF_LOG_ERROR, "Assertion failed: " "read_child >= 0"
); } while (0); } } while (0)
;
1787
1788 priv = this->private;
1789 afr_get_fresh_children (local->cont.lookup.success_children,
1790 local->cont.lookup.sources,
1791 local->fresh_children, priv->child_count);
1792 afr_inode_set_read_ctx (this, local->cont.lookup.inode, read_child,
1793 local->fresh_children);
1794
1795 return 0;
1796}
1797
1798int
1799afr_lookup_done_success_action (call_frame_t *frame, xlator_t *this,
1800 gf_boolean_t fail_conflict)
1801{
1802 int32_t read_child = -1;
1803 int32_t ret = -1;
1804 afr_local_t *local = NULL((void*)0);
1805 gf_boolean_t fresh_lookup = _gf_false;
1806
1807 local = frame->local;
1808 fresh_lookup = local->cont.lookup.fresh_lookup;
1809
1810 if (local->loc.parent == NULL((void*)0))
1811 fail_conflict = _gf_true;
1812
1813 if (afr_lookup_conflicting_entries (local, this)) {
1814 if (fail_conflict == _gf_false)
1815 ret = 0;
1816 goto out;
1817 }
1818
1819 ret = afr_lookup_select_read_child (local, this, &read_child);
1820 if (!afr_is_transaction_running (local) || fresh_lookup) {
1821 if (read_child < 0)
1822 goto out;
1823
1824 ret = afr_lookup_set_read_ctx (local, this, read_child);
1825 if (ret)
1826 goto out;
1827 }
1828
1829 ret = afr_lookup_build_response_params (local, this);
1830 if (ret)
1831 goto out;
1832 afr_update_loc_gfids (&local->loc,
1833 &local->cont.lookup.buf,
1834 &local->cont.lookup.postparent);
1835
1836 ret = 0;
1837out:
1838 if (ret) {
1839 local->op_ret = -1;
1840 local->op_errno = EIO5;
1841 }
1842 return ret;
1843}
1844
1845int
1846afr_lookup_get_latest_subvol (afr_local_t *local, xlator_t *this)
1847{
1848 afr_private_t *priv = NULL((void*)0);
1849 int32_t *success_children = NULL((void*)0);
1850 struct iatt *bufs = NULL((void*)0);
1851 int i = 0;
1852 int child = 0;
1853 int lsubvol = -1;
1854
1855 priv = this->private;
1856 success_children = local->cont.lookup.success_children;
1857 bufs = local->cont.lookup.bufs;
1858 for (i = 0; i < priv->child_count; i++) {
1859 child = success_children[i];
1860 if (child == -1)
1861 break;
1862 if (uuid_is_null (bufs[child].ia_gfid))
1863 continue;
1864 if (lsubvol < 0) {
1865 lsubvol = child;
1866 } else if (bufs[lsubvol].ia_ctime < bufs[child].ia_ctime) {
1867 lsubvol = child;
1868 } else if ((bufs[lsubvol].ia_ctime == bufs[child].ia_ctime) &&
1869 (bufs[lsubvol].ia_ctime_nsec < bufs[child].ia_ctime_nsec)) {
1870 lsubvol = child;
1871 }
1872 }
1873 return lsubvol;
1874}
1875
1876void
1877afr_lookup_mark_other_entries_stale (afr_local_t *local, xlator_t *this,
1878 int subvol)
1879{
1880 afr_private_t *priv = NULL((void*)0);
1881 int32_t *success_children = NULL((void*)0);
1882 struct iatt *bufs = NULL((void*)0);
1883 int i = 0;
1884 int child = 0;
1885
1886 priv = this->private;
1887 success_children = local->cont.lookup.success_children;
1888 bufs = local->cont.lookup.bufs;
1889 memcpy (local->fresh_children, success_children,
1890 sizeof (*success_children) * priv->child_count);
1891 for (i = 0; i < priv->child_count; i++) {
1892 child = local->fresh_children[i];
1893 if (child == -1)
1894 break;
1895 if (child == subvol)
1896 continue;
1897 if (uuid_is_null (bufs[child].ia_gfid) &&
1898 (bufs[child].ia_type == bufs[subvol].ia_type))
1899 continue;
1900 afr_children_rm_child (success_children, child,
1901 priv->child_count);
1902 local->success_count--;
1903 }
1904 afr_reset_children (local->fresh_children, priv->child_count);
1905}
1906
1907void
1908afr_succeed_lookup_on_latest_iatt (afr_local_t *local, xlator_t *this)
1909{
1910 int lsubvol = 0;
1911
1912 if (!afr_lookup_conflicting_entries (local, this))
1913 goto out;
1914
1915 lsubvol = afr_lookup_get_latest_subvol (local, this);
1916 if (lsubvol < 0)
1917 goto out;
1918 afr_lookup_mark_other_entries_stale (local, this, lsubvol);
1919out:
1920 return;
1921}
1922
1923gf_boolean_t
1924afr_is_entry_possibly_under_creation (afr_local_t *local, xlator_t *this)
1925{
1926 /*
1927 * We need to perform this test in lookup done and treat on going
1928 * create/DELETE as ENOENT.
1929 * Reason:
1930 Multiple clients A, B and C are attempting 'mkdir -p /mnt/a/b/c'
1931
1932 1 Client A is in the middle of mkdir(/a). It has acquired lock.
1933 It has performed mkdir(/a) on one subvol, and second one is still
1934 in progress
1935 2 Client B performs a lookup, sees directory /a on one,
1936 ENOENT on the other, succeeds lookup.
1937 3 Client B performs lookup on /a/b on both subvols, both return ENOENT
1938 (one subvol because /a/b does not exist, another because /a
1939 itself does not exist)
1940 4 Client B proceeds to mkdir /a/b. It obtains entrylk on inode=/a with
1941 basename=b on one subvol, but fails on other subvol as /a is yet to
1942 be created by Client A.
1943 5 Client A finishes mkdir of /a on other subvol
1944 6 Client C also attempts to create /a/b, lookup returns ENOENT on
1945 both subvols.
1946 7 Client C tries to obtain entrylk on on inode=/a with basename=b,
1947 obtains on one subvol (where B had failed), and waits for B to unlock
1948 on other subvol.
1949 8 Client B finishes mkdir() on one subvol with GFID-1 and completes
1950 transaction and unlocks
1951 9 Client C gets the lock on the second subvol, At this stage second
1952 subvol already has /a/b created from Client B, but Client C does not
1953 check that in the middle of mkdir transaction
1954 10 Client C attempts mkdir /a/b on both subvols. It succeeds on
1955 ONLY ONE (where Client B could not get lock because of
1956 missing parent /a dir) with GFID-2, and gets EEXIST from ONE subvol.
1957 This way we have /a/b in GFID mismatch. One subvol got GFID-1 because
1958 Client B performed transaction on only one subvol (because entrylk()
1959 could not be obtained on second subvol because of missing parent dir --
1960 caused by premature/speculative succeeding of lookup() on /a when locks
1961 are detected). Other subvol gets GFID-2 from Client C because while
1962 it was waiting for entrylk() on both subvols, Client B was in the
1963 middle of creating mkdir() on only one subvol, and Client C does not
1964 "expect" this when it is between lock() and pre-op()/op() phase of the
1965 transaction.
1966 */
1967 if (local->cont.lookup.parent_entrylk && local->enoent_count)
1968 return _gf_true;
1969
1970 return _gf_false;
1971}
1972
1973
1974static void
1975afr_lookup_done (call_frame_t *frame, xlator_t *this)
1976{
1977 int unwind = 1;
1978 afr_private_t *priv = NULL((void*)0);
1979 afr_local_t *local = NULL((void*)0);
1980 int ret = -1;
1981 gf_boolean_t sh_launched = _gf_false;
1982 gf_boolean_t fail_conflict = _gf_false;
1983 int gfid_miss_count = 0;
1984 int enotconn_count = 0;
1985 int up_children_count = 0;
1986
1987 priv = this->private;
1988 local = frame->local;
1989
1990 if (afr_is_entry_possibly_under_creation (local, this)) {
1991 local->op_ret = -1;
1992 local->op_errno = ENOENT2;
1993 goto unwind;
1994 }
1995
1996 if (local->op_ret < 0)
1997 goto unwind;
1998
1999 if (local->cont.lookup.parent_entrylk && local->success_count > 1)
2000 afr_succeed_lookup_on_latest_iatt (local, this);
2001
2002 gfid_miss_count = afr_lookup_gfid_missing_count (local, this);
2003 up_children_count = afr_up_children_count (local->child_up,
2004 priv->child_count);
2005 enotconn_count = priv->child_count - up_children_count;
2006 if ((gfid_miss_count == local->success_count) &&
2007 (enotconn_count > 0)) {
2008 local->op_ret = -1;
2009 local->op_errno = EIO5;
2010 gf_log (this->name, GF_LOG_ERROR, "Failing lookup for %s, "do { do { if (0) printf ("Failing lookup for %s, " "LOOKUP on a file without gfid is not allowed when "
"some of the children are down", local->loc.path); } while
(0); _gf_log (this->name, "./afr-common.c", __FUNCTION__,
2012, GF_LOG_ERROR, "Failing lookup for %s, " "LOOKUP on a file without gfid is not allowed when "
"some of the children are down", local->loc.path); } while
(0)
2011 "LOOKUP on a file without gfid is not allowed when "do { do { if (0) printf ("Failing lookup for %s, " "LOOKUP on a file without gfid is not allowed when "
"some of the children are down", local->loc.path); } while
(0); _gf_log (this->name, "./afr-common.c", __FUNCTION__,
2012, GF_LOG_ERROR, "Failing lookup for %s, " "LOOKUP on a file without gfid is not allowed when "
"some of the children are down", local->loc.path); } while
(0)
2012 "some of the children are down", local->loc.path)do { do { if (0) printf ("Failing lookup for %s, " "LOOKUP on a file without gfid is not allowed when "
"some of the children are down", local->loc.path); } while
(0); _gf_log (this->name, "./afr-common.c", __FUNCTION__,
2012, GF_LOG_ERROR, "Failing lookup for %s, " "LOOKUP on a file without gfid is not allowed when "
"some of the children are down", local->loc.path); } while
(0)
;
2013 goto unwind;
2014 }
2015
2016 if ((gfid_miss_count == local->success_count) &&
2017 uuid_is_null (local->cont.lookup.gfid_req)) {
2018 local->op_ret = -1;
2019 local->op_errno = ENODATA61;
2020 gf_log (this->name, GF_LOG_ERROR, "%s: No gfid present",do { do { if (0) printf ("%s: No gfid present", local->loc
.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 2021, GF_LOG_ERROR, "%s: No gfid present", local
->loc.path); } while (0)
2021 local->loc.path)do { do { if (0) printf ("%s: No gfid present", local->loc
.path); } while (0); _gf_log (this->name, "./afr-common.c"
, __FUNCTION__, 2021, GF_LOG_ERROR, "%s: No gfid present", local
->loc.path); } while (0)
;
2022 goto unwind;
2023 }
2024
2025 if (gfid_miss_count && uuid_is_null (local->cont.lookup.gfid_req))
2026 fail_conflict = _gf_true;
2027 ret = afr_lookup_done_success_action (frame, this, fail_conflict);
2028 if (ret)
2029 goto unwind;
2030 uuid_copy (local->self_heal.sh_gfid_req, local->cont.lookup.gfid_req);
2031
2032 afr_lookup_perform_self_heal (frame, this, &sh_launched);
2033 if (sh_launched) {
2034 unwind = 0;
2035 goto unwind;
2036 }
2037
2038 unwind:
2039 if (unwind) {
2040 AFR_STACK_UNWIND (lookup, frame, local->op_ret,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2044, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.lookup.inode,
&local->cont.lookup.buf, local->cont.lookup.xattr,
&local->cont.lookup.postparent); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
2041 local->op_errno, local->cont.lookup.inode,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2044, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.lookup.inode,
&local->cont.lookup.buf, local->cont.lookup.xattr,
&local->cont.lookup.postparent); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
2042 &local->cont.lookup.buf,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2044, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.lookup.inode,
&local->cont.lookup.buf, local->cont.lookup.xattr,
&local->cont.lookup.postparent); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
2043 local->cont.lookup.xattr,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2044, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.lookup.inode,
&local->cont.lookup.buf, local->cont.lookup.xattr,
&local->cont.lookup.postparent); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
2044 &local->cont.lookup.postparent)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2044, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.lookup.inode,
&local->cont.lookup.buf, local->cont.lookup.xattr,
&local->cont.lookup.postparent); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
2045 }
2046}
2047
2048/*
2049 * During a lookup, some errors are more "important" than
2050 * others in that they must be given higher priority while
2051 * returning to the user.
2052 *
2053 * The hierarchy is ESTALE > EIO > ENOENT > others
2054 */
2055int32_t
2056afr_most_important_error(int32_t old_errno, int32_t new_errno,
2057 gf_boolean_t eio)
2058{
2059 if (old_errno == ESTALE116 || new_errno == ESTALE116)
2060 return ESTALE116;
2061 if (eio && (old_errno == EIO5 || new_errno == EIO5))
2062 return EIO5;
2063 if (old_errno == ENOENT2 || new_errno == ENOENT2)
2064 return ENOENT2;
2065
2066 return new_errno;
2067}
2068
2069int32_t
2070afr_resultant_errno_get (int32_t *children,
2071 int *child_errno, unsigned int child_count)
2072{
2073 int i = 0;
2074 int32_t op_errno = 0;
2075 int child = 0;
2076
2077 for (i = 0; i < child_count; i++) {
2078 if (children) {
2079 child = children[i];
2080 if (child == -1)
2081 break;
2082 } else {
2083 child = i;
2084 }
2085 op_errno = afr_most_important_error(op_errno,
2086 child_errno[child],
2087 _gf_false);
2088 }
2089 return op_errno;
2090}
2091
2092static void
2093afr_lookup_handle_error (afr_local_t *local, int32_t op_ret, int32_t op_errno)
2094{
2095 GF_ASSERT (local)do { if (!(local)) { do { do { if (0) printf ("Assertion failed: "
"local"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 2095, GF_LOG_ERROR, "Assertion failed: " "local"
); } while (0); } } while (0)
;
2096 if (op_errno == ENOENT2)
2097 local->enoent_count++;
2098
2099 local->op_errno = afr_most_important_error(local->op_errno, op_errno,
2100 _gf_false);
2101
2102 if (local->op_errno == ESTALE116) {
2103 local->op_ret = -1;
2104 }
2105}
2106
2107static void
2108afr_set_root_inode_on_first_lookup (afr_local_t *local, xlator_t *this,
2109 inode_t *inode)
2110{
2111 afr_private_t *priv = NULL((void*)0);
2112 GF_ASSERT (inode)do { if (!(inode)) { do { do { if (0) printf ("Assertion failed: "
"inode"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 2112, GF_LOG_ERROR, "Assertion failed: " "inode"
); } while (0); } } while (0)
;
2113
2114 if (!__is_root_gfid (inode->gfid))
2115 goto out;
2116 if (!afr_is_fresh_lookup (&local->loc, this))
2117 goto out;
2118 priv = this->private;
2119 if ((priv->first_lookup)) {
2120 gf_log (this->name, GF_LOG_INFO, "added root inode")do { do { if (0) printf ("added root inode"); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 2120, GF_LOG_INFO
, "added root inode"); } while (0)
;
2121 priv->root_inode = inode_ref (inode);
2122 priv->first_lookup = 0;
2123 }
2124out:
2125 return;
2126}
2127
2128static void
2129afr_lookup_cache_args (afr_local_t *local, int child_index, dict_t *xattr,
2130 struct iatt *buf, struct iatt *postparent)
2131{
2132 GF_ASSERT (child_index >= 0)do { if (!(child_index >= 0)) { do { do { if (0) printf ("Assertion failed: "
"child_index >= 0"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 2132, GF_LOG_ERROR, "Assertion failed: " "child_index >= 0"
); } while (0); } } while (0)
;
2133 local->cont.lookup.xattrs[child_index] = dict_ref (xattr);
2134 local->cont.lookup.postparents[child_index] = *postparent;
2135 local->cont.lookup.bufs[child_index] = *buf;
2136}
2137
2138static void
2139afr_lookup_handle_first_success (afr_local_t *local, xlator_t *this,
2140 inode_t *inode, struct iatt *buf)
2141{
2142 local->cont.lookup.inode = inode_ref (inode);
2143 local->cont.lookup.buf = *buf;
2144 afr_set_root_inode_on_first_lookup (local, this, inode);
2145}
2146
2147static int32_t
2148afr_discovery_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2149 int32_t op_ret, int32_t op_errno, dict_t *dict,
2150 dict_t *xdata)
2151{
2152 int ret = 0;
2153 char *pathinfo = NULL((void*)0);
2154 gf_boolean_t is_local = _gf_false;
2155 afr_private_t *priv = NULL((void*)0);
2156 int32_t child_index = -1;
2157
2158 if (op_ret != 0) {
2159 goto out;
2160 }
2161
2162 ret = dict_get_str (dict, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo", &pathinfo);
2163 if (ret != 0) {
2164 goto out;
2165 }
2166
2167 ret = afr_local_pathinfo (pathinfo, &is_local);
2168 if (ret) {
2169 goto out;
2170 }
2171
2172 priv = this->private;
2173 /*
2174 * Note that one local subvolume will override another here. The only
2175 * way to avoid that would be to retain extra information about whether
2176 * the previous read_child is local, and it's just not worth it. Even
2177 * the slowest local subvolume is far preferable to a remote one.
2178 */
2179 if (is_local) {
2180 child_index = (int32_t)(long)cookie;
2181 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("selecting local read_child %s", priv
->children[child_index]->name); } while (0); _gf_log (this
->name, "./afr-common.c", __FUNCTION__, 2183, GF_LOG_INFO,
"selecting local read_child %s", priv->children[child_index
]->name); } while (0)
2182 "selecting local read_child %s",do { do { if (0) printf ("selecting local read_child %s", priv
->children[child_index]->name); } while (0); _gf_log (this
->name, "./afr-common.c", __FUNCTION__, 2183, GF_LOG_INFO,
"selecting local read_child %s", priv->children[child_index
]->name); } while (0)
2183 priv->children[child_index]->name)do { do { if (0) printf ("selecting local read_child %s", priv
->children[child_index]->name); } while (0); _gf_log (this
->name, "./afr-common.c", __FUNCTION__, 2183, GF_LOG_INFO,
"selecting local read_child %s", priv->children[child_index
]->name); } while (0)
;
2184 priv->read_child = child_index;
2185 }
2186
2187out:
2188 STACK_DESTROY(frame->root);
2189 return 0;
2190}
2191
2192static void
2193afr_attempt_local_discovery (xlator_t *this, int32_t child_index)
2194{
2195 call_frame_t *newframe = NULL((void*)0);
2196 loc_t tmploc = {0,};
2197 afr_private_t *priv = this->private;
2198
2199 newframe = create_frame(this,this->ctx->pool);
2200 if (!newframe) {
2201 return;
2202 }
2203
2204 tmploc.gfid[sizeof(tmploc.gfid)-1] = 1;
2205 STACK_WIND_COOKIE (newframe, afr_discovery_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (newframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "./afr-common.c", __FUNCTION__, 2209,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[child_index]->fops->getxattr_cbk) tmp_cbk
= afr_discovery_cbk; _new->root = newframe->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = newframe; _new->cookie = (void
*)(long)child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->getxattr"
; _new->unwind_to = "afr_discovery_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&newframe->
root->stack_lock); { newframe->ref_count++; _new->next
= newframe->root->frames.next; _new->prev = &newframe
->root->frames; if (newframe->root->frames.next) newframe
->root->frames.next->prev = _new; newframe->root->
frames.next = _new; } pthread_spin_unlock (&newframe->
root->stack_lock); priv->children[child_index]->fops
->getxattr_cbk = afr_discovery_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->getxattr); priv->children[child_index]->fops->
getxattr (_new, priv->children[child_index], &tmploc, "trusted.glusterfs.pathinfo"
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
2206 (void *)(long)child_index,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (newframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "./afr-common.c", __FUNCTION__, 2209,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[child_index]->fops->getxattr_cbk) tmp_cbk
= afr_discovery_cbk; _new->root = newframe->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = newframe; _new->cookie = (void
*)(long)child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->getxattr"
; _new->unwind_to = "afr_discovery_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&newframe->
root->stack_lock); { newframe->ref_count++; _new->next
= newframe->root->frames.next; _new->prev = &newframe
->root->frames; if (newframe->root->frames.next) newframe
->root->frames.next->prev = _new; newframe->root->
frames.next = _new; } pthread_spin_unlock (&newframe->
root->stack_lock); priv->children[child_index]->fops
->getxattr_cbk = afr_discovery_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->getxattr); priv->children[child_index]->fops->
getxattr (_new, priv->children[child_index], &tmploc, "trusted.glusterfs.pathinfo"
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
2207 priv->children[child_index],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (newframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "./afr-common.c", __FUNCTION__, 2209,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[child_index]->fops->getxattr_cbk) tmp_cbk
= afr_discovery_cbk; _new->root = newframe->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = newframe; _new->cookie = (void
*)(long)child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->getxattr"
; _new->unwind_to = "afr_discovery_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&newframe->
root->stack_lock); { newframe->ref_count++; _new->next
= newframe->root->frames.next; _new->prev = &newframe
->root->frames; if (newframe->root->frames.next) newframe
->root->frames.next->prev = _new; newframe->root->
frames.next = _new; } pthread_spin_unlock (&newframe->
root->stack_lock); priv->children[child_index]->fops
->getxattr_cbk = afr_discovery_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->getxattr); priv->children[child_index]->fops->
getxattr (_new, priv->children[child_index], &tmploc, "trusted.glusterfs.pathinfo"
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
2208 priv->children[child_index]->fops->getxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (newframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "./afr-common.c", __FUNCTION__, 2209,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[child_index]->fops->getxattr_cbk) tmp_cbk
= afr_discovery_cbk; _new->root = newframe->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = newframe; _new->cookie = (void
*)(long)child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->getxattr"
; _new->unwind_to = "afr_discovery_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&newframe->
root->stack_lock); { newframe->ref_count++; _new->next
= newframe->root->frames.next; _new->prev = &newframe
->root->frames; if (newframe->root->frames.next) newframe
->root->frames.next->prev = _new; newframe->root->
frames.next = _new; } pthread_spin_unlock (&newframe->
root->stack_lock); priv->children[child_index]->fops
->getxattr_cbk = afr_discovery_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->getxattr); priv->children[child_index]->fops->
getxattr (_new, priv->children[child_index], &tmploc, "trusted.glusterfs.pathinfo"
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
2209 &tmploc, GF_XATTR_PATHINFO_KEY, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (newframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "./afr-common.c", __FUNCTION__, 2209,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[child_index]->fops->getxattr_cbk) tmp_cbk
= afr_discovery_cbk; _new->root = newframe->root; _new
->this = priv->children[child_index]; _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = newframe; _new->cookie = (void
*)(long)child_index; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[child_index]->fops->getxattr"
; _new->unwind_to = "afr_discovery_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&newframe->
root->stack_lock); { newframe->ref_count++; _new->next
= newframe->root->frames.next; _new->prev = &newframe
->root->frames; if (newframe->root->frames.next) newframe
->root->frames.next->prev = _new; newframe->root->
frames.next = _new; } pthread_spin_unlock (&newframe->
root->stack_lock); priv->children[child_index]->fops
->getxattr_cbk = afr_discovery_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->getxattr); priv->children[child_index]->fops->
getxattr (_new, priv->children[child_index], &tmploc, "trusted.glusterfs.pathinfo"
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
;
2210}
2211
2212static void
2213afr_lookup_handle_success (afr_local_t *local, xlator_t *this, int32_t child_index,
2214 int32_t op_ret, int32_t op_errno, inode_t *inode,
2215 struct iatt *buf, dict_t *xattr,
2216 struct iatt *postparent)
2217{
2218 afr_private_t *priv = this->private;
2219
2220 if (local->success_count == 0) {
2221 if (local->op_errno != ESTALE116) {
2222 local->op_ret = op_ret;
2223 local->op_errno = 0;
2224 }
2225 afr_lookup_handle_first_success (local, this, inode, buf);
2226 }
2227 afr_lookup_update_lk_counts (local, this,
2228 child_index, xattr);
2229
2230 afr_lookup_cache_args (local, child_index, xattr,
2231 buf, postparent);
2232
2233 if (local->do_discovery && (priv->read_child == (-1))) {
2234 afr_attempt_local_discovery(this,child_index);
2235 }
2236
2237 local->cont.lookup.success_children[local->success_count] = child_index;
2238 local->success_count++;
2239}
2240
2241int
2242afr_lookup_cbk (call_frame_t *frame, void *cookie,
2243 xlator_t *this, int32_t op_ret, int32_t op_errno,
2244 inode_t *inode, struct iatt *buf, dict_t *xattr,
2245 struct iatt *postparent)
2246{
2247 afr_local_t * local = NULL((void*)0);
2248 int call_count = -1;
2249 int child_index = -1;
2250
2251 child_index = (long) cookie;
2252
2253 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2254 {
2255 local = frame->local;
2256
2257 if (op_ret == -1) {
2258 afr_lookup_handle_error (local, op_ret, op_errno);
2259 goto unlock;
2260 }
2261 afr_lookup_handle_success (local, this, child_index, op_ret,
2262 op_errno, inode, buf, xattr,
2263 postparent);
2264
2265 }
2266unlock:
2267 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2268
2269 call_count = afr_frame_return (frame);
2270 if (call_count == 0) {
2271 afr_lookup_done (frame, this);
2272 }
2273
2274 return 0;
2275}
2276
2277int
2278afr_lookup_cont_init (afr_local_t *local, unsigned int child_count)
2279{
2280 int ret = -ENOMEM12;
2281 struct iatt *iatts = NULL((void*)0);
2282 int32_t *success_children = NULL((void*)0);
2283 int32_t *sources = NULL((void*)0);
2284 int32_t **pending_matrix = NULL((void*)0);
2285
2286 GF_ASSERT (local)do { if (!(local)) { do { do { if (0) printf ("Assertion failed: "
"local"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 2286, GF_LOG_ERROR, "Assertion failed: " "local"
); } while (0); } } while (0)
;
2287 local->cont.lookup.xattrs = GF_CALLOC (child_count,__gf_calloc (child_count, sizeof (*local->cont.lookup.xattr
), gf_afr_mt_dict_t)
2288 sizeof (*local->cont.lookup.xattr),__gf_calloc (child_count, sizeof (*local->cont.lookup.xattr
), gf_afr_mt_dict_t)
2289 gf_afr_mt_dict_t)__gf_calloc (child_count, sizeof (*local->cont.lookup.xattr
), gf_afr_mt_dict_t)
;
2290 if (NULL((void*)0) == local->cont.lookup.xattrs)
2291 goto out;
2292
2293 iatts = GF_CALLOC (child_count, sizeof (*iatts), gf_afr_mt_iatt)__gf_calloc (child_count, sizeof (*iatts), gf_afr_mt_iatt);
2294 if (NULL((void*)0) == iatts)
2295 goto out;
2296 local->cont.lookup.postparents = iatts;
2297
2298 iatts = GF_CALLOC (child_count, sizeof (*iatts), gf_afr_mt_iatt)__gf_calloc (child_count, sizeof (*iatts), gf_afr_mt_iatt);
2299 if (NULL((void*)0) == iatts)
2300 goto out;
2301 local->cont.lookup.bufs = iatts;
2302
2303 success_children = afr_children_create (child_count);
2304 if (NULL((void*)0) == success_children)
2305 goto out;
2306 local->cont.lookup.success_children = success_children;
2307
2308 local->fresh_children = afr_children_create (child_count);
2309 if (NULL((void*)0) == local->fresh_children)
2310 goto out;
2311
2312 sources = GF_CALLOC (sizeof (*sources), child_count, gf_afr_mt_int32_t)__gf_calloc (sizeof (*sources), child_count, gf_afr_mt_int32_t
)
;
2313 if (NULL((void*)0) == sources)
2314 goto out;
2315 local->cont.lookup.sources = sources;
2316
2317 pending_matrix = afr_matrix_create (child_count, child_count);
2318 if (NULL((void*)0) == pending_matrix)
2319 goto out;
2320 local->cont.lookup.pending_matrix = pending_matrix;
2321
2322 ret = 0;
2323out:
2324 return ret;
2325}
2326
2327int
2328afr_lookup (call_frame_t *frame, xlator_t *this,
2329 loc_t *loc, dict_t *xattr_req)
2330{
2331 afr_private_t *priv = NULL((void*)0);
2332 afr_local_t *local = NULL((void*)0);
2333 void *gfid_req = NULL((void*)0);
2334 int ret = -1;
2335 int i = 0;
2336 int call_count = 0;
2337 uint64_t ctx = 0;
2338 int32_t op_errno = 0;
2339
2340 priv = this->private;
2341
2342 AFR_LOCAL_ALLOC_OR_GOTO (local, out)do { local = mem_get0 ((*__glusterfs_this_location())->local_pool
); if (!local) { do { do { if (0) printf ("out of memory :(")
; } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 2342, GF_LOG_ERROR, "out of memory :("); } while (0); op_errno
= 12; goto out; } } while (0);
;
2343
2344 local->op_ret = -1;
2345
2346 frame->local = local;
2347 local->fop = GF_FOP_LOOKUP;
2348
2349 loc_copy (&local->loc, loc);
2350 ret = loc_path (&local->loc, NULL((void*)0));
2351 if (ret < 0) {
2352 op_errno = EINVAL22;
2353 goto out;
2354 }
2355
2356 ret = inode_ctx_get (local->loc.inode, this, &ctx)inode_ctx_get2(local->loc.inode,this,&ctx,0);
2357 if (ret == 0) {
2358 /* lookup is a revalidate */
2359
2360 local->read_child_index = afr_inode_get_read_ctx (this,
2361 local->loc.inode,
2362 NULL((void*)0));
2363 } else {
2364 LOCK (&priv->read_child_lock)pthread_spin_lock (&priv->read_child_lock);
2365 {
2366 if (priv->hash_mode) {
2367 local->read_child_index = -1;
2368 }
2369 else {
2370 local->read_child_index =
2371 (++priv->read_child_rr) %
2372 (priv->child_count);
2373 }
2374 }
2375 UNLOCK (&priv->read_child_lock)pthread_spin_unlock (&priv->read_child_lock);
2376 local->cont.lookup.fresh_lookup = _gf_true;
2377 }
2378
2379 local->child_up = memdup (priv->child_up,
2380 sizeof (*local->child_up) * priv->child_count);
2381 if (NULL((void*)0) == local->child_up) {
2382 op_errno = ENOMEM12;
2383 goto out;
2384 }
2385
2386 ret = afr_lookup_cont_init (local, priv->child_count);
2387 if (ret < 0) {
2388 op_errno = -ret;
2389 goto out;
2390 }
2391
2392 local->call_count = afr_up_children_count (local->child_up,
2393 priv->child_count);
2394 call_count = local->call_count;
2395 if (local->call_count == 0) {
2396 ret = -1;
2397 op_errno = ENOTCONN107;
2398 goto out;
2399 }
2400
2401 /* By default assume ENOTCONN. On success it will be set to 0. */
2402 local->op_errno = ENOTCONN107;
2403
2404 ret = afr_lookup_xattr_req_prepare (local, this, xattr_req, &local->loc,
2405 &gfid_req);
2406 if (ret) {
2407 local->op_errno = -ret;
2408 goto out;
2409 }
2410 afr_lookup_save_gfid (local->cont.lookup.gfid_req, gfid_req,
2411 &local->loc);
2412 local->fop = GF_FOP_LOOKUP;
2413 if (priv->choose_local && !priv->did_discovery) {
2414 if (gfid_req && __is_root_gfid(gfid_req)) {
2415 local->do_discovery = _gf_true;
2416 priv->did_discovery = _gf_true;
2417 }
2418 }
2419 for (i = 0; i < priv->child_count; i++) {
2420 if (local->child_up[i]) {
2421 STACK_WIND_COOKIE (frame, afr_lookup_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-common.c", __FUNCTION__, 2425,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lookup_cbk) tmp_cbk = afr_lookup_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->lookup"
; _new->unwind_to = "afr_lookup_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->lookup_cbk = afr_lookup_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->lookup); priv->children[i]->fops->lookup
(_new, priv->children[i], &local->loc, local->xattr_req
); (*__glusterfs_this_location()) = old_THIS; } while (0)
2422 (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-common.c", __FUNCTION__, 2425,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lookup_cbk) tmp_cbk = afr_lookup_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->lookup"
; _new->unwind_to = "afr_lookup_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->lookup_cbk = afr_lookup_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->lookup); priv->children[i]->fops->lookup
(_new, priv->children[i], &local->loc, local->xattr_req
); (*__glusterfs_this_location()) = old_THIS; } while (0)
2423 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-common.c", __FUNCTION__, 2425,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lookup_cbk) tmp_cbk = afr_lookup_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->lookup"
; _new->unwind_to = "afr_lookup_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->lookup_cbk = afr_lookup_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->lookup); priv->children[i]->fops->lookup
(_new, priv->children[i], &local->loc, local->xattr_req
); (*__glusterfs_this_location()) = old_THIS; } while (0)
2424 priv->children[i]->fops->lookup,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-common.c", __FUNCTION__, 2425,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lookup_cbk) tmp_cbk = afr_lookup_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->lookup"
; _new->unwind_to = "afr_lookup_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->lookup_cbk = afr_lookup_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->lookup); priv->children[i]->fops->lookup
(_new, priv->children[i], &local->loc, local->xattr_req
); (*__glusterfs_this_location()) = old_THIS; } while (0)
2425 &local->loc, local->xattr_req)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-common.c", __FUNCTION__, 2425,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lookup_cbk) tmp_cbk = afr_lookup_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->lookup"
; _new->unwind_to = "afr_lookup_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->lookup_cbk = afr_lookup_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->lookup); priv->children[i]->fops->lookup
(_new, priv->children[i], &local->loc, local->xattr_req
); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
2426 if (!--call_count)
2427 break;
2428 }
2429 }
2430
2431 ret = 0;
2432out:
2433 if (ret)
2434 AFR_STACK_UNWIND (lookup, frame, -1, op_errno,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2435, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0), ((void*)0), ((void*)0), ((void*)0)); (
*__glusterfs_this_location()) = old_THIS; } while (0); if (__local
) { afr_local_cleanup (__local, __this); mem_put (__local); }
} while (0)
2435 NULL, NULL, NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lookup_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2435, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0), ((void*)0), ((void*)0), ((void*)0)); (
*__glusterfs_this_location()) = old_THIS; } while (0); if (__local
) { afr_local_cleanup (__local, __this); mem_put (__local); }
} while (0)
;
2436
2437 return 0;
2438}
2439
2440
2441/* {{{ open */
2442
2443int
2444__afr_fd_ctx_set (xlator_t *this, fd_t *fd)
2445{
2446 afr_private_t * priv = NULL((void*)0);
2447 int ret = -1;
2448 uint64_t ctx = 0;
2449 afr_fd_ctx_t * fd_ctx = NULL((void*)0);
2450
2451 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 2451, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
2452 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 2452, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
2453
2454 priv = this->private;
2455
2456 ret = __fd_ctx_get (fd, this, &ctx);
2457
2458 if (ret == 0)
2459 goto out;
2460
2461 fd_ctx = GF_CALLOC (1, sizeof (afr_fd_ctx_t),__gf_calloc (1, sizeof (afr_fd_ctx_t), gf_afr_mt_afr_fd_ctx_t
)
2462 gf_afr_mt_afr_fd_ctx_t)__gf_calloc (1, sizeof (afr_fd_ctx_t), gf_afr_mt_afr_fd_ctx_t
)
;
2463 if (!fd_ctx) {
2464 ret = -ENOMEM12;
2465 goto out;
2466 }
2467
2468 fd_ctx->pre_op_done = GF_CALLOC (sizeof (*fd_ctx->pre_op_done),__gf_calloc (sizeof (*fd_ctx->pre_op_done), priv->child_count
, gf_afr_mt_char)
2469 priv->child_count,__gf_calloc (sizeof (*fd_ctx->pre_op_done), priv->child_count
, gf_afr_mt_char)
2470 gf_afr_mt_char)__gf_calloc (sizeof (*fd_ctx->pre_op_done), priv->child_count
, gf_afr_mt_char)
;
2471 if (!fd_ctx->pre_op_done) {
2472 ret = -ENOMEM12;
2473 goto out;
2474 }
2475
2476 fd_ctx->pre_op_piggyback = GF_CALLOC (sizeof (*fd_ctx->pre_op_piggyback),__gf_calloc (sizeof (*fd_ctx->pre_op_piggyback), priv->
child_count, gf_afr_mt_char)
2477 priv->child_count,__gf_calloc (sizeof (*fd_ctx->pre_op_piggyback), priv->
child_count, gf_afr_mt_char)
2478 gf_afr_mt_char)__gf_calloc (sizeof (*fd_ctx->pre_op_piggyback), priv->
child_count, gf_afr_mt_char)
;
2479 if (!fd_ctx->pre_op_piggyback) {
2480 ret = -ENOMEM12;
2481 goto out;
2482 }
2483
2484 fd_ctx->opened_on = GF_CALLOC (sizeof (*fd_ctx->opened_on),__gf_calloc (sizeof (*fd_ctx->opened_on), priv->child_count
, gf_afr_mt_int32_t)
2485 priv->child_count,__gf_calloc (sizeof (*fd_ctx->opened_on), priv->child_count
, gf_afr_mt_int32_t)
2486 gf_afr_mt_int32_t)__gf_calloc (sizeof (*fd_ctx->opened_on), priv->child_count
, gf_afr_mt_int32_t)
;
2487 if (!fd_ctx->opened_on) {
2488 ret = -ENOMEM12;
2489 goto out;
2490 }
2491
2492 fd_ctx->lock_piggyback = GF_CALLOC (sizeof (*fd_ctx->lock_piggyback),__gf_calloc (sizeof (*fd_ctx->lock_piggyback), priv->child_count
, gf_afr_mt_char)
2493 priv->child_count,__gf_calloc (sizeof (*fd_ctx->lock_piggyback), priv->child_count
, gf_afr_mt_char)
2494 gf_afr_mt_char)__gf_calloc (sizeof (*fd_ctx->lock_piggyback), priv->child_count
, gf_afr_mt_char)
;
2495 if (!fd_ctx->lock_piggyback) {
2496 ret = -ENOMEM12;
2497 goto out;
2498 }
2499
2500 fd_ctx->lock_acquired = GF_CALLOC (sizeof (*fd_ctx->lock_acquired),__gf_calloc (sizeof (*fd_ctx->lock_acquired), priv->child_count
, gf_afr_mt_char)
2501 priv->child_count,__gf_calloc (sizeof (*fd_ctx->lock_acquired), priv->child_count
, gf_afr_mt_char)
2502 gf_afr_mt_char)__gf_calloc (sizeof (*fd_ctx->lock_acquired), priv->child_count
, gf_afr_mt_char)
;
2503 if (!fd_ctx->lock_acquired) {
2504 ret = -ENOMEM12;
2505 goto out;
2506 }
2507
2508 fd_ctx->up_count = priv->up_count;
2509 fd_ctx->down_count = priv->down_count;
2510
2511 fd_ctx->locked_on = GF_CALLOC (sizeof (*fd_ctx->locked_on),__gf_calloc (sizeof (*fd_ctx->locked_on), priv->child_count
, gf_afr_mt_char)
2512 priv->child_count,__gf_calloc (sizeof (*fd_ctx->locked_on), priv->child_count
, gf_afr_mt_char)
2513 gf_afr_mt_char)__gf_calloc (sizeof (*fd_ctx->locked_on), priv->child_count
, gf_afr_mt_char)
;
2514 if (!fd_ctx->locked_on) {
2515 ret = -ENOMEM12;
2516 goto out;
2517 }
2518
2519 pthread_mutex_init (&fd_ctx->delay_lock, NULL((void*)0));
2520 INIT_LIST_HEAD (&fd_ctx->entries)do { (&fd_ctx->entries)->next = (&fd_ctx->entries
)->prev = &fd_ctx->entries; } while (0)
;
2521 fd_ctx->call_child = -1;
2522
2523 INIT_LIST_HEAD (&fd_ctx->eager_locked)do { (&fd_ctx->eager_locked)->next = (&fd_ctx->
eager_locked)->prev = &fd_ctx->eager_locked; } while
(0)
;
2524
2525 ret = __fd_ctx_set (fd, this, (uint64_t)(long) fd_ctx);
2526 if (ret)
2527 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set fd ctx (%p)", fd); } while
(0); _gf_log (this->name, "./afr-common.c", __FUNCTION__,
2528, GF_LOG_DEBUG, "failed to set fd ctx (%p)", fd); } while
(0)
2528 "failed to set fd ctx (%p)", fd)do { do { if (0) printf ("failed to set fd ctx (%p)", fd); } while
(0); _gf_log (this->name, "./afr-common.c", __FUNCTION__,
2528, GF_LOG_DEBUG, "failed to set fd ctx (%p)", fd); } while
(0)
;
2529out:
2530 return ret;
2531}
2532
2533
2534int
2535afr_fd_ctx_set (xlator_t *this, fd_t *fd)
2536{
2537 int ret = -1;
2538
2539 LOCK (&fd->lock)pthread_spin_lock (&fd->lock);
2540 {
2541 ret = __afr_fd_ctx_set (this, fd);
2542 }
2543 UNLOCK (&fd->lock)pthread_spin_unlock (&fd->lock);
2544
2545 return ret;
2546}
2547
2548/* {{{ flush */
2549
2550int
2551afr_flush_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
2552 int32_t op_ret, int32_t op_errno, dict_t *xdata)
2553{
2554 afr_local_t * local = NULL((void*)0);
2555 int call_count = -1;
2556
2557 local = frame->local;
2558
2559 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2560 {
2561 if (op_ret != -1) {
2562 if (local->success_count == 0) {
2563 local->op_ret = op_ret;
2564 }
2565 local->success_count++;
2566 }
2567
2568 local->op_errno = op_errno;
2569 }
2570 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2571
2572 call_count = afr_frame_return (frame);
2573
2574 if (call_count == 0)
2575 AFR_STACK_UNWIND(flush, frame, local->op_ret,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_flush_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2576, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_flush_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
2576 local->op_errno, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_flush_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2576, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_flush_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
2577
2578 return 0;
2579}
2580
2581int
2582afr_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
2583{
2584 afr_private_t *priv = NULL((void*)0);
2585 afr_local_t *local = NULL((void*)0);
2586 int ret = -1;
2587 int op_errno = 0;
2588 int call_count = -1;
2589 int i = 0;
2590
2591 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 2591, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2592 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 2592, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2593 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 2593, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
2594
2595 priv = this->private;
2596
2597 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-common.c"
, __FUNCTION__, 2597, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
2598 local = frame->local;
2599
2600 ret = afr_local_init(local, priv, &op_errno);
2601 if (ret < 0)
2602 goto out;
2603
2604 local->fd = fd_ref(fd);
2605 call_count = local->call_count;
2606
2607 afr_delayed_changelog_wake_up (this, fd);
2608
2609 for (i = 0; i < priv->child_count; i++) {
2610 if (local->child_up[i]) {
2611 STACK_WIND_COOKIE (frame, afr_flush_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-common.c", __FUNCTION__, 2615,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->flush_cbk) tmp_cbk = afr_flush_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->flush"
; _new->unwind_to = "afr_flush_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->flush_cbk = afr_flush_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->flush); priv->children[i]->fops->flush
(_new, priv->children[i], local->fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2612 (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-common.c", __FUNCTION__, 2615,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->flush_cbk) tmp_cbk = afr_flush_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->flush"
; _new->unwind_to = "afr_flush_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->flush_cbk = afr_flush_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->flush); priv->children[i]->fops->flush
(_new, priv->children[i], local->fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2613 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-common.c", __FUNCTION__, 2615,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->flush_cbk) tmp_cbk = afr_flush_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->flush"
; _new->unwind_to = "afr_flush_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->flush_cbk = afr_flush_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->flush); priv->children[i]->fops->flush
(_new, priv->children[i], local->fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2614 priv->children[i]->fops->flush,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-common.c", __FUNCTION__, 2615,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->flush_cbk) tmp_cbk = afr_flush_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->flush"
; _new->unwind_to = "afr_flush_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->flush_cbk = afr_flush_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->flush); priv->children[i]->fops->flush
(_new, priv->children[i], local->fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2615 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-common.c", __FUNCTION__, 2615,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->flush_cbk) tmp_cbk = afr_flush_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->flush"
; _new->unwind_to = "afr_flush_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->flush_cbk = afr_flush_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->flush); priv->children[i]->fops->flush
(_new, priv->children[i], local->fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2616
2617 if (!--call_count)
2618 break;
2619 }
2620 }
2621
2622 ret = 0;
2623
2624out:
2625 if (ret < 0)
2626 AFR_STACK_UNWIND(flush, frame, -1, op_errno, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_flush_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2626, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_flush_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { afr_local_cleanup (__local, __this
); mem_put (__local); } } while (0)
;
2627
2628 return 0;
2629}
2630
2631/* }}} */
2632
2633
2634int
2635afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd)
2636{
2637 uint64_t ctx = 0;
2638 afr_fd_ctx_t *fd_ctx = NULL((void*)0);
2639 int ret = 0;
2640
2641 ret = fd_ctx_get (fd, this, &ctx);
2642 if (ret < 0)
2643 goto out;
2644
2645 fd_ctx = (afr_fd_ctx_t *)(long) ctx;
2646
2647 if (fd_ctx) {
2648 GF_FREE (fd_ctx->pre_op_done)__gf_free (fd_ctx->pre_op_done);
2649
2650 GF_FREE (fd_ctx->opened_on)__gf_free (fd_ctx->opened_on);
2651
2652 GF_FREE (fd_ctx->locked_on)__gf_free (fd_ctx->locked_on);
2653
2654 GF_FREE (fd_ctx->pre_op_piggyback)__gf_free (fd_ctx->pre_op_piggyback);
2655 GF_FREE (fd_ctx->lock_piggyback)__gf_free (fd_ctx->lock_piggyback);
2656
2657 GF_FREE (fd_ctx->lock_acquired)__gf_free (fd_ctx->lock_acquired);
2658
2659 pthread_mutex_destroy (&fd_ctx->delay_lock);
2660
2661 GF_FREE (fd_ctx)__gf_free (fd_ctx);
2662 }
2663
2664out:
2665 return 0;
2666}
2667
2668
2669int
2670afr_release (xlator_t *this, fd_t *fd)
2671{
2672 afr_locked_fd_t *locked_fd = NULL((void*)0);
2673 afr_locked_fd_t *tmp = NULL((void*)0);
2674 afr_private_t *priv = NULL((void*)0);
2675
2676 priv = this->private;
2677
2678 afr_cleanup_fd_ctx (this, fd);
2679
2680 list_for_each_entry_safe (locked_fd, tmp, &priv->saved_fds,for (locked_fd = ((typeof(*locked_fd) *)((char *)((&priv->
saved_fds)->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 != (&priv->saved_fds
); locked_fd = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->
list.next)-(unsigned long)(&((typeof(*tmp) *)0)->list)
)))
2681 list)for (locked_fd = ((typeof(*locked_fd) *)((char *)((&priv->
saved_fds)->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 != (&priv->saved_fds
); locked_fd = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->
list.next)-(unsigned long)(&((typeof(*tmp) *)0)->list)
)))
{
2682
2683 if (locked_fd->fd == fd) {
2684 list_del_init (&locked_fd->list);
2685 GF_FREE (locked_fd)__gf_free (locked_fd);
2686 }
2687
2688 }
2689
2690 return 0;
2691}
2692
2693
2694/* {{{ fsync */
2695
2696int
2697afr_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2698 int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
2699 struct iatt *postbuf, dict_t *xdata)
2700{
2701 afr_local_t *local = NULL((void*)0);
2702 int call_count = -1;
2703 int child_index = (long) cookie;
2704 int read_child = 0;
2705 call_stub_t *stub = NULL((void*)0);
2706
2707 local = frame->local;
2708
2709 read_child = afr_inode_get_read_ctx (this, local->fd->inode, NULL((void*)0));
2710
2711 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2712 {
2713 if (child_index == read_child) {
2714 local->read_child_returned = _gf_true;
2715 }
2716
2717 if (op_ret == 0) {
2718 local->op_ret = 0;
2719
2720 if (local->success_count == 0) {
2721 local->cont.fsync.prebuf = *prebuf;
2722 local->cont.fsync.postbuf = *postbuf;
2723 }
2724
2725 if (child_index == read_child) {
2726 local->cont.fsync.prebuf = *prebuf;
2727 local->cont.fsync.postbuf = *postbuf;
2728 }
2729
2730 local->success_count++;
2731 }
2732
2733 local->op_errno = op_errno;
2734 }
2735 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2736
2737 call_count = afr_frame_return (frame);
2738
2739 if (call_count == 0) {
2740 /* Make a stub out of the frame, and register it
2741 with the waking up post-op. When the call-stub resumes,
2742 we are guaranteed that there was no post-op pending
2743 (i.e changelogs were unset in the server). This is an
2744 essential "guarantee", that fsync() returns only after
2745 completely finishing EVERYTHING, including the delayed
2746 post-op. This guarantee is expected by FUSE graph switching
2747 for example.
2748 */
2749 stub = fop_fsync_cbk_stub (frame, default_fsync_cbk,
2750 local->op_ret, local->op_errno,
2751 &local->cont.fsync.prebuf,
2752 &local->cont.fsync.postbuf, xdata);
2753 if (!stub) {
2754 AFR_STACK_UNWIND (fsync, frame, -1, ENOMEM, 0, 0, 0)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fsync_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2754, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fsync_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, 12, 0, 0, 0); (*__glusterfs_this_location()) = old_THIS; } while
(0); if (__local) { afr_local_cleanup (__local, __this); mem_put
(__local); } } while (0)
;
2755 return 0;
2756 }
2757
2758 /* If no new unstable writes happened between the
2759 time we cleared the unstable write witness flag in afr_fsync
2760 and now, calling afr_delayed_changelog_wake_up() should
2761 wake up and skip over the fsync phase and go straight to
2762 afr_changelog_post_op_now()
2763 */
2764 afr_delayed_changelog_wake_resume (this, local->fd, stub);
2765 }
2766
2767 return 0;
2768}
2769
2770
2771int
2772afr_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd,
2773 int32_t datasync, dict_t *xdata)
2774{
2775 afr_private_t *priv = NULL((void*)0);
2776 afr_local_t *local = NULL((void*)0);
2777 int ret = -1;
2778 int i = 0;
2779 int32_t call_count = 0;
2780 int32_t op_errno = 0;
2781
2782 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 2782, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2783 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 2783, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2784 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 2784, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
2785
2786 priv = this->private;
2787
2788 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-common.c"
, __FUNCTION__, 2788, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
2789 local = frame->local;
2790
2791 ret = afr_local_init (local, priv, &op_errno);
2792 if (ret < 0)
2793 goto out;
2794
2795 call_count = local->call_count;
2796
2797 local->fd = fd_ref (fd);
2798
2799 if (afr_fd_has_witnessed_unstable_write (this, fd)) {
2800 /* don't care. we only wanted to CLEAR the bit */
2801 }
2802
2803 for (i = 0; i < priv->child_count; i++) {
2804 if (local->child_up[i]) {
2805 STACK_WIND_COOKIE (frame, afr_fsync_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-common.c", __FUNCTION__, 2809,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fsync_cbk) tmp_cbk = afr_fsync_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->fsync"
; _new->unwind_to = "afr_fsync_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->fsync_cbk = afr_fsync_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->fsync); priv->children[i]->fops->fsync
(_new, priv->children[i], fd, datasync, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2806 (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-common.c", __FUNCTION__, 2809,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fsync_cbk) tmp_cbk = afr_fsync_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->fsync"
; _new->unwind_to = "afr_fsync_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->fsync_cbk = afr_fsync_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->fsync); priv->children[i]->fops->fsync
(_new, priv->children[i], fd, datasync, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2807 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-common.c", __FUNCTION__, 2809,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fsync_cbk) tmp_cbk = afr_fsync_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->fsync"
; _new->unwind_to = "afr_fsync_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->fsync_cbk = afr_fsync_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->fsync); priv->children[i]->fops->fsync
(_new, priv->children[i], fd, datasync, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2808 priv->children[i]->fops->fsync,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-common.c", __FUNCTION__, 2809,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fsync_cbk) tmp_cbk = afr_fsync_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->fsync"
; _new->unwind_to = "afr_fsync_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->fsync_cbk = afr_fsync_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->fsync); priv->children[i]->fops->fsync
(_new, priv->children[i], fd, datasync, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2809 fd, datasync, xdata)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-common.c", __FUNCTION__, 2809,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fsync_cbk) tmp_cbk = afr_fsync_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->fsync"
; _new->unwind_to = "afr_fsync_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->fsync_cbk = afr_fsync_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->fsync); priv->children[i]->fops->fsync
(_new, priv->children[i], fd, datasync, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2810 if (!--call_count)
2811 break;
2812 }
2813 }
2814
2815 ret = 0;
2816out:
2817 if (ret < 0)
2818 AFR_STACK_UNWIND (fsync, frame, -1, op_errno, NULL, NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fsync_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2818, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fsync_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
2819 return 0;
2820}
2821
2822/* }}} */
2823
2824/* {{{ fsync */
2825
2826int32_t
2827afr_fsyncdir_cbk (call_frame_t *frame, void *cookie,
2828 xlator_t *this, int32_t op_ret, int32_t op_errno,
2829 dict_t *xdata)
2830{
2831 afr_local_t *local = NULL((void*)0);
2832 int call_count = -1;
2833
2834 local = frame->local;
2835
2836 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2837 {
2838 if (op_ret == 0)
2839 local->op_ret = 0;
2840
2841 local->op_errno = op_errno;
2842 }
2843 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2844
2845 call_count = afr_frame_return (frame);
2846
2847 if (call_count == 0)
2848 AFR_STACK_UNWIND (fsyncdir, frame, local->op_ret,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fsyncdir_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2849, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fsyncdir_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
2849 local->op_errno, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fsyncdir_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2849, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fsyncdir_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
2850
2851 return 0;
2852}
2853
2854
2855int32_t
2856afr_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd,
2857 int32_t datasync, dict_t *xdata)
2858{
2859 afr_private_t *priv = NULL((void*)0);
2860 afr_local_t *local = NULL((void*)0);
2861 int ret = -1;
2862 int i = 0;
2863 int32_t call_count = 0;
2864 int32_t op_errno = 0;
2865
2866 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 2866, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2867 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 2867, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2868 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 2868, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
2869
2870 priv = this->private;
2871
2872 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-common.c"
, __FUNCTION__, 2872, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
2873 local = frame->local;
2874
2875 ret = afr_local_init (local, priv, &op_errno);
2876 if (ret < 0)
2877 goto out;
2878
2879 call_count = local->call_count;
2880
2881 for (i = 0; i < priv->child_count; i++) {
2882 if (local->child_up[i]) {
2883 STACK_WIND (frame, afr_fsyncdir_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-common.c", __FUNCTION__, 2886,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fsyncdir_cbk) tmp_cbk = afr_fsyncdir_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fsyncdir"; _new
->unwind_to = "afr_fsyncdir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fsyncdir
); priv->children[i]->fops->fsyncdir (_new, priv->
children[i], fd, datasync, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2884 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-common.c", __FUNCTION__, 2886,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fsyncdir_cbk) tmp_cbk = afr_fsyncdir_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fsyncdir"; _new
->unwind_to = "afr_fsyncdir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fsyncdir
); priv->children[i]->fops->fsyncdir (_new, priv->
children[i], fd, datasync, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2885 priv->children[i]->fops->fsyncdir,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-common.c", __FUNCTION__, 2886,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fsyncdir_cbk) tmp_cbk = afr_fsyncdir_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fsyncdir"; _new
->unwind_to = "afr_fsyncdir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fsyncdir
); priv->children[i]->fops->fsyncdir (_new, priv->
children[i], fd, datasync, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2886 fd, datasync, xdata)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-common.c", __FUNCTION__, 2886,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fsyncdir_cbk) tmp_cbk = afr_fsyncdir_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fsyncdir"; _new
->unwind_to = "afr_fsyncdir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fsyncdir
); priv->children[i]->fops->fsyncdir (_new, priv->
children[i], fd, datasync, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2887 if (!--call_count)
2888 break;
2889 }
2890 }
2891
2892 ret = 0;
2893out:
2894 if (ret < 0)
2895 AFR_STACK_UNWIND (fsyncdir, frame, -1, op_errno, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fsyncdir_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2895, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fsyncdir_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { afr_local_cleanup (__local, __this
); mem_put (__local); } } while (0)
;
2896 return 0;
2897}
2898
2899/* }}} */
2900
2901/* {{{ xattrop */
2902
2903int32_t
2904afr_xattrop_cbk (call_frame_t *frame, void *cookie,
2905 xlator_t *this, int32_t op_ret, int32_t op_errno,
2906 dict_t *xattr, dict_t *xdata)
2907{
2908 afr_local_t *local = NULL((void*)0);
2909 int call_count = -1;
2910
2911 local = frame->local;
2912
2913 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2914 {
2915 if (op_ret == 0) {
2916 if (!local->cont.xattrop.xattr)
2917 local->cont.xattrop.xattr = dict_ref (xattr);
2918 local->op_ret = 0;
2919 }
2920
2921 local->op_errno = op_errno;
2922 }
2923 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2924
2925 call_count = afr_frame_return (frame);
2926
2927 if (call_count == 0)
2928 AFR_STACK_UNWIND (xattrop, frame, local->op_ret, local->op_errno,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_xattrop_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2929, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_xattrop_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.xattrop.xattr
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0); if (__local) { afr_local_cleanup (__local, __this); mem_put
(__local); } } while (0)
2929 local->cont.xattrop.xattr, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_xattrop_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2929, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_xattrop_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.xattrop.xattr
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0); if (__local) { afr_local_cleanup (__local, __this); mem_put
(__local); } } while (0)
;
2930
2931 return 0;
2932}
2933
2934
2935int32_t
2936afr_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc,
2937 gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
2938{
2939 afr_private_t *priv = NULL((void*)0);
2940 afr_local_t *local = NULL((void*)0);
2941 int ret = -1;
2942 int i = 0;
2943 int32_t call_count = 0;
2944 int32_t op_errno = 0;
2945
2946 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 2946, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2947 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 2947, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2948 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 2948, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
2949
2950 priv = this->private;
2951
2952 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-common.c"
, __FUNCTION__, 2952, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
2953 local = frame->local;
2954
2955 ret = afr_local_init (local, priv, &op_errno);
2956 if (ret < 0)
2957 goto out;
2958
2959 call_count = local->call_count;
2960
2961 for (i = 0; i < priv->child_count; i++) {
2962 if (local->child_up[i]) {
2963 STACK_WIND (frame, afr_xattrop_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-common.c", __FUNCTION__, 2966,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->xattrop_cbk) tmp_cbk = afr_xattrop_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->xattrop"; _new
->unwind_to = "afr_xattrop_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->xattrop); priv->
children[i]->fops->xattrop (_new, priv->children[i],
loc, optype, xattr, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
2964 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-common.c", __FUNCTION__, 2966,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->xattrop_cbk) tmp_cbk = afr_xattrop_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->xattrop"; _new
->unwind_to = "afr_xattrop_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->xattrop); priv->
children[i]->fops->xattrop (_new, priv->children[i],
loc, optype, xattr, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
2965 priv->children[i]->fops->xattrop,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-common.c", __FUNCTION__, 2966,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->xattrop_cbk) tmp_cbk = afr_xattrop_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->xattrop"; _new
->unwind_to = "afr_xattrop_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->xattrop); priv->
children[i]->fops->xattrop (_new, priv->children[i],
loc, optype, xattr, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
2966 loc, optype, xattr, xdata)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-common.c", __FUNCTION__, 2966,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->xattrop_cbk) tmp_cbk = afr_xattrop_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->xattrop"; _new
->unwind_to = "afr_xattrop_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->xattrop); priv->
children[i]->fops->xattrop (_new, priv->children[i],
loc, optype, xattr, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
;
2967 if (!--call_count)
2968 break;
2969 }
2970 }
2971
2972 ret = 0;
2973out:
2974 if (ret < 0)
2975 AFR_STACK_UNWIND (xattrop, frame, -1, op_errno, NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_xattrop_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 2975, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_xattrop_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
2976 return 0;
2977}
2978
2979/* }}} */
2980
2981/* {{{ fxattrop */
2982
2983int32_t
2984afr_fxattrop_cbk (call_frame_t *frame, void *cookie,
2985 xlator_t *this, int32_t op_ret, int32_t op_errno,
2986 dict_t *xattr, dict_t *xdata)
2987{
2988 afr_local_t *local = NULL((void*)0);
2989
2990 int call_count = -1;
2991
2992 local = frame->local;
2993
2994 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2995 {
2996 if (op_ret == 0) {
2997 if (!local->cont.fxattrop.xattr)
2998 local->cont.fxattrop.xattr = dict_ref (xattr);
2999
3000 local->op_ret = 0;
3001 }
3002
3003 local->op_errno = op_errno;
3004 }
3005 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
3006
3007 call_count = afr_frame_return (frame);
3008
3009 if (call_count == 0)
3010 AFR_STACK_UNWIND (fxattrop, frame, local->op_ret, local->op_errno,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fxattrop_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3011, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fxattrop_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.fxattrop.xattr
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0); if (__local) { afr_local_cleanup (__local, __this); mem_put
(__local); } } while (0)
3011 local->cont.fxattrop.xattr, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fxattrop_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3011, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fxattrop_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, local->cont.fxattrop.xattr
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0); if (__local) { afr_local_cleanup (__local, __this); mem_put
(__local); } } while (0)
;
3012
3013 return 0;
3014}
3015
3016
3017int32_t
3018afr_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd,
3019 gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
3020{
3021 afr_private_t *priv = NULL((void*)0);
3022 afr_local_t *local = NULL((void*)0);
3023 int ret = -1;
3024 int i = 0;
3025 int32_t call_count = 0;
3026 int32_t op_errno = 0;
3027
3028 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3028, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3029 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3029, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3030 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 3030, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
3031
3032 priv = this->private;
3033
3034 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-common.c"
, __FUNCTION__, 3034, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
3035 local = frame->local;
3036
3037 ret = afr_local_init (local, priv, &op_errno);
3038 if (ret < 0)
3039 goto out;
3040
3041 call_count = local->call_count;
3042
3043 for (i = 0; i < priv->child_count; i++) {
3044 if (local->child_up[i]) {
3045 STACK_WIND (frame, afr_fxattrop_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-common.c", __FUNCTION__, 3048,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fxattrop_cbk) tmp_cbk = afr_fxattrop_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fxattrop"; _new
->unwind_to = "afr_fxattrop_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fxattrop
); priv->children[i]->fops->fxattrop (_new, priv->
children[i], fd, optype, xattr, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3046 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-common.c", __FUNCTION__, 3048,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fxattrop_cbk) tmp_cbk = afr_fxattrop_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fxattrop"; _new
->unwind_to = "afr_fxattrop_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fxattrop
); priv->children[i]->fops->fxattrop (_new, priv->
children[i], fd, optype, xattr, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3047 priv->children[i]->fops->fxattrop,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-common.c", __FUNCTION__, 3048,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fxattrop_cbk) tmp_cbk = afr_fxattrop_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fxattrop"; _new
->unwind_to = "afr_fxattrop_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fxattrop
); priv->children[i]->fops->fxattrop (_new, priv->
children[i], fd, optype, xattr, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3048 fd, optype, xattr, xdata)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-common.c", __FUNCTION__, 3048,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fxattrop_cbk) tmp_cbk = afr_fxattrop_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fxattrop"; _new
->unwind_to = "afr_fxattrop_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fxattrop
); priv->children[i]->fops->fxattrop (_new, priv->
children[i], fd, optype, xattr, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
3049 if (!--call_count)
3050 break;
3051 }
3052 }
3053
3054 ret = 0;
3055out:
3056 if (ret < 0)
3057 AFR_STACK_UNWIND (fxattrop, frame, -1, op_errno, NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fxattrop_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3057, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fxattrop_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
3058 return 0;
3059}
3060
3061/* }}} */
3062
3063
3064int32_t
3065afr_inodelk_cbk (call_frame_t *frame, void *cookie,
3066 xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata)
3067
3068{
3069 afr_local_t *local = NULL((void*)0);
3070 int call_count = -1;
3071
3072 local = frame->local;
3073
3074 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
3075 {
3076 if (op_ret == 0)
3077 local->op_ret = 0;
3078
3079 local->op_errno = op_errno;
3080 }
3081 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
3082
3083 call_count = afr_frame_return (frame);
3084
3085 if (call_count == 0)
3086 AFR_STACK_UNWIND (inodelk, frame, local->op_ret,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_inodelk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3087, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_inodelk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
3087 local->op_errno, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_inodelk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3087, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_inodelk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
3088
3089 return 0;
3090}
3091
3092
3093int32_t
3094afr_inodelk (call_frame_t *frame, xlator_t *this,
3095 const char *volume, loc_t *loc, int32_t cmd,
3096 struct gf_flock *flock, dict_t *xdata)
3097{
3098 afr_private_t *priv = NULL((void*)0);
3099 afr_local_t *local = NULL((void*)0);
3100 int ret = -1;
3101 int i = 0;
3102 int32_t call_count = 0;
3103 int32_t op_errno = 0;
3104
3105 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3105, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3106 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3106, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3107 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 3107, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
3108
3109 priv = this->private;
3110
3111 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-common.c"
, __FUNCTION__, 3111, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
3112 local = frame->local;
3113
3114 ret = afr_local_init (local, priv, &op_errno);
3115 if (ret < 0)
3116 goto out;
3117
3118 call_count = local->call_count;
3119
3120 for (i = 0; i < priv->child_count; i++) {
3121 if (local->child_up[i]) {
3122 STACK_WIND (frame, afr_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-common.c", __FUNCTION__, 3125,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->inodelk"; _new
->unwind_to = "afr_inodelk_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->inodelk); priv->
children[i]->fops->inodelk (_new, priv->children[i],
volume, loc, cmd, flock, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3123 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-common.c", __FUNCTION__, 3125,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->inodelk"; _new
->unwind_to = "afr_inodelk_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->inodelk); priv->
children[i]->fops->inodelk (_new, priv->children[i],
volume, loc, cmd, flock, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3124 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-common.c", __FUNCTION__, 3125,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->inodelk"; _new
->unwind_to = "afr_inodelk_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->inodelk); priv->
children[i]->fops->inodelk (_new, priv->children[i],
volume, loc, cmd, flock, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3125 volume, loc, cmd, flock, xdata)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-common.c", __FUNCTION__, 3125,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->inodelk_cbk) tmp_cbk = afr_inodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->inodelk"; _new
->unwind_to = "afr_inodelk_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->inodelk); priv->
children[i]->fops->inodelk (_new, priv->children[i],
volume, loc, cmd, flock, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
3126
3127 if (!--call_count)
3128 break;
3129 }
3130 }
3131
3132 ret = 0;
3133out:
3134 if (ret < 0)
3135 AFR_STACK_UNWIND (inodelk, frame, -1, op_errno, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_inodelk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3135, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_inodelk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { afr_local_cleanup (__local, __this
); mem_put (__local); } } while (0)
;
3136 return 0;
3137}
3138
3139
3140int32_t
3141afr_finodelk_cbk (call_frame_t *frame, void *cookie,
3142 xlator_t *this, int32_t op_ret, int32_t op_errno,
3143 dict_t *xdata)
3144
3145{
3146 afr_local_t *local = NULL((void*)0);
3147 int call_count = -1;
3148
3149 local = frame->local;
3150
3151 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
3152 {
3153 if (op_ret == 0)
3154 local->op_ret = 0;
3155
3156 local->op_errno = op_errno;
3157 }
3158 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
3159
3160 call_count = afr_frame_return (frame);
3161
3162 if (call_count == 0)
3163 AFR_STACK_UNWIND (finodelk, frame, local->op_ret,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_finodelk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3164, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_finodelk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
3164 local->op_errno, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_finodelk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3164, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_finodelk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
3165
3166 return 0;
3167}
3168
3169
3170int32_t
3171afr_finodelk (call_frame_t *frame, xlator_t *this,
3172 const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *flock,
3173 dict_t *xdata)
3174{
3175 afr_private_t *priv = NULL((void*)0);
3176 afr_local_t *local = NULL((void*)0);
3177 int ret = -1;
3178 int i = 0;
3179 int32_t call_count = 0;
3180 int32_t op_errno = 0;
3181
3182 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3182, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3183 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3183, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3184 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 3184, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
3185
3186 priv = this->private;
3187
3188 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-common.c"
, __FUNCTION__, 3188, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
3189 local = frame->local;
3190
3191 ret = afr_local_init (local, priv, &op_errno);
3192 if (ret < 0)
3193 goto out;
3194
3195 call_count = local->call_count;
3196
3197 for (i = 0; i < priv->child_count; i++) {
3198 if (local->child_up[i]) {
3199 STACK_WIND (frame, afr_finodelk_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-common.c", __FUNCTION__, 3202,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_finodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->finodelk"; _new
->unwind_to = "afr_finodelk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->finodelk
); priv->children[i]->fops->finodelk (_new, priv->
children[i], volume, fd, cmd, flock, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3200 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-common.c", __FUNCTION__, 3202,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_finodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->finodelk"; _new
->unwind_to = "afr_finodelk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->finodelk
); priv->children[i]->fops->finodelk (_new, priv->
children[i], volume, fd, cmd, flock, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3201 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-common.c", __FUNCTION__, 3202,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_finodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->finodelk"; _new
->unwind_to = "afr_finodelk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->finodelk
); priv->children[i]->fops->finodelk (_new, priv->
children[i], volume, fd, cmd, flock, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3202 volume, fd, cmd, flock, xdata)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-common.c", __FUNCTION__, 3202,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->finodelk_cbk) tmp_cbk = afr_finodelk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->finodelk"; _new
->unwind_to = "afr_finodelk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->finodelk
); priv->children[i]->fops->finodelk (_new, priv->
children[i], volume, fd, cmd, flock, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
3203
3204 if (!--call_count)
3205 break;
3206 }
3207 }
3208
3209 ret = 0;
3210out:
3211 if (ret < 0)
3212 AFR_STACK_UNWIND (finodelk, frame, -1, op_errno, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_finodelk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3212, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_finodelk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { afr_local_cleanup (__local, __this
); mem_put (__local); } } while (0)
;
3213 return 0;
3214}
3215
3216
3217int32_t
3218afr_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
3219 int32_t op_ret, int32_t op_errno, dict_t *xdata)
3220{
3221 afr_local_t *local = NULL((void*)0);
3222 int call_count = -1;
3223
3224 local = frame->local;
3225
3226 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
3227 {
3228 if (op_ret == 0)
3229 local->op_ret = 0;
3230
3231 local->op_errno = op_errno;
3232 }
3233 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
3234
3235 call_count = afr_frame_return (frame);
3236
3237 if (call_count == 0)
3238 AFR_STACK_UNWIND (entrylk, frame, local->op_ret,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_entrylk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3239, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_entrylk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
3239 local->op_errno, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_entrylk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3239, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_entrylk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
3240
3241 return 0;
3242}
3243
3244
3245int32_t
3246afr_entrylk (call_frame_t *frame, xlator_t *this,
3247 const char *volume, loc_t *loc,
3248 const char *basename__xpg_basename, entrylk_cmd cmd, entrylk_type type,
3249 dict_t *xdata)
3250{
3251 afr_private_t *priv = NULL((void*)0);
3252 afr_local_t *local = NULL((void*)0);
3253 int ret = -1;
3254 int i = 0;
3255 int32_t call_count = 0;
3256 int32_t op_errno = 0;
3257
3258 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3258, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3259 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3259, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3260 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 3260, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
3261
3262 priv = this->private;
3263
3264 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-common.c"
, __FUNCTION__, 3264, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
3265 local = frame->local;
3266
3267 ret = afr_local_init (local, priv, &op_errno);
3268 if (ret < 0)
3269 goto out;
3270
3271 call_count = local->call_count;
3272
3273 for (i = 0; i < priv->child_count; i++) {
3274 if (local->child_up[i]) {
3275 STACK_WIND (frame, afr_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-common.c", __FUNCTION__, 3278,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->entrylk_cbk) tmp_cbk = afr_entrylk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->entrylk"; _new
->unwind_to = "afr_entrylk_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->entrylk); priv->
children[i]->fops->entrylk (_new, priv->children[i],
volume, loc, __xpg_basename, cmd, type, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3276 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-common.c", __FUNCTION__, 3278,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->entrylk_cbk) tmp_cbk = afr_entrylk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->entrylk"; _new
->unwind_to = "afr_entrylk_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->entrylk); priv->
children[i]->fops->entrylk (_new, priv->children[i],
volume, loc, __xpg_basename, cmd, type, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3277 priv->children[i]->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-common.c", __FUNCTION__, 3278,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->entrylk_cbk) tmp_cbk = afr_entrylk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->entrylk"; _new
->unwind_to = "afr_entrylk_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->entrylk); priv->
children[i]->fops->entrylk (_new, priv->children[i],
volume, loc, __xpg_basename, cmd, type, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3278 volume, loc, basename, cmd, type, xdata)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-common.c", __FUNCTION__, 3278,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->entrylk_cbk) tmp_cbk = afr_entrylk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->entrylk"; _new
->unwind_to = "afr_entrylk_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->entrylk); priv->
children[i]->fops->entrylk (_new, priv->children[i],
volume, loc, __xpg_basename, cmd, type, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
3279
3280 if (!--call_count)
3281 break;
3282 }
3283 }
3284
3285 ret = 0;
3286out:
3287 if (ret < 0)
3288 AFR_STACK_UNWIND (entrylk, frame, -1, op_errno, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_entrylk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3288, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_entrylk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { afr_local_cleanup (__local, __this
); mem_put (__local); } } while (0)
;
3289 return 0;
3290}
3291
3292
3293
3294int32_t
3295afr_fentrylk_cbk (call_frame_t *frame, void *cookie,
3296 xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata)
3297
3298{
3299 afr_local_t *local = NULL((void*)0);
3300 int call_count = -1;
3301
3302 local = frame->local;
3303
3304 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
3305 {
3306 if (op_ret == 0)
3307 local->op_ret = 0;
3308
3309 local->op_errno = op_errno;
3310 }
3311 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
3312
3313 call_count = afr_frame_return (frame);
3314
3315 if (call_count == 0)
3316 AFR_STACK_UNWIND (fentrylk, frame, local->op_ret,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fentrylk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3317, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fentrylk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
3317 local->op_errno, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fentrylk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3317, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fentrylk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
3318
3319 return 0;
3320}
3321
3322
3323int32_t
3324afr_fentrylk (call_frame_t *frame, xlator_t *this,
3325 const char *volume, fd_t *fd,
3326 const char *basename__xpg_basename, entrylk_cmd cmd,
3327 entrylk_type type, dict_t *xdata)
3328{
3329 afr_private_t *priv = NULL((void*)0);
3330 afr_local_t *local = NULL((void*)0);
3331 int ret = -1;
3332 int i = 0;
3333 int32_t call_count = 0;
3334 int32_t op_errno = 0;
3335
3336 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3336, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3337 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3337, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3338 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 3338, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
3339
3340 priv = this->private;
3341
3342 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-common.c"
, __FUNCTION__, 3342, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
3343 local = frame->local;
3344
3345 ret = afr_local_init (local, priv, &op_errno);
3346 if (ret < 0)
3347 goto out;
3348
3349 call_count = local->call_count;
3350
3351 for (i = 0; i < priv->child_count; i++) {
3352 if (local->child_up[i]) {
3353 STACK_WIND (frame, afr_fentrylk_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-common.c", __FUNCTION__, 3356,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fentrylk_cbk) tmp_cbk = afr_fentrylk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fentrylk"; _new
->unwind_to = "afr_fentrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fentrylk
); priv->children[i]->fops->fentrylk (_new, priv->
children[i], volume, fd, __xpg_basename, cmd, type, xdata); (
*__glusterfs_this_location()) = old_THIS; } while (0)
3354 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-common.c", __FUNCTION__, 3356,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fentrylk_cbk) tmp_cbk = afr_fentrylk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fentrylk"; _new
->unwind_to = "afr_fentrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fentrylk
); priv->children[i]->fops->fentrylk (_new, priv->
children[i], volume, fd, __xpg_basename, cmd, type, xdata); (
*__glusterfs_this_location()) = old_THIS; } while (0)
3355 priv->children[i]->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-common.c", __FUNCTION__, 3356,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fentrylk_cbk) tmp_cbk = afr_fentrylk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fentrylk"; _new
->unwind_to = "afr_fentrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fentrylk
); priv->children[i]->fops->fentrylk (_new, priv->
children[i], volume, fd, __xpg_basename, cmd, type, xdata); (
*__glusterfs_this_location()) = old_THIS; } while (0)
3356 volume, fd, basename, cmd, type, xdata)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-common.c", __FUNCTION__, 3356,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->fentrylk_cbk) tmp_cbk = afr_fentrylk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->fentrylk"; _new
->unwind_to = "afr_fentrylk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _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; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = priv->children[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, priv->children[i]->fops->fentrylk
); priv->children[i]->fops->fentrylk (_new, priv->
children[i], volume, fd, __xpg_basename, cmd, type, xdata); (
*__glusterfs_this_location()) = old_THIS; } while (0)
;
3357
3358 if (!--call_count)
3359 break;
3360 }
3361 }
3362
3363 ret = 0;
3364out:
3365 if (ret < 0)
3366 AFR_STACK_UNWIND (fentrylk, frame, -1, op_errno, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_fentrylk_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3366, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_fentrylk_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { afr_local_cleanup (__local, __this
); mem_put (__local); } } while (0)
;
3367 return 0;
3368}
3369
3370int32_t
3371afr_statfs_cbk (call_frame_t *frame, void *cookie,
3372 xlator_t *this, int32_t op_ret, int32_t op_errno,
3373 struct statvfs *statvfs, dict_t *xdata)
3374{
3375 afr_local_t *local = NULL((void*)0);
3376 int call_count = 0;
3377
3378 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
3379 {
3380 local = frame->local;
3381
3382 if (op_ret == 0) {
3383 local->op_ret = op_ret;
3384
3385 if (local->cont.statfs.buf_set) {
3386 if (statvfs->f_bavail < local->cont.statfs.buf.f_bavail)
3387 local->cont.statfs.buf = *statvfs;
3388 } else {
3389 local->cont.statfs.buf = *statvfs;
3390 local->cont.statfs.buf_set = 1;
3391 }
3392 }
3393
3394 if (op_ret == -1)
3395 local->op_errno = op_errno;
3396
3397 }
3398 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
3399
3400 call_count = afr_frame_return (frame);
3401
3402 if (call_count == 0)
3403 AFR_STACK_UNWIND (statfs, frame, local->op_ret, local->op_errno,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_statfs_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3404, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_statfs_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, &local->cont.statfs.buf
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0); if (__local) { afr_local_cleanup (__local, __this); mem_put
(__local); } } while (0)
3404 &local->cont.statfs.buf, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_statfs_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3404, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_statfs_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, local
->op_ret, local->op_errno, &local->cont.statfs.buf
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0); if (__local) { afr_local_cleanup (__local, __this); mem_put
(__local); } } while (0)
;
3405
3406 return 0;
3407}
3408
3409
3410int32_t
3411afr_statfs (call_frame_t *frame, xlator_t *this,
3412 loc_t *loc, dict_t *xdata)
3413{
3414 afr_private_t * priv = NULL((void*)0);
3415 int child_count = 0;
3416 afr_local_t * local = NULL((void*)0);
3417 int i = 0;
3418 int ret = -1;
3419 int call_count = 0;
3420 int32_t op_errno = 0;
3421
3422 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3422, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3423 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 3423, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
3424 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3424, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
3425
3426 priv = this->private;
3427 child_count = priv->child_count;
3428
3429 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-common.c"
, __FUNCTION__, 3429, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
3430 local = frame->local;
3431
3432 ret = afr_local_init (local, priv, &op_errno);
3433 if (ret < 0)
3434 goto out;
3435
3436 call_count = local->call_count;
3437
3438 for (i = 0; i < child_count; i++) {
3439 if (local->child_up[i]) {
3440 STACK_WIND (frame, afr_statfs_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-common.c", __FUNCTION__, 3443,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->statfs_cbk) tmp_cbk = afr_statfs_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->statfs"; _new
->unwind_to = "afr_statfs_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->statfs); priv->children
[i]->fops->statfs (_new, priv->children[i], loc, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0)
3441 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-common.c", __FUNCTION__, 3443,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->statfs_cbk) tmp_cbk = afr_statfs_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->statfs"; _new
->unwind_to = "afr_statfs_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->statfs); priv->children
[i]->fops->statfs (_new, priv->children[i], loc, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0)
3442 priv->children[i]->fops->statfs,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-common.c", __FUNCTION__, 3443,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->statfs_cbk) tmp_cbk = afr_statfs_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->statfs"; _new
->unwind_to = "afr_statfs_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->statfs); priv->children
[i]->fops->statfs (_new, priv->children[i], loc, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0)
3443 loc, xdata)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-common.c", __FUNCTION__, 3443,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->statfs_cbk) tmp_cbk = afr_statfs_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->statfs"; _new
->unwind_to = "afr_statfs_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->statfs); priv->children
[i]->fops->statfs (_new, priv->children[i], loc, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
3444 if (!--call_count)
3445 break;
3446 }
3447 }
3448
3449 ret = 0;
3450out:
3451 if (ret < 0)
3452 AFR_STACK_UNWIND (statfs, frame, -1, op_errno, NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_statfs_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "./afr-common.c",
__FUNCTION__, 3452, GF_LOG_CRITICAL, "!frame"); } while (0);
break; } fn = (fop_statfs_cbk_t )frame->ret; _parent = frame
->parent; pthread_spin_lock (&frame->root->stack_lock
); { _parent->ref_count--; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
3453 return 0;
3454}
3455
3456
3457int32_t
3458afr_lk_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
3459 int32_t op_ret, int32_t op_errno, struct gf_flock *lock,
3460 dict_t *xdata)
3461{
3462 afr_local_t * local = NULL((void*)0);
3463 int call_count = -1;
3464
3465 local = frame->local;
3466 call_count = afr_frame_return (frame);
3467
3468 if (call_count == 0)
3469 AFR_STACK_UNWIND (lk, frame, local->op_ret, local->op_errno,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lk_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "./afr-common.c", __FUNCTION__
, 3470, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_lk_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, lock, xdata)
; (*__glusterfs_this_location()) = old_THIS; } while (0); if (
__local) { afr_local_cleanup (__local, __this); mem_put (__local
); } } while (0)
3470 lock, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lk_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "./afr-common.c", __FUNCTION__
, 3470, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_lk_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, lock, xdata)
; (*__glusterfs_this_location()) = old_THIS; } while (0); if (
__local) { afr_local_cleanup (__local, __this); mem_put (__local
); } } while (0)
;
3471
3472 return 0;
3473}
3474
3475
3476int32_t
3477afr_lk_unlock (call_frame_t *frame, xlator_t *this)
3478{
3479 afr_local_t * local = NULL((void*)0);
3480 afr_private_t * priv = NULL((void*)0);
3481 int i = 0;
3482 int call_count = 0;
3483
3484 local = frame->local;
3485 priv = this->private;
3486
3487 call_count = afr_locked_nodes_count (local->cont.lk.locked_nodes,
3488 priv->child_count);
3489
3490 if (call_count == 0) {
3491 AFR_STACK_UNWIND (lk, frame, local->op_ret, local->op_errno,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lk_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "./afr-common.c", __FUNCTION__
, 3492, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_lk_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
cont.lk.ret_flock, ((void*)0)); (*__glusterfs_this_location()
) = old_THIS; } while (0); if (__local) { afr_local_cleanup (
__local, __this); mem_put (__local); } } while (0)
3492 &local->cont.lk.ret_flock, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lk_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "./afr-common.c", __FUNCTION__
, 3492, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_lk_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
cont.lk.ret_flock, ((void*)0)); (*__glusterfs_this_location()
) = old_THIS; } while (0); if (__local) { afr_local_cleanup (
__local, __this); mem_put (__local); } } while (0)
;
3493 return 0;
3494 }
3495
3496 local->call_count = call_count;
3497
3498 local->cont.lk.user_flock.l_type = F_UNLCK2;
3499
3500 for (i = 0; i < priv->child_count; i++) {
3501 if (local->cont.lk.locked_nodes[i]) {
3502 STACK_WIND (frame, afr_lk_unlock_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-common.c", __FUNCTION__, 3506,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lk_cbk) tmp_cbk = afr_lk_unlock_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->lk"; _new->
unwind_to = "afr_lk_unlock_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->lk); priv->children
[i]->fops->lk (_new, priv->children[i], local->fd
, 13, &local->cont.lk.user_flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3503 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-common.c", __FUNCTION__, 3506,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lk_cbk) tmp_cbk = afr_lk_unlock_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->lk"; _new->
unwind_to = "afr_lk_unlock_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->lk); priv->children
[i]->fops->lk (_new, priv->children[i], local->fd
, 13, &local->cont.lk.user_flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3504 priv->children[i]->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-common.c", __FUNCTION__, 3506,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lk_cbk) tmp_cbk = afr_lk_unlock_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->lk"; _new->
unwind_to = "afr_lk_unlock_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->lk); priv->children
[i]->fops->lk (_new, priv->children[i], local->fd
, 13, &local->cont.lk.user_flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3505 local->fd, F_SETLK,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-common.c", __FUNCTION__, 3506,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lk_cbk) tmp_cbk = afr_lk_unlock_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->lk"; _new->
unwind_to = "afr_lk_unlock_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->lk); priv->children
[i]->fops->lk (_new, priv->children[i], local->fd
, 13, &local->cont.lk.user_flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3506 &local->cont.lk.user_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-common.c", __FUNCTION__, 3506,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lk_cbk) tmp_cbk = afr_lk_unlock_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "priv->children[i]->fops->lk"; _new->
unwind_to = "afr_lk_unlock_cbk"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _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; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = priv->children[i]; if
(frame->this->ctx->measure_latency) gf_latency_begin
(_new, priv->children[i]->fops->lk); priv->children
[i]->fops->lk (_new, priv->children[i], local->fd
, 13, &local->cont.lk.user_flock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
3507
3508 if (!--call_count)
3509 break;
3510 }
3511 }
3512
3513 return 0;
3514}
3515
3516
3517int32_t
3518afr_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
3519 int32_t op_ret, int32_t op_errno, struct gf_flock *lock, dict_t *xdata)
3520{
3521 afr_local_t *local = NULL((void*)0);
3522 afr_private_t *priv = NULL((void*)0);
3523 int child_index = -1;
3524/* int ret = 0; */
3525
3526
3527 local = frame->local;
3528 priv = this->private;
3529
3530 child_index = (long) cookie;
3531
3532 if (!child_went_down (op_ret, op_errno)(((op_ret) < 0) && ((op_errno == 107) || (op_errno
== 77)))
&& (op_ret == -1)) {
3533 local->op_ret = -1;
3534 local->op_errno = op_errno;
3535
3536 afr_lk_unlock (frame, this);
3537 return 0;
3538 }
3539
3540 if (op_ret == 0) {
3541 local->op_ret = 0;
3542 local->op_errno = 0;
3543 local->cont.lk.locked_nodes[child_index] = 1;
3544 local->cont.lk.ret_flock = *lock;
3545 }
3546
3547 child_index++;
3548
3549 if (child_index < priv->child_count) {
3550 STACK_WIND_COOKIE (frame, afr_lk_cbk, (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-common.c", __FUNCTION__, 3554,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[child_index]->fops->lk_cbk) tmp_cbk =
afr_lk_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->lk"
; _new->unwind_to = "afr_lk_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->lk_cbk = afr_lk_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->lk); priv->children[child_index
]->fops->lk (_new, priv->children[child_index], local
->fd, local->cont.lk.cmd, &local->cont.lk.user_flock
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
3551 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-common.c", __FUNCTION__, 3554,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[child_index]->fops->lk_cbk) tmp_cbk =
afr_lk_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->lk"
; _new->unwind_to = "afr_lk_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->lk_cbk = afr_lk_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->lk); priv->children[child_index
]->fops->lk (_new, priv->children[child_index], local
->fd, local->cont.lk.cmd, &local->cont.lk.user_flock
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
3552 priv->children[child_index]->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-common.c", __FUNCTION__, 3554,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[child_index]->fops->lk_cbk) tmp_cbk =
afr_lk_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->lk"
; _new->unwind_to = "afr_lk_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->lk_cbk = afr_lk_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->lk); priv->children[child_index
]->fops->lk (_new, priv->children[child_index], local
->fd, local->cont.lk.cmd, &local->cont.lk.user_flock
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
3553 local->fd, local->cont.lk.cmd,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-common.c", __FUNCTION__, 3554,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[child_index]->fops->lk_cbk) tmp_cbk =
afr_lk_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->lk"
; _new->unwind_to = "afr_lk_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->lk_cbk = afr_lk_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->lk); priv->children[child_index
]->fops->lk (_new, priv->children[child_index], local
->fd, local->cont.lk.cmd, &local->cont.lk.user_flock
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
3554 &local->cont.lk.user_flock, xdata)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-common.c", __FUNCTION__, 3554,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[child_index]->fops->lk_cbk) tmp_cbk =
afr_lk_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->lk"
; _new->unwind_to = "afr_lk_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->lk_cbk = afr_lk_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->lk); priv->children[child_index
]->fops->lk (_new, priv->children[child_index], local
->fd, local->cont.lk.cmd, &local->cont.lk.user_flock
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
;
3555 } else if (local->op_ret == -1) {
3556 /* all nodes have gone down */
3557
3558 AFR_STACK_UNWIND (lk, frame, -1, ENOTCONN,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lk_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "./afr-common.c", __FUNCTION__
, 3559, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_lk_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, -1, 107, &local->cont.lk.ret_flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0);
if (__local) { afr_local_cleanup (__local, __this); mem_put (
__local); } } while (0)
3559 &local->cont.lk.ret_flock, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lk_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "./afr-common.c", __FUNCTION__
, 3559, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_lk_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, -1, 107, &local->cont.lk.ret_flock, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0);
if (__local) { afr_local_cleanup (__local, __this); mem_put (
__local); } } while (0)
;
3560 } else {
3561 /* locking has succeeded on all nodes that are up */
3562
3563 /* temporarily
3564 ret = afr_mark_locked_nodes (this, local->fd,
3565 local->cont.lk.locked_nodes);
3566 if (ret)
3567 gf_log (this->name, GF_LOG_DEBUG,
3568 "Could not save locked nodes info in fdctx");
3569
3570 ret = afr_save_locked_fd (this, local->fd);
3571 if (ret)
3572 gf_log (this->name, GF_LOG_DEBUG,
3573 "Could not save locked fd");
3574
3575 */
3576 AFR_STACK_UNWIND (lk, frame, local->op_ret, local->op_errno,do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lk_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "./afr-common.c", __FUNCTION__
, 3577, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_lk_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
cont.lk.ret_flock, ((void*)0)); (*__glusterfs_this_location()
) = old_THIS; } while (0); if (__local) { afr_local_cleanup (
__local, __this); mem_put (__local); } } while (0)
3577 &local->cont.lk.ret_flock, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lk_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "./afr-common.c", __FUNCTION__
, 3577, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_lk_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
cont.lk.ret_flock, ((void*)0)); (*__glusterfs_this_location()
) = old_THIS; } while (0); if (__local) { afr_local_cleanup (
__local, __this); mem_put (__local); } } while (0)
;
3578 }
3579
3580 return 0;
3581}
3582
3583
3584int
3585afr_lk (call_frame_t *frame, xlator_t *this,
3586 fd_t *fd, int32_t cmd, struct gf_flock *flock, dict_t *xdata)
3587{
3588 afr_private_t *priv = NULL((void*)0);
3589 afr_local_t *local = NULL((void*)0);
3590 int i = 0;
3591 int32_t op_errno = 0;
3592 int ret = -1;
3593
3594 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3594, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3595 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "./afr-common.c"
, __FUNCTION__, 3595, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3596 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "./afr-common.c", __FUNCTION__, 3596, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
3597
3598 priv = this->private;
3599
3600 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-common.c"
, __FUNCTION__, 3600, GF_LOG_ERROR, "out of memory :("); } while
(0); op_errno = 12; goto out; } } while (0);
;
3601 local = frame->local;
3602
3603 ret = afr_local_init (local, priv, &op_errno);
3604 if (ret < 0)
3605 goto out;
3606
3607 local->cont.lk.locked_nodes = GF_CALLOC (priv->child_count,__gf_calloc (priv->child_count, sizeof (*local->cont.lk
.locked_nodes), gf_afr_mt_char)
3608 sizeof (*local->cont.lk.locked_nodes),__gf_calloc (priv->child_count, sizeof (*local->cont.lk
.locked_nodes), gf_afr_mt_char)
3609 gf_afr_mt_char)__gf_calloc (priv->child_count, sizeof (*local->cont.lk
.locked_nodes), gf_afr_mt_char)
;
3610
3611 if (!local->cont.lk.locked_nodes) {
3612 op_errno = ENOMEM12;
3613 goto out;
3614 }
3615
3616 local->fd = fd_ref (fd);
3617 local->cont.lk.cmd = cmd;
3618 local->cont.lk.user_flock = *flock;
3619 local->cont.lk.ret_flock = *flock;
3620
3621 STACK_WIND_COOKIE (frame, afr_lk_cbk, (void *) (long) 0,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-common.c", __FUNCTION__, 3624,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lk_cbk) tmp_cbk = afr_lk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) 0; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->lk"; _new
->unwind_to = "afr_lk_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->lk_cbk = afr_lk_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->lk); priv->children
[i]->fops->lk (_new, priv->children[i], fd, cmd, flock
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
3622 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-common.c", __FUNCTION__, 3624,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lk_cbk) tmp_cbk = afr_lk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) 0; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->lk"; _new
->unwind_to = "afr_lk_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->lk_cbk = afr_lk_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->lk); priv->children
[i]->fops->lk (_new, priv->children[i], fd, cmd, flock
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
3623 priv->children[i]->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-common.c", __FUNCTION__, 3624,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lk_cbk) tmp_cbk = afr_lk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) 0; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->lk"; _new
->unwind_to = "afr_lk_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->lk_cbk = afr_lk_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->lk); priv->children
[i]->fops->lk (_new, priv->children[i], fd, cmd, flock
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
3624 fd, cmd, flock, xdata)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-common.c", __FUNCTION__, 3624,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
priv->children[i]->fops->lk_cbk) tmp_cbk = afr_lk_cbk
; _new->root = frame->root; _new->this = priv->children
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = (void *) (long) 0; _new->wind_from = __FUNCTION__
; _new->wind_to = "priv->children[i]->fops->lk"; _new
->unwind_to = "afr_lk_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->lk_cbk = afr_lk_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->lk); priv->children
[i]->fops->lk (_new, priv->children[i], fd, cmd, flock
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
;
3625
3626 ret = 0;
3627out:
3628 if (ret < 0)
3629 AFR_STACK_UNWIND (lk, frame, -1, op_errno, NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = ((
void*)0); if (frame) { __local = frame->local; __this = frame
->this; frame->local = ((void*)0); } do { fop_lk_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "./afr-common.c", __FUNCTION__
, 3629, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_lk_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, -1, op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { afr_local_cleanup
(__local, __this); mem_put (__local); } } while (0)
;
3630 return 0;
3631}
3632
3633int
3634afr_forget (xlator_t *this, inode_t *inode)
3635{
3636 uint64_t ctx_addr = 0;
3637 afr_inode_ctx_t *ctx = NULL((void*)0);
3638
3639 inode_ctx_get (inode, this, &ctx_addr)inode_ctx_get2(inode,this,&ctx_addr,0);
3640
3641 if (!ctx_addr)
3642 goto out;
3643
3644 ctx = (afr_inode_ctx_t *)(long)ctx_addr;
3645 GF_FREE (ctx->fresh_children)__gf_free (ctx->fresh_children);
3646 GF_FREE (ctx)__gf_free (ctx);
3647out:
3648 return 0;
3649}
3650
3651int
3652afr_priv_dump (xlator_t *this)
3653{
3654 afr_private_t *priv = NULL((void*)0);
3655 char key_prefix[GF_DUMP_MAX_BUF_LEN4096];
3656 char key[GF_DUMP_MAX_BUF_LEN4096];
3657 int i = 0;
3658
3659
3660 GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: "
"this"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 3660, GF_LOG_ERROR, "Assertion failed: " "this"
); } while (0); } } while (0)
;
3661 priv = this->private;
3662
3663 GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: "
"priv"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 3663, GF_LOG_ERROR, "Assertion failed: " "priv"
); } while (0); } } while (0)
;
3664 snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN4096, "%s.%s", this->type, this->name);
3665 gf_proc_dump_add_section(key_prefix);
3666 gf_proc_dump_write("child_count", "%u", priv->child_count);
3667 gf_proc_dump_write("read_child_rr", "%u", priv->read_child_rr);
3668 for (i = 0; i < priv->child_count; i++) {
3669 sprintf (key, "child_up[%d]", i);
3670 gf_proc_dump_write(key, "%d", priv->child_up[i]);
3671 sprintf (key, "pending_key[%d]", i);
3672 gf_proc_dump_write(key, "%s", priv->pending_key[i]);
3673 }
3674 gf_proc_dump_write("data_self_heal", "%s", priv->data_self_heal);
3675 gf_proc_dump_write("metadata_self_heal", "%d", priv->metadata_self_heal);
3676 gf_proc_dump_write("entry_self_heal", "%d", priv->entry_self_heal);
3677 gf_proc_dump_write("data_change_log", "%d", priv->data_change_log);
3678 gf_proc_dump_write("metadata_change_log", "%d", priv->metadata_change_log);
3679 gf_proc_dump_write("entry-change_log", "%d", priv->entry_change_log);
3680 gf_proc_dump_write("read_child", "%d", priv->read_child);
3681 gf_proc_dump_write("favorite_child", "%d", priv->favorite_child);
3682 gf_proc_dump_write("wait_count", "%u", priv->wait_count);
3683
3684 return 0;
3685}
3686
3687
3688/**
3689 * find_child_index - find the child's index in the array of subvolumes
3690 * @this: AFR
3691 * @child: child
3692 */
3693
3694static int
3695find_child_index (xlator_t *this, xlator_t *child)
3696{
3697 afr_private_t *priv = NULL((void*)0);
3698 int i = -1;
3699
3700 priv = this->private;
3701
3702 for (i = 0; i < priv->child_count; i++) {
3703 if ((xlator_t *) child == priv->children[i])
3704 break;
3705 }
3706
3707 return i;
3708}
3709
3710int32_t
3711afr_notify (xlator_t *this, int32_t event,
3712 void *data, void *data2)
3713{
3714 afr_private_t *priv = NULL((void*)0);
3715 int i = -1;
3716 int up_children = 0;
3717 int down_children = 0;
3718 int propagate = 0;
3719 int had_heard_from_all = 0;
3720 int have_heard_from_all = 0;
3721 int idx = -1;
3722 int ret = -1;
3723 int call_psh = 0;
3724 int up_child = AFR_ALL_CHILDREN-1;
3725 dict_t *input = NULL((void*)0);
3726 dict_t *output = NULL((void*)0);
3727
3728 priv = this->private;
3729
3730 if (!priv)
3731 return 0;
3732
3733 /*
3734 * We need to reset this in case children come up in "staggered"
3735 * fashion, so that we discover a late-arriving local subvolume. Note
3736 * that we could end up issuing N lookups to the first subvolume, and
3737 * O(N^2) overall, but N is small for AFR so it shouldn't be an issue.
3738 */
3739 priv->did_discovery = _gf_false;
3740
3741 had_heard_from_all = 1;
3742 for (i = 0; i < priv->child_count; i++) {
3743 if (!priv->last_event[i]) {
3744 had_heard_from_all = 0;
3745 }
3746 }
3747
3748 /* parent xlators dont need to know about every child_up, child_down
3749 * because of afr ha. If all subvolumes go down, child_down has
3750 * to be triggered. In that state when 1 subvolume comes up child_up
3751 * needs to be triggered. dht optimizes revalidate lookup by sending
3752 * it only to one of its subvolumes. When child up/down happens
3753 * for afr's subvolumes dht should be notified by child_modified. The
3754 * subsequent revalidate lookup happens on all the dht's subvolumes
3755 * which triggers afr self-heals if any.
3756 */
3757 idx = find_child_index (this, data);
3758 if (idx < 0) {
3759 gf_log (this->name, GF_LOG_ERROR, "Received child_up "do { do { if (0) printf ("Received child_up " "from invalid subvolume"
); } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 3760, GF_LOG_ERROR, "Received child_up " "from invalid subvolume"
); } while (0)
3760 "from invalid subvolume")do { do { if (0) printf ("Received child_up " "from invalid subvolume"
); } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 3760, GF_LOG_ERROR, "Received child_up " "from invalid subvolume"
); } while (0)
;
3761 goto out;
3762 }
3763
3764 switch (event) {
3765 case GF_EVENT_CHILD_UP:
3766 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
3767 {
3768 /*
3769 * This only really counts if the child was never up
3770 * (value = -1) or had been down (value = 0). See
3771 * comment at GF_EVENT_CHILD_DOWN for a more detailed
3772 * explanation.
3773 */
3774 if (priv->child_up[idx] != 1) {
3775 priv->up_count++;
3776 }
3777 priv->child_up[idx] = 1;
3778
3779 call_psh = 1;
3780 up_child = idx;
3781 for (i = 0; i < priv->child_count; i++)
3782 if (priv->child_up[i] == 1)
3783 up_children++;
3784 if (up_children == 1) {
3785 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("Subvolume '%s' came back up; " "going online."
, ((xlator_t *)data)->name); } while (0); _gf_log (this->
name, "./afr-common.c", __FUNCTION__, 3787, GF_LOG_INFO, "Subvolume '%s' came back up; "
"going online.", ((xlator_t *)data)->name); } while (0)
3786 "Subvolume '%s' came back up; "do { do { if (0) printf ("Subvolume '%s' came back up; " "going online."
, ((xlator_t *)data)->name); } while (0); _gf_log (this->
name, "./afr-common.c", __FUNCTION__, 3787, GF_LOG_INFO, "Subvolume '%s' came back up; "
"going online.", ((xlator_t *)data)->name); } while (0)
3787 "going online.", ((xlator_t *)data)->name)do { do { if (0) printf ("Subvolume '%s' came back up; " "going online."
, ((xlator_t *)data)->name); } while (0); _gf_log (this->
name, "./afr-common.c", __FUNCTION__, 3787, GF_LOG_INFO, "Subvolume '%s' came back up; "
"going online.", ((xlator_t *)data)->name); } while (0)
;
3788 } else {
3789 event = GF_EVENT_CHILD_MODIFIED;
3790 }
3791
3792 priv->last_event[idx] = event;
3793 }
3794 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
3795
3796 break;
3797
3798 case GF_EVENT_CHILD_DOWN:
3799 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
3800 {
3801 /*
3802 * If a brick is down when we start, we'll get a
3803 * CHILD_DOWN to indicate its initial state. There
3804 * was never a CHILD_UP in this case, so if we
3805 * increment "down_count" the difference between than
3806 * and "up_count" will no longer be the number of
3807 * children that are currently up. This has serious
3808 * implications e.g. for quorum enforcement, so we
3809 * don't increment these values unless the event
3810 * represents an actual state transition between "up"
3811 * (value = 1) and anything else.
3812 */
3813 if (priv->child_up[idx] == 1) {
3814 priv->down_count++;
3815 }
3816 priv->child_up[idx] = 0;
3817
3818 for (i = 0; i < priv->child_count; i++)
3819 if (priv->child_up[i] == 0)
3820 down_children++;
3821 if (down_children == priv->child_count) {
3822 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("All subvolumes are down. Going offline "
"until atleast one of them comes back up."); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 3824, GF_LOG_ERROR
, "All subvolumes are down. Going offline " "until atleast one of them comes back up."
); } while (0)
3823 "All subvolumes are down. Going offline "do { do { if (0) printf ("All subvolumes are down. Going offline "
"until atleast one of them comes back up."); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 3824, GF_LOG_ERROR
, "All subvolumes are down. Going offline " "until atleast one of them comes back up."
); } while (0)
3824 "until atleast one of them comes back up.")do { do { if (0) printf ("All subvolumes are down. Going offline "
"until atleast one of them comes back up."); } while (0); _gf_log
(this->name, "./afr-common.c", __FUNCTION__, 3824, GF_LOG_ERROR
, "All subvolumes are down. Going offline " "until atleast one of them comes back up."
); } while (0)
;
3825 } else {
3826 event = GF_EVENT_CHILD_MODIFIED;
3827 }
3828
3829 priv->last_event[idx] = event;
3830 }
3831 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
3832
3833 break;
3834
3835 case GF_EVENT_CHILD_CONNECTING:
3836 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
3837 {
3838 priv->last_event[idx] = event;
3839 }
3840 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
3841
3842 break;
3843
3844 case GF_EVENT_TRANSLATOR_OP:
3845 input = data;
3846 output = data2;
3847 ret = afr_xl_op (this, input, output);
3848 goto out;
3849 break;
3850
3851 default:
3852 propagate = 1;
3853 break;
3854 }
3855
3856 /* have all subvolumes reported status once by now? */
3857 have_heard_from_all = 1;
3858 for (i = 0; i < priv->child_count; i++) {
3859 if (!priv->last_event[i])
3860 have_heard_from_all = 0;
3861 }
3862
3863 /* if all subvols have reported status, no need to hide anything
3864 or wait for anything else. Just propagate blindly */
3865 if (have_heard_from_all)
3866 propagate = 1;
3867
3868 if (!had_heard_from_all && have_heard_from_all) {
3869 /* This is the first event which completes aggregation
3870 of events from all subvolumes. If at least one subvol
3871 had come up, propagate CHILD_UP, but only this time
3872 */
3873 event = GF_EVENT_CHILD_DOWN;
3874
3875 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
3876 {
3877 up_children = afr_up_children_count (priv->child_up,
Value stored to 'up_children' is never read
3878 priv->child_count);
3879 for (i = 0; i < priv->child_count; i++) {
3880 if (priv->last_event[i] == GF_EVENT_CHILD_UP) {
3881 event = GF_EVENT_CHILD_UP;
3882 break;
3883 }
3884
3885 if (priv->last_event[i] ==
3886 GF_EVENT_CHILD_CONNECTING) {
3887 event = GF_EVENT_CHILD_CONNECTING;
3888 /* continue to check other events for CHILD_UP */
3889 }
3890 }
3891 }
3892 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
3893 }
3894
3895 ret = 0;
3896 if (propagate)
3897 ret = default_notify (this, event, data);
3898 if (call_psh && priv->shd.iamshd)
3899 afr_proactive_self_heal ((void*) (long) up_child);
3900
3901out:
3902 return ret;
3903}
3904
3905int
3906afr_first_up_child (unsigned char *child_up, size_t child_count)
3907{
3908 int ret = -1;
3909 int i = 0;
3910
3911 GF_ASSERT (child_up)do { if (!(child_up)) { do { do { if (0) printf ("Assertion failed: "
"child_up"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 3911, GF_LOG_ERROR, "Assertion failed: " "child_up"
); } while (0); } } while (0)
;
3912
3913 for (i = 0; i < child_count; i++) {
3914 if (child_up[i]) {
3915 ret = i;
3916 break;
3917 }
3918 }
3919
3920 return ret;
3921}
3922
3923int
3924afr_local_init (afr_local_t *local, afr_private_t *priv, int32_t *op_errno)
3925{
3926 int ret = -1;
3927
3928 local->op_ret = -1;
3929 local->op_errno = EUCLEAN117;
3930
3931 local->child_up = GF_CALLOC (priv->child_count,__gf_calloc (priv->child_count, sizeof (*local->child_up
), gf_afr_mt_char)
3932 sizeof (*local->child_up),__gf_calloc (priv->child_count, sizeof (*local->child_up
), gf_afr_mt_char)
3933 gf_afr_mt_char)__gf_calloc (priv->child_count, sizeof (*local->child_up
), gf_afr_mt_char)
;
3934 if (!local->child_up) {
3935 if (op_errno)
3936 *op_errno = ENOMEM12;
3937 goto out;
3938 }
3939
3940 memcpy (local->child_up, priv->child_up,
3941 sizeof (*local->child_up) * priv->child_count);
3942 local->call_count = afr_up_children_count (local->child_up,
3943 priv->child_count);
3944 if (local->call_count == 0) {
3945 gf_log (THIS->name, GF_LOG_INFO, "no subvolumes up")do { do { if (0) printf ("no subvolumes up"); } while (0); _gf_log
((*__glusterfs_this_location())->name, "./afr-common.c", __FUNCTION__
, 3945, GF_LOG_INFO, "no subvolumes up"); } while (0)
;
3946 if (op_errno)
3947 *op_errno = ENOTCONN107;
3948 goto out;
3949 }
3950
3951 local->child_errno = GF_CALLOC (priv->child_count,__gf_calloc (priv->child_count, sizeof (*local->child_errno
), gf_afr_mt_int32_t)
3952 sizeof (*local->child_errno),__gf_calloc (priv->child_count, sizeof (*local->child_errno
), gf_afr_mt_int32_t)
3953 gf_afr_mt_int32_t)__gf_calloc (priv->child_count, sizeof (*local->child_errno
), gf_afr_mt_int32_t)
;
3954 if (!local->child_errno) {
3955 if (op_errno)
3956 *op_errno = ENOMEM12;
3957 goto out;
3958 }
3959
3960 local->transaction.postop_piggybacked = GF_CALLOC (priv->child_count,__gf_calloc (priv->child_count, sizeof (int), gf_afr_mt_int32_t
)
3961 sizeof (int),__gf_calloc (priv->child_count, sizeof (int), gf_afr_mt_int32_t
)
3962 gf_afr_mt_int32_t)__gf_calloc (priv->child_count, sizeof (int), gf_afr_mt_int32_t
)
;
3963 if (!local->transaction.postop_piggybacked) {
3964 if (op_errno)
3965 *op_errno = ENOMEM12;
3966 goto out;
3967 }
3968
3969 ret = 0;
3970out:
3971 return ret;
3972}
3973
3974int
3975afr_internal_lock_init (afr_internal_lock_t *lk, size_t child_count,
3976 transaction_lk_type_t lk_type)
3977{
3978 int ret = -ENOMEM12;
3979
3980 lk->inode_locked_nodes = GF_CALLOC (sizeof (*lk->inode_locked_nodes),__gf_calloc (sizeof (*lk->inode_locked_nodes), child_count
, gf_afr_mt_char)
3981 child_count, gf_afr_mt_char)__gf_calloc (sizeof (*lk->inode_locked_nodes), child_count
, gf_afr_mt_char)
;
3982 if (NULL((void*)0) == lk->inode_locked_nodes)
3983 goto out;
3984
3985 lk->locked_nodes = GF_CALLOC (sizeof (*lk->locked_nodes),__gf_calloc (sizeof (*lk->locked_nodes), child_count, gf_afr_mt_char
)
3986 child_count, gf_afr_mt_char)__gf_calloc (sizeof (*lk->locked_nodes), child_count, gf_afr_mt_char
)
;
3987 if (NULL((void*)0) == lk->locked_nodes)
3988 goto out;
3989
3990 lk->lower_locked_nodes = GF_CALLOC (sizeof (*lk->lower_locked_nodes),__gf_calloc (sizeof (*lk->lower_locked_nodes), child_count
, gf_afr_mt_char)
3991 child_count, gf_afr_mt_char)__gf_calloc (sizeof (*lk->lower_locked_nodes), child_count
, gf_afr_mt_char)
;
3992 if (NULL((void*)0) == lk->lower_locked_nodes)
3993 goto out;
3994
3995 lk->lock_op_ret = -1;
3996 lk->lock_op_errno = EUCLEAN117;
3997 lk->transaction_lk_type = lk_type;
3998
3999 ret = 0;
4000out:
4001 return ret;
4002}
4003
4004void
4005afr_matrix_cleanup (int32_t **matrix, unsigned int m)
4006{
4007 int i = 0;
4008
4009 if (!matrix)
4010 goto out;
4011 for (i = 0; i < m; i++) {
4012 GF_FREE (matrix[i])__gf_free (matrix[i]);
4013 }
4014
4015 GF_FREE (matrix)__gf_free (matrix);
4016out:
4017 return;
4018}
4019
4020int32_t**
4021afr_matrix_create (unsigned int m, unsigned int n)
4022{
4023 int32_t **matrix = NULL((void*)0);
4024 int i = 0;
4025
4026 matrix = GF_CALLOC (sizeof (*matrix), m, gf_afr_mt_int32_t)__gf_calloc (sizeof (*matrix), m, gf_afr_mt_int32_t);
4027 if (!matrix)
4028 goto out;
4029
4030 for (i = 0; i < m; i++) {
4031 matrix[i] = GF_CALLOC (sizeof (*matrix[i]), n,__gf_calloc (sizeof (*matrix[i]), n, gf_afr_mt_int32_t)
4032 gf_afr_mt_int32_t)__gf_calloc (sizeof (*matrix[i]), n, gf_afr_mt_int32_t);
4033 if (!matrix[i])
4034 goto out;
4035 }
4036 return matrix;
4037out:
4038 afr_matrix_cleanup (matrix, m);
4039 return NULL((void*)0);
4040}
4041
4042int
4043afr_transaction_local_init (afr_local_t *local, xlator_t *this)
4044{
4045 int child_up_count = 0;
4046 int ret = -ENOMEM12;
4047 afr_private_t *priv = NULL((void*)0);
4048
4049 priv = this->private;
4050 ret = afr_internal_lock_init (&local->internal_lock, priv->child_count,
4051 AFR_TRANSACTION_LK);
4052 if (ret < 0)
4053 goto out;
4054
4055 ret = -ENOMEM12;
4056 child_up_count = afr_up_children_count (local->child_up,
4057 priv->child_count);
4058 if (priv->optimistic_change_log && child_up_count == priv->child_count)
4059 local->optimistic_change_log = 1;
4060
4061 local->first_up_child = afr_first_up_child (local->child_up,
4062 priv->child_count);
4063
4064 local->transaction.eager_lock =
4065 GF_CALLOC (sizeof (*local->transaction.eager_lock),__gf_calloc (sizeof (*local->transaction.eager_lock), priv
->child_count, gf_afr_mt_int32_t)
4066 priv->child_count,__gf_calloc (sizeof (*local->transaction.eager_lock), priv
->child_count, gf_afr_mt_int32_t)
4067 gf_afr_mt_int32_t)__gf_calloc (sizeof (*local->transaction.eager_lock), priv
->child_count, gf_afr_mt_int32_t)
;
4068
4069 if (!local->transaction.eager_lock)
4070 goto out;
4071
4072 local->fresh_children = afr_children_create (priv->child_count);
4073 if (!local->fresh_children)
4074 goto out;
4075
4076 local->transaction.pre_op = GF_CALLOC (sizeof (*local->transaction.pre_op),__gf_calloc (sizeof (*local->transaction.pre_op), priv->
child_count, gf_afr_mt_char)
4077 priv->child_count,__gf_calloc (sizeof (*local->transaction.pre_op), priv->
child_count, gf_afr_mt_char)
4078 gf_afr_mt_char)__gf_calloc (sizeof (*local->transaction.pre_op), priv->
child_count, gf_afr_mt_char)
;
4079 if (!local->transaction.pre_op)
4080 goto out;
4081
4082 local->pending = afr_matrix_create (priv->child_count,
4083 AFR_NUM_CHANGE_LOGS3);
4084 if (!local->pending)
4085 goto out;
4086
4087 local->transaction.txn_changelog = afr_matrix_create (priv->child_count,
4088 AFR_NUM_CHANGE_LOGS3);
4089 if (!local->transaction.txn_changelog)
4090 goto out;
4091
4092 INIT_LIST_HEAD (&local->transaction.eager_locked)do { (&local->transaction.eager_locked)->next = (&
local->transaction.eager_locked)->prev = &local->
transaction.eager_locked; } while (0)
;
4093
4094 ret = 0;
4095out:
4096 return ret;
4097}
4098
4099void
4100afr_reset_children (int32_t *fresh_children, int32_t child_count)
4101{
4102 unsigned int i = 0;
4103 for (i = 0; i < child_count; i++)
4104 fresh_children[i] = -1;
4105}
4106
4107int32_t*
4108afr_children_create (int32_t child_count)
4109{
4110 int32_t *children = NULL((void*)0);
4111 int i = 0;
4112
4113 GF_ASSERT (child_count > 0)do { if (!(child_count > 0)) { do { do { if (0) printf ("Assertion failed: "
"child_count > 0"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 4113, GF_LOG_ERROR, "Assertion failed: " "child_count > 0"
); } while (0); } } while (0)
;
4114
4115 children = GF_CALLOC (child_count, sizeof (*children),__gf_calloc (child_count, sizeof (*children), gf_afr_mt_int32_t
)
4116 gf_afr_mt_int32_t)__gf_calloc (child_count, sizeof (*children), gf_afr_mt_int32_t
)
;
4117 if (NULL((void*)0) == children)
4118 goto out;
4119 for (i = 0; i < child_count; i++)
4120 children[i] = -1;
4121out:
4122 return children;
4123}
4124
4125void
4126afr_children_add_child (int32_t *children, int32_t child,
4127 int32_t child_count)
4128{
4129 gf_boolean_t child_found = _gf_false;
4130 int i = 0;
4131
4132 for (i = 0; i < child_count; i++) {
4133 if (children[i] == -1)
4134 break;
4135 if (children[i] == child) {
4136 child_found = _gf_true;
4137 break;
4138 }
4139 }
4140
4141 if (!child_found) {
4142 GF_ASSERT (i < child_count)do { if (!(i < child_count)) { do { do { if (0) printf ("Assertion failed: "
"i < child_count"); } while (0); _gf_log_callingfn ("", "./afr-common.c"
, __FUNCTION__, 4142, GF_LOG_ERROR, "Assertion failed: " "i < child_count"
); } while (0); } } while (0)
;
4143 children[i] = child;
4144 }
4145}
4146
4147void
4148afr_children_rm_child (int32_t *children, int32_t child, int32_t child_count)
4149{
4150 int i = 0;
4151
4152 GF_ASSERT ((child >= 0) && (child < child_count))do { if (!((child >= 0) && (child < child_count
))) { do { do { if (0) printf ("Assertion failed: " "(child >= 0) && (child < child_count)"
); } while (0); _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__
, 4152, GF_LOG_ERROR, "Assertion failed: " "(child >= 0) && (child < child_count)"
); } while (0); } } while (0)
;
4153 for (i = 0; i < child_count; i++) {
4154 if (children[i] == -1)
4155 break;
4156 if (children[i] == child) {
4157 if (i != (child_count - 1))
4158 memmove (children + i, children + i + 1,
4159 sizeof (*children)*(child_count - i - 1));
4160 children[child_count - 1] = -1;
4161 break;
4162 }
4163 }
4164}
4165
4166int
4167afr_get_children_count (int32_t *children, unsigned int child_count)
4168{
4169 int count = 0;
4170 int i = 0;
4171
4172 for (i = 0; i < child_count; i++) {
4173 if (children[i] == -1)
4174 break;
4175 count++;
4176 }
4177 return count;
4178}
4179
4180void
4181afr_set_low_priority (call_frame_t *frame)
4182{
4183 frame->root->pid = LOW_PRIO_PROC_PID-1;
4184}
4185
4186int
4187afr_child_fd_ctx_set (xlator_t *this, fd_t *fd, int32_t child,
4188 int flags)
4189{
4190 int ret = 0;
4191 uint64_t ctx = 0;
4192 afr_fd_ctx_t *fd_ctx = NULL((void*)0);
4193
4194 GF_ASSERT (fd && fd->inode)do { if (!(fd && fd->inode)) { do { do { if (0) printf
("Assertion failed: " "fd && fd->inode"); } while
(0); _gf_log_callingfn ("", "./afr-common.c", __FUNCTION__, 4194
, GF_LOG_ERROR, "Assertion failed: " "fd && fd->inode"
); } while (0); } } while (0)
;
4195 ret = afr_fd_ctx_set (this, fd);
4196 if (ret < 0) {
4197 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("could not set fd ctx for fd=%p", fd
); } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 4198, GF_LOG_ERROR, "could not set fd ctx for fd=%p", fd); }
while (0)
4198 "could not set fd ctx for fd=%p", fd)do { do { if (0) printf ("could not set fd ctx for fd=%p", fd
); } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 4198, GF_LOG_ERROR, "could not set fd ctx for fd=%p", fd); }
while (0)
;
4199 goto out;
4200 }
4201
4202 ret = fd_ctx_get (fd, this, &ctx);
4203 if (ret < 0) {
4204 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("could not get fd ctx for fd=%p", fd
); } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 4205, GF_LOG_ERROR, "could not get fd ctx for fd=%p", fd); }
while (0)
4205 "could not get fd ctx for fd=%p", fd)do { do { if (0) printf ("could not get fd ctx for fd=%p", fd
); } while (0); _gf_log (this->name, "./afr-common.c", __FUNCTION__
, 4205, GF_LOG_ERROR, "could not get fd ctx for fd=%p", fd); }
while (0)
;
4206 goto out;
4207 }
4208
4209 fd_ctx = (afr_fd_ctx_t *)(long) ctx;
4210 fd_ctx->opened_on[child] = AFR_FD_OPENED;
4211 if (!IA_ISDIR (fd->inode->ia_type)(fd->inode->ia_type == IA_IFDIR)) {
4212 fd_ctx->flags = flags;
4213 }
4214 ret = 0;
4215out:
4216 return ret;
4217}
4218
4219gf_boolean_t
4220afr_have_quorum (char *logname, afr_private_t *priv)
4221{
4222 unsigned int quorum = 0;
4223
4224 GF_VALIDATE_OR_GOTO(logname,priv,out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
(logname, "./afr-common.c", __FUNCTION__, 4224, GF_LOG_ERROR
, "invalid argument: " "priv"); } while (0); goto out; } } while
(0)
;
4225
4226 quorum = priv->quorum_count;
4227 if (quorum != AFR_QUORUM_AUTO2147483647) {
4228 return (priv->up_count >= (priv->down_count + quorum));
4229 }
4230
4231 quorum = priv->child_count / 2 + 1;
4232 if (priv->up_count >= (priv->down_count + quorum)) {
4233 return _gf_true;
4234 }
4235
4236 /*
4237 * Special case for even numbers of nodes: if we have exactly half
4238 * and that includes the first ("senior-most") node, then that counts
4239 * as quorum even if it wouldn't otherwise. This supports e.g. N=2
4240 * while preserving the critical property that there can only be one
4241 * such group.
4242 */
4243 if ((priv->child_count % 2) == 0) {
4244 quorum = priv->child_count / 2;
4245 if (priv->up_count >= (priv->down_count + quorum)) {
4246 if (priv->child_up[0]) {
4247 return _gf_true;
4248 }
4249 }
4250 }
4251
4252out:
4253 return _gf_false;
4254}
4255
4256void
4257afr_priv_destroy (afr_private_t *priv)
4258{
4259 int i = 0;
4260
4261 if (!priv)
4262 goto out;
4263 inode_unref (priv->root_inode);
4264 GF_FREE (priv->shd.pos)__gf_free (priv->shd.pos);
4265 GF_FREE (priv->shd.pending)__gf_free (priv->shd.pending);
4266 GF_FREE (priv->shd.inprogress)__gf_free (priv->shd.inprogress);
4267// for (i = 0; i < priv->child_count; i++)
4268// if (priv->shd.timer && priv->shd.timer[i])
4269// gf_timer_call_cancel (this->ctx, priv->shd.timer[i]);
4270 GF_FREE (priv->shd.timer)__gf_free (priv->shd.timer);
4271
4272 if (priv->shd.healed)
4273 eh_destroy (priv->shd.healed);
4274
4275 if (priv->shd.heal_failed)
4276 eh_destroy (priv->shd.heal_failed);
4277
4278 if (priv->shd.split_brain)
4279 eh_destroy (priv->shd.split_brain);
4280
4281 GF_FREE (priv->last_event)__gf_free (priv->last_event);
4282 if (priv->pending_key) {
4283 for (i = 0; i < priv->child_count; i++)
4284 GF_FREE (priv->pending_key[i])__gf_free (priv->pending_key[i]);
4285 }
4286 GF_FREE (priv->pending_key)__gf_free (priv->pending_key);
4287 GF_FREE (priv->children)__gf_free (priv->children);
4288 GF_FREE (priv->child_up)__gf_free (priv->child_up);
4289 LOCK_DESTROY (&priv->lock)pthread_spin_destroy (&priv->lock);
4290 LOCK_DESTROY (&priv->read_child_lock)pthread_spin_destroy (&priv->read_child_lock);
4291 pthread_mutex_destroy (&priv->mutex);
4292 GF_FREE (priv)__gf_free (priv);
4293out:
4294 return;
4295}
4296
4297int
4298xlator_subvolume_count (xlator_t *this)
4299{
4300 int i = 0;
4301 xlator_list_t *list = NULL((void*)0);
4302
4303 for (list = this->children; list; list = list->next)
4304 i++;
4305 return i;
4306}
4307
4308inline gf_boolean_t
4309afr_is_errno_set (int *child_errno, int child)
4310{
4311 return child_errno[child];
4312}
4313
4314inline gf_boolean_t
4315afr_is_errno_unset (int *child_errno, int child)
4316{
4317 return !afr_is_errno_set (child_errno, child);
4318}
4319
4320void
4321afr_prepare_new_entry_pending_matrix (int32_t **pending,
4322 gf_boolean_t (*is_pending) (int *, int),
4323 int *ctx, struct iatt *buf,
4324 unsigned int child_count)
4325{
4326 int midx = 0;
4327 int idx = 0;
4328 int i = 0;
4329
4330 midx = afr_index_for_transaction_type (AFR_METADATA_TRANSACTION);
4331 if (IA_ISDIR (buf->ia_type)(buf->ia_type == IA_IFDIR))
4332 idx = afr_index_for_transaction_type (AFR_ENTRY_TRANSACTION);
4333 else if (IA_ISREG (buf->ia_type)(buf->ia_type == IA_IFREG))
4334 idx = afr_index_for_transaction_type (AFR_DATA_TRANSACTION);
4335 else
4336 idx = -1;
4337 for (i = 0; i < child_count; i++) {
4338 if (is_pending (ctx, i)) {
4339 pending[i][midx] = hton32 (1);
4340 if (idx == -1)
4341 continue;
4342 pending[i][idx] = hton32 (1);
4343 }
4344 }
4345}
4346
4347gf_boolean_t
4348afr_is_fd_fixable (fd_t *fd)
4349{
4350 if (!fd || !fd->inode)
4351 return _gf_false;
4352 else if (fd_is_anonymous (fd))
4353 return _gf_false;
4354 else if (uuid_is_null (fd->inode->gfid))
4355 return _gf_false;
4356
4357 return _gf_true;
4358}