Bug Summary

File:xlators/cluster/stripe/src/stripe.c
Location:line 4811, column 17
Description:Access to field 'op_ret' results in a dereference of a null pointer (loaded from variable 'local')

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/**
12 * xlators/cluster/stripe:
13 * Stripe translator, stripes the data across its child nodes,
14 * as per the options given in the volfile. The striping works
15 * fairly simple. It writes files at different offset as per
16 * calculation. So, 'ls -l' output at the real posix level will
17 * show file size bigger than the actual size. But when one does
18 * 'df' or 'du <file>', real size of the file on the server is shown.
19 *
20 * WARNING:
21 * Stripe translator can't regenerate data if a child node gets disconnected.
22 * So, no 'self-heal' for stripe. Hence the advice, use stripe only when its
23 * very much necessary, or else, use it in combination with AFR, to have a
24 * backup copy.
25 */
26#include <fnmatch.h>
27
28#include "stripe.h"
29#include "libxlator.h"
30#include "byte-order.h"
31#include "statedump.h"
32
33struct volume_options options[];
34
35int32_t
36stripe_sh_chown_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
37 int32_t op_ret, int32_t op_errno,
38 struct iatt *preop, struct iatt *postop, dict_t *xdata)
39{
40 int callcnt = -1;
41 stripe_local_t *local = NULL((void*)0);
42
43 if (!this || !frame || !frame->local) {
44 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 44, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
45 goto out;
46 }
47
48 local = frame->local;
49
50 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
51 {
52 callcnt = --local->call_count;
53 }
54 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
55
56 if (!callcnt) {
57 STRIPE_STACK_DESTROY (frame)do { stripe_local_t *__local = ((void*)0); __local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); if (__local) { stripe_local_wipe (__local); mem_put (__local
); } } while (0)
;
58 }
59out:
60 return 0;
61}
62
63int32_t
64stripe_sh_make_entry_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
65 int32_t op_ret, int32_t op_errno, inode_t *inode,
66 struct iatt *buf, struct iatt *preparent,
67 struct iatt *postparent, dict_t *xdata)
68{
69 stripe_local_t *local = NULL((void*)0);
70 call_frame_t *prev = NULL((void*)0);
71
72 if (!frame || !frame->local || !cookie || !this) {
73 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 73, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
74 goto out;
75 }
76
77 prev = cookie;
78 local = frame->local;
79
80 STACK_WIND (frame, stripe_sh_chown_cbk, prev->this,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", "stripe.c", __FUNCTION__, 82, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( prev->this
->fops->setattr_cbk) tmp_cbk = stripe_sh_chown_cbk; _new
->root = frame->root; _new->this = prev->this; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "prev->this->fops->setattr"; _new->unwind_to =
"stripe_sh_chown_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()) = prev->this; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, prev->this->fops->setattr); prev->this->fops
->setattr (_new, prev->this, &local->loc, &local
->stbuf, (0x2 | 0x4), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
81 prev->this->fops->setattr, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 82, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( prev->this
->fops->setattr_cbk) tmp_cbk = stripe_sh_chown_cbk; _new
->root = frame->root; _new->this = prev->this; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "prev->this->fops->setattr"; _new->unwind_to =
"stripe_sh_chown_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()) = prev->this; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, prev->this->fops->setattr); prev->this->fops
->setattr (_new, prev->this, &local->loc, &local
->stbuf, (0x2 | 0x4), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
82 &local->stbuf, (GF_SET_ATTR_UID | GF_SET_ATTR_GID), 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", "stripe.c", __FUNCTION__, 82, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( prev->this
->fops->setattr_cbk) tmp_cbk = stripe_sh_chown_cbk; _new
->root = frame->root; _new->this = prev->this; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "prev->this->fops->setattr"; _new->unwind_to =
"stripe_sh_chown_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()) = prev->this; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, prev->this->fops->setattr); prev->this->fops
->setattr (_new, prev->this, &local->loc, &local
->stbuf, (0x2 | 0x4), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
83
84out:
85 return 0;
86}
87
88int32_t
89stripe_entry_self_heal (call_frame_t *frame, xlator_t *this,
90 stripe_local_t *local)
91{
92 xlator_list_t *trav = NULL((void*)0);
93 call_frame_t *rframe = NULL((void*)0);
94 stripe_local_t *rlocal = NULL((void*)0);
95 stripe_private_t *priv = NULL((void*)0);
96 dict_t *xdata = NULL((void*)0);
97 int ret = 0;
98
99 if (!local || !this || !frame) {
100 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 100, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
101 goto out;
102 }
103
104 if (!(IA_ISREG (local->stbuf.ia_type)(local->stbuf.ia_type == IA_IFREG) ||
105 IA_ISDIR (local->stbuf.ia_type)(local->stbuf.ia_type == IA_IFDIR)))
106 return 0;
107
108 priv = this->private;
109 trav = this->children;
110 rframe = copy_frame (frame);
111 if (!rframe) {
112 goto out;
113 }
114 rlocal = mem_get0 (this->local_pool);
115 if (!rlocal) {
116 goto out;
117 }
118 rframe->local = rlocal;
119 rlocal->call_count = priv->child_count;
120 loc_copy (&rlocal->loc, &local->loc);
121 memcpy (&rlocal->stbuf, &local->stbuf, sizeof (struct iatt));
122
123 xdata = dict_new ();
124 if (!xdata)
125 goto out;
126
127 ret = dict_set_static_bin (xdata, "gfid-req", local->stbuf.ia_gfid, 16);
128 if (ret)
129 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to set gfid-req", local->
loc.path); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 130, GF_LOG_WARNING, "%s: failed to set gfid-req", local->
loc.path); } while (0)
130 "%s: failed to set gfid-req", local->loc.path)do { do { if (0) printf ("%s: failed to set gfid-req", local->
loc.path); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 130, GF_LOG_WARNING, "%s: failed to set gfid-req", local->
loc.path); } while (0)
;
131
132 while (trav) {
133 if (IA_ISREG (local->stbuf.ia_type)(local->stbuf.ia_type == IA_IFREG)) {
134 STACK_WIND (rframe, stripe_sh_make_entry_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 139, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mknod_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mknod"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mknod)
; trav->xlator->fops->mknod (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, 0, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
135 trav->xlator, trav->xlator->fops->mknod,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 139, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mknod_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mknod"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mknod)
; trav->xlator->fops->mknod (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, 0, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
136 &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 139, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mknod_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mknod"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mknod)
; trav->xlator->fops->mknod (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, 0, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
137 st_mode_from_ia (local->stbuf.ia_prot,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 139, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mknod_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mknod"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mknod)
; trav->xlator->fops->mknod (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, 0, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
138 local->stbuf.ia_type),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 139, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mknod_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mknod"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mknod)
; trav->xlator->fops->mknod (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, 0, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
139 0, 0, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 139, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mknod_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mknod"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mknod)
; trav->xlator->fops->mknod (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, 0, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
140 }
141 if (IA_ISDIR (local->stbuf.ia_type)(local->stbuf.ia_type == IA_IFDIR)) {
142 STACK_WIND (rframe, stripe_sh_make_entry_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 147, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mkdir"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mkdir)
; trav->xlator->fops->mkdir (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, xdata); (*__glusterfs_this_location()
) = old_THIS; } while (0)
143 trav->xlator, trav->xlator->fops->mkdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 147, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mkdir"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mkdir)
; trav->xlator->fops->mkdir (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, xdata); (*__glusterfs_this_location()
) = old_THIS; } while (0)
144 &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 147, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mkdir"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mkdir)
; trav->xlator->fops->mkdir (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, xdata); (*__glusterfs_this_location()
) = old_THIS; } while (0)
145 st_mode_from_ia (local->stbuf.ia_prot,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 147, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mkdir"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mkdir)
; trav->xlator->fops->mkdir (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, xdata); (*__glusterfs_this_location()
) = old_THIS; } while (0)
146 local->stbuf.ia_type),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 147, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mkdir"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mkdir)
; trav->xlator->fops->mkdir (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, xdata); (*__glusterfs_this_location()
) = old_THIS; } while (0)
147 0, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 147, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_sh_make_entry_cbk; _new
->root = rframe->root; _new->this = trav->xlator;
_new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->mkdir"; _new->
unwind_to = "stripe_sh_make_entry_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (rframe->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->mkdir)
; trav->xlator->fops->mkdir (_new, trav->xlator, &
local->loc, st_mode_from_ia (local->stbuf.ia_prot, local
->stbuf.ia_type), 0, xdata); (*__glusterfs_this_location()
) = old_THIS; } while (0)
;
148 }
149 trav = trav->next;
150 }
151
152 if (xdata)
153 dict_unref (xdata);
154 return 0;
155
156out:
157 if (rframe)
158 STRIPE_STACK_DESTROY (rframe)do { stripe_local_t *__local = ((void*)0); __local = rframe->
local; rframe->local = ((void*)0); STACK_DESTROY (rframe->
root); if (__local) { stripe_local_wipe (__local); mem_put (__local
); } } while (0)
;
159 if (xdata)
160 dict_unref (xdata);
161
162 return 0;
163}
164
165
166int32_t
167stripe_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
168 int32_t op_ret, int32_t op_errno, inode_t *inode,
169 struct iatt *buf, dict_t *xdata, struct iatt *postparent)
170{
171 int32_t callcnt = 0;
172 stripe_local_t *local = NULL((void*)0);
173 call_frame_t *prev = NULL((void*)0);
174 int ret = 0;
175
176 if (!this || !frame || !frame->local || !cookie) {
177 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 177, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
178 goto out;
179 }
180
181 prev = cookie;
182 local = frame->local;
183
184 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
185 {
186 callcnt = --local->call_count;
187
188 if (op_ret == -1) {
189 if (op_errno != ENOENT2)
190 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 193, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
191 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 193, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
192 prev->this->name,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 193, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
193 strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 193, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
194 if (local->op_errno != ESTALE116)
195 local->op_errno = op_errno;
196 if (((op_errno != ENOENT2) && (op_errno != ENOTCONN107)) ||
197 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
198 local->failed = 1;
199 if (op_errno == ENOENT2)
200 local->entry_self_heal_needed = 1;
201 }
202
203 if (op_ret >= 0) {
204 local->op_ret = 0;
205 if (IA_ISREG (buf->ia_type)(buf->ia_type == IA_IFREG)) {
206 ret = stripe_ctx_handle (this, prev, local,
207 xdata);
208 if (ret)
209 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Error getting fctx info from" " dict"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 211, GF_LOG_ERROR, "Error getting fctx info from" " dict");
} while (0)
210 "Error getting fctx info from"do { do { if (0) printf ("Error getting fctx info from" " dict"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 211, GF_LOG_ERROR, "Error getting fctx info from" " dict");
} while (0)
211 " dict")do { do { if (0) printf ("Error getting fctx info from" " dict"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 211, GF_LOG_ERROR, "Error getting fctx info from" " dict");
} while (0)
;
212 }
213
214 if (FIRST_CHILD(this)(this->children->xlator) == prev->this) {
215 local->stbuf = *buf;
216 local->postparent = *postparent;
217 local->inode = inode_ref (inode);
218 if (xdata)
219 local->xdata = dict_ref (xdata);
220 if (local->xattr) {
221 stripe_aggregate_xattr (local->xdata,
222 local->xattr);
223 dict_unref (local->xattr);
224 local->xattr = NULL((void*)0);
225 }
226 }
227
228 if (!local->xdata && !local->xattr) {
229 local->xattr = dict_ref (xdata);
230 } else if (local->xdata) {
231 stripe_aggregate_xattr (local->xdata, xdata);
232 } else if (local->xattr) {
233 stripe_aggregate_xattr (local->xattr, xdata);
234 }
235
236 local->stbuf_blocks += buf->ia_blocks;
237 local->postparent_blocks += postparent->ia_blocks;
238
239 correct_file_size(buf, local->fctx, prev);
240
241 if (local->stbuf_size < buf->ia_size)
242 local->stbuf_size = buf->ia_size;
243 if (local->postparent_size < postparent->ia_size)
244 local->postparent_size = postparent->ia_size;
245
246 if (uuid_is_null (local->ia_gfid))
247 uuid_copy (local->ia_gfid, buf->ia_gfid);
248
249 /* Make sure the gfid on all the nodes are same */
250 if (uuid_compare (local->ia_gfid, buf->ia_gfid)) {
251 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: gfid different on subvolume %s"
, local->loc.path, prev->this->name); } while (0); _gf_log
(this->name, "stripe.c", __FUNCTION__, 253, GF_LOG_WARNING
, "%s: gfid different on subvolume %s", local->loc.path, prev
->this->name); } while (0)
252 "%s: gfid different on subvolume %s",do { do { if (0) printf ("%s: gfid different on subvolume %s"
, local->loc.path, prev->this->name); } while (0); _gf_log
(this->name, "stripe.c", __FUNCTION__, 253, GF_LOG_WARNING
, "%s: gfid different on subvolume %s", local->loc.path, prev
->this->name); } while (0)
253 local->loc.path, prev->this->name)do { do { if (0) printf ("%s: gfid different on subvolume %s"
, local->loc.path, prev->this->name); } while (0); _gf_log
(this->name, "stripe.c", __FUNCTION__, 253, GF_LOG_WARNING
, "%s: gfid different on subvolume %s", local->loc.path, prev
->this->name); } while (0)
;
254 }
255 }
256 }
257 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
258
259 if (!callcnt) {
260 if (local->op_ret == 0 && local->entry_self_heal_needed &&
261 !uuid_is_null (local->loc.inode->gfid))
262 stripe_entry_self_heal (frame, this, local);
263
264 if (local->failed)
265 local->op_ret = -1;
266
267 if (local->op_ret != -1) {
268 local->stbuf.ia_blocks = local->stbuf_blocks;
269 local->stbuf.ia_size = local->stbuf_size;
270 local->postparent.ia_blocks = local->postparent_blocks;
271 local->postparent.ia_size = local->postparent_size;
272 inode_ctx_put (local->inode, this,
273 (uint64_t) (long)local->fctx);
274 }
275
276 STRIPE_STACK_UNWIND (lookup, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 279, 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->inode
, &local->stbuf, local->xdata, &local->postparent
); (*__glusterfs_this_location()) = old_THIS; } while (0); if
(__local) { stripe_local_wipe(__local); mem_put (__local); }
} while (0)
277 local->op_errno, local->inode,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 279, 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->inode
, &local->stbuf, local->xdata, &local->postparent
); (*__glusterfs_this_location()) = old_THIS; } while (0); if
(__local) { stripe_local_wipe(__local); mem_put (__local); }
} while (0)
278 &local->stbuf, local->xdata,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 279, 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->inode
, &local->stbuf, local->xdata, &local->postparent
); (*__glusterfs_this_location()) = old_THIS; } while (0); if
(__local) { stripe_local_wipe(__local); mem_put (__local); }
} while (0)
279 &local->postparent)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 279, 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->inode
, &local->stbuf, local->xdata, &local->postparent
); (*__glusterfs_this_location()) = old_THIS; } while (0); if
(__local) { stripe_local_wipe(__local); mem_put (__local); }
} while (0)
;
280 }
281out:
282 return 0;
283}
284
285int32_t
286stripe_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
287 dict_t *xdata)
288{
289 stripe_local_t *local = NULL((void*)0);
290 xlator_list_t *trav = NULL((void*)0);
291 stripe_private_t *priv = NULL((void*)0);
292 int32_t op_errno = EINVAL22;
293 int64_t filesize = 0;
294 int ret = 0;
295 uint64_t tmpctx = 0;
296
297 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 297, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
298 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 298, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
299 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 299, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
300 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 300, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
301 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 301, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
302
303 priv = this->private;
304 trav = this->children;
305
306 /* Initialization */
307 local = mem_get0 (this->local_pool);
308 if (!local) {
309 op_errno = ENOMEM12;
310 goto err;
311 }
312 local->op_ret = -1;
313 frame->local = local;
314 loc_copy (&local->loc, loc);
315
316 inode_ctx_get (local->inode, this, &tmpctx)inode_ctx_get2(local->inode,this,&tmpctx,0);
317 if (tmpctx)
318 local->fctx = (stripe_fd_ctx_t*) (long)tmpctx;
319
320 /* quick-read friendly changes */
321 if (xdata && dict_get (xdata, GF_CONTENT_KEY"glusterfs.content")) {
322 ret = dict_get_int64 (xdata, GF_CONTENT_KEY"glusterfs.content", &filesize);
323 if (!ret && (filesize > priv->block_size))
324 dict_del (xdata, GF_CONTENT_KEY"glusterfs.content");
325 }
326
327 /* get stripe-size xattr on lookup. This would be required for
328 * open/read/write/pathinfo calls. Hence we send down the request
329 * even when type == IA_INVAL */
330
331 /*
332 * We aren't guaranteed to have xdata here. We need the format info for
333 * the file, so allocate xdata if necessary.
334 */
335 if (!xdata)
336 xdata = dict_new();
337 else
338 xdata = dict_ref(xdata);
339
340 if (xdata && (IA_ISREG (loc->inode->ia_type)(loc->inode->ia_type == IA_IFREG) ||
341 (loc->inode->ia_type == IA_INVAL))) {
342 ret = stripe_xattr_request_build (this, xdata, 8, 4, 4, 0);
343 if (ret)
344 gf_log (this->name , GF_LOG_ERROR, "Failed to build"do { do { if (0) printf ("Failed to build" " xattr request for %s"
, loc->path); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 345, GF_LOG_ERROR, "Failed to build" " xattr request for %s"
, loc->path); } while (0)
345 " xattr request for %s", loc->path)do { do { if (0) printf ("Failed to build" " xattr request for %s"
, loc->path); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 345, GF_LOG_ERROR, "Failed to build" " xattr request for %s"
, loc->path); } while (0)
;
346
347 }
348
349 /* Everytime in stripe lookup, all child nodes
350 should be looked up */
351 local->call_count = priv->child_count;
352 while (trav) {
353 STACK_WIND (frame, stripe_lookup_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 354, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->lookup_cbk) tmp_cbk = stripe_lookup_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->lookup"; _new->unwind_to = "stripe_lookup_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->lookup); trav->xlator->fops
->lookup (_new, trav->xlator, loc, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
354 trav->xlator->fops->lookup, 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", "stripe.c", __FUNCTION__, 354, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->lookup_cbk) tmp_cbk = stripe_lookup_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->lookup"; _new->unwind_to = "stripe_lookup_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->lookup); trav->xlator->fops
->lookup (_new, trav->xlator, loc, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
355 trav = trav->next;
356 }
357
358 dict_unref(xdata);
359
360 return 0;
361err:
362 STRIPE_STACK_UNWIND (lookup, frame, -1, op_errno, NULL, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 362, 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) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
;
363 return 0;
364}
365
366
367int32_t
368stripe_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
369 int32_t op_ret, int32_t op_errno, struct iatt *buf, dict_t *xdata)
370{
371 int32_t callcnt = 0;
372 stripe_local_t *local = NULL((void*)0);
373 call_frame_t *prev = NULL((void*)0);
374
375 if (!this || !frame || !frame->local || !cookie) {
376 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 376, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
377 goto out;
378 }
379 prev = cookie;
380 local = frame->local;
381
382 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
383 {
384 callcnt = --local->call_count;
385
386 if (op_ret == -1) {
387 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 389, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
388 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 389, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
389 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 389, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
390 local->op_errno = op_errno;
391 if ((op_errno != ENOENT2) ||
392 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
393 local->failed = 1;
394 }
395
396 if (op_ret == 0) {
397 local->op_ret = 0;
398
399 if (FIRST_CHILD(this)(this->children->xlator) == prev->this) {
400 local->stbuf = *buf;
401 }
402
403 local->stbuf_blocks += buf->ia_blocks;
404
405 correct_file_size(buf, local->fctx, prev);
406
407 if (local->stbuf_size < buf->ia_size)
408 local->stbuf_size = buf->ia_size;
409 }
410 }
411 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
412
413 if (!callcnt) {
414 if (local->failed)
415 local->op_ret = -1;
416
417 if (local->op_ret != -1) {
418 local->stbuf.ia_size = local->stbuf_size;
419 local->stbuf.ia_blocks = local->stbuf_blocks;
420 }
421
422 STRIPE_STACK_UNWIND (stat, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_stat_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", "stripe.c", __FUNCTION__
, 423, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_stat_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->
stbuf, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
423 local->op_errno, &local->stbuf, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_stat_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", "stripe.c", __FUNCTION__
, 423, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_stat_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->
stbuf, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
424 }
425out:
426 return 0;
427}
428
429int32_t
430stripe_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
431{
432 xlator_list_t *trav = NULL((void*)0);
433 stripe_local_t *local = NULL((void*)0);
434 stripe_private_t *priv = NULL((void*)0);
435 stripe_fd_ctx_t *fctx = NULL((void*)0);
436 int32_t op_errno = EINVAL22;
437
438 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 438, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
439 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 439, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
440 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 440, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
441 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 441, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
442 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 442, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
443
444 priv = this->private;
445 trav = this->children;
446
447 if (priv->first_child_down) {
448 op_errno = ENOTCONN107;
449 goto err;
450 }
451
452 /* Initialization */
453 local = mem_get0 (this->local_pool);
454 if (!local) {
455 op_errno = ENOMEM12;
456 goto err;
457 }
458 local->op_ret = -1;
459 frame->local = local;
460 local->call_count = priv->child_count;
461
462 if (IA_ISREG(loc->inode->ia_type)(loc->inode->ia_type == IA_IFREG)) {
463 inode_ctx_get(loc->inode, this, (uint64_t *) &fctx)inode_ctx_get2(loc->inode,this,(uint64_t *) &fctx,0);
464 if (!fctx)
465 goto err;
466 local->fctx = fctx;
467 }
468
469 while (trav) {
470 STACK_WIND (frame, stripe_stat_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 471, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->stat_cbk) tmp_cbk = stripe_stat_cbk; _new->root
= frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->stat"; _new->unwind_to = "stripe_stat_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->stat); trav->xlator->fops
->stat (_new, trav->xlator, loc, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
471 trav->xlator->fops->stat, loc, 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", "stripe.c", __FUNCTION__, 471, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->stat_cbk) tmp_cbk = stripe_stat_cbk; _new->root
= frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->stat"; _new->unwind_to = "stripe_stat_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->stat); trav->xlator->fops
->stat (_new, trav->xlator, loc, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
472 trav = trav->next;
473 }
474
475 return 0;
476
477err:
478 STRIPE_STACK_UNWIND (stat, frame, -1, op_errno, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_stat_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", "stripe.c", __FUNCTION__
, 478, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_stat_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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
479 return 0;
480}
481
482
483int32_t
484stripe_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
485 int32_t op_ret, int32_t op_errno, struct statvfs *stbuf, dict_t *xdata)
486{
487 stripe_local_t *local = NULL((void*)0);
488 int32_t callcnt = 0;
489
490 if (!this || !frame || !frame->local) {
491 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 491, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
492 goto out;
493 }
494 local = frame->local;
495
496 LOCK(&frame->lock)pthread_spin_lock (&frame->lock);
497 {
498 callcnt = --local->call_count;
499
500 if (op_ret && (op_errno != ENOTCONN107)) {
501 local->op_errno = op_errno;
502 }
503 if (op_ret == 0) {
504 struct statvfs *dict_buf = &local->statvfs_buf;
505 dict_buf->f_bsize = stbuf->f_bsize;
506 dict_buf->f_frsize = stbuf->f_frsize;
507 dict_buf->f_blocks += stbuf->f_blocks;
508 dict_buf->f_bfree += stbuf->f_bfree;
509 dict_buf->f_bavail += stbuf->f_bavail;
510 dict_buf->f_files += stbuf->f_files;
511 dict_buf->f_ffree += stbuf->f_ffree;
512 dict_buf->f_favail += stbuf->f_favail;
513 dict_buf->f_fsid = stbuf->f_fsid;
514 dict_buf->f_flag = stbuf->f_flag;
515 dict_buf->f_namemax = stbuf->f_namemax;
516 local->op_ret = 0;
517 }
518 }
519 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
520
521 if (!callcnt) {
522 STRIPE_STACK_UNWIND (statfs, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 523, 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->
statvfs_buf, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
523 local->op_errno, &local->statvfs_buf, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 523, 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->
statvfs_buf, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
524 }
525out:
526 return 0;
527}
528
529int32_t
530stripe_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
531{
532 stripe_local_t *local = NULL((void*)0);
533 xlator_list_t *trav = NULL((void*)0);
534 stripe_private_t *priv = NULL((void*)0);
535 int32_t op_errno = EINVAL22;
536
537 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 537, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
538 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 538, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
539 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 539, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
540
541 trav = this->children;
542 priv = this->private;
543
544 /* Initialization */
545 local = mem_get0 (this->local_pool);
546 if (!local) {
547 op_errno = ENOMEM12;
548 goto err;
549 }
550 local->op_ret = -1;
551 local->op_errno = ENOTCONN107;
552 frame->local = local;
553
554 local->call_count = priv->child_count;
555 while (trav) {
556 STACK_WIND (frame, stripe_statfs_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 557, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->statfs_cbk) tmp_cbk = stripe_statfs_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->statfs"; _new->unwind_to = "stripe_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->statfs); trav->xlator->fops
->statfs (_new, trav->xlator, loc, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
557 trav->xlator->fops->statfs, loc, 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", "stripe.c", __FUNCTION__, 557, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->statfs_cbk) tmp_cbk = stripe_statfs_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->statfs"; _new->unwind_to = "stripe_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->statfs); trav->xlator->fops
->statfs (_new, trav->xlator, loc, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
558 trav = trav->next;
559 }
560
561 return 0;
562err:
563 STRIPE_STACK_UNWIND (statfs, frame, -1, op_errno, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 563, 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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
564 return 0;
565}
566
567
568
569int32_t
570stripe_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
571 int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
572 struct iatt *postbuf, dict_t *xdata)
573{
574 int32_t callcnt = 0;
575 stripe_local_t *local = NULL((void*)0);
576 call_frame_t *prev = NULL((void*)0);
577
578 if (!this || !frame || !frame->local || !cookie) {
579 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 579, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
580 goto out;
581 }
582
583 prev = cookie;
584 local = frame->local;
585
586 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
587 {
588 callcnt = --local->call_count;
589
590 if (op_ret == -1) {
591 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 593, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
592 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 593, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
593 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 593, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
594 local->op_errno = op_errno;
595 if ((op_errno != ENOENT2) ||
596 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
597 local->failed = 1;
598 }
599
600 if (op_ret == 0) {
601 local->op_ret = 0;
602 if (FIRST_CHILD(this)(this->children->xlator) == prev->this) {
603 local->pre_buf = *prebuf;
604 local->post_buf = *postbuf;
605 }
606
607 local->prebuf_blocks += prebuf->ia_blocks;
608 local->postbuf_blocks += postbuf->ia_blocks;
609
610 correct_file_size(prebuf, local->fctx, prev);
611 correct_file_size(postbuf, local->fctx, prev);
612
613 if (local->prebuf_size < prebuf->ia_size)
614 local->prebuf_size = prebuf->ia_size;
615
616 if (local->postbuf_size < postbuf->ia_size)
617 local->postbuf_size = postbuf->ia_size;
618 }
619 }
620 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
621
622 if (!callcnt) {
623 if (local->failed)
624 local->op_ret = -1;
625
626 if (local->op_ret != -1) {
627 local->pre_buf.ia_blocks = local->prebuf_blocks;
628 local->pre_buf.ia_size = local->prebuf_size;
629 local->post_buf.ia_blocks = local->postbuf_blocks;
630 local->post_buf.ia_size = local->postbuf_size;
631 }
632
633 STRIPE_STACK_UNWIND (truncate, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_truncate_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", "stripe.c", __FUNCTION__
, 635, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_truncate_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->
pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
634 local->op_errno, &local->pre_buf,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_truncate_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", "stripe.c", __FUNCTION__
, 635, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_truncate_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->
pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
635 &local->post_buf, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_truncate_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", "stripe.c", __FUNCTION__
, 635, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_truncate_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->
pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
636 }
637out:
638 return 0;
639}
640
641int32_t
642stripe_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, dict_t *xdata)
643{
644 stripe_local_t *local = NULL((void*)0);
645 stripe_private_t *priv = NULL((void*)0);
646 stripe_fd_ctx_t *fctx = NULL((void*)0);
647 int32_t op_errno = EINVAL22;
648 int i, eof_idx;
649 off_t dest_offset, tmp_offset;
650
651 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 651, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
652 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 652, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
653 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 653, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
654 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 654, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
655 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 655, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
656
657 priv = this->private;
658
659 if (priv->first_child_down) {
660 op_errno = ENOTCONN107;
661 goto err;
662 }
663
664 /* Initialization */
665 local = mem_get0 (this->local_pool);
666 if (!local) {
667 op_errno = ENOMEM12;
668 goto err;
669 }
670 local->op_ret = -1;
671 frame->local = local;
672 local->call_count = priv->child_count;
673
674 inode_ctx_get(loc->inode, this, (uint64_t *) &fctx)inode_ctx_get2(loc->inode,this,(uint64_t *) &fctx,0);
675 if (!fctx) {
676 gf_log(this->name, GF_LOG_ERROR, "no stripe context")do { do { if (0) printf ("no stripe context"); } while (0); _gf_log
(this->name, "stripe.c", __FUNCTION__, 676, GF_LOG_ERROR,
"no stripe context"); } while (0)
;
677 op_errno = EINVAL22;
678 goto err;
679 }
680
681 local->fctx = fctx;
682 eof_idx = (offset / fctx->stripe_size) % fctx->stripe_count;
683
684 for (i = 0; i < fctx->stripe_count; i++) {
685 if (!fctx->xl_array[i]) {
686 gf_log(this->name, GF_LOG_ERROR,do { do { if (0) printf ("no xlator at index %d", i); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 687, GF_LOG_ERROR
, "no xlator at index %d", i); } while (0)
687 "no xlator at index %d", i)do { do { if (0) printf ("no xlator at index %d", i); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 687, GF_LOG_ERROR
, "no xlator at index %d", i); } while (0)
;
688 op_errno = EINVAL22;
689 goto err;
690 }
691
692 if (fctx->stripe_coalesce) {
693 /*
694 * The node that owns EOF is truncated to the exact
695 * coalesced offset. Nodes prior to this index should
696 * be rounded up to the size of the complete stripe,
697 * while nodes after this index should be rounded down
698 * to the size of the previous stripe.
699 */
700 if (i < eof_idx)
701 tmp_offset = roof(offset, fctx->stripe_size *((((offset)+(fctx->stripe_size * fctx->stripe_count)-1)
/((fctx->stripe_size * fctx->stripe_count)?(fctx->stripe_size
* fctx->stripe_count):1))*(fctx->stripe_size * fctx->
stripe_count))
702 fctx->stripe_count)((((offset)+(fctx->stripe_size * fctx->stripe_count)-1)
/((fctx->stripe_size * fctx->stripe_count)?(fctx->stripe_size
* fctx->stripe_count):1))*(fctx->stripe_size * fctx->
stripe_count))
;
703 else if (i > eof_idx)
704 tmp_offset = floor(offset, fctx->stripe_size *(((offset)/((fctx->stripe_size * fctx->stripe_count)?(fctx
->stripe_size * fctx->stripe_count):1))*(fctx->stripe_size
* fctx->stripe_count))
705 fctx->stripe_count)(((offset)/((fctx->stripe_size * fctx->stripe_count)?(fctx
->stripe_size * fctx->stripe_count):1))*(fctx->stripe_size
* fctx->stripe_count))
;
706 else
707 tmp_offset = offset;
708
709 dest_offset = coalesced_offset(tmp_offset,
710 fctx->stripe_size, fctx->stripe_count);
711 } else {
712 dest_offset = offset;
713 }
714
715 STACK_WIND(frame, stripe_truncate_cbk, fctx->xl_array[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", "stripe.c", __FUNCTION__, 717, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[i]->fops->truncate_cbk) tmp_cbk = stripe_truncate_cbk;
_new->root = frame->root; _new->this = fctx->xl_array
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[i]->fops->truncate"; _new
->unwind_to = "stripe_truncate_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
()) = fctx->xl_array[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, fctx->xl_array[i]->fops->truncate
); fctx->xl_array[i]->fops->truncate (_new, fctx->
xl_array[i], loc, dest_offset, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
716 fctx->xl_array[i]->fops->truncate, loc, dest_offset,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", "stripe.c", __FUNCTION__, 717, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[i]->fops->truncate_cbk) tmp_cbk = stripe_truncate_cbk;
_new->root = frame->root; _new->this = fctx->xl_array
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[i]->fops->truncate"; _new
->unwind_to = "stripe_truncate_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
()) = fctx->xl_array[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, fctx->xl_array[i]->fops->truncate
); fctx->xl_array[i]->fops->truncate (_new, fctx->
xl_array[i], loc, dest_offset, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
717 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", "stripe.c", __FUNCTION__, 717, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[i]->fops->truncate_cbk) tmp_cbk = stripe_truncate_cbk;
_new->root = frame->root; _new->this = fctx->xl_array
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[i]->fops->truncate"; _new
->unwind_to = "stripe_truncate_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
()) = fctx->xl_array[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, fctx->xl_array[i]->fops->truncate
); fctx->xl_array[i]->fops->truncate (_new, fctx->
xl_array[i], loc, dest_offset, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
718 }
719
720 return 0;
721err:
722 STRIPE_STACK_UNWIND (truncate, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_truncate_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", "stripe.c", __FUNCTION__
, 722, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_truncate_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
723 return 0;
724}
725
726
727int32_t
728stripe_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
729 int32_t op_ret, int32_t op_errno,
730 struct iatt *preop, struct iatt *postop, dict_t *xdata)
731{
732 int32_t callcnt = 0;
733 stripe_local_t *local = NULL((void*)0);
734 call_frame_t *prev = NULL((void*)0);
735
736 if (!this || !frame || !frame->local || !cookie) {
737 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 737, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
738 goto out;
739 }
740
741 prev = cookie;
742 local = frame->local;
743
744 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
745 {
746 callcnt = --local->call_count;
747
748 if (op_ret == -1) {
749 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 751, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
750 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 751, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
751 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 751, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
752 local->op_errno = op_errno;
753 if ((op_errno != ENOENT2) ||
754 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
755 local->failed = 1;
756 }
757
758 if (op_ret == 0) {
759 local->op_ret = 0;
760
761 if (FIRST_CHILD(this)(this->children->xlator) == prev->this) {
762 local->pre_buf = *preop;
763 local->post_buf = *postop;
764 }
765
766 local->prebuf_blocks += preop->ia_blocks;
767 local->postbuf_blocks += postop->ia_blocks;
768
769 correct_file_size(preop, local->fctx, prev);
770 correct_file_size(postop, local->fctx, prev);
771
772 if (local->prebuf_size < preop->ia_size)
773 local->prebuf_size = preop->ia_size;
774 if (local->postbuf_size < postop->ia_size)
775 local->postbuf_size = postop->ia_size;
776 }
777 }
778 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
779
780 if (!callcnt) {
781 if (local->failed)
782 local->op_ret = -1;
783
784 if (local->op_ret != -1) {
785 local->pre_buf.ia_blocks = local->prebuf_blocks;
786 local->pre_buf.ia_size = local->prebuf_size;
787 local->post_buf.ia_blocks = local->postbuf_blocks;
788 local->post_buf.ia_size = local->postbuf_size;
789 }
790
791 STRIPE_STACK_UNWIND (setattr, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_setattr_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", "stripe.c", __FUNCTION__
, 793, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_setattr_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->
pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
792 local->op_errno, &local->pre_buf,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_setattr_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", "stripe.c", __FUNCTION__
, 793, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_setattr_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->
pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
793 &local->post_buf, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_setattr_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", "stripe.c", __FUNCTION__
, 793, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_setattr_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->
pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
794 }
795out:
796 return 0;
797}
798
799
800int32_t
801stripe_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
802 struct iatt *stbuf, int32_t valid, dict_t *xdata)
803{
804 xlator_list_t *trav = NULL((void*)0);
805 stripe_local_t *local = NULL((void*)0);
806 stripe_private_t *priv = NULL((void*)0);
807 stripe_fd_ctx_t *fctx = NULL((void*)0);
808 int32_t op_errno = EINVAL22;
809
810 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 810, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
811 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 811, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
812 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 812, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
813 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 813, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
814 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 814, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
815
816 priv = this->private;
817 trav = this->children;
818
819 if (priv->first_child_down) {
820 op_errno = ENOTCONN107;
821 goto err;
822 }
823
824 /* Initialization */
825 local = mem_get0 (this->local_pool);
826 if (!local) {
827 op_errno = ENOMEM12;
828 goto err;
829 }
830 local->op_ret = -1;
831 frame->local = local;
832 if (!IA_ISDIR (loc->inode->ia_type)(loc->inode->ia_type == IA_IFDIR) &&
833 !IA_ISREG (loc->inode->ia_type)(loc->inode->ia_type == IA_IFREG)) {
834 local->call_count = 1;
835 STACK_WIND (frame, stripe_setattr_cbk, FIRST_CHILD (this),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", "stripe.c", __FUNCTION__, 837, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setattr_cbk) tmp_cbk = stripe_setattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->setattr"
; _new->unwind_to = "stripe_setattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setattr); (this->children->xlator
)->fops->setattr (_new, (this->children->xlator),
loc, stbuf, valid, ((void*)0)); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
836 FIRST_CHILD (this)->fops->setattr,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", "stripe.c", __FUNCTION__, 837, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setattr_cbk) tmp_cbk = stripe_setattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->setattr"
; _new->unwind_to = "stripe_setattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setattr); (this->children->xlator
)->fops->setattr (_new, (this->children->xlator),
loc, stbuf, valid, ((void*)0)); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
837 loc, stbuf, valid, 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", "stripe.c", __FUNCTION__, 837, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setattr_cbk) tmp_cbk = stripe_setattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->setattr"
; _new->unwind_to = "stripe_setattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setattr); (this->children->xlator
)->fops->setattr (_new, (this->children->xlator),
loc, stbuf, valid, ((void*)0)); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
;
838 return 0;
839 }
840
841 if (IA_ISREG(loc->inode->ia_type)(loc->inode->ia_type == IA_IFREG)) {
842 inode_ctx_get(loc->inode, this, (uint64_t *) &fctx)inode_ctx_get2(loc->inode,this,(uint64_t *) &fctx,0);
843 if (!fctx)
844 goto err;
845 local->fctx = fctx;
846 }
847
848 local->call_count = priv->child_count;
849 while (trav) {
850 STACK_WIND (frame, stripe_setattr_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", "stripe.c", __FUNCTION__, 852, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->setattr_cbk) tmp_cbk = stripe_setattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->setattr"; _new->unwind_to
= "stripe_setattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->setattr); trav->xlator->
fops->setattr (_new, trav->xlator, loc, stbuf, valid, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
851 trav->xlator, trav->xlator->fops->setattr,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", "stripe.c", __FUNCTION__, 852, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->setattr_cbk) tmp_cbk = stripe_setattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->setattr"; _new->unwind_to
= "stripe_setattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->setattr); trav->xlator->
fops->setattr (_new, trav->xlator, loc, stbuf, valid, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
852 loc, stbuf, valid, 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", "stripe.c", __FUNCTION__, 852, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->setattr_cbk) tmp_cbk = stripe_setattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->setattr"; _new->unwind_to
= "stripe_setattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->setattr); trav->xlator->
fops->setattr (_new, trav->xlator, loc, stbuf, valid, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
;
853 trav = trav->next;
854 }
855
856 return 0;
857err:
858 STRIPE_STACK_UNWIND (setattr, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_setattr_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", "stripe.c", __FUNCTION__
, 858, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_setattr_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
859 return 0;
860}
861
862
863int32_t
864stripe_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
865 struct iatt *stbuf, int32_t valid, dict_t *xdata)
866{
867 stripe_local_t *local = NULL((void*)0);
868 stripe_private_t *priv = NULL((void*)0);
869 xlator_list_t *trav = NULL((void*)0);
870 int32_t op_errno = EINVAL22;
871
872 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 872, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
873 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 873, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
874 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 874, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
875 VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "fd->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 875, GF_LOG_WARNING, "invalid argument: "
"fd->inode"); } while (0); goto err; } } while (0)
;
876
877 priv = this->private;
878 trav = this->children;
879
880 /* Initialization */
881 local = mem_get0 (this->local_pool);
882 if (!local) {
883 op_errno = ENOMEM12;
884 goto err;
885 }
886 local->op_ret = -1;
887 frame->local = local;
888 local->call_count = priv->child_count;
889
890 while (trav) {
891 STACK_WIND (frame, stripe_setattr_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 892, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fsetattr_cbk) tmp_cbk = stripe_setattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->fsetattr"; _new->unwind_to
= "stripe_setattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->fsetattr); trav->xlator->
fops->fsetattr (_new, trav->xlator, fd, stbuf, valid, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
892 trav->xlator->fops->fsetattr, fd, stbuf, valid, 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", "stripe.c", __FUNCTION__, 892, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fsetattr_cbk) tmp_cbk = stripe_setattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->fsetattr"; _new->unwind_to
= "stripe_setattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->fsetattr); trav->xlator->
fops->fsetattr (_new, trav->xlator, fd, stbuf, valid, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
;
893 trav = trav->next;
894 }
895
896 return 0;
897err:
898 STRIPE_STACK_UNWIND (fsetattr, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_fsetattr_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", "stripe.c", __FUNCTION__
, 898, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_fsetattr_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
899 return 0;
900}
901
902int32_t
903stripe_stack_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
904 int32_t op_ret, int32_t op_errno, struct iatt *buf,
905 struct iatt *preoldparent, struct iatt *postoldparent,
906 struct iatt *prenewparent, struct iatt *postnewparent,
907 dict_t *xdata)
908{
909 int32_t callcnt = 0;
910 stripe_local_t *local = NULL((void*)0);
911 call_frame_t *prev = NULL((void*)0);
912
913 if (!this || !frame || !frame->local || !cookie) {
914 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 914, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
915 goto out;
916 }
917
918 prev = cookie;
919 local = frame->local;
920
921 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
922 {
923 callcnt = --local->call_count;
924
925 if (op_ret == -1) {
926 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 928, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
927 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 928, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
928 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 928, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
929 local->op_errno = op_errno;
930 if ((op_errno != ENOENT2) ||
931 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
932 local->failed = 1;
933 }
934
935 if (op_ret == 0) {
936 local->op_ret = 0;
937
938 local->stbuf.ia_blocks += buf->ia_blocks;
939 local->preparent.ia_blocks += preoldparent->ia_blocks;
940 local->postparent.ia_blocks += postoldparent->ia_blocks;
941 local->pre_buf.ia_blocks += prenewparent->ia_blocks;
942 local->post_buf.ia_blocks += postnewparent->ia_blocks;
943
944 correct_file_size(buf, local->fctx, prev);
945
946 if (local->stbuf.ia_size < buf->ia_size)
947 local->stbuf.ia_size = buf->ia_size;
948
949 if (local->preparent.ia_size < preoldparent->ia_size)
950 local->preparent.ia_size = preoldparent->ia_size;
951
952 if (local->postparent.ia_size < postoldparent->ia_size)
953 local->postparent.ia_size = postoldparent->ia_size;
954
955 if (local->pre_buf.ia_size < prenewparent->ia_size)
956 local->pre_buf.ia_size = prenewparent->ia_size;
957
958 if (local->post_buf.ia_size < postnewparent->ia_size)
959 local->post_buf.ia_size = postnewparent->ia_size;
960 }
961 }
962 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
963
964 if (!callcnt) {
965 if (local->failed)
966 local->op_ret = -1;
967
968 STRIPE_STACK_UNWIND (rename, frame, local->op_ret, local->op_errno,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rename_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", "stripe.c", __FUNCTION__
, 971, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_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->
stbuf, &local->preparent, &local->postparent, &
local->pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
969 &local->stbuf, &local->preparent,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rename_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", "stripe.c", __FUNCTION__
, 971, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_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->
stbuf, &local->preparent, &local->postparent, &
local->pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
970 &local->postparent, &local->pre_buf,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rename_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", "stripe.c", __FUNCTION__
, 971, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_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->
stbuf, &local->preparent, &local->postparent, &
local->pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
971 &local->post_buf, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rename_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", "stripe.c", __FUNCTION__
, 971, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_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->
stbuf, &local->preparent, &local->postparent, &
local->pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
972 }
973out:
974 return 0;
975}
976
977int32_t
978stripe_first_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
979 int32_t op_ret, int32_t op_errno, struct iatt *buf,
980 struct iatt *preoldparent, struct iatt *postoldparent,
981 struct iatt *prenewparent, struct iatt *postnewparent,
982 dict_t *xdata)
983{
984 stripe_local_t *local = NULL((void*)0);
985 xlator_list_t *trav = NULL((void*)0);
986
987 if (!this || !frame || !frame->local) {
988 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 988, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
989 op_errno = EINVAL22;
990 goto unwind;
991 }
992
993 if (op_ret == -1) {
994 goto unwind;
995 }
996
997 local = frame->local;
998 trav = this->children;
999
1000 local->stbuf = *buf;
1001 local->preparent = *preoldparent;
1002 local->postparent = *postoldparent;
1003 local->pre_buf = *prenewparent;
1004 local->post_buf = *postnewparent;
1005
1006 local->op_ret = 0;
1007 local->call_count--;
1008
1009 trav = trav->next; /* Skip first child */
1010 while (trav) {
1011 STACK_WIND (frame, stripe_stack_rename_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", "stripe.c", __FUNCTION__, 1013, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->rename_cbk) tmp_cbk = stripe_stack_rename_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->rename"; _new->unwind_to =
"stripe_stack_rename_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->rename); trav->xlator->fops
->rename (_new, trav->xlator, &local->loc, &
local->loc2, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1012 trav->xlator, trav->xlator->fops->rename,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", "stripe.c", __FUNCTION__, 1013, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->rename_cbk) tmp_cbk = stripe_stack_rename_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->rename"; _new->unwind_to =
"stripe_stack_rename_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->rename); trav->xlator->fops
->rename (_new, trav->xlator, &local->loc, &
local->loc2, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1013 &local->loc, &local->loc2, 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", "stripe.c", __FUNCTION__, 1013, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->rename_cbk) tmp_cbk = stripe_stack_rename_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->rename"; _new->unwind_to =
"stripe_stack_rename_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->rename); trav->xlator->fops
->rename (_new, trav->xlator, &local->loc, &
local->loc2, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
;
1014 trav = trav->next;
1015 }
1016 return 0;
1017
1018unwind:
1019 STRIPE_STACK_UNWIND (rename, frame, -1, op_errno, buf, preoldparent,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rename_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", "stripe.c", __FUNCTION__
, 1020, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_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, buf, preoldparent, postoldparent, prenewparent
, postnewparent, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0); if (__local) { stripe_local_wipe(__local
); mem_put (__local); } } while (0)
1020 postoldparent, prenewparent, postnewparent, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rename_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", "stripe.c", __FUNCTION__
, 1020, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_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, buf, preoldparent, postoldparent, prenewparent
, postnewparent, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0); if (__local) { stripe_local_wipe(__local
); mem_put (__local); } } while (0)
;
1021 return 0;
1022}
1023
1024int32_t
1025stripe_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
1026 loc_t *newloc, dict_t *xdata)
1027{
1028 stripe_private_t *priv = NULL((void*)0);
1029 stripe_local_t *local = NULL((void*)0);
1030 xlator_list_t *trav = NULL((void*)0);
1031 stripe_fd_ctx_t *fctx = NULL((void*)0);
1032 int32_t op_errno = EINVAL22;
1033
1034 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1034, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
1035 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1035, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
1036 VALIDATE_OR_GOTO (oldloc, err)do { if (!oldloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "oldloc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1036, GF_LOG_WARNING, "invalid argument: " "oldloc"
); } while (0); goto err; } } while (0)
;
1037 VALIDATE_OR_GOTO (oldloc->path, err)do { if (!oldloc->path) { (*__errno_location ()) = 22; do {
do { if (0) printf ("invalid argument: " "oldloc->path");
} while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 1037, GF_LOG_WARNING, "invalid argument: "
"oldloc->path"); } while (0); goto err; } } while (0)
;
1038 VALIDATE_OR_GOTO (oldloc->inode, err)do { if (!oldloc->inode) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "oldloc->inode"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 1038, GF_LOG_WARNING, "invalid argument: "
"oldloc->inode"); } while (0); goto err; } } while (0)
;
1039 VALIDATE_OR_GOTO (newloc, err)do { if (!newloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "newloc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1039, GF_LOG_WARNING, "invalid argument: " "newloc"
); } while (0); goto err; } } while (0)
;
1040
1041 priv = this->private;
1042 trav = this->children;
1043
1044 /* If any one node is down, don't allow rename */
1045 if (priv->nodes_down) {
1046 op_errno = ENOTCONN107;
1047 goto err;
1048 }
1049
1050 /* Initialization */
1051 local = mem_get0 (this->local_pool);
1052 if (!local) {
1053 op_errno = ENOMEM12;
1054 goto err;
1055 }
1056 local->op_ret = -1;
1057 loc_copy (&local->loc, oldloc);
1058 loc_copy (&local->loc2, newloc);
1059
1060 local->call_count = priv->child_count;
1061
1062 if (IA_ISREG(oldloc->inode->ia_type)(oldloc->inode->ia_type == IA_IFREG)) {
1063 inode_ctx_get(oldloc->inode, this, (uint64_t *) &fctx)inode_ctx_get2(oldloc->inode,this,(uint64_t *) &fctx,0
)
;
1064 if (!fctx)
1065 goto err;
1066 local->fctx = fctx;
1067 }
1068
1069 frame->local = local;
1070
1071 STACK_WIND (frame, stripe_first_rename_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 1072, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->rename_cbk) tmp_cbk = stripe_first_rename_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->rename"; _new->unwind_to =
"stripe_first_rename_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->rename); trav->xlator->fops
->rename (_new, trav->xlator, oldloc, newloc, ((void*)0
)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1072 trav->xlator->fops->rename, oldloc, newloc, 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", "stripe.c", __FUNCTION__, 1072, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->rename_cbk) tmp_cbk = stripe_first_rename_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->rename"; _new->unwind_to =
"stripe_first_rename_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->rename); trav->xlator->fops
->rename (_new, trav->xlator, oldloc, newloc, ((void*)0
)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
1073
1074 return 0;
1075err:
1076 STRIPE_STACK_UNWIND (rename, frame, -1, op_errno, NULL, NULL, NULL,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rename_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", "stripe.c", __FUNCTION__
, 1077, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_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), ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
1077 NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rename_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", "stripe.c", __FUNCTION__
, 1077, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_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), ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
1078 return 0;
1079}
1080int32_t
1081stripe_first_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1082 int32_t op_ret, int32_t op_errno, struct iatt *preparent,
1083 struct iatt *postparent, dict_t *xdata)
1084{
1085 stripe_local_t *local = NULL((void*)0);
1086 call_frame_t *prev = NULL((void*)0);
1087
1088 if (!this || !frame || !frame->local || !cookie) {
1089 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1089, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1090 goto out;
1091 }
1092
1093 prev = cookie;
1094 local = frame->local;
1095
1096 if (op_ret == -1) {
1097 gf_log (this->name, GF_LOG_DEBUG, "%s returned %s",do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 1098, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
1098 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 1098, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
1099 goto out;
1100 }
1101 local->op_ret = 0;
1102 local->preparent = *preparent;
1103 local->postparent = *postparent;
1104 local->preparent_blocks += preparent->ia_blocks;
1105 local->postparent_blocks += postparent->ia_blocks;
1106
1107 STRIPE_STACK_UNWIND(unlink, frame, local->op_ret, local->op_errno,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_unlink_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", "stripe.c", __FUNCTION__
, 1108, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_unlink_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->
preparent, &local->postparent, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
1108 &local->preparent, &local->postparent, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_unlink_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", "stripe.c", __FUNCTION__
, 1108, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_unlink_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->
preparent, &local->postparent, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
1109 return 0;
1110out:
1111 STRIPE_STACK_UNWIND (unlink, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_unlink_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", "stripe.c", __FUNCTION__
, 1111, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_unlink_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
1112
1113 return 0;
1114}
1115
1116
1117
1118
1119int32_t
1120stripe_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1121 int32_t op_ret, int32_t op_errno, struct iatt *preparent,
1122 struct iatt *postparent, dict_t *xdata)
1123{
1124 int32_t callcnt = 0;
1125 stripe_local_t *local = NULL((void*)0);
1126 call_frame_t *prev = NULL((void*)0);
1127
1128 if (!this || !frame || !frame->local || !cookie) {
1129 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1129, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1130 goto out;
1131 }
1132
1133 prev = cookie;
1134 local = frame->local;
1135
1136 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
1137 {
1138 callcnt = --local->call_count;
1139
1140 if (op_ret == -1) {
1141 gf_log (this->name, GF_LOG_DEBUG, "%s returned %s",do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 1142, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
1142 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 1142, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
1143 local->op_errno = op_errno;
1144 if (op_errno != ENOENT2) {
1145 local->failed = 1;
1146 local->op_ret = op_ret;
1147 }
1148 }
1149 }
1150 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
1151
1152 if (callcnt == 1) {
1153 if (local->failed) {
1154 op_errno = local->op_errno;
1155 goto out;
1156 }
1157 STACK_WIND(frame, stripe_first_unlink_cbk, FIRST_CHILD (this),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", "stripe.c", __FUNCTION__, 1159, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->unlink_cbk) tmp_cbk = stripe_first_unlink_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->unlink"
; _new->unwind_to = "stripe_first_unlink_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->unlink); (this->children->xlator
)->fops->unlink (_new, (this->children->xlator), &
local->loc, local->xflag, local->xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1158 FIRST_CHILD (this)->fops->unlink, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 1159, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->unlink_cbk) tmp_cbk = stripe_first_unlink_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->unlink"
; _new->unwind_to = "stripe_first_unlink_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->unlink); (this->children->xlator
)->fops->unlink (_new, (this->children->xlator), &
local->loc, local->xflag, local->xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1159 local->xflag, local->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", "stripe.c", __FUNCTION__, 1159, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->unlink_cbk) tmp_cbk = stripe_first_unlink_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->unlink"
; _new->unwind_to = "stripe_first_unlink_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->unlink); (this->children->xlator
)->fops->unlink (_new, (this->children->xlator), &
local->loc, local->xflag, local->xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1160 }
1161 return 0;
1162out:
1163 STRIPE_STACK_UNWIND (unlink, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_unlink_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", "stripe.c", __FUNCTION__
, 1163, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_unlink_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
1164
1165 return 0;
1166}
1167
1168int32_t
1169stripe_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc,
1170 int xflag, dict_t *xdata)
1171{
1172 xlator_list_t *trav = NULL((void*)0);
1173 stripe_local_t *local = NULL((void*)0);
1174 stripe_private_t *priv = NULL((void*)0);
1175 int32_t op_errno = EINVAL22;
1176
1177 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1177, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
1178 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1178, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
1179 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1179, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
1180 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 1180, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
1181 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 1181, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
1182
1183 priv = this->private;
1184 trav = this->children;
1185
1186 if (priv->first_child_down) {
1187 op_errno = ENOTCONN107;
1188 goto err;
1189 }
1190
1191 /* Don't unlink a file if a node is down */
1192 if (priv->nodes_down) {
1193 op_errno = ENOTCONN107;
1194 goto err;
1195 }
1196
1197 /* Initialization */
1198 local = mem_get0 (this->local_pool);
1199 if (!local) {
1200 op_errno = ENOMEM12;
1201 goto err;
1202 }
1203 local->op_ret = -1;
1204 loc_copy (&local->loc, loc);
1205 local->xflag = xflag;
1206
1207 if (xdata)
1208 local->xdata = dict_ref (xdata);
1209
1210 frame->local = local;
1211 local->call_count = priv->child_count;
1212 trav = trav->next; /* Skip the first child */
1213
1214 while (trav) {
1215 STACK_WIND (frame, stripe_unlink_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", "stripe.c", __FUNCTION__, 1217, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_unlink_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->unlink"; _new->unwind_to = "stripe_unlink_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->unlink); trav->xlator->fops
->unlink (_new, trav->xlator, loc, xflag, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1216 trav->xlator, trav->xlator->fops->unlink,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", "stripe.c", __FUNCTION__, 1217, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_unlink_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->unlink"; _new->unwind_to = "stripe_unlink_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->unlink); trav->xlator->fops
->unlink (_new, trav->xlator, loc, xflag, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1217 loc, xflag, 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", "stripe.c", __FUNCTION__, 1217, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_unlink_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->unlink"; _new->unwind_to = "stripe_unlink_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->unlink); trav->xlator->fops
->unlink (_new, trav->xlator, loc, xflag, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1218 trav = trav->next;
1219 }
1220
1221 return 0;
1222err:
1223 STRIPE_STACK_UNWIND (unlink, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_unlink_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", "stripe.c", __FUNCTION__
, 1223, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_unlink_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
1224 return 0;
1225}
1226
1227
1228int32_t
1229stripe_first_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1230 int32_t op_ret, int32_t op_errno,struct iatt *preparent,
1231 struct iatt *postparent, dict_t *xdata)
1232{
1233 stripe_local_t *local = NULL((void*)0);
1234
1235 if (!this || !frame || !frame->local) {
1236 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1236, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1237 op_errno = EINVAL22;
1238 goto err;
1239 }
1240
1241 if (op_ret == -1) {
1242 goto err;
1243 }
1244
1245 local = frame->local;
1246 local->op_ret = 0;
1247
1248 local->call_count--; /* First child successful */
1249
1250 local->preparent = *preparent;
1251 local->postparent = *postparent;
1252 local->preparent_size = preparent->ia_size;
1253 local->postparent_size = postparent->ia_size;
1254 local->preparent_blocks += preparent->ia_blocks;
1255 local->postparent_blocks += postparent->ia_blocks;
1256
1257 STRIPE_STACK_UNWIND (rmdir, frame, local->op_ret, local->op_errno,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rmdir_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", "stripe.c", __FUNCTION__
, 1258, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rmdir_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->
preparent, &local->postparent, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
1258 &local->preparent, &local->postparent, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rmdir_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", "stripe.c", __FUNCTION__
, 1258, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rmdir_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->
preparent, &local->postparent, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
1259 return 0;
1260err:
1261 STRIPE_STACK_UNWIND (rmdir, frame, op_ret, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rmdir_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", "stripe.c", __FUNCTION__
, 1261, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rmdir_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, op_ret, op_errno, ((void*)0), ((void*)0), ((void*)
0)); (*__glusterfs_this_location()) = old_THIS; } while (0); if
(__local) { stripe_local_wipe(__local); mem_put (__local); }
} while (0)
;
1262 return 0;
1263
1264}
1265
1266int32_t
1267stripe_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1268 int32_t op_ret, int32_t op_errno, struct iatt *preparent,
1269 struct iatt *postparent, dict_t *xdata)
1270{
1271 int32_t callcnt = 0;
1272 stripe_local_t *local = NULL((void*)0);
1273 call_frame_t *prev = NULL((void*)0);
1274
1275 if (!this || !frame || !frame->local || !cookie) {
1276 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1276, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1277 goto out;
1278 }
1279
1280 prev = cookie;
1281 local = frame->local;
1282
1283 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
1284 {
1285 callcnt = --local->call_count;
1286
1287 if (op_ret == -1) {
1288 gf_log (this->name, GF_LOG_DEBUG, "%s returned %s",do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 1289, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
1289 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 1289, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
1290 if (op_errno != ENOENT2)
1291 local->failed = 1;
1292 }
1293 }
1294 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
1295
1296 if (callcnt == 1) {
1297 if (local->failed)
1298 goto out;
1299 STACK_WIND (frame, stripe_first_rmdir_cbk, FIRST_CHILD (this),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", "stripe.c", __FUNCTION__, 1301, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->rmdir_cbk) tmp_cbk = stripe_first_rmdir_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->rmdir";
_new->unwind_to = "stripe_first_rmdir_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->rmdir); (this->children->xlator
)->fops->rmdir (_new, (this->children->xlator), &
local->loc, local->flags, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1300 FIRST_CHILD (this)->fops->rmdir, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 1301, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->rmdir_cbk) tmp_cbk = stripe_first_rmdir_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->rmdir";
_new->unwind_to = "stripe_first_rmdir_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->rmdir); (this->children->xlator
)->fops->rmdir (_new, (this->children->xlator), &
local->loc, local->flags, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1301 local->flags, 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", "stripe.c", __FUNCTION__, 1301, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->rmdir_cbk) tmp_cbk = stripe_first_rmdir_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->rmdir";
_new->unwind_to = "stripe_first_rmdir_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->rmdir); (this->children->xlator
)->fops->rmdir (_new, (this->children->xlator), &
local->loc, local->flags, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1302 }
1303 return 0;
1304out:
1305 STRIPE_STACK_UNWIND (rmdir, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rmdir_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", "stripe.c", __FUNCTION__
, 1305, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rmdir_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
1306 return 0;
1307}
1308
1309int32_t
1310stripe_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, dict_t *xdata)
1311{
1312 xlator_list_t *trav = NULL((void*)0);
1313 stripe_local_t *local = NULL((void*)0);
1314 stripe_private_t *priv = NULL((void*)0);
1315 int32_t op_errno = EINVAL22;
1316
1317 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1317, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
1318 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1318, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
1319 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1319, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
1320 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 1320, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
1321 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 1321, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
1322
1323 priv = this->private;
1324 trav = this->children;
1325
1326 /* don't delete a directory if any of the subvolume is down */
1327 if (priv->nodes_down) {
1328 op_errno = ENOTCONN107;
1329 goto err;
1330 }
1331
1332 /* Initialization */
1333 local = mem_get0 (this->local_pool);
1334 if (!local) {
1335 op_errno = ENOMEM12;
1336 goto err;
1337 }
1338 local->op_ret = -1;
1339 frame->local = local;
1340 loc_copy (&local->loc, loc);
1341 local->flags = flags;
1342 local->call_count = priv->child_count;
1343 trav = trav->next; /* skip the first child */
1344
1345 while (trav) {
1346 STACK_WIND (frame, stripe_rmdir_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 1347, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->rmdir_cbk) tmp_cbk = stripe_rmdir_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->rmdir"; _new->unwind_to = "stripe_rmdir_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->rmdir); trav->xlator->fops
->rmdir (_new, trav->xlator, loc, flags, ((void*)0)); (
*__glusterfs_this_location()) = old_THIS; } while (0)
1347 trav->xlator->fops->rmdir, loc, flags, 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", "stripe.c", __FUNCTION__, 1347, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->rmdir_cbk) tmp_cbk = stripe_rmdir_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->rmdir"; _new->unwind_to = "stripe_rmdir_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->rmdir); trav->xlator->fops
->rmdir (_new, trav->xlator, loc, flags, ((void*)0)); (
*__glusterfs_this_location()) = old_THIS; } while (0)
;
1348 trav = trav->next;
1349 }
1350
1351 return 0;
1352err:
1353 STRIPE_STACK_UNWIND (rmdir, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_rmdir_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", "stripe.c", __FUNCTION__
, 1353, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rmdir_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
1354 return 0;
1355}
1356
1357
1358int32_t
1359stripe_mknod_ifreg_fail_unlink_cbk (call_frame_t *frame, void *cookie,
1360 xlator_t *this, int32_t op_ret,
1361 int32_t op_errno, struct iatt *preparent,
1362 struct iatt *postparent, dict_t *xdata)
1363{
1364 int32_t callcnt = 0;
1365 stripe_local_t *local = NULL((void*)0);
1366
1367 if (!this || !frame || !frame->local) {
1368 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1368, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1369 goto out;
1370 }
1371
1372 local = frame->local;
1373
1374 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
1375 {
1376 callcnt = --local->call_count;
1377 }
1378 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
1379
1380 if (!callcnt) {
1381 STRIPE_STACK_UNWIND (mknod, frame, local->op_ret, local->op_errno,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1383, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
1382 local->inode, &local->stbuf,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1383, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
1383 &local->preparent, &local->postparent, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1383, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
1384 }
1385out:
1386 return 0;
1387}
1388
1389
1390/**
1391 */
1392int32_t
1393stripe_mknod_ifreg_setxattr_cbk (call_frame_t *frame, void *cookie,
1394 xlator_t *this, int32_t op_ret,
1395 int32_t op_errno, dict_t *xdata)
1396{
1397 int32_t callcnt = 0;
1398 stripe_local_t *local = NULL((void*)0);
1399 stripe_private_t *priv = NULL((void*)0);
1400 xlator_list_t *trav = NULL((void*)0);
1401 call_frame_t *prev = NULL((void*)0);
1402
1403 if (!this || !frame || !frame->local || !cookie) {
1404 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1404, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1405 goto out;
1406 }
1407
1408 prev = cookie;
1409 priv = this->private;
1410 local = frame->local;
1411
1412 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
1413 {
1414 callcnt = --local->call_count;
1415
1416 if (op_ret == -1) {
1417 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1419, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
1418 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1419, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
1419 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1419, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
1420 local->op_ret = -1;
1421 local->op_errno = op_errno;
1422 }
1423 }
1424 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
1425
1426 if (!callcnt) {
1427 if (local->op_ret == -1) {
1428 local->call_count = priv->child_count;
1429 while (trav) {
1430 STACK_WIND (frame,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", "stripe.c", __FUNCTION__, 1434, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_mknod_ifreg_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_mknod_ifreg_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1431 stripe_mknod_ifreg_fail_unlink_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", "stripe.c", __FUNCTION__, 1434, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_mknod_ifreg_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_mknod_ifreg_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1432 trav->xlator,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", "stripe.c", __FUNCTION__, 1434, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_mknod_ifreg_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_mknod_ifreg_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1433 trav->xlator->fops->unlink,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", "stripe.c", __FUNCTION__, 1434, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_mknod_ifreg_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_mknod_ifreg_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1434 &local->loc, 0, 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", "stripe.c", __FUNCTION__, 1434, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_mknod_ifreg_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_mknod_ifreg_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1435 trav = trav->next;
1436 }
1437 return 0;
1438 }
1439
1440 STRIPE_STACK_UNWIND (mknod, frame, local->op_ret, local->op_errno,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1442, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
1441 local->inode, &local->stbuf,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1442, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
1442 &local->preparent, &local->postparent, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1442, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
1443 }
1444out:
1445 return 0;
1446}
1447
1448int32_t
1449stripe_mknod_ifreg_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1450 int32_t op_ret, int32_t op_errno, inode_t *inode,
1451 struct iatt *buf, struct iatt *preparent,
1452 struct iatt *postparent, dict_t *xdata)
1453{
1454 int32_t callcnt = 0;
1455 stripe_local_t *local = NULL((void*)0);
1456 stripe_private_t *priv = NULL((void*)0);
1457 call_frame_t *prev = NULL((void*)0);
1458 xlator_list_t *trav = NULL((void*)0);
1459
1460 if (!this || !frame || !frame->local || !cookie) {
1461 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1461, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1462 goto out;
1463 }
1464
1465 prev = cookie;
1466 priv = this->private;
1467 local = frame->local;
1468
1469 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
1470 {
1471 callcnt = --local->call_count;
1472
1473 if (op_ret == -1) {
1474 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1476, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
1475 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1476, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
1476 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1476, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
1477 if ((op_errno != ENOENT2) ||
1478 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
1479 local->failed = 1;
1480 local->op_errno = op_errno;
1481 }
1482 if (op_ret >= 0) {
1483 local->op_ret = op_ret;
1484
1485 /* Can be used as a mechanism to understand if mknod
1486 was successful in at least one place */
1487 if (uuid_is_null (local->ia_gfid))
1488 uuid_copy (local->ia_gfid, buf->ia_gfid);
1489
1490 if (stripe_ctx_handle(this, prev, local, xdata))
1491 gf_log(this->name, GF_LOG_ERROR,do { do { if (0) printf ("Error getting fctx info from dict")
; } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 1492, GF_LOG_ERROR, "Error getting fctx info from dict"); }
while (0)
1492 "Error getting fctx info from dict")do { do { if (0) printf ("Error getting fctx info from dict")
; } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 1492, GF_LOG_ERROR, "Error getting fctx info from dict"); }
while (0)
;
1493
1494 local->stbuf_blocks += buf->ia_blocks;
1495 local->preparent_blocks += preparent->ia_blocks;
1496 local->postparent_blocks += postparent->ia_blocks;
1497
1498 correct_file_size(buf, local->fctx, prev);
1499
1500 if (local->stbuf_size < buf->ia_size)
1501 local->stbuf_size = buf->ia_size;
1502 if (local->preparent_size < preparent->ia_size)
1503 local->preparent_size = preparent->ia_size;
1504 if (local->postparent_size < postparent->ia_size)
1505 local->postparent_size = postparent->ia_size;
1506 }
1507 }
1508 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
1509
1510 if (!callcnt) {
1511 if (local->failed)
1512 local->op_ret = -1;
1513
1514 if ((local->op_ret == -1) && !uuid_is_null (local->ia_gfid)) {
1515 /* ia_gfid set means, at least on one node 'mknod'
1516 is successful */
1517 local->call_count = priv->child_count;
1518 trav = this->children;
1519 while (trav) {
1520 STACK_WIND (frame,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", "stripe.c", __FUNCTION__, 1524, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_mknod_ifreg_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_mknod_ifreg_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1521 stripe_mknod_ifreg_fail_unlink_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", "stripe.c", __FUNCTION__, 1524, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_mknod_ifreg_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_mknod_ifreg_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1522 trav->xlator,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", "stripe.c", __FUNCTION__, 1524, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_mknod_ifreg_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_mknod_ifreg_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1523 trav->xlator->fops->unlink,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", "stripe.c", __FUNCTION__, 1524, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_mknod_ifreg_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_mknod_ifreg_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1524 &local->loc, 0, 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", "stripe.c", __FUNCTION__, 1524, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_mknod_ifreg_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_mknod_ifreg_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1525 trav = trav->next;
1526 }
1527 return 0;
1528 }
1529
1530
1531 if (local->op_ret != -1) {
1532 local->preparent.ia_blocks = local->preparent_blocks;
1533 local->preparent.ia_size = local->preparent_size;
1534 local->postparent.ia_blocks = local->postparent_blocks;
1535 local->postparent.ia_size = local->postparent_size;
1536 local->stbuf.ia_size = local->stbuf_size;
1537 local->stbuf.ia_blocks = local->stbuf_blocks;
1538 inode_ctx_put (local->inode, this,
1539 (uint64_t)(long) local->fctx);
1540
1541 }
1542 STRIPE_STACK_UNWIND (mknod, frame, local->op_ret, local->op_errno,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1544, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
1543 local->inode, &local->stbuf,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1544, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
1544 &local->preparent, &local->postparent, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1544, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
1545 }
1546out:
1547 return 0;
1548}
1549
1550
1551int32_t
1552stripe_mknod_first_ifreg_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1553 int32_t op_ret, int32_t op_errno, inode_t *inode,
1554 struct iatt *buf, struct iatt *preparent,
1555 struct iatt *postparent, dict_t *xdata)
1556{
1557 stripe_local_t *local = NULL((void*)0);
1558 stripe_private_t *priv = NULL((void*)0);
1559 call_frame_t *prev = NULL((void*)0);
1560 xlator_list_t *trav = NULL((void*)0);
1561 int i = 1;
1562 dict_t *dict = NULL((void*)0);
1563 int ret = 0;
1564 int need_unref = 0;
1565
1566 if (!this || !frame || !frame->local || !cookie) {
1567 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1567, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1568 goto out;
1569 }
1570
1571 prev = cookie;
1572 priv = this->private;
1573 local = frame->local;
1574 trav = this->children;
1575
1576 local->call_count--;
1577
1578 if (op_ret == -1) {
1579 gf_log (this->name, GF_LOG_DEBUG, "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1580, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
1580 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1580, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
1581 local->failed = 1;
1582 local->op_errno = op_errno;
1583 goto out;
1584 }
1585
1586 local->op_ret = op_ret;
1587
1588 local->stbuf = *buf;
1589 local->preparent = *preparent;
1590 local->postparent = *postparent;
1591
1592 if (uuid_is_null (local->ia_gfid))
1593 uuid_copy (local->ia_gfid, buf->ia_gfid);
1594 local->preparent.ia_blocks = local->preparent_blocks;
1595 local->preparent.ia_size = local->preparent_size;
1596 local->postparent.ia_blocks = local->postparent_blocks;
1597 local->postparent.ia_size = local->postparent_size;
1598 local->stbuf.ia_size = local->stbuf_size;
1599 local->stbuf.ia_blocks = local->stbuf_blocks;
1600
1601 trav = trav->next;
1602 while (trav) {
1603 if (priv->xattr_supported) {
1604 dict = dict_new ();
1605 if (!dict) {
1606 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to allocate dict %s", local->
loc.path); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 1607, GF_LOG_ERROR, "failed to allocate dict %s", local->
loc.path); } while (0)
1607 "failed to allocate dict %s", local->loc.path)do { do { if (0) printf ("failed to allocate dict %s", local->
loc.path); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 1607, GF_LOG_ERROR, "failed to allocate dict %s", local->
loc.path); } while (0)
;
1608 }
1609 need_unref = 1;
1610
1611 dict_copy (local->xattr, dict);
1612
1613 ret = stripe_xattr_request_build (this, dict,
1614 local->stripe_size,
1615 priv->child_count, i,
1616 priv->coalesce);
1617 if (ret)
1618 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to build xattr request"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 1619,
GF_LOG_ERROR, "Failed to build xattr request"); } while (0)
1619 "Failed to build xattr request")do { do { if (0) printf ("Failed to build xattr request"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 1619,
GF_LOG_ERROR, "Failed to build xattr request"); } while (0)
;
1620
1621 } else {
1622 dict = local->xattr;
1623 }
1624
1625 STACK_WIND (frame, stripe_mknod_ifreg_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", "stripe.c", __FUNCTION__, 1627, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mknod_cbk) tmp_cbk = stripe_mknod_ifreg_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->mknod"; _new->unwind_to =
"stripe_mknod_ifreg_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->mknod); trav->xlator->fops
->mknod (_new, trav->xlator, &local->loc, local->
mode, local->rdev, 0, dict); (*__glusterfs_this_location()
) = old_THIS; } while (0)
1626 trav->xlator, trav->xlator->fops->mknod,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", "stripe.c", __FUNCTION__, 1627, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mknod_cbk) tmp_cbk = stripe_mknod_ifreg_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->mknod"; _new->unwind_to =
"stripe_mknod_ifreg_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->mknod); trav->xlator->fops
->mknod (_new, trav->xlator, &local->loc, local->
mode, local->rdev, 0, dict); (*__glusterfs_this_location()
) = old_THIS; } while (0)
1627 &local->loc, local->mode, local->rdev, 0, dict)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", "stripe.c", __FUNCTION__, 1627, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mknod_cbk) tmp_cbk = stripe_mknod_ifreg_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->mknod"; _new->unwind_to =
"stripe_mknod_ifreg_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->mknod); trav->xlator->fops
->mknod (_new, trav->xlator, &local->loc, local->
mode, local->rdev, 0, dict); (*__glusterfs_this_location()
) = old_THIS; } while (0)
;
1628 trav = trav->next;
1629 i++;
1630
1631 if (dict && need_unref)
1632 dict_unref (dict);
1633 }
1634
1635 return 0;
1636
1637out:
1638
1639 STRIPE_STACK_UNWIND (mknod, frame, op_ret, op_errno, NULL, NULL, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1639, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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, op_ret, op_errno, ((void*)0), ((void*)0), ((void*)
0), ((void*)0), ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0); if (__local) { stripe_local_wipe(__local
); mem_put (__local); } } while (0)
;
1640 return 0;
1641}
1642
1643
1644int32_t
1645stripe_single_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1646 int32_t op_ret, int32_t op_errno, inode_t *inode,
1647 struct iatt *buf, struct iatt *preparent,
1648 struct iatt *postparent, dict_t *xdata)
1649{
1650 STRIPE_STACK_UNWIND (mknod, frame, op_ret, op_errno, inode, buf,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1651, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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, op_ret, op_errno, inode, buf, preparent, postparent
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
1651 preparent, postparent, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1651, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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, op_ret, op_errno, inode, buf, preparent, postparent
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
;
1652 return 0;
1653}
1654
1655
1656int
1657stripe_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
1658 dev_t rdev, mode_t umask, dict_t *xdata)
1659{
1660 stripe_private_t *priv = NULL((void*)0);
1661 stripe_local_t *local = NULL((void*)0);
1662 int32_t op_errno = EINVAL22;
1663 int32_t i = 0;
1664 dict_t *dict = NULL((void*)0);
1665 int ret = 0;
1666 int need_unref = 0;
1667
1668 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1668, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
1669 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1669, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
1670 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1670, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
1671 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 1671, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
1672 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 1672, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
1673
1674 priv = this->private;
1675
1676 if (priv->first_child_down) {
1677 op_errno = ENOTCONN107;
1678 goto err;
1679 }
1680
1681 if (S_ISREG(mode)((((mode)) & 0170000) == (0100000))) {
1682 /* NOTE: on older kernels (older than 2.6.9),
1683 creat() fops is sent as mknod() + open(). Hence handling
1684 S_IFREG files is necessary */
1685 if (priv->nodes_down) {
1686 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Some node down, returning EIO"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 1687,
GF_LOG_WARNING, "Some node down, returning EIO"); } while (0
)
1687 "Some node down, returning EIO")do { do { if (0) printf ("Some node down, returning EIO"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 1687,
GF_LOG_WARNING, "Some node down, returning EIO"); } while (0
)
;
1688 op_errno = EIO5;
1689 goto err;
1690 }
1691
1692 /* Initialization */
1693 local = mem_get0 (this->local_pool);
1694 if (!local) {
1695 op_errno = ENOMEM12;
1696 goto err;
1697 }
1698 local->op_ret = -1;
1699 local->op_errno = ENOTCONN107;
1700 local->stripe_size = stripe_get_matching_bs (loc->path, priv);
1701 frame->local = local;
1702 local->inode = inode_ref (loc->inode);
1703 loc_copy (&local->loc, loc);
1704 local->xattr = dict_copy_with_ref (xdata, NULL((void*)0));
1705 local->mode = mode;
1706 local->umask = umask;
1707 local->rdev = rdev;
1708
1709 /* Everytime in stripe lookup, all child nodes should
1710 be looked up */
1711 local->call_count = priv->child_count;
1712
1713 if (priv->xattr_supported) {
1714 dict = dict_new ();
1715 if (!dict) {
1716 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to allocate dict %s", loc->
path); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 1717, GF_LOG_ERROR, "failed to allocate dict %s", loc->path
); } while (0)
1717 "failed to allocate dict %s", loc->path)do { do { if (0) printf ("failed to allocate dict %s", loc->
path); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 1717, GF_LOG_ERROR, "failed to allocate dict %s", loc->path
); } while (0)
;
1718 }
1719 need_unref = 1;
1720
1721 dict_copy (xdata, dict);
1722
1723 ret = stripe_xattr_request_build (this, dict,
1724 local->stripe_size,
1725 priv->child_count,
1726 i, priv->coalesce);
1727 if (ret)
1728 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to build xattr request"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 1729,
GF_LOG_ERROR, "failed to build xattr request"); } while (0)
1729 "failed to build xattr request")do { do { if (0) printf ("failed to build xattr request"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 1729,
GF_LOG_ERROR, "failed to build xattr request"); } while (0)
;
1730 } else {
1731 dict = xdata;
1732 }
1733
1734 STACK_WIND (frame, stripe_mknod_first_ifreg_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", "stripe.c", __FUNCTION__, 1736, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->mknod_cbk) tmp_cbk = stripe_mknod_first_ifreg_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->mknod";
_new->unwind_to = "stripe_mknod_first_ifreg_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->mknod); (this->children->xlator
)->fops->mknod (_new, (this->children->xlator), loc
, mode, rdev, umask, dict); (*__glusterfs_this_location()) = old_THIS
; } while (0)
1735 FIRST_CHILD (this), FIRST_CHILD (this)->fops->mknod,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", "stripe.c", __FUNCTION__, 1736, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->mknod_cbk) tmp_cbk = stripe_mknod_first_ifreg_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->mknod";
_new->unwind_to = "stripe_mknod_first_ifreg_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->mknod); (this->children->xlator
)->fops->mknod (_new, (this->children->xlator), loc
, mode, rdev, umask, dict); (*__glusterfs_this_location()) = old_THIS
; } while (0)
1736 loc, mode, rdev, umask, dict)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", "stripe.c", __FUNCTION__, 1736, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->mknod_cbk) tmp_cbk = stripe_mknod_first_ifreg_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->mknod";
_new->unwind_to = "stripe_mknod_first_ifreg_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->mknod); (this->children->xlator
)->fops->mknod (_new, (this->children->xlator), loc
, mode, rdev, umask, dict); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
1737
1738 if (dict && need_unref)
1739 dict_unref (dict);
1740 return 0;
1741 }
1742
1743 STACK_WIND (frame, stripe_single_mknod_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", "stripe.c", __FUNCTION__, 1745, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->mknod_cbk) tmp_cbk = stripe_single_mknod_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->mknod"; _new
->unwind_to = "stripe_single_mknod_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->mknod); (this->children->xlator
)->fops->mknod (_new, (this->children->xlator), loc
, mode, rdev, umask, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1744 FIRST_CHILD(this), FIRST_CHILD(this)->fops->mknod,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", "stripe.c", __FUNCTION__, 1745, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->mknod_cbk) tmp_cbk = stripe_single_mknod_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->mknod"; _new
->unwind_to = "stripe_single_mknod_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->mknod); (this->children->xlator
)->fops->mknod (_new, (this->children->xlator), loc
, mode, rdev, umask, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
1745 loc, mode, rdev, umask, 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", "stripe.c", __FUNCTION__, 1745, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->mknod_cbk) tmp_cbk = stripe_single_mknod_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->mknod"; _new
->unwind_to = "stripe_single_mknod_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->mknod); (this->children->xlator
)->fops->mknod (_new, (this->children->xlator), loc
, mode, rdev, umask, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
;
1746
1747 return 0;
1748err:
1749 STRIPE_STACK_UNWIND (mknod, frame, -1, op_errno, NULL, NULL, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mknod_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", "stripe.c", __FUNCTION__
, 1749, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mknod_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), ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
1750 return 0;
1751}
1752
1753
1754int32_t
1755stripe_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1756 int32_t op_ret, int32_t op_errno, inode_t *inode,
1757 struct iatt *buf, struct iatt *preparent,
1758 struct iatt *postparent, dict_t *xdata)
1759{
1760 int32_t callcnt = 0;
1761 stripe_local_t *local = NULL((void*)0);
1762 call_frame_t *prev = NULL((void*)0);
1763
1764 if (!this || !frame || !frame->local || !cookie) {
1765 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1765, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1766 goto out;
1767 }
1768
1769 prev = cookie;
1770 local = frame->local;
1771
1772 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
1773 {
1774 callcnt = --local->call_count;
1775
1776 if (op_ret == -1) {
1777 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1779, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
1778 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1779, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
1779 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1779, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
1780 local->op_errno = op_errno;
1781 if ((op_errno != ENOENT2) ||
1782 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
1783 local->failed = 1;
1784 }
1785
1786 if (op_ret >= 0) {
1787 local->op_ret = 0;
1788
1789 local->stbuf_blocks += buf->ia_blocks;
1790 local->preparent_blocks += preparent->ia_blocks;
1791 local->postparent_blocks += postparent->ia_blocks;
1792
1793 if (local->stbuf_size < buf->ia_size)
1794 local->stbuf_size = buf->ia_size;
1795 if (local->preparent_size < preparent->ia_size)
1796 local->preparent_size = preparent->ia_size;
1797 if (local->postparent_size < postparent->ia_size)
1798 local->postparent_size = postparent->ia_size;
1799 }
1800 }
1801 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
1802
1803 if (!callcnt) {
1804 if (local->failed != -1) {
1805 local->preparent.ia_blocks = local->preparent_blocks;
1806 local->preparent.ia_size = local->preparent_size;
1807 local->postparent.ia_blocks = local->postparent_blocks;
1808 local->postparent.ia_size = local->postparent_size;
1809 local->stbuf.ia_size = local->stbuf_size;
1810 local->stbuf.ia_blocks = local->stbuf_blocks;
1811 }
1812 STRIPE_STACK_UNWIND (mkdir, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mkdir_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", "stripe.c", __FUNCTION__
, 1815, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mkdir_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
1813 local->op_errno, local->inode,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mkdir_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", "stripe.c", __FUNCTION__
, 1815, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mkdir_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
1814 &local->stbuf, &local->preparent,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mkdir_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", "stripe.c", __FUNCTION__
, 1815, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mkdir_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
1815 &local->postparent, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mkdir_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", "stripe.c", __FUNCTION__
, 1815, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mkdir_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
1816 }
1817out:
1818 return 0;
1819}
1820
1821
1822int32_t
1823stripe_first_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1824 int32_t op_ret, int32_t op_errno, inode_t *inode,
1825 struct iatt *buf, struct iatt *preparent,
1826 struct iatt *postparent, dict_t *xdata)
1827{
1828 stripe_local_t *local = NULL((void*)0);
1829 call_frame_t *prev = NULL((void*)0);
1830 xlator_list_t *trav = NULL((void*)0);
1831
1832 if (!this || !frame || !frame->local || !cookie) {
1833 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1833, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1834 goto out;
1835 }
1836
1837 prev = cookie;
1838 local = frame->local;
1839 trav = this->children;
1840
1841 local->call_count--; /* first child is successful */
1842 trav = trav->next; /* skip first child */
1843
1844 if (op_ret == -1) {
1845 gf_log (this->name, GF_LOG_DEBUG, "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1846, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
1846 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1846, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
1847 local->op_errno = op_errno;
1848 goto out;
1849 }
1850
1851 local->op_ret = 0;
1852
1853 local->inode = inode_ref (inode);
1854 local->stbuf = *buf;
1855 local->postparent = *postparent;
1856 local->preparent = *preparent;
1857
1858 local->stbuf_blocks += buf->ia_blocks;
1859 local->preparent_blocks += preparent->ia_blocks;
1860 local->postparent_blocks += postparent->ia_blocks;
1861
1862 local->stbuf_size = buf->ia_size;
1863 local->preparent_size = preparent->ia_size;
1864 local->postparent_size = postparent->ia_size;
1865
1866 while (trav) {
1867 STACK_WIND (frame, stripe_mkdir_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 1869, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_mkdir_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->mkdir"; _new->unwind_to = "stripe_mkdir_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->mkdir); trav->xlator->fops
->mkdir (_new, trav->xlator, &local->loc, local->
mode, local->umask, local->xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1868 trav->xlator->fops->mkdir, &local->loc, local->mode,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", "stripe.c", __FUNCTION__, 1869, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_mkdir_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->mkdir"; _new->unwind_to = "stripe_mkdir_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->mkdir); trav->xlator->fops
->mkdir (_new, trav->xlator, &local->loc, local->
mode, local->umask, local->xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1869 local->umask, local->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", "stripe.c", __FUNCTION__, 1869, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_mkdir_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->mkdir"; _new->unwind_to = "stripe_mkdir_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->mkdir); trav->xlator->fops
->mkdir (_new, trav->xlator, &local->loc, local->
mode, local->umask, local->xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1870 trav = trav->next;
1871 }
1872 return 0;
1873out:
1874 STRIPE_STACK_UNWIND (mkdir, frame, -1, op_errno, NULL, NULL, NULL,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mkdir_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", "stripe.c", __FUNCTION__
, 1875, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mkdir_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), ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
1875 NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mkdir_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", "stripe.c", __FUNCTION__
, 1875, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mkdir_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), ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
1876
1877 return 0;
1878
1879}
1880
1881
1882int
1883stripe_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
1884 mode_t umask, dict_t *xdata)
1885{
1886 stripe_private_t *priv = NULL((void*)0);
1887 stripe_local_t *local = NULL((void*)0);
1888 xlator_list_t *trav = NULL((void*)0);
1889 int32_t op_errno = 1;
1890
1891 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1891, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
1892 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1892, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
1893 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 1893, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
1894 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 1894, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
1895 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 1895, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
1896
1897 priv = this->private;
1898 trav = this->children;
1899
1900 if (priv->first_child_down) {
1901 op_errno = ENOTCONN107;
1902 goto err;
1903 }
1904
1905 /* Initialization */
1906 local = mem_get0 (this->local_pool);
1907 if (!local) {
1908 op_errno = ENOMEM12;
1909 goto err;
1910 }
1911 local->op_ret = -1;
1912 local->call_count = priv->child_count;
1913 if (xdata)
1914 local->xdata = dict_ref (xdata);
1915 local->mode = mode;
1916 local->umask = umask;
1917 loc_copy (&local->loc, loc);
1918 frame->local = local;
1919
1920 /* Everytime in stripe lookup, all child nodes should be looked up */
1921 STACK_WIND (frame, stripe_first_mkdir_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 1922, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_first_mkdir_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->mkdir"; _new->unwind_to =
"stripe_first_mkdir_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->mkdir); trav->xlator->fops
->mkdir (_new, trav->xlator, loc, mode, umask, xdata); (
*__glusterfs_this_location()) = old_THIS; } while (0)
1922 trav->xlator->fops->mkdir, loc, mode, umask, 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", "stripe.c", __FUNCTION__, 1922, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->mkdir_cbk) tmp_cbk = stripe_first_mkdir_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->mkdir"; _new->unwind_to =
"stripe_first_mkdir_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->mkdir); trav->xlator->fops
->mkdir (_new, trav->xlator, loc, mode, umask, xdata); (
*__glusterfs_this_location()) = old_THIS; } while (0)
;
1923
1924 return 0;
1925err:
1926 STRIPE_STACK_UNWIND (mkdir, frame, -1, op_errno, NULL, NULL, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_mkdir_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", "stripe.c", __FUNCTION__
, 1926, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_mkdir_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), ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
1927 return 0;
1928}
1929
1930
1931int32_t
1932stripe_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1933 int32_t op_ret, int32_t op_errno, inode_t *inode,
1934 struct iatt *buf, struct iatt *preparent,
1935 struct iatt *postparent, dict_t *xdata)
1936{
1937 int32_t callcnt = 0;
1938 stripe_local_t *local = NULL((void*)0);
1939 call_frame_t *prev = NULL((void*)0);
1940 stripe_fd_ctx_t *fctx = NULL((void*)0);
1941
1942 if (!this || !frame || !frame->local || !cookie) {
1943 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 1943, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
1944 goto out;
1945 }
1946
1947 prev = cookie;
1948 local = frame->local;
1949
1950 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
1951 {
1952 callcnt = --local->call_count;
1953
1954 if (op_ret == -1) {
1955 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1957, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
1956 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1957, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
1957 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 1957, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
1958 local->op_errno = op_errno;
1959 if ((op_errno != ENOENT2) ||
1960 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
1961 local->failed = 1;
1962 }
1963
1964 if (op_ret >= 0) {
1965 local->op_ret = 0;
1966
1967 if (IA_ISREG(inode->ia_type)(inode->ia_type == IA_IFREG)) {
1968 inode_ctx_get(inode, this, (uint64_t *) &fctx)inode_ctx_get2(inode,this,(uint64_t *) &fctx,0);
1969 if (!fctx) {
1970 gf_log(this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to get stripe context"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 1971,
GF_LOG_ERROR, "failed to get stripe context"); } while (0)
1971 "failed to get stripe context")do { do { if (0) printf ("failed to get stripe context"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 1971,
GF_LOG_ERROR, "failed to get stripe context"); } while (0)
;
1972 op_ret = -1;
1973 op_errno = EINVAL22;
1974 }
1975 }
1976
1977 if (FIRST_CHILD(this)(this->children->xlator) == prev->this) {
1978 local->inode = inode_ref (inode);
1979 local->stbuf = *buf;
1980 local->postparent = *postparent;
1981 local->preparent = *preparent;
1982 }
1983 local->stbuf_blocks += buf->ia_blocks;
1984 local->preparent_blocks += preparent->ia_blocks;
1985 local->postparent_blocks += postparent->ia_blocks;
1986
1987 correct_file_size(buf, fctx, prev);
1988
1989 if (local->stbuf_size < buf->ia_size)
1990 local->stbuf_size = buf->ia_size;
1991 if (local->preparent_size < preparent->ia_size)
1992 local->preparent_size = preparent->ia_size;
1993 if (local->postparent_size < postparent->ia_size)
1994 local->postparent_size = postparent->ia_size;
1995 }
1996 }
1997 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
1998
1999 if (!callcnt) {
2000 if (local->failed)
2001 local->op_ret = -1;
2002
2003 if (local->op_ret != -1) {
2004 local->preparent.ia_blocks = local->preparent_blocks;
2005 local->preparent.ia_size = local->preparent_size;
2006 local->postparent.ia_blocks = local->postparent_blocks;
2007 local->postparent.ia_size = local->postparent_size;
2008 local->stbuf.ia_size = local->stbuf_size;
2009 local->stbuf.ia_blocks = local->stbuf_blocks;
2010 }
2011 STRIPE_STACK_UNWIND (link, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_link_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", "stripe.c", __FUNCTION__
, 2014, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_link_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
2012 local->op_errno, local->inode,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_link_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", "stripe.c", __FUNCTION__
, 2014, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_link_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
2013 &local->stbuf, &local->preparent,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_link_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", "stripe.c", __FUNCTION__
, 2014, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_link_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
2014 &local->postparent, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_link_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", "stripe.c", __FUNCTION__
, 2014, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_link_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->inode
, &local->stbuf, &local->preparent, &local->
postparent, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
2015 }
2016out:
2017 return 0;
2018}
2019
2020int32_t
2021stripe_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, dict_t *xdata)
2022{
2023 xlator_list_t *trav = NULL((void*)0);
2024 stripe_local_t *local = NULL((void*)0);
2025 stripe_private_t *priv = NULL((void*)0);
2026 int32_t op_errno = 1;
2027
2028 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2028, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
2029 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2029, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
2030 VALIDATE_OR_GOTO (oldloc, err)do { if (!oldloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "oldloc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2030, GF_LOG_WARNING, "invalid argument: " "oldloc"
); } while (0); goto err; } } while (0)
;
2031 VALIDATE_OR_GOTO (oldloc->path, err)do { if (!oldloc->path) { (*__errno_location ()) = 22; do {
do { if (0) printf ("invalid argument: " "oldloc->path");
} while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2031, GF_LOG_WARNING, "invalid argument: "
"oldloc->path"); } while (0); goto err; } } while (0)
;
2032 VALIDATE_OR_GOTO (oldloc->inode, err)do { if (!oldloc->inode) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "oldloc->inode"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2032, GF_LOG_WARNING, "invalid argument: "
"oldloc->inode"); } while (0); goto err; } } while (0)
;
2033
2034 priv = this->private;
2035 trav = this->children;
2036
2037 /* If any one node is down, don't allow link operation */
2038 if (priv->nodes_down) {
2039 op_errno = ENOTCONN107;
2040 goto err;
2041 }
2042
2043 /* Initialization */
2044 local = mem_get0 (this->local_pool);
2045 if (!local) {
2046 op_errno = ENOMEM12;
2047 goto err;
2048 }
2049 local->op_ret = -1;
2050 frame->local = local;
2051 local->call_count = priv->child_count;
2052
2053 /* Everytime in stripe lookup, all child
2054 nodes should be looked up */
2055 while (trav) {
2056 STACK_WIND (frame, stripe_link_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", "stripe.c", __FUNCTION__, 2058, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->link_cbk) tmp_cbk = stripe_link_cbk; _new->root
= frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->link"; _new->unwind_to = "stripe_link_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->link); trav->xlator->fops
->link (_new, trav->xlator, oldloc, newloc, ((void*)0))
; (*__glusterfs_this_location()) = old_THIS; } while (0)
2057 trav->xlator, trav->xlator->fops->link,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", "stripe.c", __FUNCTION__, 2058, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->link_cbk) tmp_cbk = stripe_link_cbk; _new->root
= frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->link"; _new->unwind_to = "stripe_link_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->link); trav->xlator->fops
->link (_new, trav->xlator, oldloc, newloc, ((void*)0))
; (*__glusterfs_this_location()) = old_THIS; } while (0)
2058 oldloc, newloc, 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", "stripe.c", __FUNCTION__, 2058, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->link_cbk) tmp_cbk = stripe_link_cbk; _new->root
= frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->link"; _new->unwind_to = "stripe_link_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->link); trav->xlator->fops
->link (_new, trav->xlator, oldloc, newloc, ((void*)0))
; (*__glusterfs_this_location()) = old_THIS; } while (0)
;
2059 trav = trav->next;
2060 }
2061
2062 return 0;
2063err:
2064 STRIPE_STACK_UNWIND (link, frame, -1, op_errno, NULL, NULL, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_link_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", "stripe.c", __FUNCTION__
, 2064, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_link_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), ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
2065 return 0;
2066}
2067
2068int32_t
2069stripe_create_fail_unlink_cbk (call_frame_t *frame, void *cookie,
2070 xlator_t *this, int32_t op_ret,
2071 int32_t op_errno, struct iatt *preparent,
2072 struct iatt *postparent, dict_t *xdata)
2073{
2074 int32_t callcnt = 0;
2075 stripe_local_t *local = NULL((void*)0);
2076
2077 if (!this || !frame || !frame->local) {
2078 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 2078, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
2079 goto out;
2080 }
2081
2082 local = frame->local;
2083
2084 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2085 {
2086 callcnt = --local->call_count;
2087 }
2088 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2089
2090 if (!callcnt) {
2091 STRIPE_STACK_UNWIND (create, frame, local->op_ret, local->op_errno,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_create_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", "stripe.c", __FUNCTION__
, 2093, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_create_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->fd
, local->inode, &local->stbuf, &local->preparent
, &local->postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
2092 local->fd, local->inode, &local->stbuf,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_create_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", "stripe.c", __FUNCTION__
, 2093, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_create_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->fd
, local->inode, &local->stbuf, &local->preparent
, &local->postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
2093 &local->preparent, &local->postparent, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_create_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", "stripe.c", __FUNCTION__
, 2093, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_create_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->fd
, local->inode, &local->stbuf, &local->preparent
, &local->postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
2094 }
2095out:
2096 return 0;
2097}
2098
2099
2100int32_t
2101stripe_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2102 int32_t op_ret, int32_t op_errno, fd_t *fd,
2103 inode_t *inode, struct iatt *buf, struct iatt *preparent,
2104 struct iatt *postparent, dict_t *xdata)
2105{
2106 int32_t callcnt = 0;
2107 stripe_local_t *local = NULL((void*)0);
2108 stripe_private_t *priv = NULL((void*)0);
2109 call_frame_t *prev = NULL((void*)0);
2110 xlator_list_t *trav = NULL((void*)0);
2111
2112 if (!this || !frame || !frame->local || !cookie) {
2113 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 2113, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
2114 goto out;
2115 }
2116
2117 prev = cookie;
2118 priv = this->private;
2119 local = frame->local;
2120
2121 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2122 {
2123 callcnt = --local->call_count;
2124
2125 if (op_ret == -1) {
2126 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2128, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2127 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2128, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2128 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2128, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
2129 local->failed = 1;
2130 local->op_errno = op_errno;
2131 }
2132
2133 if (op_ret >= 0) {
2134 if (IA_ISREG(buf->ia_type)(buf->ia_type == IA_IFREG)) {
2135 if (stripe_ctx_handle(this, prev, local, xdata))
2136 gf_log(this->name, GF_LOG_ERROR,do { do { if (0) printf ("Error getting fctx info from " "dict"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 2138, GF_LOG_ERROR, "Error getting fctx info from " "dict")
; } while (0)
2137 "Error getting fctx info from "do { do { if (0) printf ("Error getting fctx info from " "dict"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 2138, GF_LOG_ERROR, "Error getting fctx info from " "dict")
; } while (0)
2138 "dict")do { do { if (0) printf ("Error getting fctx info from " "dict"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 2138, GF_LOG_ERROR, "Error getting fctx info from " "dict")
; } while (0)
;
2139 }
2140
2141 local->op_ret = op_ret;
2142
2143 local->stbuf_blocks += buf->ia_blocks;
2144 local->preparent_blocks += preparent->ia_blocks;
2145 local->postparent_blocks += postparent->ia_blocks;
2146
2147 correct_file_size(buf, local->fctx, prev);
2148
2149 if (local->stbuf_size < buf->ia_size)
2150 local->stbuf_size = buf->ia_size;
2151 if (local->preparent_size < preparent->ia_size)
2152 local->preparent_size = preparent->ia_size;
2153 if (local->postparent_size < postparent->ia_size)
2154 local->postparent_size = postparent->ia_size;
2155 }
2156 }
2157 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2158
2159 if (!callcnt) {
2160 if (local->failed)
2161 local->op_ret = -1;
2162
2163 if (local->op_ret == -1) {
2164 local->call_count = priv->child_count;
2165 trav = this->children;
2166 while (trav) {
2167 STACK_WIND (frame,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", "stripe.c", __FUNCTION__, 2171, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_create_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_create_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2168 stripe_create_fail_unlink_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", "stripe.c", __FUNCTION__, 2171, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_create_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_create_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2169 trav->xlator,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", "stripe.c", __FUNCTION__, 2171, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_create_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_create_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2170 trav->xlator->fops->unlink,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", "stripe.c", __FUNCTION__, 2171, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_create_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_create_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2171 &local->loc, 0, 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", "stripe.c", __FUNCTION__, 2171, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->unlink_cbk) tmp_cbk = stripe_create_fail_unlink_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->unlink"; _new->
unwind_to = "stripe_create_fail_unlink_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->unlink
); trav->xlator->fops->unlink (_new, trav->xlator
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2172 trav = trav->next;
2173 }
2174
2175 return 0;
2176 }
2177
2178 if (local->op_ret >= 0) {
2179 local->preparent.ia_blocks = local->preparent_blocks;
2180 local->preparent.ia_size = local->preparent_size;
2181 local->postparent.ia_blocks = local->postparent_blocks;
2182 local->postparent.ia_size = local->postparent_size;
2183 local->stbuf.ia_size = local->stbuf_size;
2184 local->stbuf.ia_blocks = local->stbuf_blocks;
2185
2186 stripe_copy_xl_array(local->fctx->xl_array,
2187 priv->xl_array,
2188 local->fctx->stripe_count);
2189 inode_ctx_put(local->inode, this,
2190 (uint64_t) local->fctx);
2191 }
2192
2193 /* Create itself has failed.. so return
2194 without setxattring */
2195 STRIPE_STACK_UNWIND (create, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_create_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", "stripe.c", __FUNCTION__
, 2198, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_create_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->fd
, local->inode, &local->stbuf, &local->preparent
, &local->postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
2196 local->op_errno, local->fd,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_create_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", "stripe.c", __FUNCTION__
, 2198, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_create_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->fd
, local->inode, &local->stbuf, &local->preparent
, &local->postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
2197 local->inode, &local->stbuf,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_create_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", "stripe.c", __FUNCTION__
, 2198, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_create_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->fd
, local->inode, &local->stbuf, &local->preparent
, &local->postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
2198 &local->preparent, &local->postparent, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_create_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", "stripe.c", __FUNCTION__
, 2198, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_create_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->fd
, local->inode, &local->stbuf, &local->preparent
, &local->postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
2199 }
2200
2201out:
2202 return 0;
2203}
2204
2205
2206
2207int32_t
2208stripe_first_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2209 int32_t op_ret, int32_t op_errno, fd_t *fd,
2210 inode_t *inode, struct iatt *buf, struct iatt *preparent,
2211 struct iatt *postparent, dict_t *xdata)
2212{
2213 stripe_local_t *local = NULL((void*)0);
2214 stripe_private_t *priv = NULL((void*)0);
2215 call_frame_t *prev = NULL((void*)0);
2216 xlator_list_t *trav = NULL((void*)0);
2217 int i = 1;
2218 dict_t *dict = NULL((void*)0);
2219 loc_t *loc = NULL((void*)0);
2220 int32_t need_unref = 0;
2221 int32_t ret = -1;
2222
2223 if (!this || !frame || !frame->local || !cookie) {
2224 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 2224, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
2225 goto out;
2226 }
2227
2228 prev = cookie;
2229 priv = this->private;
2230 local = frame->local;
2231 trav = this->children;
2232 loc = &local->loc;
2233
2234 --local->call_count;
2235
2236 if (op_ret == -1) {
2237 gf_log (this->name, GF_LOG_DEBUG, "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2238, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2238 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2238, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
2239 local->failed = 1;
2240 local->op_errno = op_errno;
2241 }
2242
2243 local->op_ret = 0;
2244 /* Get the mapping in inode private */
2245 /* Get the stat buf right */
2246 local->stbuf = *buf;
2247 local->preparent = *preparent;
2248 local->postparent = *postparent;
2249
2250 local->stbuf_blocks += buf->ia_blocks;
2251 local->preparent_blocks += preparent->ia_blocks;
2252 local->postparent_blocks += postparent->ia_blocks;
2253
2254 if (local->stbuf_size < buf->ia_size)
2255 local->stbuf_size = buf->ia_size;
2256 if (local->preparent_size < preparent->ia_size)
2257 local->preparent_size = preparent->ia_size;
2258 if (local->postparent_size < postparent->ia_size)
2259 local->postparent_size = postparent->ia_size;
2260
2261 if (local->failed)
2262 local->op_ret = -1;
2263
2264 if (local->op_ret == -1) {
2265 local->call_count = 1;
2266 STACK_WIND (frame, stripe_create_fail_unlink_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", "stripe.c", __FUNCTION__, 2268, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->unlink_cbk) tmp_cbk = stripe_create_fail_unlink_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->unlink"
; _new->unwind_to = "stripe_create_fail_unlink_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->unlink); (this->children->xlator
)->fops->unlink (_new, (this->children->xlator), &
local->loc, 0, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
2267 FIRST_CHILD (this), FIRST_CHILD (this)->fops->unlink,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", "stripe.c", __FUNCTION__, 2268, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->unlink_cbk) tmp_cbk = stripe_create_fail_unlink_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->unlink"
; _new->unwind_to = "stripe_create_fail_unlink_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->unlink); (this->children->xlator
)->fops->unlink (_new, (this->children->xlator), &
local->loc, 0, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
2268 &local->loc, 0, 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", "stripe.c", __FUNCTION__, 2268, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->unlink_cbk) tmp_cbk = stripe_create_fail_unlink_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->unlink"
; _new->unwind_to = "stripe_create_fail_unlink_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->unlink); (this->children->xlator
)->fops->unlink (_new, (this->children->xlator), &
local->loc, 0, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
;
2269 return 0;
2270 }
2271
2272 if (local->op_ret >= 0) {
2273 local->preparent.ia_blocks = local->preparent_blocks;
2274 local->preparent.ia_size = local->preparent_size;
2275 local->postparent.ia_blocks = local->postparent_blocks;
2276 local->postparent.ia_size = local->postparent_size;
2277 local->stbuf.ia_size = local->stbuf_size;
2278 local->stbuf.ia_blocks = local->stbuf_blocks;
2279 }
2280
2281 /* Send a setxattr request to nodes where the
2282 files are created */
2283 trav = trav->next;
2284 while (trav) {
2285 if (priv->xattr_supported) {
2286 dict = dict_new ();
2287 if (!dict) {
2288 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to allocate dict %s", loc->
path); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 2289, GF_LOG_ERROR, "failed to allocate dict %s", loc->path
); } while (0)
2289 "failed to allocate dict %s", loc->path)do { do { if (0) printf ("failed to allocate dict %s", loc->
path); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 2289, GF_LOG_ERROR, "failed to allocate dict %s", loc->path
); } while (0)
;
2290 }
2291 need_unref = 1;
2292
2293 dict_copy (local->xattr, dict);
2294
2295 ret = stripe_xattr_request_build (this, dict,
2296 local->stripe_size,
2297 priv->child_count,
2298 i, priv->coalesce);
2299 if (ret)
2300 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to build xattr request"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 2301,
GF_LOG_ERROR, "failed to build xattr request"); } while (0)
2301 "failed to build xattr request")do { do { if (0) printf ("failed to build xattr request"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 2301,
GF_LOG_ERROR, "failed to build xattr request"); } while (0)
;
2302 } else {
2303 dict = local->xattr;
2304 }
2305
2306 STACK_WIND (frame, stripe_create_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 2309, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->create_cbk) tmp_cbk = stripe_create_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->create"; _new->unwind_to = "stripe_create_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->create); trav->xlator->fops
->create (_new, trav->xlator, &local->loc, local
->flags, local->mode, local->umask, local->fd, dict
); (*__glusterfs_this_location()) = old_THIS; } while (0)
2307 trav->xlator->fops->create, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 2309, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->create_cbk) tmp_cbk = stripe_create_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->create"; _new->unwind_to = "stripe_create_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->create); trav->xlator->fops
->create (_new, trav->xlator, &local->loc, local
->flags, local->mode, local->umask, local->fd, dict
); (*__glusterfs_this_location()) = old_THIS; } while (0)
2308 local->flags, local->mode, local->umask, local->fd,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 2309, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->create_cbk) tmp_cbk = stripe_create_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->create"; _new->unwind_to = "stripe_create_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->create); trav->xlator->fops
->create (_new, trav->xlator, &local->loc, local
->flags, local->mode, local->umask, local->fd, dict
); (*__glusterfs_this_location()) = old_THIS; } while (0)
2309 dict)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", "stripe.c", __FUNCTION__, 2309, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->create_cbk) tmp_cbk = stripe_create_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->create"; _new->unwind_to = "stripe_create_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->create); trav->xlator->fops
->create (_new, trav->xlator, &local->loc, local
->flags, local->mode, local->umask, local->fd, dict
); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
2310 trav = trav->next;
2311 if (need_unref && dict)
2312 dict_unref (dict);
2313 i++;
2314 }
2315
2316out:
2317 return 0;
2318}
2319
2320
2321
2322/**
2323 * stripe_create - If a block-size is specified for the 'name', create the
2324 * file in all the child nodes. If not, create it in only first child.
2325 *
2326 * @name- complete path of the file to be created.
2327 */
2328int32_t
2329stripe_create (call_frame_t *frame, xlator_t *this, loc_t *loc,
2330 int32_t flags, mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
2331{
2332 stripe_private_t *priv = NULL((void*)0);
2333 stripe_local_t *local = NULL((void*)0);
2334 int32_t op_errno = EINVAL22;
2335 int ret = 0;
2336 int need_unref = 0;
2337 int i = 0;
2338 dict_t *dict = NULL((void*)0);
2339
2340 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2340, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
2341 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2341, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
2342 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2342, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
2343 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2343, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
2344 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2344, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
2345
2346 priv = this->private;
2347
2348 /* files created in O_APPEND mode does not allow lseek() on fd */
2349 flags &= ~O_APPEND02000;
2350
2351 if (priv->first_child_down || priv->nodes_down) {
2352 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("First node down, returning EIO"); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
2353, GF_LOG_DEBUG, "First node down, returning EIO"); } while
(0)
2353 "First node down, returning EIO")do { do { if (0) printf ("First node down, returning EIO"); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
2353, GF_LOG_DEBUG, "First node down, returning EIO"); } while
(0)
;
2354 op_errno = EIO5;
2355 goto err;
2356 }
2357
2358 /* Initialization */
2359 local = mem_get0 (this->local_pool);
2360 if (!local) {
2361 op_errno = ENOMEM12;
2362 goto err;
2363 }
2364 local->op_ret = -1;
2365 local->op_errno = ENOTCONN107;
2366 local->stripe_size = stripe_get_matching_bs (loc->path, priv);
2367 frame->local = local;
2368 local->inode = inode_ref (loc->inode);
2369 loc_copy (&local->loc, loc);
2370 local->fd = fd_ref (fd);
2371 local->flags = flags;
2372 local->mode = mode;
2373 local->umask = umask;
2374 if (xdata)
2375 local->xattr = dict_ref (xdata);
2376
2377 local->call_count = priv->child_count;
2378 /* Send a setxattr request to nodes where the
2379 files are created */
2380
2381 if (priv->xattr_supported) {
2382 dict = dict_new ();
2383 if (!dict) {
2384 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to allocate dict %s", loc->
path); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 2385, GF_LOG_ERROR, "failed to allocate dict %s", loc->path
); } while (0)
2385 "failed to allocate dict %s", loc->path)do { do { if (0) printf ("failed to allocate dict %s", loc->
path); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 2385, GF_LOG_ERROR, "failed to allocate dict %s", loc->path
); } while (0)
;
2386 }
2387 need_unref = 1;
2388
2389 dict_copy (xdata, dict);
2390
2391 ret = stripe_xattr_request_build (this, dict,
2392 local->stripe_size,
2393 priv->child_count,
2394 i, priv->coalesce);
2395 if (ret)
2396 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to build xattr request"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 2397,
GF_LOG_ERROR, "failed to build xattr request"); } while (0)
2397 "failed to build xattr request")do { do { if (0) printf ("failed to build xattr request"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 2397,
GF_LOG_ERROR, "failed to build xattr request"); } while (0)
;
2398 } else {
2399 dict = xdata;
2400 }
2401
2402
2403 STACK_WIND (frame, stripe_first_create_cbk, FIRST_CHILD (this),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", "stripe.c", __FUNCTION__, 2405, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->create_cbk) tmp_cbk = stripe_first_create_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->create"
; _new->unwind_to = "stripe_first_create_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->create); (this->children->xlator
)->fops->create (_new, (this->children->xlator), loc
, flags, mode, umask, fd, dict); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
2404 FIRST_CHILD (this)->fops->create, loc, flags, mode,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", "stripe.c", __FUNCTION__, 2405, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->create_cbk) tmp_cbk = stripe_first_create_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->create"
; _new->unwind_to = "stripe_first_create_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->create); (this->children->xlator
)->fops->create (_new, (this->children->xlator), loc
, flags, mode, umask, fd, dict); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
2405 umask, fd, dict)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", "stripe.c", __FUNCTION__, 2405, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->create_cbk) tmp_cbk = stripe_first_create_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD (this)->fops->create"
; _new->unwind_to = "stripe_first_create_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->create); (this->children->xlator
)->fops->create (_new, (this->children->xlator), loc
, flags, mode, umask, fd, dict); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
;
2406
2407 if (need_unref && dict)
2408 dict_unref (dict);
2409
2410
2411 return 0;
2412err:
2413 STRIPE_STACK_UNWIND (create, frame, -1, op_errno, NULL, NULL, NULL,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_create_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", "stripe.c", __FUNCTION__
, 2414, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_create_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), ((void*)0), xdata); (*__glusterfs_this_location())
= old_THIS; } while (0); if (__local) { stripe_local_wipe(__local
); mem_put (__local); } } while (0)
2414 NULL, NULL, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_create_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", "stripe.c", __FUNCTION__
, 2414, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_create_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), ((void*)0), xdata); (*__glusterfs_this_location())
= old_THIS; } while (0); if (__local) { stripe_local_wipe(__local
); mem_put (__local); } } while (0)
;
2415 return 0;
2416}
2417
2418int32_t
2419stripe_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2420 int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
2421{
2422 int32_t callcnt = 0;
2423 stripe_local_t *local = NULL((void*)0);
2424 call_frame_t *prev = NULL((void*)0);
2425
2426 if (!this || !frame || !frame->local || !cookie) {
2427 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 2427, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
2428 goto out;
2429 }
2430
2431 prev = cookie;
2432 local = frame->local;
2433
2434 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2435 {
2436 callcnt = --local->call_count;
2437
2438 if (op_ret == -1) {
2439
2440 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2442, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2441 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2442, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2442 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2442, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
2443 if ((op_errno != ENOENT2) ||
2444 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
2445 local->failed = 1;
2446 local->op_errno = op_errno;
2447 }
2448
2449 if (op_ret >= 0)
2450 local->op_ret = op_ret;
2451 }
2452 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2453
2454 if (!callcnt) {
2455 if (local->failed)
2456 local->op_ret = -1;
2457
2458 STRIPE_STACK_UNWIND (open, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_open_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", "stripe.c", __FUNCTION__
, 2459, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_open_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->fd
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
2459 local->op_errno, local->fd, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_open_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", "stripe.c", __FUNCTION__
, 2459, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_open_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->fd
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
;
2460 }
2461out:
2462 return 0;
2463}
2464
2465
2466/**
2467 * stripe_open -
2468 */
2469int32_t
2470stripe_open (call_frame_t *frame, xlator_t *this, loc_t *loc,
2471 int32_t flags, fd_t *fd, dict_t *xdata)
2472{
2473 stripe_local_t *local = NULL((void*)0);
2474 stripe_private_t *priv = NULL((void*)0);
2475 xlator_list_t *trav = NULL((void*)0);
2476 int32_t op_errno = 1;
2477
2478 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2478, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
2479 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2479, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
2480 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2480, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
2481 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2481, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
2482 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2482, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
2483
2484 priv = this->private;
2485 trav = this->children;
2486
2487 if (priv->first_child_down) {
2488 op_errno = ENOTCONN107;
2489 goto err;
2490 }
2491
2492 /* Initialization */
2493 local = mem_get0 (this->local_pool);
2494 if (!local) {
2495 op_errno = ENOMEM12;
2496 goto err;
2497 }
2498
2499 /* files opened in O_APPEND mode does not allow lseek() on fd */
2500 flags &= ~O_APPEND02000;
2501
2502 local->fd = fd_ref (fd);
2503 frame->local = local;
2504 loc_copy (&local->loc, loc);
2505
2506 /* Striped files */
2507 local->flags = flags;
2508 local->call_count = priv->child_count;
2509 local->stripe_size = stripe_get_matching_bs (loc->path, priv);
2510
2511 while (trav) {
2512 STACK_WIND (frame, stripe_open_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 2515, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->open_cbk) tmp_cbk = stripe_open_cbk; _new->root
= frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->open"; _new->unwind_to = "stripe_open_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->open); trav->xlator->fops
->open (_new, trav->xlator, &local->loc, local->
flags, local->fd, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
2513 trav->xlator->fops->open,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 2515, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->open_cbk) tmp_cbk = stripe_open_cbk; _new->root
= frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->open"; _new->unwind_to = "stripe_open_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->open); trav->xlator->fops
->open (_new, trav->xlator, &local->loc, local->
flags, local->fd, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
2514 &local->loc, local->flags, local->fd,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 2515, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->open_cbk) tmp_cbk = stripe_open_cbk; _new->root
= frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->open"; _new->unwind_to = "stripe_open_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->open); trav->xlator->fops
->open (_new, trav->xlator, &local->loc, local->
flags, local->fd, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
2515 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", "stripe.c", __FUNCTION__, 2515, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->open_cbk) tmp_cbk = stripe_open_cbk; _new->root
= frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->open"; _new->unwind_to = "stripe_open_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->open); trav->xlator->fops
->open (_new, trav->xlator, &local->loc, local->
flags, local->fd, xdata); (*__glusterfs_this_location()) =
old_THIS; } while (0)
;
2516 trav = trav->next;
2517 }
2518 return 0;
2519err:
2520 STRIPE_STACK_UNWIND (open, frame, -1, op_errno, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_open_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", "stripe.c", __FUNCTION__
, 2520, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_open_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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
2521 return 0;
2522}
2523
2524
2525int32_t
2526stripe_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2527 int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
2528{
2529 int32_t callcnt = 0;
2530 stripe_local_t *local = NULL((void*)0);
2531 call_frame_t *prev = NULL((void*)0);
2532
2533 if (!this || !frame || !frame->local || !cookie) {
2534 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 2534, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
2535 goto out;
2536 }
2537
2538 prev = cookie;
2539 local = frame->local;
2540
2541 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2542 {
2543 callcnt = --local->call_count;
2544
2545 if (op_ret == -1) {
2546 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2548, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2547 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2548, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2548 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2548, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
2549 local->op_ret = -1;
2550 local->op_errno = op_errno;
2551 }
2552
2553 if (op_ret >= 0)
2554 local->op_ret = op_ret;
2555 }
2556 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2557
2558 if (!callcnt) {
2559 STRIPE_STACK_UNWIND (opendir, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_opendir_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", "stripe.c", __FUNCTION__
, 2560, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_opendir_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->fd
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
2560 local->op_errno, local->fd, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_opendir_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", "stripe.c", __FUNCTION__
, 2560, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_opendir_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->fd
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
;
2561 }
2562out:
2563 return 0;
2564}
2565
2566
2567int32_t
2568stripe_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, dict_t *xdata)
2569{
2570 xlator_list_t *trav = NULL((void*)0);
2571 stripe_local_t *local = NULL((void*)0);
2572 stripe_private_t *priv = NULL((void*)0);
2573 int32_t op_errno = EINVAL22;
2574
2575 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2575, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
2576 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2576, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
2577 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2577, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
2578 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2578, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
2579 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2579, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
2580
2581 priv = this->private;
2582 trav = this->children;
2583
2584 if (priv->first_child_down) {
2585 op_errno = ENOTCONN107;
2586 goto err;
2587 }
2588
2589 /* Initialization */
2590 local = mem_get0 (this->local_pool);
2591 if (!local) {
2592 op_errno = ENOMEM12;
2593 goto err;
2594 }
2595 frame->local = local;
2596 local->call_count = priv->child_count;
2597 local->fd = fd_ref (fd);
2598
2599 while (trav) {
2600 STACK_WIND (frame, stripe_opendir_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 2601, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->opendir_cbk) tmp_cbk = stripe_opendir_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->opendir"; _new->unwind_to
= "stripe_opendir_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->opendir); trav->xlator->
fops->opendir (_new, trav->xlator, loc, fd, ((void*)0))
; (*__glusterfs_this_location()) = old_THIS; } while (0)
2601 trav->xlator->fops->opendir, loc, 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", "stripe.c", __FUNCTION__, 2601, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->opendir_cbk) tmp_cbk = stripe_opendir_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->opendir"; _new->unwind_to
= "stripe_opendir_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->opendir); trav->xlator->
fops->opendir (_new, trav->xlator, loc, fd, ((void*)0))
; (*__glusterfs_this_location()) = old_THIS; } while (0)
;
2602 trav = trav->next;
2603 }
2604
2605 return 0;
2606err:
2607 STRIPE_STACK_UNWIND (opendir, frame, -1, op_errno, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_opendir_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", "stripe.c", __FUNCTION__
, 2607, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_opendir_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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
2608 return 0;
2609}
2610
2611int32_t
2612stripe_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2613 int32_t op_ret, int32_t op_errno, struct gf_flock *lock, dict_t *xdata)
2614{
2615 int32_t callcnt = 0;
2616 stripe_local_t *local = NULL((void*)0);
2617 call_frame_t *prev = NULL((void*)0);
2618
2619 if (!this || !frame || !frame->local || !cookie) {
2620 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 2620, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
2621 goto out;
2622 }
2623
2624 prev = cookie;
2625 local = frame->local;
2626
2627 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2628 {
2629 callcnt = --local->call_count;
2630 if (op_ret == -1) {
2631 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2633, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2632 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2633, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2633 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2633, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
2634 local->op_errno = op_errno;
2635 if ((op_errno != ENOENT2) ||
2636 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
2637 local->failed = 1;
2638 }
2639 if (op_ret >= 0) {
2640 if (FIRST_CHILD(this)(this->children->xlator) == prev->this) {
2641 /* First successful call, copy the *lock */
2642 local->op_ret = op_ret;
2643 local->lock = *lock;
2644 }
2645 }
2646 }
2647 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2648
2649 if (!callcnt) {
2650 if (local->failed)
2651 local->op_ret = -1;
2652 STRIPE_STACK_UNWIND (lk, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 2653, 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->
lock, ((void*)0)); (*__glusterfs_this_location()) = old_THIS;
} while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
2653 local->op_errno, &local->lock, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 2653, 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->
lock, ((void*)0)); (*__glusterfs_this_location()) = old_THIS;
} while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
2654 }
2655out:
2656 return 0;
2657}
2658
2659int32_t
2660stripe_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
2661 struct gf_flock *lock, dict_t *xdata)
2662{
2663 stripe_local_t *local = NULL((void*)0);
2664 xlator_list_t *trav = NULL((void*)0);
2665 stripe_private_t *priv = NULL((void*)0);
2666 int32_t op_errno = EINVAL22;
2667
2668 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2668, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
2669 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2669, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
2670 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2670, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
2671 VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "fd->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2671, GF_LOG_WARNING, "invalid argument: "
"fd->inode"); } while (0); goto err; } } while (0)
;
2672
2673 trav = this->children;
2674 priv = this->private;
2675
2676 /* Initialization */
2677 local = mem_get0 (this->local_pool);
2678 if (!local) {
2679 op_errno = ENOMEM12;
2680 goto err;
2681 }
2682 local->op_ret = -1;
2683 frame->local = local;
2684 local->call_count = priv->child_count;
2685
2686 while (trav) {
2687 STACK_WIND (frame, stripe_lk_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 2688, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->lk_cbk) tmp_cbk = stripe_lk_cbk; _new->root =
frame->root; _new->this = trav->xlator; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->lk"; _new->unwind_to = "stripe_lk_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->lk); trav->xlator->fops->
lk (_new, trav->xlator, fd, cmd, lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2688 trav->xlator->fops->lk, fd, cmd, lock, 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", "stripe.c", __FUNCTION__, 2688, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->lk_cbk) tmp_cbk = stripe_lk_cbk; _new->root =
frame->root; _new->this = trav->xlator; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->lk"; _new->unwind_to = "stripe_lk_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->lk); trav->xlator->fops->
lk (_new, trav->xlator, fd, cmd, lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2689 trav = trav->next;
2690 }
2691
2692 return 0;
2693err:
2694 STRIPE_STACK_UNWIND (lk, frame, -1, op_errno, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 2694, 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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
2695 return 0;
2696}
2697
2698
2699int32_t
2700stripe_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2701 int32_t op_ret, int32_t op_errno, dict_t *xdata)
2702{
2703 int32_t callcnt = 0;
2704 stripe_local_t *local = NULL((void*)0);
2705 call_frame_t *prev = NULL((void*)0);
2706
2707 if (!this || !frame || !frame->local || !cookie) {
2708 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 2708, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
2709 goto out;
2710 }
2711
2712 prev = cookie;
2713 local = frame->local;
2714
2715 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2716 {
2717 callcnt = --local->call_count;
2718
2719 if (op_ret == -1) {
2720 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 2722, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
2721 "%s returned %s",do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 2722, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
2722 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 2722, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
2723 local->op_errno = op_errno;
2724 if ((op_errno != ENOENT2) ||
2725 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
2726 local->failed = 1;
2727 }
2728 if (op_ret >= 0)
2729 local->op_ret = op_ret;
2730 }
2731 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2732
2733 if (!callcnt) {
2734 if (local->failed)
2735 local->op_ret = -1;
2736
2737 STRIPE_STACK_UNWIND (flush, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 2738, 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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
2738 local->op_errno, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 2738, 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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
2739 }
2740out:
2741 return 0;
2742}
2743
2744int32_t
2745stripe_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
2746{
2747 stripe_local_t *local = NULL((void*)0);
2748 stripe_private_t *priv = NULL((void*)0);
2749 xlator_list_t *trav = NULL((void*)0);
2750 int32_t op_errno = 1;
2751
2752 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2752, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
2753 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2753, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
2754 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2754, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
2755 VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "fd->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2755, GF_LOG_WARNING, "invalid argument: "
"fd->inode"); } while (0); goto err; } } while (0)
;
2756
2757 priv = this->private;
2758 trav = this->children;
2759
2760 if (priv->first_child_down) {
2761 op_errno = ENOTCONN107;
2762 goto err;
2763 }
2764 /* Initialization */
2765 local = mem_get0 (this->local_pool);
2766 if (!local) {
2767 op_errno = ENOMEM12;
2768 goto err;
2769 }
2770 local->op_ret = -1;
2771 frame->local = local;
2772 local->call_count = priv->child_count;
2773
2774 while (trav) {
2775 STACK_WIND (frame, stripe_flush_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 2776, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->flush_cbk) tmp_cbk = stripe_flush_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->flush"; _new->unwind_to = "stripe_flush_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->flush); trav->xlator->fops
->flush (_new, trav->xlator, fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2776 trav->xlator->fops->flush, 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", "stripe.c", __FUNCTION__, 2776, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->flush_cbk) tmp_cbk = stripe_flush_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->flush"; _new->unwind_to = "stripe_flush_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->flush); trav->xlator->fops
->flush (_new, trav->xlator, fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2777 trav = trav->next;
2778 }
2779
2780 return 0;
2781err:
2782 STRIPE_STACK_UNWIND (flush, frame, -1, op_errno, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 2782, 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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
2783 return 0;
2784}
2785
2786
2787
2788int32_t
2789stripe_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2790 int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
2791 struct iatt *postbuf, dict_t *xdata)
2792{
2793 int32_t callcnt = 0;
2794 stripe_local_t *local = NULL((void*)0);
2795 call_frame_t *prev = NULL((void*)0);
2796
2797 if (!this || !frame || !frame->local || !cookie) {
2798 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 2798, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
2799 goto out;
2800 }
2801
2802 prev = cookie;
2803 local = frame->local;
2804
2805 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2806 {
2807 callcnt = --local->call_count;
2808
2809 if (op_ret == -1) {
2810 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 2812, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
2811 "%s returned %s",do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 2812, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
2812 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 2812, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
2813 local->op_errno = op_errno;
2814 if ((op_errno != ENOENT2) ||
2815 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
2816 local->failed = 1;
2817 }
2818 if (op_ret >= 0) {
2819 local->op_ret = op_ret;
2820 if (FIRST_CHILD(this)(this->children->xlator) == prev->this) {
2821 local->pre_buf = *prebuf;
2822 local->post_buf = *postbuf;
2823 }
2824 local->prebuf_blocks += prebuf->ia_blocks;
2825 local->postbuf_blocks += postbuf->ia_blocks;
2826
2827 correct_file_size(prebuf, local->fctx, prev);
2828 correct_file_size(postbuf, local->fctx, prev);
2829
2830 if (local->prebuf_size < prebuf->ia_size)
2831 local->prebuf_size = prebuf->ia_size;
2832
2833 if (local->postbuf_size < postbuf->ia_size)
2834 local->postbuf_size = postbuf->ia_size;
2835 }
2836 }
2837 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2838
2839 if (!callcnt) {
2840 if (local->failed)
2841 local->op_ret = -1;
2842
2843 if (local->op_ret != -1) {
2844 local->pre_buf.ia_blocks = local->prebuf_blocks;
2845 local->pre_buf.ia_size = local->prebuf_size;
2846 local->post_buf.ia_blocks = local->postbuf_blocks;
2847 local->post_buf.ia_size = local->postbuf_size;
2848 }
2849
2850 STRIPE_STACK_UNWIND (fsync, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 2852, 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, local->op_ret, local->op_errno, &local->
pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
2851 local->op_errno, &local->pre_buf,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 2852, 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, local->op_ret, local->op_errno, &local->
pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
2852 &local->post_buf, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 2852, 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, local->op_ret, local->op_errno, &local->
pre_buf, &local->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
2853 }
2854out:
2855 return 0;
2856}
2857
2858int32_t
2859stripe_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, dict_t *xdata)
2860{
2861 stripe_local_t *local = NULL((void*)0);
2862 stripe_private_t *priv = NULL((void*)0);
2863 xlator_list_t *trav = NULL((void*)0);
2864 stripe_fd_ctx_t *fctx = NULL((void*)0);
2865 int32_t op_errno = 1;
2866
2867 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2867, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
2868 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2868, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
2869 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2869, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
2870 VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "fd->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2870, GF_LOG_WARNING, "invalid argument: "
"fd->inode"); } while (0); goto err; } } while (0)
;
2871
2872 priv = this->private;
2873 trav = this->children;
2874
2875 /* Initialization */
2876 local = mem_get0 (this->local_pool);
2877 if (!local) {
2878 op_errno = ENOMEM12;
2879 goto err;
2880 }
2881
2882 inode_ctx_get(fd->inode, this, (uint64_t *) &fctx)inode_ctx_get2(fd->inode,this,(uint64_t *) &fctx,0);
2883 if (!fctx) {
2884 op_errno = EINVAL22;
2885 goto err;
2886 }
2887 local->fctx = fctx;
2888
2889 local->op_ret = -1;
2890 frame->local = local;
2891 local->call_count = priv->child_count;
2892
2893 while (trav) {
2894 STACK_WIND (frame, stripe_fsync_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 2895, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fsync_cbk) tmp_cbk = stripe_fsync_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->fsync"; _new->unwind_to = "stripe_fsync_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->fsync); trav->xlator->fops
->fsync (_new, trav->xlator, fd, flags, ((void*)0)); (*
__glusterfs_this_location()) = old_THIS; } while (0)
2895 trav->xlator->fops->fsync, fd, flags, 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", "stripe.c", __FUNCTION__, 2895, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fsync_cbk) tmp_cbk = stripe_fsync_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->fsync"; _new->unwind_to = "stripe_fsync_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->fsync); trav->xlator->fops
->fsync (_new, trav->xlator, fd, flags, ((void*)0)); (*
__glusterfs_this_location()) = old_THIS; } while (0)
;
2896 trav = trav->next;
2897 }
2898
2899 return 0;
2900err:
2901 STRIPE_STACK_UNWIND (fsync, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 2901, 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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
2902 return 0;
2903}
2904
2905int32_t
2906stripe_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2907 int32_t op_ret, int32_t op_errno, struct iatt *buf, dict_t *xdata)
2908{
2909 int32_t callcnt = 0;
2910 stripe_local_t *local = NULL((void*)0);
2911 call_frame_t *prev = NULL((void*)0);
2912
2913 if (!this || !frame || !frame->local || !cookie) {
2914 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 2914, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
2915 goto out;
2916 }
2917
2918 prev = cookie;
2919 local = frame->local;
2920
2921 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
2922 {
2923 callcnt = --local->call_count;
2924
2925 if (op_ret == -1) {
2926 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2928, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2927 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2928, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
2928 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 2928, GF_LOG_DEBUG, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
2929 local->op_errno = op_errno;
2930 if ((op_errno != ENOENT2) ||
2931 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
2932 local->failed = 1;
2933 }
2934
2935 if (op_ret == 0) {
2936 local->op_ret = 0;
2937
2938 if (FIRST_CHILD(this)(this->children->xlator) == prev->this)
2939 local->stbuf = *buf;
2940
2941 local->stbuf_blocks += buf->ia_blocks;
2942
2943 correct_file_size(buf, local->fctx, prev);
2944
2945 if (local->stbuf_size < buf->ia_size)
2946 local->stbuf_size = buf->ia_size;
2947 }
2948 }
2949 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
2950
2951 if (!callcnt) {
2952 if (local->failed)
2953 local->op_ret = -1;
2954
2955 if (local->op_ret != -1) {
2956 local->stbuf.ia_size = local->stbuf_size;
2957 local->stbuf.ia_blocks = local->stbuf_blocks;
2958 }
2959
2960 STRIPE_STACK_UNWIND (fstat, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_fstat_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", "stripe.c", __FUNCTION__
, 2961, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_fstat_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->
stbuf, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
2961 local->op_errno, &local->stbuf, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_fstat_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", "stripe.c", __FUNCTION__
, 2961, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_fstat_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->
stbuf, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
2962 }
2963
2964out:
2965 return 0;
2966}
2967
2968int32_t
2969stripe_fstat (call_frame_t *frame,
2970 xlator_t *this,
2971 fd_t *fd, dict_t *xdata)
2972{
2973 stripe_local_t *local = NULL((void*)0);
2974 stripe_private_t *priv = NULL((void*)0);
2975 xlator_list_t *trav = NULL((void*)0);
2976 stripe_fd_ctx_t *fctx = NULL((void*)0);
2977 int32_t op_errno = 1;
2978
2979 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2979, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
2980 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2980, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
2981 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 2981, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
2982 VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "fd->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 2982, GF_LOG_WARNING, "invalid argument: "
"fd->inode"); } while (0); goto err; } } while (0)
;
2983
2984 priv = this->private;
2985 trav = this->children;
2986
2987 /* Initialization */
2988 local = mem_get0 (this->local_pool);
2989 if (!local) {
2990 op_errno = ENOMEM12;
2991 goto err;
2992 }
2993 local->op_ret = -1;
2994 frame->local = local;
2995 local->call_count = priv->child_count;
2996
2997 if (IA_ISREG(fd->inode->ia_type)(fd->inode->ia_type == IA_IFREG)) {
2998 inode_ctx_get(fd->inode, this, (uint64_t *) &fctx)inode_ctx_get2(fd->inode,this,(uint64_t *) &fctx,0);
2999 if (!fctx)
3000 goto err;
3001 local->fctx = fctx;
3002 }
3003
3004 while (trav) {
3005 STACK_WIND (frame, stripe_fstat_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 3006, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fstat_cbk) tmp_cbk = stripe_fstat_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->fstat"; _new->unwind_to = "stripe_fstat_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->fstat); trav->xlator->fops
->fstat (_new, trav->xlator, fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3006 trav->xlator->fops->fstat, 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", "stripe.c", __FUNCTION__, 3006, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fstat_cbk) tmp_cbk = stripe_fstat_cbk; _new->
root = frame->root; _new->this = trav->xlator; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"trav->xlator->fops->fstat"; _new->unwind_to = "stripe_fstat_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->fstat); trav->xlator->fops
->fstat (_new, trav->xlator, fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
3007 trav = trav->next;
3008 }
3009
3010 return 0;
3011err:
3012 STRIPE_STACK_UNWIND (fstat, frame, -1, op_errno, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_fstat_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", "stripe.c", __FUNCTION__
, 3012, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_fstat_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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
3013 return 0;
3014}
3015
3016
3017int32_t
3018stripe_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, dict_t *xdata)
3019{
3020 stripe_local_t *local = NULL((void*)0);
3021 stripe_private_t *priv = NULL((void*)0);
3022 stripe_fd_ctx_t *fctx = NULL((void*)0);
3023 int i, eof_idx;
3024 off_t dest_offset, tmp_offset;
3025 int32_t op_errno = 1;
3026
3027 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3027, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
3028 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3028, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
3029 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3029, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
3030 VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "fd->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 3030, GF_LOG_WARNING, "invalid argument: "
"fd->inode"); } while (0); goto err; } } while (0)
;
3031
3032 priv = this->private;
3033
3034 /* Initialization */
3035 local = mem_get0 (this->local_pool);
3036 if (!local) {
3037 op_errno = ENOMEM12;
3038 goto err;
3039 }
3040 local->op_ret = -1;
3041 frame->local = local;
3042 local->call_count = priv->child_count;
3043
3044 inode_ctx_get(fd->inode, this, (uint64_t *) &fctx)inode_ctx_get2(fd->inode,this,(uint64_t *) &fctx,0);
3045 if (!fctx) {
3046 gf_log(this->name, GF_LOG_ERROR, "no stripe context")do { do { if (0) printf ("no stripe context"); } while (0); _gf_log
(this->name, "stripe.c", __FUNCTION__, 3046, GF_LOG_ERROR
, "no stripe context"); } while (0)
;
3047 op_errno = EINVAL22;
3048 goto err;
3049 }
3050 if (!fctx->stripe_count) {
3051 gf_log(this->name, GF_LOG_ERROR, "no stripe count")do { do { if (0) printf ("no stripe count"); } while (0); _gf_log
(this->name, "stripe.c", __FUNCTION__, 3051, GF_LOG_ERROR
, "no stripe count"); } while (0)
;
3052 op_errno = EINVAL22;
3053 goto err;
3054 }
3055
3056 local->fctx = fctx;
3057 eof_idx = (offset / fctx->stripe_size) % fctx->stripe_count;
3058
3059 for (i = 0; i < fctx->stripe_count; i++) {
3060 if (!fctx->xl_array[i]) {
3061 gf_log(this->name, GF_LOG_ERROR, "no xlator at index "do { do { if (0) printf ("no xlator at index " "%d", i); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 3062,
GF_LOG_ERROR, "no xlator at index " "%d", i); } while (0)
3062 "%d", i)do { do { if (0) printf ("no xlator at index " "%d", i); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 3062,
GF_LOG_ERROR, "no xlator at index " "%d", i); } while (0)
;
3063 op_errno = EINVAL22;
3064 goto err;
3065 }
3066
3067 if (fctx->stripe_coalesce) {
3068 if (i < eof_idx)
3069 tmp_offset = roof(offset, fctx->stripe_size *((((offset)+(fctx->stripe_size * fctx->stripe_count)-1)
/((fctx->stripe_size * fctx->stripe_count)?(fctx->stripe_size
* fctx->stripe_count):1))*(fctx->stripe_size * fctx->
stripe_count))
3070 fctx->stripe_count)((((offset)+(fctx->stripe_size * fctx->stripe_count)-1)
/((fctx->stripe_size * fctx->stripe_count)?(fctx->stripe_size
* fctx->stripe_count):1))*(fctx->stripe_size * fctx->
stripe_count))
;
3071 else if (i > eof_idx)
3072 tmp_offset = floor(offset, fctx->stripe_size *(((offset)/((fctx->stripe_size * fctx->stripe_count)?(fctx
->stripe_size * fctx->stripe_count):1))*(fctx->stripe_size
* fctx->stripe_count))
3073 fctx->stripe_count)(((offset)/((fctx->stripe_size * fctx->stripe_count)?(fctx
->stripe_size * fctx->stripe_count):1))*(fctx->stripe_size
* fctx->stripe_count))
;
3074 else
3075 tmp_offset = offset;
3076
3077 dest_offset = coalesced_offset(tmp_offset,
3078 fctx->stripe_size, fctx->stripe_count);
3079 } else {
3080 dest_offset = offset;
3081 }
3082
3083 STACK_WIND(frame, stripe_truncate_cbk, fctx->xl_array[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", "stripe.c", __FUNCTION__, 3085, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[i]->fops->ftruncate_cbk) tmp_cbk = stripe_truncate_cbk
; _new->root = frame->root; _new->this = fctx->xl_array
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[i]->fops->ftruncate";
_new->unwind_to = "stripe_truncate_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
()) = fctx->xl_array[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, fctx->xl_array[i]->fops->ftruncate
); fctx->xl_array[i]->fops->ftruncate (_new, fctx->
xl_array[i], fd, dest_offset, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3084 fctx->xl_array[i]->fops->ftruncate, fd, dest_offset,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", "stripe.c", __FUNCTION__, 3085, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[i]->fops->ftruncate_cbk) tmp_cbk = stripe_truncate_cbk
; _new->root = frame->root; _new->this = fctx->xl_array
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[i]->fops->ftruncate";
_new->unwind_to = "stripe_truncate_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
()) = fctx->xl_array[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, fctx->xl_array[i]->fops->ftruncate
); fctx->xl_array[i]->fops->ftruncate (_new, fctx->
xl_array[i], fd, dest_offset, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3085 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", "stripe.c", __FUNCTION__, 3085, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[i]->fops->ftruncate_cbk) tmp_cbk = stripe_truncate_cbk
; _new->root = frame->root; _new->this = fctx->xl_array
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[i]->fops->ftruncate";
_new->unwind_to = "stripe_truncate_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
()) = fctx->xl_array[i]; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, fctx->xl_array[i]->fops->ftruncate
); fctx->xl_array[i]->fops->ftruncate (_new, fctx->
xl_array[i], fd, dest_offset, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
3086 }
3087
3088 return 0;
3089err:
3090 STRIPE_STACK_UNWIND (ftruncate, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_ftruncate_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", "stripe.c", __FUNCTION__
, 3090, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_ftruncate_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
3091 return 0;
3092}
3093
3094
3095int32_t
3096stripe_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
3097 int32_t op_ret, int32_t op_errno, dict_t *xdata)
3098{
3099 int32_t callcnt = 0;
3100 stripe_local_t *local = NULL((void*)0);
3101 call_frame_t *prev = NULL((void*)0);
3102
3103 if (!this || !frame || !frame->local || !cookie) {
3104 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 3104, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
3105 goto out;
3106 }
3107
3108 prev = cookie;
3109 local = frame->local;
3110
3111 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
3112 {
3113 callcnt = --local->call_count;
3114
3115 if (op_ret == -1) {
3116 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 3118, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
3117 "%s returned %s",do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 3118, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
3118 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned %s", prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "stripe.c", __FUNCTION__, 3118, GF_LOG_DEBUG, "%s returned %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
3119 local->op_errno = op_errno;
3120 if ((op_errno != ENOENT2) ||
3121 (prev->this == FIRST_CHILD (this)(this->children->xlator)))
3122 local->failed = 1;
3123 }
3124 if (op_ret >= 0)
3125 local->op_ret = op_ret;
3126 }
3127 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
3128
3129 if (!callcnt) {
3130 if (local->failed)
3131 local->op_ret = -1;
3132
3133 STRIPE_STACK_UNWIND (fsyncdir, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 3134, 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, ((void*)0));
(*__glusterfs_this_location()) = old_THIS; } while (0); if (
__local) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
3134 local->op_errno, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 3134, 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, ((void*)0));
(*__glusterfs_this_location()) = old_THIS; } while (0); if (
__local) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
3135 }
3136out:
3137 return 0;
3138}
3139
3140int32_t
3141stripe_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, dict_t *xdata)
3142{
3143 stripe_local_t *local = NULL((void*)0);
3144 stripe_private_t *priv = NULL((void*)0);
3145 xlator_list_t *trav = NULL((void*)0);
3146 int32_t op_errno = 1;
3147
3148 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3148, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
3149 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3149, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
3150 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3150, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
3151 VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "fd->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 3151, GF_LOG_WARNING, "invalid argument: "
"fd->inode"); } while (0); goto err; } } while (0)
;
3152
3153 priv = this->private;
3154 trav = this->children;
3155
3156 /* Initialization */
3157 local = mem_get0 (this->local_pool);
3158 if (!local) {
3159 op_errno = ENOMEM12;
3160 goto err;
3161 }
3162 local->op_ret = -1;
3163 frame->local = local;
3164 local->call_count = priv->child_count;
3165
3166 while (trav) {
3167 STACK_WIND (frame, stripe_fsyncdir_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 3168, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fsyncdir_cbk) tmp_cbk = stripe_fsyncdir_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->fsyncdir"; _new->unwind_to
= "stripe_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->fsyncdir); trav->xlator->
fops->fsyncdir (_new, trav->xlator, fd, flags, ((void*)
0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
3168 trav->xlator->fops->fsyncdir, fd, flags, 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", "stripe.c", __FUNCTION__, 3168, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fsyncdir_cbk) tmp_cbk = stripe_fsyncdir_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->fsyncdir"; _new->unwind_to
= "stripe_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->fsyncdir); trav->xlator->
fops->fsyncdir (_new, trav->xlator, fd, flags, ((void*)
0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
3169 trav = trav->next;
3170 }
3171
3172 return 0;
3173err:
3174 STRIPE_STACK_UNWIND (fsyncdir, frame, -1, op_errno, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; 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", "stripe.c", __FUNCTION__
, 3174, 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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
3175 return 0;
3176}
3177
3178
3179int32_t
3180stripe_readv_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
3181 int32_t op_ret, int32_t op_errno, struct iatt *buf, dict_t *xdata)
3182{
3183 int32_t i = 0;
3184 int32_t callcnt = 0;
3185 int32_t count = 0;
3186 stripe_local_t *local = NULL((void*)0);
3187 struct iovec *vec = NULL((void*)0);
3188 struct iatt tmp_stbuf = {0,};
3189 struct iobref *tmp_iobref = NULL((void*)0);
3190 struct iobuf *iobuf = NULL((void*)0);
3191 call_frame_t *prev = NULL((void*)0);
3192
3193 if (!this || !frame || !frame->local) {
3194 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 3194, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
3195 goto out;
3196 }
3197
3198 local = frame->local;
3199 prev = cookie;
3200
3201 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
3202 {
3203 callcnt = --local->call_count;
3204 if (op_ret != -1) {
3205 correct_file_size(buf, local->fctx, prev);
3206 if (local->stbuf_size < buf->ia_size)
3207 local->stbuf_size = buf->ia_size;
3208 }
3209 }
3210 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
3211
3212 if (!callcnt) {
3213 op_ret = 0;
3214
3215 /* Keep extra space for filling in '\0's */
3216 vec = GF_CALLOC ((local->count * 2), sizeof (struct iovec),__gf_calloc ((local->count * 2), sizeof (struct iovec), gf_stripe_mt_iovec
)
3217 gf_stripe_mt_iovec)__gf_calloc ((local->count * 2), sizeof (struct iovec), gf_stripe_mt_iovec
)
;
3218 if (!vec) {
3219 op_ret = -1;
3220 goto done;
3221 }
3222
3223 for (i = 0; i < local->wind_count; i++) {
3224 if (local->replies[i].op_ret) {
3225 memcpy ((vec + count), local->replies[i].vector,
3226 (local->replies[i].count * sizeof (struct iovec)));
3227 count += local->replies[i].count;
3228 op_ret += local->replies[i].op_ret;
3229 }
3230 if ((local->replies[i].op_ret <
3231 local->replies[i].requested_size) &&
3232 (local->stbuf_size > (local->offset + op_ret))) {
3233 /* Fill in 0s here */
3234 vec[count].iov_len =
3235 (local->replies[i].requested_size -
3236 local->replies[i].op_ret);
3237 iobuf = iobuf_get2 (this->ctx->iobuf_pool,
3238 vec[count].iov_len);
3239 if (!iobuf) {
3240 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Out of memory."); } while (0); _gf_log
(this->name, "stripe.c", __FUNCTION__, 3241, GF_LOG_ERROR
, "Out of memory."); } while (0)
3241 "Out of memory.")do { do { if (0) printf ("Out of memory."); } while (0); _gf_log
(this->name, "stripe.c", __FUNCTION__, 3241, GF_LOG_ERROR
, "Out of memory."); } while (0)
;
3242 op_ret = -1;
3243 op_errno = ENOMEM12;
3244 goto done;
3245 }
3246 memset (iobuf->ptr, 0, vec[count].iov_len);
3247 vec[count].iov_base = iobuf->ptr;
3248
3249 iobref_add (local->iobref, iobuf);
3250 iobuf_unref(iobuf);
3251
3252 op_ret += vec[count].iov_len;
3253 count++;
3254 }
3255 GF_FREE (local->replies[i].vector)__gf_free (local->replies[i].vector);
3256 }
3257
3258 /* FIXME: notice that st_ino, and st_dev (gen) will be
3259 * different than what inode will have. Make sure this doesn't
3260 * cause any bugs at higher levels */
3261 memcpy (&tmp_stbuf, &local->replies[0].stbuf,
3262 sizeof (struct iatt));
3263 tmp_stbuf.ia_size = local->stbuf_size;
3264
3265 done:
3266 GF_FREE (local->replies)__gf_free (local->replies);
3267 tmp_iobref = local->iobref;
3268 STRIPE_STACK_UNWIND (readv, frame, op_ret, op_errno, vec,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_readv_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", "stripe.c", __FUNCTION__
, 3269, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_readv_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, op_ret, op_errno, vec, count, &tmp_stbuf, tmp_iobref
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
3269 count, &tmp_stbuf, tmp_iobref, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_readv_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", "stripe.c", __FUNCTION__
, 3269, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_readv_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, op_ret, op_errno, vec, count, &tmp_stbuf, tmp_iobref
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
;
3270
3271 iobref_unref (tmp_iobref);
3272 GF_FREE (vec)__gf_free (vec);
3273 }
3274out:
3275 return 0;
3276}
3277
3278/**
3279 * stripe_readv_cbk - get all the striped reads, and order it properly, send it
3280 * to above layer after putting it in a single vector.
3281 */
3282int32_t
3283stripe_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
3284 int32_t op_ret, int32_t op_errno, struct iovec *vector,
3285 int32_t count, struct iatt *stbuf, struct iobref *iobref, dict_t *xdata)
3286{
3287 int32_t index = 0;
3288 int32_t callcnt = 0;
3289 int32_t final_count = 0;
3290 int32_t need_to_check_proper_size = 0;
3291 call_frame_t *mframe = NULL((void*)0);
3292 stripe_local_t *mlocal = NULL((void*)0);
3293 stripe_local_t *local = NULL((void*)0);
3294 struct iovec *final_vec = NULL((void*)0);
3295 struct iatt tmp_stbuf = {0,};
3296 struct iatt *tmp_stbuf_p = NULL((void*)0); //need it for a warning
3297 struct iobref *tmp_iobref = NULL((void*)0);
3298 stripe_fd_ctx_t *fctx = NULL((void*)0);
3299 call_frame_t *prev = NULL((void*)0);
3300
3301 if (!this || !frame || !frame->local || !cookie) {
3302 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 3302, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
3303 goto end;
3304 }
3305
3306 local = frame->local;
3307 index = local->node_index;
3308 prev = cookie;
3309 mframe = local->orig_frame;
3310 if (!mframe)
3311 goto out;
3312
3313 mlocal = mframe->local;
3314 if (!mlocal)
3315 goto out;
3316
3317 fctx = mlocal->fctx;
3318
3319 LOCK (&mframe->lock)pthread_spin_lock (&mframe->lock);
3320 {
3321 mlocal->replies[index].op_ret = op_ret;
3322 mlocal->replies[index].op_errno = op_errno;
3323 mlocal->replies[index].requested_size = local->readv_size;
3324 if (op_ret >= 0) {
3325 mlocal->replies[index].stbuf = *stbuf;
3326 mlocal->replies[index].count = count;
3327 mlocal->replies[index].vector = iov_dup (vector, count);
3328
3329 correct_file_size(stbuf, fctx, prev);
3330
3331 if (local->stbuf_size < stbuf->ia_size)
3332 local->stbuf_size = stbuf->ia_size;
3333 local->stbuf_blocks += stbuf->ia_blocks;
3334
3335 if (!mlocal->iobref)
3336 mlocal->iobref = iobref_new ();
3337 iobref_merge (mlocal->iobref, iobref);
3338 }
3339 callcnt = ++mlocal->call_count;
3340 }
3341 UNLOCK(&mframe->lock)pthread_spin_unlock (&mframe->lock);
3342
3343 if (callcnt == mlocal->wind_count) {
3344 op_ret = 0;
3345
3346 for (index=0; index < mlocal->wind_count; index++) {
3347 /* check whether each stripe returned
3348 * 'expected' number of bytes */
3349 if (mlocal->replies[index].op_ret == -1) {
3350 op_ret = -1;
3351 op_errno = mlocal->replies[index].op_errno;
3352 break;
3353 }
3354 /* TODO: handle the 'holes' within the read range
3355 properly */
3356 if (mlocal->replies[index].op_ret <
3357 mlocal->replies[index].requested_size) {
3358 need_to_check_proper_size = 1;
3359 }
3360
3361 op_ret += mlocal->replies[index].op_ret;
3362 mlocal->count += mlocal->replies[index].count;
3363 }
3364 if (op_ret == -1)
3365 goto done;
3366 if (need_to_check_proper_size)
3367 goto check_size;
3368
3369 final_vec = GF_CALLOC (mlocal->count, sizeof (struct iovec),__gf_calloc (mlocal->count, sizeof (struct iovec), gf_stripe_mt_iovec
)
3370 gf_stripe_mt_iovec)__gf_calloc (mlocal->count, sizeof (struct iovec), gf_stripe_mt_iovec
)
;
3371
3372 if (!final_vec) {
3373 op_ret = -1;
3374 goto done;
3375 }
3376
3377 for (index = 0; index < mlocal->wind_count; index++) {
3378 memcpy ((final_vec + final_count),
3379 mlocal->replies[index].vector,
3380 (mlocal->replies[index].count *
3381 sizeof (struct iovec)));
3382 final_count += mlocal->replies[index].count;
3383 GF_FREE (mlocal->replies[index].vector)__gf_free (mlocal->replies[index].vector);
3384 }
3385
3386 /* FIXME: notice that st_ino, and st_dev (gen) will be
3387 * different than what inode will have. Make sure this doesn't
3388 * cause any bugs at higher levels */
3389 memcpy (&tmp_stbuf, &mlocal->replies[0].stbuf,
3390 sizeof (struct iatt));
3391 tmp_stbuf.ia_size = local->stbuf_size;
3392 tmp_stbuf.ia_blocks = local->stbuf_blocks;
3393
3394 done:
3395 /* */
3396 GF_FREE (mlocal->replies)__gf_free (mlocal->replies);
3397 tmp_iobref = mlocal->iobref;
3398 /* work around for nfs truncated read. Bug 3774 */
3399 tmp_stbuf_p = &tmp_stbuf;
3400 WIPE (tmp_stbuf_p)do { typeof(*tmp_stbuf_p) z = {0,}; if (tmp_stbuf_p) *tmp_stbuf_p
= z; } while (0)
;
3401 STRIPE_STACK_UNWIND (readv, mframe, op_ret, op_errno, final_vec,do { stripe_local_t *__local = ((void*)0); if (mframe) { __local
= mframe->local; mframe->local = ((void*)0); } do { fop_readv_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!mframe) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "stripe.c", __FUNCTION__
, 3402, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_readv_cbk_t )mframe->ret; _parent = mframe->parent
; pthread_spin_lock (&mframe->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&mframe->root
->stack_lock); old_THIS = (*__glusterfs_this_location()); (
*__glusterfs_this_location()) = _parent->this; mframe->
complete = _gf_true; mframe->unwind_from = __FUNCTION__; if
(mframe->this->ctx->measure_latency) gf_latency_end
(mframe); fn (_parent, mframe->cookie, _parent->this, op_ret
, op_errno, final_vec, final_count, &tmp_stbuf, tmp_iobref
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
3402 final_count, &tmp_stbuf, tmp_iobref, NULL)do { stripe_local_t *__local = ((void*)0); if (mframe) { __local
= mframe->local; mframe->local = ((void*)0); } do { fop_readv_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!mframe) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "stripe.c", __FUNCTION__
, 3402, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_readv_cbk_t )mframe->ret; _parent = mframe->parent
; pthread_spin_lock (&mframe->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&mframe->root
->stack_lock); old_THIS = (*__glusterfs_this_location()); (
*__glusterfs_this_location()) = _parent->this; mframe->
complete = _gf_true; mframe->unwind_from = __FUNCTION__; if
(mframe->this->ctx->measure_latency) gf_latency_end
(mframe); fn (_parent, mframe->cookie, _parent->this, op_ret
, op_errno, final_vec, final_count, &tmp_stbuf, tmp_iobref
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
;
3403
3404 iobref_unref (tmp_iobref);
3405 GF_FREE (final_vec)__gf_free (final_vec);
3406 }
3407
3408 goto out;
3409
3410check_size:
3411 mlocal->call_count = fctx->stripe_count;
3412
3413 for (index = 0; index < fctx->stripe_count; index++) {
3414 STACK_WIND (mframe, stripe_readv_fstat_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (mframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3417, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (fctx->xl_array
[index])->fops->fstat_cbk) tmp_cbk = stripe_readv_fstat_cbk
; _new->root = mframe->root; _new->this = (fctx->
xl_array[index]); _new->ret = (ret_fn_t) tmp_cbk; _new->
parent = mframe; _new->cookie = _new; _new->wind_from =
__FUNCTION__; _new->wind_to = "(fctx->xl_array[index])->fops->fstat"
; _new->unwind_to = "stripe_readv_fstat_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&mframe->
root->stack_lock); { _new->next = mframe->root->frames
.next; _new->prev = &mframe->root->frames; if (mframe
->root->frames.next) mframe->root->frames.next->
prev = _new; mframe->root->frames.next = _new; mframe->
ref_count++; } pthread_spin_unlock (&mframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (fctx->xl_array[index]); if (mframe->this->ctx
->measure_latency) gf_latency_begin (_new, (fctx->xl_array
[index])->fops->fstat); (fctx->xl_array[index])->
fops->fstat (_new, (fctx->xl_array[index]), mlocal->
fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; }
while (0)
3415 (fctx->xl_array[index]),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (mframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3417, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (fctx->xl_array
[index])->fops->fstat_cbk) tmp_cbk = stripe_readv_fstat_cbk
; _new->root = mframe->root; _new->this = (fctx->
xl_array[index]); _new->ret = (ret_fn_t) tmp_cbk; _new->
parent = mframe; _new->cookie = _new; _new->wind_from =
__FUNCTION__; _new->wind_to = "(fctx->xl_array[index])->fops->fstat"
; _new->unwind_to = "stripe_readv_fstat_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&mframe->
root->stack_lock); { _new->next = mframe->root->frames
.next; _new->prev = &mframe->root->frames; if (mframe
->root->frames.next) mframe->root->frames.next->
prev = _new; mframe->root->frames.next = _new; mframe->
ref_count++; } pthread_spin_unlock (&mframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (fctx->xl_array[index]); if (mframe->this->ctx
->measure_latency) gf_latency_begin (_new, (fctx->xl_array
[index])->fops->fstat); (fctx->xl_array[index])->
fops->fstat (_new, (fctx->xl_array[index]), mlocal->
fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; }
while (0)
3416 (fctx->xl_array[index])->fops->fstat,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (mframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3417, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (fctx->xl_array
[index])->fops->fstat_cbk) tmp_cbk = stripe_readv_fstat_cbk
; _new->root = mframe->root; _new->this = (fctx->
xl_array[index]); _new->ret = (ret_fn_t) tmp_cbk; _new->
parent = mframe; _new->cookie = _new; _new->wind_from =
__FUNCTION__; _new->wind_to = "(fctx->xl_array[index])->fops->fstat"
; _new->unwind_to = "stripe_readv_fstat_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&mframe->
root->stack_lock); { _new->next = mframe->root->frames
.next; _new->prev = &mframe->root->frames; if (mframe
->root->frames.next) mframe->root->frames.next->
prev = _new; mframe->root->frames.next = _new; mframe->
ref_count++; } pthread_spin_unlock (&mframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (fctx->xl_array[index]); if (mframe->this->ctx
->measure_latency) gf_latency_begin (_new, (fctx->xl_array
[index])->fops->fstat); (fctx->xl_array[index])->
fops->fstat (_new, (fctx->xl_array[index]), mlocal->
fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; }
while (0)
3417 mlocal->fd, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (mframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3417, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (fctx->xl_array
[index])->fops->fstat_cbk) tmp_cbk = stripe_readv_fstat_cbk
; _new->root = mframe->root; _new->this = (fctx->
xl_array[index]); _new->ret = (ret_fn_t) tmp_cbk; _new->
parent = mframe; _new->cookie = _new; _new->wind_from =
__FUNCTION__; _new->wind_to = "(fctx->xl_array[index])->fops->fstat"
; _new->unwind_to = "stripe_readv_fstat_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&mframe->
root->stack_lock); { _new->next = mframe->root->frames
.next; _new->prev = &mframe->root->frames; if (mframe
->root->frames.next) mframe->root->frames.next->
prev = _new; mframe->root->frames.next = _new; mframe->
ref_count++; } pthread_spin_unlock (&mframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (fctx->xl_array[index]); if (mframe->this->ctx
->measure_latency) gf_latency_begin (_new, (fctx->xl_array
[index])->fops->fstat); (fctx->xl_array[index])->
fops->fstat (_new, (fctx->xl_array[index]), mlocal->
fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; }
while (0)
;
3418 }
3419
3420out:
3421 STRIPE_STACK_DESTROY (frame)do { stripe_local_t *__local = ((void*)0); __local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); if (__local) { stripe_local_wipe (__local); mem_put (__local
); } } while (0)
;
3422end:
3423 return 0;
3424}
3425
3426
3427int32_t
3428stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
3429 size_t size, off_t offset, uint32_t flags, dict_t *xdata)
3430{
3431 int32_t op_errno = EINVAL22;
3432 int32_t idx = 0;
3433 int32_t index = 0;
3434 int32_t num_stripe = 0;
3435 int32_t off_index = 0;
3436 size_t frame_size = 0;
3437 off_t rounded_end = 0;
3438 uint64_t tmp_fctx = 0;
3439 uint64_t stripe_size = 0;
3440 off_t rounded_start = 0;
3441 off_t frame_offset = offset;
3442 off_t dest_offset = 0;
3443 stripe_local_t *local = NULL((void*)0);
3444 call_frame_t *rframe = NULL((void*)0);
3445 stripe_local_t *rlocal = NULL((void*)0);
3446 stripe_fd_ctx_t *fctx = NULL((void*)0);
3447
3448 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3448, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
3449 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3449, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
3450 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3450, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
3451 VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "fd->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 3451, GF_LOG_WARNING, "invalid argument: "
"fd->inode"); } while (0); goto err; } } while (0)
;
3452
3453 inode_ctx_get (fd->inode, this, &tmp_fctx)inode_ctx_get2(fd->inode,this,&tmp_fctx,0);
3454 if (!tmp_fctx) {
3455 op_errno = EBADFD77;
3456 goto err;
3457 }
3458 fctx = (stripe_fd_ctx_t *)(long)tmp_fctx;
3459 stripe_size = fctx->stripe_size;
3460
3461 STRIPE_VALIDATE_FCTX (fctx, err)do { int idx = 0; if (!fctx) { op_errno = 22; goto err; } for
(idx = 0; idx < fctx->stripe_count; idx++) { if (!fctx
->xl_array[idx]) { do { do { if (0) printf ("fctx->xl_array[%d] is NULL"
, idx); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 3461, GF_LOG_ERROR, "fctx->xl_array[%d] is NULL", idx); }
while (0); op_errno = 116; goto err; } } } while (0)
;
3462
3463 if (!stripe_size) {
3464 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Wrong stripe size for the file"); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
3465, GF_LOG_DEBUG, "Wrong stripe size for the file"); } while
(0)
3465 "Wrong stripe size for the file")do { do { if (0) printf ("Wrong stripe size for the file"); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
3465, GF_LOG_DEBUG, "Wrong stripe size for the file"); } while
(0)
;
3466 goto err;
3467 }
3468 /* The file is stripe across the child nodes. Send the read request
3469 * to the child nodes appropriately after checking which region of
3470 * the file is in which child node. Always '0-<stripe_size>' part of
3471 * the file resides in the first child.
3472 */
3473 rounded_start = floor (offset, stripe_size)(((offset)/((stripe_size)?(stripe_size):1))*(stripe_size));
3474 rounded_end = roof (offset+size, stripe_size)((((offset+size)+(stripe_size)-1)/((stripe_size)?(stripe_size
):1))*(stripe_size))
;
3475 num_stripe = (rounded_end- rounded_start)/stripe_size;
3476
3477 local = mem_get0 (this->local_pool);
3478 if (!local) {
3479 op_errno = ENOMEM12;
3480 goto err;
3481 }
3482 frame->local = local;
3483
3484 /* This is where all the vectors should be copied. */
3485 local->replies = GF_CALLOC (num_stripe, sizeof (struct stripe_replies),__gf_calloc (num_stripe, sizeof (struct stripe_replies), gf_stripe_mt_stripe_replies
)
3486 gf_stripe_mt_stripe_replies)__gf_calloc (num_stripe, sizeof (struct stripe_replies), gf_stripe_mt_stripe_replies
)
;
3487 if (!local->replies) {
3488 op_errno = ENOMEM12;
3489 goto err;
3490 }
3491
3492 off_index = (offset / stripe_size) % fctx->stripe_count;
3493 local->wind_count = num_stripe;
3494 local->readv_size = size;
3495 local->offset = offset;
3496 local->fd = fd_ref (fd);
3497 local->fctx = fctx;
3498
3499 for (index = off_index; index < (num_stripe + off_index); index++) {
3500 rframe = copy_frame (frame);
3501 rlocal = mem_get0 (this->local_pool);
3502 if (!rlocal) {
3503 op_errno = ENOMEM12;
3504 goto err;
3505 }
3506
3507 frame_size = min (roof (frame_offset+1, stripe_size),((((((frame_offset+1)+(stripe_size)-1)/((stripe_size)?(stripe_size
):1))*(stripe_size)))<((offset + size))?(((((frame_offset+
1)+(stripe_size)-1)/((stripe_size)?(stripe_size):1))*(stripe_size
))):((offset + size)))
3508 (offset + size))((((((frame_offset+1)+(stripe_size)-1)/((stripe_size)?(stripe_size
):1))*(stripe_size)))<((offset + size))?(((((frame_offset+
1)+(stripe_size)-1)/((stripe_size)?(stripe_size):1))*(stripe_size
))):((offset + size)))
- frame_offset;
3509
3510 rlocal->node_index = index - off_index;
3511 rlocal->orig_frame = frame;
3512 rlocal->readv_size = frame_size;
3513 rframe->local = rlocal;
3514 idx = (index % fctx->stripe_count);
3515
3516 if (fctx->stripe_coalesce)
3517 dest_offset = coalesced_offset(frame_offset,
3518 stripe_size, fctx->stripe_count);
3519 else
3520 dest_offset = frame_offset;
3521
3522 STACK_WIND (rframe, stripe_readv_cbk, fctx->xl_array[idx],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3524, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[idx]->fops->readv_cbk) tmp_cbk = stripe_readv_cbk; _new
->root = rframe->root; _new->this = fctx->xl_array
[idx]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[idx]->fops->readv"; _new
->unwind_to = "stripe_readv_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = fctx->xl_array[idx]; if (rframe->this->ctx->
measure_latency) gf_latency_begin (_new, fctx->xl_array[idx
]->fops->readv); fctx->xl_array[idx]->fops->readv
(_new, fctx->xl_array[idx], fd, frame_size, dest_offset, flags
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
3523 fctx->xl_array[idx]->fops->readv,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3524, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[idx]->fops->readv_cbk) tmp_cbk = stripe_readv_cbk; _new
->root = rframe->root; _new->this = fctx->xl_array
[idx]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[idx]->fops->readv"; _new
->unwind_to = "stripe_readv_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = fctx->xl_array[idx]; if (rframe->this->ctx->
measure_latency) gf_latency_begin (_new, fctx->xl_array[idx
]->fops->readv); fctx->xl_array[idx]->fops->readv
(_new, fctx->xl_array[idx], fd, frame_size, dest_offset, flags
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
3524 fd, frame_size, dest_offset, flags, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (rframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3524, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[idx]->fops->readv_cbk) tmp_cbk = stripe_readv_cbk; _new
->root = rframe->root; _new->this = fctx->xl_array
[idx]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = rframe
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[idx]->fops->readv"; _new
->unwind_to = "stripe_readv_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&rframe->root->
stack_lock); { _new->next = rframe->root->frames.next
; _new->prev = &rframe->root->frames; if (rframe
->root->frames.next) rframe->root->frames.next->
prev = _new; rframe->root->frames.next = _new; rframe->
ref_count++; } pthread_spin_unlock (&rframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = fctx->xl_array[idx]; if (rframe->this->ctx->
measure_latency) gf_latency_begin (_new, fctx->xl_array[idx
]->fops->readv); fctx->xl_array[idx]->fops->readv
(_new, fctx->xl_array[idx], fd, frame_size, dest_offset, flags
, xdata); (*__glusterfs_this_location()) = old_THIS; } while (
0)
;
3525
3526 frame_offset += frame_size;
3527 }
3528
3529 return 0;
3530err:
3531 if (rframe)
3532 STRIPE_STACK_DESTROY (rframe)do { stripe_local_t *__local = ((void*)0); __local = rframe->
local; rframe->local = ((void*)0); STACK_DESTROY (rframe->
root); if (__local) { stripe_local_wipe (__local); mem_put (__local
); } } while (0)
;
3533
3534 STRIPE_STACK_UNWIND (readv, frame, -1, op_errno, NULL, 0, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_readv_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", "stripe.c", __FUNCTION__
, 3534, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_readv_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), 0, ((void*)0), ((void*)0
), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0); if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
;
3535 return 0;
3536}
3537
3538
3539int32_t
3540stripe_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
3541 int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
3542 struct iatt *postbuf, dict_t *xdata)
3543{
3544 int32_t callcnt = 0;
3545 stripe_local_t *local = NULL((void*)0);
3546 stripe_local_t *mlocal = NULL((void*)0);
3547 call_frame_t *prev = NULL((void*)0);
3548 call_frame_t *mframe = NULL((void*)0);
3549 struct stripe_replies *reply = NULL((void*)0);
3550 int32_t i = 0;
3551
3552 if (!this || !frame || !frame->local || !cookie) {
3553 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 3553, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
3554 goto out;
3555 }
3556
3557 prev = cookie;
3558 local = frame->local;
3559 mframe = local->orig_frame;
3560 mlocal = mframe->local;
3561
3562 LOCK(&frame->lock)pthread_spin_lock (&frame->lock);
3563 {
3564 callcnt = ++mlocal->call_count;
3565
3566 mlocal->replies[local->node_index].op_ret = op_ret;
3567 mlocal->replies[local->node_index].op_errno = op_errno;
3568
3569 if (op_ret >= 0) {
3570 mlocal->post_buf = *postbuf;
3571 mlocal->pre_buf = *prebuf;
3572
3573 mlocal->prebuf_blocks += prebuf->ia_blocks;
3574 mlocal->postbuf_blocks += postbuf->ia_blocks;
3575
3576 correct_file_size(prebuf, mlocal->fctx, prev);
3577 correct_file_size(postbuf, mlocal->fctx, prev);
3578
3579 if (mlocal->prebuf_size < prebuf->ia_size)
3580 mlocal->prebuf_size = prebuf->ia_size;
3581 if (mlocal->postbuf_size < postbuf->ia_size)
3582 mlocal->postbuf_size = postbuf->ia_size;
3583 }
3584 }
3585 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
3586
3587 if ((callcnt == mlocal->wind_count) && mlocal->unwind) {
3588 mlocal->pre_buf.ia_size = mlocal->prebuf_size;
3589 mlocal->pre_buf.ia_blocks = mlocal->prebuf_blocks;
3590 mlocal->post_buf.ia_size = mlocal->postbuf_size;
3591 mlocal->post_buf.ia_blocks = mlocal->postbuf_blocks;
3592
3593 /*
3594 * Only return the number of consecutively written bytes up until
3595 * the first error. Only return an error if it occurs first.
3596 *
3597 * When a short write occurs, the application should retry at the
3598 * appropriate offset, at which point we'll potentially pass back
3599 * the error.
3600 */
3601 for (i = 0, reply = mlocal->replies; i < mlocal->wind_count;
3602 i++, reply++) {
3603 if (reply->op_ret == -1) {
3604 gf_log(this->name, GF_LOG_DEBUG, "reply %d "do { do { if (0) printf ("reply %d " "returned error %s", i, strerror
(reply->op_errno)); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 3606, GF_LOG_DEBUG, "reply %d " "returned error %s"
, i, strerror(reply->op_errno)); } while (0)
3605 "returned error %s", i,do { do { if (0) printf ("reply %d " "returned error %s", i, strerror
(reply->op_errno)); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 3606, GF_LOG_DEBUG, "reply %d " "returned error %s"
, i, strerror(reply->op_errno)); } while (0)
3606 strerror(reply->op_errno))do { do { if (0) printf ("reply %d " "returned error %s", i, strerror
(reply->op_errno)); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 3606, GF_LOG_DEBUG, "reply %d " "returned error %s"
, i, strerror(reply->op_errno)); } while (0)
;
3607 if (!mlocal->op_ret) {
3608 mlocal->op_ret = -1;
3609 mlocal->op_errno = reply->op_errno;
3610 }
3611 break;
3612 }
3613
3614 mlocal->op_ret += reply->op_ret;
3615
3616 if (reply->op_ret < reply->requested_size)
3617 break;
3618 }
3619
3620 GF_FREE(mlocal->replies)__gf_free (mlocal->replies);
3621
3622 STRIPE_STACK_UNWIND (writev, mframe, mlocal->op_ret,do { stripe_local_t *__local = ((void*)0); if (mframe) { __local
= mframe->local; mframe->local = ((void*)0); } do { fop_writev_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!mframe) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "stripe.c", __FUNCTION__
, 3624, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_writev_cbk_t )mframe->ret; _parent = mframe->parent
; pthread_spin_lock (&mframe->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&mframe->root
->stack_lock); old_THIS = (*__glusterfs_this_location()); (
*__glusterfs_this_location()) = _parent->this; mframe->
complete = _gf_true; mframe->unwind_from = __FUNCTION__; if
(mframe->this->ctx->measure_latency) gf_latency_end
(mframe); fn (_parent, mframe->cookie, _parent->this, mlocal
->op_ret, mlocal->op_errno, &mlocal->pre_buf, &
mlocal->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
3623 mlocal->op_errno, &mlocal->pre_buf,do { stripe_local_t *__local = ((void*)0); if (mframe) { __local
= mframe->local; mframe->local = ((void*)0); } do { fop_writev_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!mframe) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "stripe.c", __FUNCTION__
, 3624, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_writev_cbk_t )mframe->ret; _parent = mframe->parent
; pthread_spin_lock (&mframe->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&mframe->root
->stack_lock); old_THIS = (*__glusterfs_this_location()); (
*__glusterfs_this_location()) = _parent->this; mframe->
complete = _gf_true; mframe->unwind_from = __FUNCTION__; if
(mframe->this->ctx->measure_latency) gf_latency_end
(mframe); fn (_parent, mframe->cookie, _parent->this, mlocal
->op_ret, mlocal->op_errno, &mlocal->pre_buf, &
mlocal->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
3624 &mlocal->post_buf, NULL)do { stripe_local_t *__local = ((void*)0); if (mframe) { __local
= mframe->local; mframe->local = ((void*)0); } do { fop_writev_cbk_t
fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t
*old_THIS = ((void*)0); if (!mframe) { do { do { if (0) printf
("!frame"); } while (0); _gf_log ("stack", "stripe.c", __FUNCTION__
, 3624, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_writev_cbk_t )mframe->ret; _parent = mframe->parent
; pthread_spin_lock (&mframe->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&mframe->root
->stack_lock); old_THIS = (*__glusterfs_this_location()); (
*__glusterfs_this_location()) = _parent->this; mframe->
complete = _gf_true; mframe->unwind_from = __FUNCTION__; if
(mframe->this->ctx->measure_latency) gf_latency_end
(mframe); fn (_parent, mframe->cookie, _parent->this, mlocal
->op_ret, mlocal->op_errno, &mlocal->pre_buf, &
mlocal->post_buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
3625 }
3626out:
3627 STRIPE_STACK_DESTROY(frame)do { stripe_local_t *__local = ((void*)0); __local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); if (__local) { stripe_local_wipe (__local); mem_put (__local
); } } while (0)
;
3628 return 0;
3629}
3630
3631int32_t
3632stripe_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
3633 struct iovec *vector, int32_t count, off_t offset,
3634 uint32_t flags, struct iobref *iobref, dict_t *xdata)
3635{
3636 struct iovec *tmp_vec = NULL((void*)0);
3637 stripe_local_t *local = NULL((void*)0);
3638 stripe_fd_ctx_t *fctx = NULL((void*)0);
3639 int32_t op_errno = 1;
3640 int32_t idx = 0;
3641 int32_t total_size = 0;
3642 int32_t offset_offset = 0;
3643 int32_t remaining_size = 0;
3644 int32_t tmp_count = count;
3645 off_t fill_size = 0;
3646 uint64_t stripe_size = 0;
3647 uint64_t tmp_fctx = 0;
3648 off_t dest_offset = 0;
3649 off_t rounded_start = 0;
3650 off_t rounded_end = 0;
3651 int32_t total_chunks = 0;
3652 call_frame_t *wframe = NULL((void*)0);
3653 stripe_local_t *wlocal = NULL((void*)0);
3654
3655 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3655, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
3656 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3656, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
3657 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3657, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
3658 VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "fd->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 3658, GF_LOG_WARNING, "invalid argument: "
"fd->inode"); } while (0); goto err; } } while (0)
;
3659
3660 inode_ctx_get (fd->inode, this, &tmp_fctx)inode_ctx_get2(fd->inode,this,&tmp_fctx,0);
3661 if (!tmp_fctx) {
3662 op_errno = EINVAL22;
3663 goto err;
3664 }
3665 fctx = (stripe_fd_ctx_t *)(long)tmp_fctx;
3666 stripe_size = fctx->stripe_size;
3667
3668 STRIPE_VALIDATE_FCTX (fctx, err)do { int idx = 0; if (!fctx) { op_errno = 22; goto err; } for
(idx = 0; idx < fctx->stripe_count; idx++) { if (!fctx
->xl_array[idx]) { do { do { if (0) printf ("fctx->xl_array[%d] is NULL"
, idx); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 3668, GF_LOG_ERROR, "fctx->xl_array[%d] is NULL", idx); }
while (0); op_errno = 116; goto err; } } } while (0)
;
3669
3670 /* File has to be stripped across the child nodes */
3671 for (idx = 0; idx< count; idx ++) {
3672 total_size += vector[idx].iov_len;
3673 }
3674 remaining_size = total_size;
3675
3676 local = mem_get0 (this->local_pool);
3677 if (!local) {
3678 op_errno = ENOMEM12;
3679 goto err;
3680 }
3681 frame->local = local;
3682 local->stripe_size = stripe_size;
3683 local->fctx = fctx;
3684
3685 if (!stripe_size) {
3686 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Wrong stripe size for the file"); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
3687, GF_LOG_DEBUG, "Wrong stripe size for the file"); } while
(0)
3687 "Wrong stripe size for the file")do { do { if (0) printf ("Wrong stripe size for the file"); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
3687, GF_LOG_DEBUG, "Wrong stripe size for the file"); } while
(0)
;
3688 op_errno = EINVAL22;
3689 goto err;
3690 }
3691
3692 rounded_start = floor(offset, stripe_size)(((offset)/((stripe_size)?(stripe_size):1))*(stripe_size));
3693 rounded_end = roof(offset + total_size, stripe_size)((((offset + total_size)+(stripe_size)-1)/((stripe_size)?(stripe_size
):1))*(stripe_size))
;
3694 total_chunks = (rounded_end - rounded_start) / stripe_size;
3695 local->replies = GF_CALLOC(total_chunks, sizeof(struct stripe_replies),__gf_calloc (total_chunks, sizeof(struct stripe_replies), gf_stripe_mt_stripe_replies
)
3696 gf_stripe_mt_stripe_replies)__gf_calloc (total_chunks, sizeof(struct stripe_replies), gf_stripe_mt_stripe_replies
)
;
3697 if (!local->replies) {
3698 op_errno = ENOMEM12;
3699 goto err;
3700 }
3701
3702 total_chunks = 0;
3703 while (1) {
3704 wframe = copy_frame(frame);
3705 wlocal = mem_get0(this->local_pool);
3706 if (!wlocal) {
3707 op_errno = ENOMEM12;
3708 goto err;
3709 }
3710 wlocal->orig_frame = frame;
3711 wframe->local = wlocal;
3712
3713 /* Send striped chunk of the vector to child
3714 nodes appropriately. */
3715 idx = (((offset + offset_offset) /
3716 local->stripe_size) % fctx->stripe_count);
3717
3718 fill_size = (local->stripe_size -
3719 ((offset + offset_offset) % local->stripe_size));
3720 if (fill_size > remaining_size)
3721 fill_size = remaining_size;
3722
3723 remaining_size -= fill_size;
3724
3725 tmp_count = iov_subset (vector, count, offset_offset,
3726 offset_offset + fill_size, NULL((void*)0));
3727 tmp_vec = GF_CALLOC (tmp_count, sizeof (struct iovec),__gf_calloc (tmp_count, sizeof (struct iovec), gf_stripe_mt_iovec
)
3728 gf_stripe_mt_iovec)__gf_calloc (tmp_count, sizeof (struct iovec), gf_stripe_mt_iovec
)
;
3729 if (!tmp_vec) {
3730 op_errno = ENOMEM12;
3731 goto err;
3732 }
3733 tmp_count = iov_subset (vector, count, offset_offset,
3734 offset_offset + fill_size, tmp_vec);
3735
3736 local->wind_count++;
3737 if (remaining_size == 0)
3738 local->unwind = 1;
3739
3740 /*
3741 * Store off the request index (with respect to the chunk of the
3742 * initial offset) and the size of the request. This is required
3743 * in the callback to calculate an appropriate return value in
3744 * the event of a write failure in one or more requests.
3745 */
3746 wlocal->node_index = total_chunks;
3747 local->replies[total_chunks].requested_size = fill_size;
3748
3749 dest_offset = offset + offset_offset;
3750 if (fctx->stripe_coalesce)
3751 dest_offset = coalesced_offset(dest_offset,
3752 local->stripe_size, fctx->stripe_count);
3753
3754 STACK_WIND (wframe, stripe_writev_cbk, fctx->xl_array[idx],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (wframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3757, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[idx]->fops->writev_cbk) tmp_cbk = stripe_writev_cbk; _new
->root = wframe->root; _new->this = fctx->xl_array
[idx]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = wframe
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[idx]->fops->writev"; _new
->unwind_to = "stripe_writev_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&wframe->root->
stack_lock); { _new->next = wframe->root->frames.next
; _new->prev = &wframe->root->frames; if (wframe
->root->frames.next) wframe->root->frames.next->
prev = _new; wframe->root->frames.next = _new; wframe->
ref_count++; } pthread_spin_unlock (&wframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = fctx->xl_array[idx]; if (wframe->this->ctx->
measure_latency) gf_latency_begin (_new, fctx->xl_array[idx
]->fops->writev); fctx->xl_array[idx]->fops->writev
(_new, fctx->xl_array[idx], fd, tmp_vec, tmp_count, dest_offset
, flags, iobref, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
3755 fctx->xl_array[idx]->fops->writev, fd, tmp_vec,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (wframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3757, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[idx]->fops->writev_cbk) tmp_cbk = stripe_writev_cbk; _new
->root = wframe->root; _new->this = fctx->xl_array
[idx]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = wframe
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[idx]->fops->writev"; _new
->unwind_to = "stripe_writev_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&wframe->root->
stack_lock); { _new->next = wframe->root->frames.next
; _new->prev = &wframe->root->frames; if (wframe
->root->frames.next) wframe->root->frames.next->
prev = _new; wframe->root->frames.next = _new; wframe->
ref_count++; } pthread_spin_unlock (&wframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = fctx->xl_array[idx]; if (wframe->this->ctx->
measure_latency) gf_latency_begin (_new, fctx->xl_array[idx
]->fops->writev); fctx->xl_array[idx]->fops->writev
(_new, fctx->xl_array[idx], fd, tmp_vec, tmp_count, dest_offset
, flags, iobref, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
3756 tmp_count, dest_offset, flags, iobref,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (wframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3757, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[idx]->fops->writev_cbk) tmp_cbk = stripe_writev_cbk; _new
->root = wframe->root; _new->this = fctx->xl_array
[idx]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = wframe
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[idx]->fops->writev"; _new
->unwind_to = "stripe_writev_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&wframe->root->
stack_lock); { _new->next = wframe->root->frames.next
; _new->prev = &wframe->root->frames; if (wframe
->root->frames.next) wframe->root->frames.next->
prev = _new; wframe->root->frames.next = _new; wframe->
ref_count++; } pthread_spin_unlock (&wframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = fctx->xl_array[idx]; if (wframe->this->ctx->
measure_latency) gf_latency_begin (_new, fctx->xl_array[idx
]->fops->writev); fctx->xl_array[idx]->fops->writev
(_new, fctx->xl_array[idx], fd, tmp_vec, tmp_count, dest_offset
, flags, iobref, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
3757 xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (wframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "stripe.c", __FUNCTION__, 3757, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( fctx->xl_array
[idx]->fops->writev_cbk) tmp_cbk = stripe_writev_cbk; _new
->root = wframe->root; _new->this = fctx->xl_array
[idx]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = wframe
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "fctx->xl_array[idx]->fops->writev"; _new
->unwind_to = "stripe_writev_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&wframe->root->
stack_lock); { _new->next = wframe->root->frames.next
; _new->prev = &wframe->root->frames; if (wframe
->root->frames.next) wframe->root->frames.next->
prev = _new; wframe->root->frames.next = _new; wframe->
ref_count++; } pthread_spin_unlock (&wframe->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = fctx->xl_array[idx]; if (wframe->this->ctx->
measure_latency) gf_latency_begin (_new, fctx->xl_array[idx
]->fops->writev); fctx->xl_array[idx]->fops->writev
(_new, fctx->xl_array[idx], fd, tmp_vec, tmp_count, dest_offset
, flags, iobref, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
3758
3759 GF_FREE (tmp_vec)__gf_free (tmp_vec);
3760 offset_offset += fill_size;
3761 total_chunks++;
3762 if (remaining_size == 0)
3763 break;
3764 }
3765
3766 return 0;
3767err:
3768 if (wframe)
3769 STRIPE_STACK_DESTROY(wframe)do { stripe_local_t *__local = ((void*)0); __local = wframe->
local; wframe->local = ((void*)0); STACK_DESTROY (wframe->
root); if (__local) { stripe_local_wipe (__local); mem_put (__local
); } } while (0)
;
3770
3771 STRIPE_STACK_UNWIND (writev, frame, -1, op_errno, NULL, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_writev_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", "stripe.c", __FUNCTION__
, 3771, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_writev_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
3772 return 0;
3773}
3774
3775
3776int32_t
3777stripe_release (xlator_t *this, fd_t *fd)
3778{
3779 return 0;
3780}
3781
3782int
3783stripe_forget (xlator_t *this, inode_t *inode)
3784{
3785 uint64_t tmp_fctx = 0;
3786 stripe_fd_ctx_t *fctx = NULL((void*)0);
3787
3788 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3788, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
3789 VALIDATE_OR_GOTO (inode, err)do { if (!inode) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "inode"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3789, GF_LOG_WARNING, "invalid argument: " "inode"
); } while (0); goto err; } } while (0)
;
3790
3791 (void) inode_ctx_del (inode, this, &tmp_fctx)inode_ctx_del2(inode,this,&tmp_fctx,0);
3792 if (!tmp_fctx) {
3793 goto err;
3794 }
3795
3796 fctx = (stripe_fd_ctx_t *)(long)tmp_fctx;
3797
3798 if (!fctx->static_array)
3799 GF_FREE (fctx->xl_array)__gf_free (fctx->xl_array);
3800
3801 GF_FREE (fctx)__gf_free (fctx);
3802err:
3803 return 0;
3804}
3805
3806int32_t
3807notify (xlator_t *this, int32_t event, void *data, ...)
3808{
3809 stripe_private_t *priv = NULL((void*)0);
3810 int down_client = 0;
3811 int i = 0;
3812 gf_boolean_t heard_from_all_children = _gf_false;
3813
3814 if (!this)
3815 return 0;
3816
3817 priv = this->private;
3818 if (!priv)
3819 return 0;
3820
3821 switch (event)
3822 {
3823 case GF_EVENT_CHILD_UP:
3824 {
3825 /* get an index number to set */
3826 for (i = 0; i < priv->child_count; i++) {
3827 if (data == priv->xl_array[i])
3828 break;
3829 }
3830
3831 if (priv->child_count == i) {
3832 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("got GF_EVENT_CHILD_UP bad subvolume %s"
, data? ((xlator_t *)data)->name: ((void*)0)); } while (0)
; _gf_log (this->name, "stripe.c", __FUNCTION__, 3834, GF_LOG_ERROR
, "got GF_EVENT_CHILD_UP bad subvolume %s", data? ((xlator_t *
)data)->name: ((void*)0)); } while (0)
3833 "got GF_EVENT_CHILD_UP bad subvolume %s",do { do { if (0) printf ("got GF_EVENT_CHILD_UP bad subvolume %s"
, data? ((xlator_t *)data)->name: ((void*)0)); } while (0)
; _gf_log (this->name, "stripe.c", __FUNCTION__, 3834, GF_LOG_ERROR
, "got GF_EVENT_CHILD_UP bad subvolume %s", data? ((xlator_t *
)data)->name: ((void*)0)); } while (0)
3834 data? ((xlator_t *)data)->name: NULL)do { do { if (0) printf ("got GF_EVENT_CHILD_UP bad subvolume %s"
, data? ((xlator_t *)data)->name: ((void*)0)); } while (0)
; _gf_log (this->name, "stripe.c", __FUNCTION__, 3834, GF_LOG_ERROR
, "got GF_EVENT_CHILD_UP bad subvolume %s", data? ((xlator_t *
)data)->name: ((void*)0)); } while (0)
;
3835 break;
3836 }
3837
3838 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
3839 {
3840 if (data == FIRST_CHILD (this)(this->children->xlator))
3841 priv->first_child_down = 0;
3842 priv->last_event[i] = event;
3843 }
3844 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
3845 }
3846 break;
3847 case GF_EVENT_CHILD_CONNECTING:
3848 {
3849 // 'CONNECTING' doesn't ensure its CHILD_UP, so do nothing
3850 goto out;
3851 }
3852 case GF_EVENT_CHILD_DOWN:
3853 {
3854 /* get an index number to set */
3855 for (i = 0; i < priv->child_count; i++) {
3856 if (data == priv->xl_array[i])
3857 break;
3858 }
3859
3860 if (priv->child_count == i) {
3861 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("got GF_EVENT_CHILD_DOWN bad subvolume %s"
, data? ((xlator_t *)data)->name: ((void*)0)); } while (0)
; _gf_log (this->name, "stripe.c", __FUNCTION__, 3863, GF_LOG_ERROR
, "got GF_EVENT_CHILD_DOWN bad subvolume %s", data? ((xlator_t
*)data)->name: ((void*)0)); } while (0)
3862 "got GF_EVENT_CHILD_DOWN bad subvolume %s",do { do { if (0) printf ("got GF_EVENT_CHILD_DOWN bad subvolume %s"
, data? ((xlator_t *)data)->name: ((void*)0)); } while (0)
; _gf_log (this->name, "stripe.c", __FUNCTION__, 3863, GF_LOG_ERROR
, "got GF_EVENT_CHILD_DOWN bad subvolume %s", data? ((xlator_t
*)data)->name: ((void*)0)); } while (0)
3863 data? ((xlator_t *)data)->name: NULL)do { do { if (0) printf ("got GF_EVENT_CHILD_DOWN bad subvolume %s"
, data? ((xlator_t *)data)->name: ((void*)0)); } while (0)
; _gf_log (this->name, "stripe.c", __FUNCTION__, 3863, GF_LOG_ERROR
, "got GF_EVENT_CHILD_DOWN bad subvolume %s", data? ((xlator_t
*)data)->name: ((void*)0)); } while (0)
;
3864 break;
3865 }
3866
3867 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
3868 {
3869 if (data == FIRST_CHILD (this)(this->children->xlator))
3870 priv->first_child_down = 1;
3871 priv->last_event[i] = event;
3872 }
3873 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
3874 }
3875 break;
3876
3877 default:
3878 {
3879 /* */
3880 default_notify (this, event, data);
3881 goto out;
3882 }
3883 break;
3884 }
3885
3886 // Consider child as down if it's last_event is not CHILD_UP
3887 for (i = 0, down_client = 0; i < priv->child_count; i++)
3888 if (priv->last_event[i] != GF_EVENT_CHILD_UP)
3889 down_client++;
3890
3891 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
3892 {
3893 priv->nodes_down = down_client;
3894 }
3895 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
3896
3897 heard_from_all_children = _gf_true;
3898 for (i = 0; i < priv->child_count; i++)
3899 if (!priv->last_event[i])
3900 heard_from_all_children = _gf_false;
3901
3902 if (heard_from_all_children)
3903 default_notify (this, event, data);
3904out:
3905 return 0;
3906}
3907
3908int
3909stripe_setxattr_cbk (call_frame_t *frame, void *cookie,
3910 xlator_t *this, int op_ret, int op_errno, dict_t *xdata)
3911{
3912 int ret = -1;
3913 int call_cnt = 0;
3914 stripe_local_t *local = NULL((void*)0);
3915
3916 if (!frame || !frame->local || !this) {
3917 gf_log ("", GF_LOG_ERROR, "Possible NULL deref")do { do { if (0) printf ("Possible NULL deref"); } while (0);
_gf_log ("", "stripe.c", __FUNCTION__, 3917, GF_LOG_ERROR, "Possible NULL deref"
); } while (0)
;
3918 return ret;
3919 }
3920
3921 local = frame->local;
3922
3923 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
3924 {
3925 call_cnt = --local->wind_count;
3926
3927 /**
3928 * We overwrite ->op_* values here for subsequent faliure
3929 * conditions, hence we propogate the last errno down the
3930 * stack.
3931 */
3932 if (op_ret < 0) {
3933 local->op_ret = op_ret;
3934 local->op_errno = op_errno;
3935 goto unlock;
3936 }
3937 }
3938
3939 unlock:
3940 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
3941
3942 if (!call_cnt) {
3943 STRIPE_STACK_UNWIND (setxattr, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_setxattr_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", "stripe.c", __FUNCTION__
, 3944, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_setxattr_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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
3944 local->op_errno, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_setxattr_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", "stripe.c", __FUNCTION__
, 3944, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_setxattr_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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
3945 }
3946
3947 return 0;
3948}
3949
3950int
3951stripe_setxattr (call_frame_t *frame, xlator_t *this,
3952 loc_t *loc, dict_t *dict, int flags, dict_t *xdata)
3953{
3954 int32_t op_errno = EINVAL22;
3955 xlator_list_t *trav = NULL((void*)0);
3956 stripe_private_t *priv = NULL((void*)0);
3957 stripe_local_t *local = NULL((void*)0);
3958 int i = 0;
3959
3960 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3960, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
3961 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3961, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
3962 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 3962, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
3963 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 3963, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
3964
3965 GF_IF_INTERNAL_XATTR_GOTO ("trusted.*stripe*", dict,do { if (!dict) { do { do { if (0) printf ("setxattr dict is null"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 3966, GF_LOG_ERROR, "setxattr dict is null"); } while (0); goto
err; } if (dict_foreach_fnmatch (dict, "trusted.*stripe*", dict_null_foreach_fn
, ((void*)0)) > 0) { op_errno = 1; do { do { if (0) printf
("attempt to set internal" " xattr: %s: %s", "trusted.*stripe*"
, strerror (op_errno)); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 3966, GF_LOG_ERROR, "attempt to set internal"
" xattr: %s: %s", "trusted.*stripe*", strerror (op_errno)); }
while (0); goto err; } } while (0)
3966 op_errno, err)do { if (!dict) { do { do { if (0) printf ("setxattr dict is null"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 3966, GF_LOG_ERROR, "setxattr dict is null"); } while (0); goto
err; } if (dict_foreach_fnmatch (dict, "trusted.*stripe*", dict_null_foreach_fn
, ((void*)0)) > 0) { op_errno = 1; do { do { if (0) printf
("attempt to set internal" " xattr: %s: %s", "trusted.*stripe*"
, strerror (op_errno)); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 3966, GF_LOG_ERROR, "attempt to set internal"
" xattr: %s: %s", "trusted.*stripe*", strerror (op_errno)); }
while (0); goto err; } } while (0)
;
3967
3968 priv = this->private;
3969 trav = this->children;
3970
3971 local = mem_get0 (this->local_pool);
3972 if (!local) {
3973 op_errno = ENOMEM12;
3974 goto err;
3975 }
3976
3977 frame->local = local;
3978 local->wind_count = priv->child_count;
3979 local->op_ret = local->op_errno = 0;
3980
3981 /**
3982 * Set xattrs for directories on all subvolumes. Additionally
3983 * this power is only given to a special client.
3984 */
3985 if ((frame->root->pid == GF_CLIENT_PID_GSYNCD) && IA_ISDIR (loc->inode->ia_type)(loc->inode->ia_type == IA_IFDIR)) {
3986 for (i = 0; i < priv->child_count; i++, trav = trav->next) {
3987 STACK_WIND (frame, stripe_setxattr_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", "stripe.c", __FUNCTION__, 3989, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->setxattr_cbk) tmp_cbk = stripe_setxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->setxattr"; _new->unwind_to
= "stripe_setxattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->setxattr); trav->xlator->
fops->setxattr (_new, trav->xlator, loc, dict, flags, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0)
3988 trav->xlator, trav->xlator->fops->setxattr,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", "stripe.c", __FUNCTION__, 3989, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->setxattr_cbk) tmp_cbk = stripe_setxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->setxattr"; _new->unwind_to
= "stripe_setxattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->setxattr); trav->xlator->
fops->setxattr (_new, trav->xlator, loc, dict, flags, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0)
3989 loc, dict, flags, 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", "stripe.c", __FUNCTION__, 3989, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->setxattr_cbk) tmp_cbk = stripe_setxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->setxattr"; _new->unwind_to
= "stripe_setxattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->setxattr); trav->xlator->
fops->setxattr (_new, trav->xlator, loc, dict, flags, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
3990 }
3991 } else {
3992 local->wind_count = 1;
3993 STACK_WIND (frame, stripe_setxattr_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", "stripe.c", __FUNCTION__, 3996, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = stripe_setxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "stripe_setxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, loc, dict, flags, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
3994 FIRST_CHILD(this),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", "stripe.c", __FUNCTION__, 3996, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = stripe_setxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "stripe_setxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, loc, dict, flags, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
3995 FIRST_CHILD(this)->fops->setxattr,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", "stripe.c", __FUNCTION__, 3996, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = stripe_setxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "stripe_setxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, loc, dict, flags, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
3996 loc, dict, flags, 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", "stripe.c", __FUNCTION__, 3996, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = stripe_setxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "stripe_setxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, loc, dict, flags, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
3997 }
3998
3999 return 0;
4000err:
4001 STRIPE_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_setxattr_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", "stripe.c", __FUNCTION__
, 4001, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_setxattr_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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
4002 return 0;
4003}
4004
4005
4006int
4007stripe_fsetxattr_cbk (call_frame_t *frame, void *cookie,
4008 xlator_t *this, int op_ret, int op_errno, dict_t *xdata)
4009{
4010 STRIPE_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_fsetxattr_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", "stripe.c", __FUNCTION__
, 4010, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_fsetxattr_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, op_ret, op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
4011 return 0;
4012}
4013
4014
4015int
4016stripe_is_lockinfo (dict_t *this,
4017 char *key,
4018 data_t *value,
4019 void *data)
4020{
4021 gf_boolean_t *is_lockinfo = NULL((void*)0);
4022
4023 if (data == NULL((void*)0)) {
4024 goto out;
4025 }
4026
4027 is_lockinfo = data;
4028
4029 if (XATTR_IS_LOCKINFO (key)(strncmp (key, "trusted.glusterfs.lockinfo", strlen ("trusted.glusterfs.lockinfo"
)) == 0)
)
4030 *is_lockinfo = _gf_true;
4031
4032out:
4033 return 0;
4034}
4035
4036int32_t
4037stripe_fsetxattr_everyone_cbk (call_frame_t *frame, void *cookie,
4038 xlator_t *this, int32_t op_ret, int32_t op_errno,
4039 dict_t *xdata)
4040{
4041 int call_count = 0;
4042 stripe_local_t *local = NULL((void*)0);
4043
4044 local = frame->local;
4045
4046 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
4047 {
4048 call_count = --local->wind_count;
4049
4050 if (op_ret < 0) {
4051 local->op_ret = op_ret;
4052 local->op_errno = op_errno;
4053 }
4054 }
4055 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
4056
4057 if (call_count == 0) {
4058 STRIPE_STACK_UNWIND (fsetxattr, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_fsetxattr_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", "stripe.c", __FUNCTION__
, 4059, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_fsetxattr_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
4059 local->op_errno, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_fsetxattr_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", "stripe.c", __FUNCTION__
, 4059, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_fsetxattr_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) { stripe_local_wipe(__local); mem_put (__local); } }
while (0)
;
4060 }
4061 return 0;
4062}
4063
4064int
4065stripe_fsetxattr_to_everyone (call_frame_t *frame, xlator_t *this, fd_t *fd,
4066 dict_t *dict, int flags, dict_t *xdata)
4067{
4068 xlator_list_t *trav = NULL((void*)0);
4069 stripe_private_t *priv = NULL((void*)0);
4070 int ret = -1;
4071 stripe_local_t *local = NULL((void*)0);
4072
4073 priv = this->private;
4074
4075 local = mem_get0 (this->local_pool);
4076 if (local == NULL((void*)0)) {
4077 goto out;
4078 }
4079
4080 frame->local = local;
4081
4082 local->wind_count = priv->child_count;
4083
4084 trav = this->children;
4085
4086 while (trav) {
4087 STACK_WIND (frame, stripe_fsetxattr_everyone_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", "stripe.c", __FUNCTION__, 4089, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fsetxattr_cbk) tmp_cbk = stripe_fsetxattr_everyone_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->fsetxattr"; _new
->unwind_to = "stripe_fsetxattr_everyone_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->fsetxattr
); trav->xlator->fops->fsetxattr (_new, trav->xlator
, fd, dict, flags, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
4088 trav->xlator, trav->xlator->fops->fsetxattr,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", "stripe.c", __FUNCTION__, 4089, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fsetxattr_cbk) tmp_cbk = stripe_fsetxattr_everyone_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->fsetxattr"; _new
->unwind_to = "stripe_fsetxattr_everyone_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->fsetxattr
); trav->xlator->fops->fsetxattr (_new, trav->xlator
, fd, dict, flags, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
4089 fd, dict, flags, 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", "stripe.c", __FUNCTION__, 4089, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fsetxattr_cbk) tmp_cbk = stripe_fsetxattr_everyone_cbk
; _new->root = frame->root; _new->this = trav->xlator
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->fsetxattr"; _new
->unwind_to = "stripe_fsetxattr_everyone_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
()) = trav->xlator; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->fsetxattr
); trav->xlator->fops->fsetxattr (_new, trav->xlator
, fd, dict, flags, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
4090 trav = trav->next;
4091 }
4092
4093 ret = 0;
4094out:
4095 return ret;
4096}
4097
4098inline gf_boolean_t
4099stripe_fsetxattr_is_special (dict_t *dict)
4100{
4101 gf_boolean_t is_spl = _gf_false;
4102
4103 if (dict == NULL((void*)0)) {
4104 goto out;
4105 }
4106
4107 dict_foreach (dict, stripe_is_lockinfo, &is_spl);
4108
4109out:
4110 return is_spl;
4111}
4112
4113int
4114stripe_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
4115 dict_t *dict, int flags, dict_t *xdata)
4116{
4117 int32_t op_ret = -1, ret = -1, op_errno = EINVAL22;
4118 gf_boolean_t is_spl = _gf_false;
4119
4120 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4120, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
4121 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4121, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
4122 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4122, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
4123
4124 GF_IF_INTERNAL_XATTR_GOTO ("trusted.*stripe*", dict,do { if (!dict) { do { do { if (0) printf ("setxattr dict is null"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4125, GF_LOG_ERROR, "setxattr dict is null"); } while (0); goto
err; } if (dict_foreach_fnmatch (dict, "trusted.*stripe*", dict_null_foreach_fn
, ((void*)0)) > 0) { op_errno = 1; do { do { if (0) printf
("attempt to set internal" " xattr: %s: %s", "trusted.*stripe*"
, strerror (op_errno)); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 4125, GF_LOG_ERROR, "attempt to set internal"
" xattr: %s: %s", "trusted.*stripe*", strerror (op_errno)); }
while (0); goto err; } } while (0)
4125 op_errno, err)do { if (!dict) { do { do { if (0) printf ("setxattr dict is null"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4125, GF_LOG_ERROR, "setxattr dict is null"); } while (0); goto
err; } if (dict_foreach_fnmatch (dict, "trusted.*stripe*", dict_null_foreach_fn
, ((void*)0)) > 0) { op_errno = 1; do { do { if (0) printf
("attempt to set internal" " xattr: %s: %s", "trusted.*stripe*"
, strerror (op_errno)); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 4125, GF_LOG_ERROR, "attempt to set internal"
" xattr: %s: %s", "trusted.*stripe*", strerror (op_errno)); }
while (0); goto err; } } while (0)
;
4126
4127 is_spl = stripe_fsetxattr_is_special (dict);
4128 if (is_spl) {
4129 ret = stripe_fsetxattr_to_everyone (frame, this, fd, dict,
4130 flags, xdata);
4131 if (ret < 0) {
4132 op_errno = ENOMEM12;
4133 goto err;
4134 }
4135
4136 goto out;
4137 }
4138
4139 STACK_WIND (frame, stripe_fsetxattr_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", "stripe.c", __FUNCTION__, 4142, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->fsetxattr_cbk) tmp_cbk = stripe_fsetxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->fsetxattr"
; _new->unwind_to = "stripe_fsetxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->fsetxattr); (this->children->
xlator)->fops->fsetxattr (_new, (this->children->
xlator), fd, dict, flags, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
4140 FIRST_CHILD(this),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", "stripe.c", __FUNCTION__, 4142, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->fsetxattr_cbk) tmp_cbk = stripe_fsetxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->fsetxattr"
; _new->unwind_to = "stripe_fsetxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->fsetxattr); (this->children->
xlator)->fops->fsetxattr (_new, (this->children->
xlator), fd, dict, flags, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
4141 FIRST_CHILD(this)->fops->fsetxattr,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", "stripe.c", __FUNCTION__, 4142, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->fsetxattr_cbk) tmp_cbk = stripe_fsetxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->fsetxattr"
; _new->unwind_to = "stripe_fsetxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->fsetxattr); (this->children->
xlator)->fops->fsetxattr (_new, (this->children->
xlator), fd, dict, flags, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
4142 fd, dict, flags, 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", "stripe.c", __FUNCTION__, 4142, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->fsetxattr_cbk) tmp_cbk = stripe_fsetxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->fsetxattr"
; _new->unwind_to = "stripe_fsetxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->fsetxattr); (this->children->
xlator)->fops->fsetxattr (_new, (this->children->
xlator), fd, dict, flags, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
4143out:
4144 return 0;
4145err:
4146 STRIPE_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_fsetxattr_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", "stripe.c", __FUNCTION__
, 4146, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_fsetxattr_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, op_ret, op_errno, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
4147 return 0;
4148}
4149
4150int
4151stripe_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
4152 int32_t op_ret, int32_t op_errno, dict_t *xdata)
4153{
4154 STRIPE_STACK_UNWIND (removexattr, frame, op_ret, op_errno, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_removexattr_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", "stripe.c", __FUNCTION__
, 4154, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_removexattr_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, op_ret, op_errno, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
4155 return 0;
4156}
4157
4158int
4159stripe_removexattr (call_frame_t *frame, xlator_t *this,
4160 loc_t *loc, const char *name, dict_t *xdata)
4161{
4162 int32_t op_errno = EINVAL22;
4163
4164 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4164, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
4165
4166 GF_IF_NATIVE_XATTR_GOTO ("trusted.*stripe*",do { if (!name) { do { do { if (0) printf ("no key for removexattr"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4167, GF_LOG_ERROR, "no key for removexattr"); } while (0);
goto err; } if (!fnmatch ("trusted.*stripe*", name, 0)) { op_errno
= 1; do { do { if (0) printf ("attempt to remove internal " "xattr: %s: %s"
, name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 4167, GF_LOG_ERROR, "attempt to remove internal "
"xattr: %s: %s", name, strerror (op_errno)); } while (0); goto
err; } } while (0)
4167 name, op_errno, err)do { if (!name) { do { do { if (0) printf ("no key for removexattr"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4167, GF_LOG_ERROR, "no key for removexattr"); } while (0);
goto err; } if (!fnmatch ("trusted.*stripe*", name, 0)) { op_errno
= 1; do { do { if (0) printf ("attempt to remove internal " "xattr: %s: %s"
, name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 4167, GF_LOG_ERROR, "attempt to remove internal "
"xattr: %s: %s", name, strerror (op_errno)); } while (0); goto
err; } } while (0)
;
4168
4169 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4169, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
4170 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4170, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
4171
4172 STACK_WIND (frame, stripe_removexattr_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", "stripe.c", __FUNCTION__, 4175, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->removexattr_cbk) tmp_cbk = stripe_removexattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->removexattr"
; _new->unwind_to = "stripe_removexattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->removexattr); (this->children->
xlator)->fops->removexattr (_new, (this->children->
xlator), loc, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
4173 FIRST_CHILD(this),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", "stripe.c", __FUNCTION__, 4175, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->removexattr_cbk) tmp_cbk = stripe_removexattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->removexattr"
; _new->unwind_to = "stripe_removexattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->removexattr); (this->children->
xlator)->fops->removexattr (_new, (this->children->
xlator), loc, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
4174 FIRST_CHILD(this)->fops->removexattr,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", "stripe.c", __FUNCTION__, 4175, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->removexattr_cbk) tmp_cbk = stripe_removexattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->removexattr"
; _new->unwind_to = "stripe_removexattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->removexattr); (this->children->
xlator)->fops->removexattr (_new, (this->children->
xlator), loc, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
4175 loc, name, 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", "stripe.c", __FUNCTION__, 4175, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->removexattr_cbk) tmp_cbk = stripe_removexattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->removexattr"
; _new->unwind_to = "stripe_removexattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->removexattr); (this->children->
xlator)->fops->removexattr (_new, (this->children->
xlator), loc, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
4176 return 0;
4177err:
4178 STRIPE_STACK_UNWIND (removexattr, frame, -1, op_errno, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_removexattr_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", "stripe.c", __FUNCTION__
, 4178, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_removexattr_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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
4179 return 0;
4180}
4181
4182
4183int
4184stripe_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
4185 int32_t op_ret, int32_t op_errno, dict_t *xdata)
4186{
4187 STRIPE_STACK_UNWIND (fremovexattr, frame, op_ret, op_errno, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_fremovexattr_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", "stripe.c", __FUNCTION__
, 4187, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_fremovexattr_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, op_ret
, op_errno, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
4188 return 0;
4189}
4190
4191int
4192stripe_fremovexattr (call_frame_t *frame, xlator_t *this,
4193 fd_t *fd, const char *name, dict_t *xdata)
4194{
4195 int32_t op_ret = -1;
4196 int32_t op_errno = EINVAL22;
4197
4198 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4198, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
4199 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4199, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
4200 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4200, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
4201
4202 GF_IF_NATIVE_XATTR_GOTO ("trusted.*stripe*",do { if (!name) { do { do { if (0) printf ("no key for removexattr"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4203, GF_LOG_ERROR, "no key for removexattr"); } while (0);
goto err; } if (!fnmatch ("trusted.*stripe*", name, 0)) { op_errno
= 1; do { do { if (0) printf ("attempt to remove internal " "xattr: %s: %s"
, name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 4203, GF_LOG_ERROR, "attempt to remove internal "
"xattr: %s: %s", name, strerror (op_errno)); } while (0); goto
err; } } while (0)
4203 name, op_errno, err)do { if (!name) { do { do { if (0) printf ("no key for removexattr"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4203, GF_LOG_ERROR, "no key for removexattr"); } while (0);
goto err; } if (!fnmatch ("trusted.*stripe*", name, 0)) { op_errno
= 1; do { do { if (0) printf ("attempt to remove internal " "xattr: %s: %s"
, name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 4203, GF_LOG_ERROR, "attempt to remove internal "
"xattr: %s: %s", name, strerror (op_errno)); } while (0); goto
err; } } while (0)
;
4204
4205 STACK_WIND (frame, stripe_fremovexattr_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", "stripe.c", __FUNCTION__, 4208, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->fremovexattr_cbk) tmp_cbk = stripe_fremovexattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->fremovexattr"
; _new->unwind_to = "stripe_fremovexattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->fremovexattr); (this->children->
xlator)->fops->fremovexattr (_new, (this->children->
xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
4206 FIRST_CHILD(this),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", "stripe.c", __FUNCTION__, 4208, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->fremovexattr_cbk) tmp_cbk = stripe_fremovexattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->fremovexattr"
; _new->unwind_to = "stripe_fremovexattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->fremovexattr); (this->children->
xlator)->fops->fremovexattr (_new, (this->children->
xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
4207 FIRST_CHILD(this)->fops->fremovexattr,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", "stripe.c", __FUNCTION__, 4208, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->fremovexattr_cbk) tmp_cbk = stripe_fremovexattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->fremovexattr"
; _new->unwind_to = "stripe_fremovexattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->fremovexattr); (this->children->
xlator)->fops->fremovexattr (_new, (this->children->
xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
4208 fd, name, 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", "stripe.c", __FUNCTION__, 4208, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->fremovexattr_cbk) tmp_cbk = stripe_fremovexattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->fremovexattr"
; _new->unwind_to = "stripe_fremovexattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->fremovexattr); (this->children->
xlator)->fops->fremovexattr (_new, (this->children->
xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
4209 return 0;
4210 err:
4211 STRIPE_STACK_UNWIND (fremovexattr, frame, op_ret, op_errno, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_fremovexattr_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", "stripe.c", __FUNCTION__
, 4211, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_fremovexattr_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, op_ret
, op_errno, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
4212 return 0;
4213}
4214
4215int32_t
4216stripe_readdirp_lookup_cbk (call_frame_t *frame, void *cookie,
4217 xlator_t *this, int op_ret, int op_errno,
4218 inode_t *inode, struct iatt *stbuf,
4219 dict_t *xattr, struct iatt *parent)
4220{
4221 stripe_local_t *local = NULL((void*)0);
4222 call_frame_t *main_frame = NULL((void*)0);
4223 stripe_local_t *main_local = NULL((void*)0);
4224 gf_dirent_t *entry = NULL((void*)0);
4225 call_frame_t *prev = NULL((void*)0);
4226 int done = 0;
4227
4228 local = frame->local;
4229 prev = cookie;
4230
4231 entry = local->dirent;
4232
4233 main_frame = local->orig_frame;
4234 main_local = main_frame->local;
4235 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
4236 {
4237
4238 local->call_count--;
4239 if (!local->call_count)
4240 done = 1;
4241 if (op_ret == -1) {
4242 local->op_errno = op_errno;
4243 local->op_ret = op_ret;
4244 goto unlock;
4245 }
4246
4247 if (stripe_ctx_handle(this, prev, local, xattr))
4248 gf_log(this->name, GF_LOG_ERROR,do { do { if (0) printf ("Error getting fctx info from dict."
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4249, GF_LOG_ERROR, "Error getting fctx info from dict."); }
while (0)
4249 "Error getting fctx info from dict.")do { do { if (0) printf ("Error getting fctx info from dict."
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4249, GF_LOG_ERROR, "Error getting fctx info from dict."); }
while (0)
;
4250
4251 correct_file_size(stbuf, local->fctx, prev);
4252
4253 stripe_iatt_merge (stbuf, &entry->d_stat);
4254 local->stbuf_blocks += stbuf->ia_blocks;
4255 }
4256unlock:
4257 UNLOCK(&frame->lock)pthread_spin_unlock (&frame->lock);
4258
4259 if (done) {
4260 inode_ctx_put (entry->inode, this,
4261 (uint64_t) (long)local->fctx);
4262
4263 done = 0;
4264 LOCK (&main_frame->lock)pthread_spin_lock (&main_frame->lock);
4265 {
4266 main_local->wind_count--;
4267 if (!main_local->wind_count)
4268 done = 1;
4269 if (local->op_ret == -1) {
4270 main_local->op_errno = local->op_errno;
4271 main_local->op_ret = local->op_ret;
4272 }
4273 entry->d_stat.ia_blocks = local->stbuf_blocks;
4274 }
4275 UNLOCK (&main_frame->lock)pthread_spin_unlock (&main_frame->lock);
4276 if (done) {
4277 main_frame->local = NULL((void*)0);
4278 STRIPE_STACK_UNWIND (readdir, main_frame,do { stripe_local_t *__local = ((void*)0); if (main_frame) { __local
= main_frame->local; main_frame->local = ((void*)0); }
do { fop_readdir_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!main_frame
) { do { do { if (0) printf ("!frame"); } while (0); _gf_log (
"stack", "stripe.c", __FUNCTION__, 4281, GF_LOG_CRITICAL, "!frame"
); } while (0); break; } fn = (fop_readdir_cbk_t )main_frame->
ret; _parent = main_frame->parent; pthread_spin_lock (&
main_frame->root->stack_lock); { _parent->ref_count--
; } pthread_spin_unlock (&main_frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; main_frame->complete = _gf_true; main_frame
->unwind_from = __FUNCTION__; if (main_frame->this->
ctx->measure_latency) gf_latency_end (main_frame); fn (_parent
, main_frame->cookie, _parent->this, main_local->op_ret
, main_local->op_errno, &main_local->entries, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
4279 main_local->op_ret,do { stripe_local_t *__local = ((void*)0); if (main_frame) { __local
= main_frame->local; main_frame->local = ((void*)0); }
do { fop_readdir_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!main_frame
) { do { do { if (0) printf ("!frame"); } while (0); _gf_log (
"stack", "stripe.c", __FUNCTION__, 4281, GF_LOG_CRITICAL, "!frame"
); } while (0); break; } fn = (fop_readdir_cbk_t )main_frame->
ret; _parent = main_frame->parent; pthread_spin_lock (&
main_frame->root->stack_lock); { _parent->ref_count--
; } pthread_spin_unlock (&main_frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; main_frame->complete = _gf_true; main_frame
->unwind_from = __FUNCTION__; if (main_frame->this->
ctx->measure_latency) gf_latency_end (main_frame); fn (_parent
, main_frame->cookie, _parent->this, main_local->op_ret
, main_local->op_errno, &main_local->entries, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
4280 main_local->op_errno,do { stripe_local_t *__local = ((void*)0); if (main_frame) { __local
= main_frame->local; main_frame->local = ((void*)0); }
do { fop_readdir_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!main_frame
) { do { do { if (0) printf ("!frame"); } while (0); _gf_log (
"stack", "stripe.c", __FUNCTION__, 4281, GF_LOG_CRITICAL, "!frame"
); } while (0); break; } fn = (fop_readdir_cbk_t )main_frame->
ret; _parent = main_frame->parent; pthread_spin_lock (&
main_frame->root->stack_lock); { _parent->ref_count--
; } pthread_spin_unlock (&main_frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; main_frame->complete = _gf_true; main_frame
->unwind_from = __FUNCTION__; if (main_frame->this->
ctx->measure_latency) gf_latency_end (main_frame); fn (_parent
, main_frame->cookie, _parent->this, main_local->op_ret
, main_local->op_errno, &main_local->entries, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
4281 &main_local->entries, NULL)do { stripe_local_t *__local = ((void*)0); if (main_frame) { __local
= main_frame->local; main_frame->local = ((void*)0); }
do { fop_readdir_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!main_frame
) { do { do { if (0) printf ("!frame"); } while (0); _gf_log (
"stack", "stripe.c", __FUNCTION__, 4281, GF_LOG_CRITICAL, "!frame"
); } while (0); break; } fn = (fop_readdir_cbk_t )main_frame->
ret; _parent = main_frame->parent; pthread_spin_lock (&
main_frame->root->stack_lock); { _parent->ref_count--
; } pthread_spin_unlock (&main_frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; main_frame->complete = _gf_true; main_frame
->unwind_from = __FUNCTION__; if (main_frame->this->
ctx->measure_latency) gf_latency_end (main_frame); fn (_parent
, main_frame->cookie, _parent->this, main_local->op_ret
, main_local->op_errno, &main_local->entries, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; if (__local) { stripe_local_wipe(__local); mem_put (__local
); } } while (0)
;
4282 gf_dirent_free (&main_local->entries);
4283 stripe_local_wipe (main_local);
4284 mem_put (main_local);
4285 }
4286 frame->local = NULL((void*)0);
4287 stripe_local_wipe (local);
4288 mem_put (local);
4289 STRIPE_STACK_DESTROY (frame)do { stripe_local_t *__local = ((void*)0); __local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); if (__local) { stripe_local_wipe (__local); mem_put (__local
); } } while (0)
;
4290 }
4291
4292 return 0;
4293}
4294
4295int32_t
4296stripe_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
4297 int32_t op_ret, int32_t op_errno,
4298 gf_dirent_t *orig_entries, dict_t *xdata)
4299{
4300 stripe_local_t *local = NULL((void*)0);
4301 call_frame_t *prev = NULL((void*)0);
4302 gf_dirent_t *local_entry = NULL((void*)0);
4303 gf_dirent_t *tmp_entry = NULL((void*)0);
4304 xlator_list_t *trav = NULL((void*)0);
4305 loc_t loc = {0, };
4306 int32_t count = 0;
4307 stripe_private_t *priv = NULL((void*)0);
4308 int32_t subvols = 0;
4309 dict_t *xattrs = NULL((void*)0);
4310 call_frame_t *local_frame = NULL((void*)0);
4311 stripe_local_t *local_ent = NULL((void*)0);
4312
4313 if (!this || !frame || !frame->local || !cookie) {
4314 gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0);
_gf_log ("stripe", "stripe.c", __FUNCTION__, 4314, GF_LOG_DEBUG
, "possible NULL deref"); } while (0)
;
4315 goto out;
4316 }
4317 prev = cookie;
4318 local = frame->local;
4319 trav = this->children;
4320 priv = this->private;
4321
4322 subvols = priv->child_count;
4323
4324 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
4325 {
4326 if (op_ret == -1) {
4327 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 4329, GF_LOG_WARNING, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
4328 "%s returned error %s",do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 4329, GF_LOG_WARNING, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
4329 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s returned error %s", prev->this
->name, strerror (op_errno)); } while (0); _gf_log (this->
name, "stripe.c", __FUNCTION__, 4329, GF_LOG_WARNING, "%s returned error %s"
, prev->this->name, strerror (op_errno)); } while (0)
;
4330 local->op_errno = op_errno;
4331 local->op_ret = op_ret;
4332 goto unlock;
4333 } else {
4334 local->op_ret = op_ret;
4335 list_splice_init (&orig_entries->list,
4336 &local->entries.list);
4337 local->wind_count = op_ret;
4338 }
4339
4340 }
4341unlock:
4342 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
4343
4344 if (op_ret == -1)
4345 goto out;
4346
4347 xattrs = dict_new ();
4348 if (xattrs)
4349 (void) stripe_xattr_request_build (this, xattrs, 0, 0, 0, 0);
4350 count = op_ret;
4351 list_for_each_entry_safe (local_entry, tmp_entry,for (local_entry = ((typeof(*local_entry) *)((char *)(((&
local->entries.list))->next)-(unsigned long)(&((typeof
(*local_entry) *)0)->list))), tmp_entry = ((typeof(*local_entry
) *)((char *)(local_entry->list.next)-(unsigned long)(&
((typeof(*local_entry) *)0)->list))); &local_entry->
list != ((&local->entries.list)); local_entry = tmp_entry
, tmp_entry = ((typeof(*tmp_entry) *)((char *)(tmp_entry->
list.next)-(unsigned long)(&((typeof(*tmp_entry) *)0)->
list))))
4352 (&local->entries.list), list)for (local_entry = ((typeof(*local_entry) *)((char *)(((&
local->entries.list))->next)-(unsigned long)(&((typeof
(*local_entry) *)0)->list))), tmp_entry = ((typeof(*local_entry
) *)((char *)(local_entry->list.next)-(unsigned long)(&
((typeof(*local_entry) *)0)->list))); &local_entry->
list != ((&local->entries.list)); local_entry = tmp_entry
, tmp_entry = ((typeof(*tmp_entry) *)((char *)(tmp_entry->
list.next)-(unsigned long)(&((typeof(*tmp_entry) *)0)->
list))))
{
4353
4354 if (!local_entry)
4355 break;
4356 if (!IA_ISREG (local_entry->d_stat.ia_type)(local_entry->d_stat.ia_type == IA_IFREG)) {
4357 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
4358 {
4359 local->wind_count--;
4360 count = local->wind_count;
4361 }
4362 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
4363 continue;
4364 }
4365
4366 local_frame = copy_frame (frame);
4367
4368 if (!local_frame) {
4369 op_errno = ENOMEM12;
4370 op_ret = -1;
4371 goto out;
4372 }
4373
4374 local_ent = mem_get0 (this->local_pool);
4375 if (!local_ent) {
4376 op_errno = ENOMEM12;
4377 op_ret = -1;
4378 goto out;
4379 }
4380
4381 loc.inode = inode_ref (local_entry->inode);
4382
4383 uuid_copy (loc.gfid, local_entry->d_stat.ia_gfid);
4384
4385 local_ent->orig_frame = frame;
4386
4387 local_ent->call_count = subvols;
4388
4389 local_ent->dirent = local_entry;
4390
4391 local_frame->local = local_ent;
4392
4393 trav = this->children;
4394 while (trav) {
4395 STACK_WIND (local_frame, stripe_readdirp_lookup_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (local_frame->root->pool->
frame_mem_pool); if (!_new) { do { do { if (0) printf ("alloc failed"
); } while (0); _gf_log ("stack", "stripe.c", __FUNCTION__, 4397
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( trav->xlator->fops->lookup_cbk) tmp_cbk = stripe_readdirp_lookup_cbk
; _new->root = local_frame->root; _new->this = trav->
xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = local_frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->lookup"; _new->
unwind_to = "stripe_readdirp_lookup_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&local_frame->
root->stack_lock); { _new->next = local_frame->root->
frames.next; _new->prev = &local_frame->root->frames
; if (local_frame->root->frames.next) local_frame->root
->frames.next->prev = _new; local_frame->root->frames
.next = _new; local_frame->ref_count++; } pthread_spin_unlock
(&local_frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = trav->xlator; if (local_frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->lookup); trav->xlator->fops
->lookup (_new, trav->xlator, &loc, xattrs); (*__glusterfs_this_location
()) = old_THIS; } while (0)
4396 trav->xlator, trav->xlator->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (local_frame->root->pool->
frame_mem_pool); if (!_new) { do { do { if (0) printf ("alloc failed"
); } while (0); _gf_log ("stack", "stripe.c", __FUNCTION__, 4397
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( trav->xlator->fops->lookup_cbk) tmp_cbk = stripe_readdirp_lookup_cbk
; _new->root = local_frame->root; _new->this = trav->
xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = local_frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->lookup"; _new->
unwind_to = "stripe_readdirp_lookup_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&local_frame->
root->stack_lock); { _new->next = local_frame->root->
frames.next; _new->prev = &local_frame->root->frames
; if (local_frame->root->frames.next) local_frame->root
->frames.next->prev = _new; local_frame->root->frames
.next = _new; local_frame->ref_count++; } pthread_spin_unlock
(&local_frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = trav->xlator; if (local_frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->lookup); trav->xlator->fops
->lookup (_new, trav->xlator, &loc, xattrs); (*__glusterfs_this_location
()) = old_THIS; } while (0)
4397 &loc, xattrs)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (local_frame->root->pool->
frame_mem_pool); if (!_new) { do { do { if (0) printf ("alloc failed"
); } while (0); _gf_log ("stack", "stripe.c", __FUNCTION__, 4397
, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof
( trav->xlator->fops->lookup_cbk) tmp_cbk = stripe_readdirp_lookup_cbk
; _new->root = local_frame->root; _new->this = trav->
xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = local_frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "trav->xlator->fops->lookup"; _new->
unwind_to = "stripe_readdirp_lookup_cbk"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&local_frame->
root->stack_lock); { _new->next = local_frame->root->
frames.next; _new->prev = &local_frame->root->frames
; if (local_frame->root->frames.next) local_frame->root
->frames.next->prev = _new; local_frame->root->frames
.next = _new; local_frame->ref_count++; } pthread_spin_unlock
(&local_frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = trav->xlator; if (local_frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->lookup); trav->xlator->fops
->lookup (_new, trav->xlator, &loc, xattrs); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
4398 trav = trav->next;
4399 }
4400 loc_wipe (&loc);
4401 }
4402out:
4403 if (!count) {
4404 /* all entries are directories */
4405 frame->local = NULL((void*)0);
4406 STRIPE_STACK_UNWIND (readdir, frame, local->op_ret,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_readdir_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", "stripe.c", __FUNCTION__
, 4407, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_readdir_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->
entries, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
4407 local->op_errno, &local->entries, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_readdir_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", "stripe.c", __FUNCTION__
, 4407, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_readdir_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->
entries, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0); if (__local) { stripe_local_wipe(__local); mem_put
(__local); } } while (0)
;
4408 gf_dirent_free (&local->entries);
4409 stripe_local_wipe (local);
4410 mem_put (local);
4411 }
4412 if (xattrs)
4413 dict_unref (xattrs);
4414 return 0;
4415
4416}
4417int32_t
4418stripe_readdirp (call_frame_t *frame, xlator_t *this,
4419 fd_t *fd, size_t size, off_t off, dict_t *xdata)
4420{
4421 stripe_local_t *local = NULL((void*)0);
4422 stripe_private_t *priv = NULL((void*)0);
4423 xlator_list_t *trav = NULL((void*)0);
4424 int op_errno = -1;
4425
4426 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4426, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
4427 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4427, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
4428 VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4428, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto err; } } while (0)
;
4429
4430 priv = this->private;
4431 trav = this->children;
4432
4433 if (priv->first_child_down) {
4434 op_errno = ENOTCONN107;
4435 goto err;
4436 }
4437
4438 /* Initialization */
4439 local = mem_get0 (this->local_pool);
4440 if (!local) {
4441 op_errno = ENOMEM12;
4442 goto err;
4443 }
4444
4445 frame->local = local;
4446
4447 local->fd = fd_ref (fd);
4448
4449 local->wind_count = 0;
4450
4451 local->count = 0;
4452 local->op_ret = -1;
4453 INIT_LIST_HEAD(&local->entries)do { (&local->entries)->next = (&local->entries
)->prev = &local->entries; } while (0)
;
4454
4455 if (!trav)
4456 goto err;
4457
4458 STACK_WIND (frame, stripe_readdirp_cbk, trav->xlator,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", "stripe.c", __FUNCTION__, 4459, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->readdirp_cbk) tmp_cbk = stripe_readdirp_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->readdirp"; _new->unwind_to
= "stripe_readdirp_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->readdirp); trav->xlator->
fops->readdirp (_new, trav->xlator, fd, size, off, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0)
4459 trav->xlator->fops->readdirp, fd, size, off, 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", "stripe.c", __FUNCTION__, 4459, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->readdirp_cbk) tmp_cbk = stripe_readdirp_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->readdirp"; _new->unwind_to
= "stripe_readdirp_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->readdirp); trav->xlator->
fops->readdirp (_new, trav->xlator, fd, size, off, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
4460 return 0;
4461err:
4462 op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno;
4463 STRIPE_STACK_UNWIND (readdir, frame, -1, op_errno, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_readdir_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", "stripe.c", __FUNCTION__
, 4463, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_readdir_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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
4464
4465 return 0;
4466
4467}
4468
4469int32_t
4470mem_acct_init (xlator_t *this)
4471{
4472 int ret = -1;
4473
4474 if (!this)
4475 goto out;
4476
4477 ret = xlator_mem_acct_init (this, gf_stripe_mt_end + 1);
4478
4479 if (ret != 0) {
4480 gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"do { do { if (0) printf ("Memory accounting init" "failed"); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
4481, GF_LOG_ERROR, "Memory accounting init" "failed"); } while
(0)
4481 "failed")do { do { if (0) printf ("Memory accounting init" "failed"); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
4481, GF_LOG_ERROR, "Memory accounting init" "failed"); } while
(0)
;
4482 goto out;
4483 }
4484
4485out:
4486 return ret;
4487}
4488
4489static int
4490clear_pattern_list (stripe_private_t *priv)
4491{
4492 struct stripe_options *prev = NULL((void*)0);
4493 struct stripe_options *trav = NULL((void*)0);
4494 int ret = -1;
4495
4496 GF_VALIDATE_OR_GOTO ("stripe", priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
("stripe", "stripe.c", __FUNCTION__, 4496, GF_LOG_ERROR, "invalid argument: "
"priv"); } while (0); goto out; } } while (0)
;
4497
4498 trav = priv->pattern;
4499 priv->pattern = NULL((void*)0);
4500 while (trav) {
4501 prev = trav;
4502 trav = trav->next;
4503 GF_FREE (prev)__gf_free (prev);
4504 }
4505
4506 ret = 0;
4507 out:
4508 return ret;
4509
4510
4511}
4512
4513
4514int
4515reconfigure (xlator_t *this, dict_t *options)
4516{
4517
4518 stripe_private_t *priv = NULL((void*)0);
4519 data_t *data = NULL((void*)0);
4520 int ret = -1;
4521 volume_option_t *opt = NULL((void*)0);
4522
4523 GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: "
"this"); } while (0); _gf_log_callingfn ("", "stripe.c", __FUNCTION__
, 4523, GF_LOG_ERROR, "Assertion failed: " "this"); } while (
0); } } while (0)
;
4524 GF_ASSERT (this->private)do { if (!(this->private)) { do { do { if (0) printf ("Assertion failed: "
"this->private"); } while (0); _gf_log_callingfn ("", "stripe.c"
, __FUNCTION__, 4524, GF_LOG_ERROR, "Assertion failed: " "this->private"
); } while (0); } } while (0)
;
4525
4526 priv = this->private;
4527
4528
4529 ret = 0;
4530 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
4531 {
4532 ret = clear_pattern_list (priv);
4533 if (ret)
4534 goto unlock;
4535
4536 data = dict_get (options, "block-size");
4537 if (data) {
4538 ret = set_stripe_block_size (this, priv, data->data);
4539 if (ret)
4540 goto unlock;
4541 } else {
4542 opt = xlator_volume_option_get (this, "block-size");
4543 if (!opt) {
4544 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("option 'block-size' not found"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 4545,
GF_LOG_WARNING, "option 'block-size' not found"); } while (0
)
4545 "option 'block-size' not found")do { do { if (0) printf ("option 'block-size' not found"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 4545,
GF_LOG_WARNING, "option 'block-size' not found"); } while (0
)
;
4546 ret = -1;
4547 goto unlock;
4548 }
4549
4550 if (gf_string2bytesize (opt->default_value, &priv->block_size)){
4551 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Unable to set default block-size ")
; } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4552, GF_LOG_ERROR, "Unable to set default block-size "); }
while (0)
4552 "Unable to set default block-size ")do { do { if (0) printf ("Unable to set default block-size ")
; } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4552, GF_LOG_ERROR, "Unable to set default block-size "); }
while (0)
;
4553 ret = -1;
4554 goto unlock;
4555 }
4556 }
4557
4558 GF_OPTION_RECONF("coalesce", priv->coalesce, options, bool,do { int val_ret = 0; val_ret = xlator_option_reconf_bool ((*
__glusterfs_this_location()), options, "coalesce", &(priv
->coalesce)); if (val_ret) goto unlock; } while (0)
4559 unlock)do { int val_ret = 0; val_ret = xlator_option_reconf_bool ((*
__glusterfs_this_location()), options, "coalesce", &(priv
->coalesce)); if (val_ret) goto unlock; } while (0)
;
4560 }
4561 unlock:
4562 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
4563 if (ret)
4564 goto out;
4565
4566 ret = 0;
4567 out:
4568 return ret;
4569
4570}
4571
4572/**
4573 * init - This function is called when xlator-graph gets initialized.
4574 * The option given in volfiles are parsed here.
4575 * @this -
4576 */
4577int32_t
4578init (xlator_t *this)
4579{
4580 stripe_private_t *priv = NULL((void*)0);
4581 volume_option_t *opt = NULL((void*)0);
4582 xlator_list_t *trav = NULL((void*)0);
4583 data_t *data = NULL((void*)0);
4584 int32_t count = 0;
4585 int ret = -1;
4586
4587 if (!this)
4588 goto out;
4589
4590 trav = this->children;
4591 while (trav) {
4592 count++;
4593 trav = trav->next;
4594 }
4595
4596 if (!count) {
4597 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("stripe configured without \"subvolumes\" option. "
"exiting"); } while (0); _gf_log (this->name, "stripe.c",
__FUNCTION__, 4599, GF_LOG_ERROR, "stripe configured without \"subvolumes\" option. "
"exiting"); } while (0)
4598 "stripe configured without \"subvolumes\" option. "do { do { if (0) printf ("stripe configured without \"subvolumes\" option. "
"exiting"); } while (0); _gf_log (this->name, "stripe.c",
__FUNCTION__, 4599, GF_LOG_ERROR, "stripe configured without \"subvolumes\" option. "
"exiting"); } while (0)
4599 "exiting")do { do { if (0) printf ("stripe configured without \"subvolumes\" option. "
"exiting"); } while (0); _gf_log (this->name, "stripe.c",
__FUNCTION__, 4599, GF_LOG_ERROR, "stripe configured without \"subvolumes\" option. "
"exiting"); } while (0)
;
4600 goto out;
4601 }
4602
4603 if (!this->parents) {
4604 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("dangling volume. check volfile "); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
4605, GF_LOG_WARNING, "dangling volume. check volfile "); } while
(0)
4605 "dangling volume. check volfile ")do { do { if (0) printf ("dangling volume. check volfile "); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
4605, GF_LOG_WARNING, "dangling volume. check volfile "); } while
(0)
;
4606 }
4607
4608 if (count == 1) {
4609 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("stripe configured with only one \"subvolumes\" option."
" please check the volume. exiting"); } while (0); _gf_log (
this->name, "stripe.c", __FUNCTION__, 4611, GF_LOG_ERROR, "stripe configured with only one \"subvolumes\" option."
" please check the volume. exiting"); } while (0)
4610 "stripe configured with only one \"subvolumes\" option."do { do { if (0) printf ("stripe configured with only one \"subvolumes\" option."
" please check the volume. exiting"); } while (0); _gf_log (
this->name, "stripe.c", __FUNCTION__, 4611, GF_LOG_ERROR, "stripe configured with only one \"subvolumes\" option."
" please check the volume. exiting"); } while (0)
4611 " please check the volume. exiting")do { do { if (0) printf ("stripe configured with only one \"subvolumes\" option."
" please check the volume. exiting"); } while (0); _gf_log (
this->name, "stripe.c", __FUNCTION__, 4611, GF_LOG_ERROR, "stripe configured with only one \"subvolumes\" option."
" please check the volume. exiting"); } while (0)
;
4612 goto out;
4613 }
4614
4615 priv = GF_CALLOC (1, sizeof (stripe_private_t),__gf_calloc (1, sizeof (stripe_private_t), gf_stripe_mt_stripe_private_t
)
4616 gf_stripe_mt_stripe_private_t)__gf_calloc (1, sizeof (stripe_private_t), gf_stripe_mt_stripe_private_t
)
;
4617
4618 if (!priv)
4619 goto out;
4620 priv->xl_array = GF_CALLOC (count, sizeof (xlator_t *),__gf_calloc (count, sizeof (xlator_t *), gf_stripe_mt_xlator_t
)
4621 gf_stripe_mt_xlator_t)__gf_calloc (count, sizeof (xlator_t *), gf_stripe_mt_xlator_t
)
;
4622 if (!priv->xl_array)
4623 goto out;
4624
4625 priv->last_event = GF_CALLOC (count, sizeof (int),__gf_calloc (count, sizeof (int), gf_stripe_mt_int32_t)
4626 gf_stripe_mt_int32_t)__gf_calloc (count, sizeof (int), gf_stripe_mt_int32_t);
4627 if (!priv->last_event)
4628 goto out;
4629
4630 priv->child_count = count;
4631 LOCK_INIT (&priv->lock)pthread_spin_init (&priv->lock, 0);
4632
4633 trav = this->children;
4634 count = 0;
4635 while (trav) {
4636 priv->xl_array[count++] = trav->xlator;
4637 trav = trav->next;
4638 }
4639
4640 if (count > 256) {
4641 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("maximum number of stripe subvolumes supported "
"is 256"); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4643, GF_LOG_ERROR, "maximum number of stripe subvolumes supported "
"is 256"); } while (0)
4642 "maximum number of stripe subvolumes supported "do { do { if (0) printf ("maximum number of stripe subvolumes supported "
"is 256"); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4643, GF_LOG_ERROR, "maximum number of stripe subvolumes supported "
"is 256"); } while (0)
4643 "is 256")do { do { if (0) printf ("maximum number of stripe subvolumes supported "
"is 256"); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4643, GF_LOG_ERROR, "maximum number of stripe subvolumes supported "
"is 256"); } while (0)
;
4644 goto out;
4645 }
4646
4647 ret = 0;
4648 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
4649 {
4650 opt = xlator_volume_option_get (this, "block-size");
4651 if (!opt) {
4652 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("option 'block-size' not found"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 4653,
GF_LOG_WARNING, "option 'block-size' not found"); } while (0
)
4653 "option 'block-size' not found")do { do { if (0) printf ("option 'block-size' not found"); } while
(0); _gf_log (this->name, "stripe.c", __FUNCTION__, 4653,
GF_LOG_WARNING, "option 'block-size' not found"); } while (0
)
;
4654 ret = -1;
4655 goto unlock;
4656 }
4657 if (gf_string2bytesize (opt->default_value, &priv->block_size)){
4658 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Unable to set default block-size ")
; } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4659, GF_LOG_ERROR, "Unable to set default block-size "); }
while (0)
4659 "Unable to set default block-size ")do { do { if (0) printf ("Unable to set default block-size ")
; } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4659, GF_LOG_ERROR, "Unable to set default block-size "); }
while (0)
;
4660 ret = -1;
4661 goto unlock;
4662 }
4663 /* option stripe-pattern *avi:1GB,*pdf:16K */
4664 data = dict_get (this->options, "block-size");
4665 if (data) {
4666 ret = set_stripe_block_size (this, priv, data->data);
4667 if (ret)
4668 goto unlock;
4669 }
4670 }
4671 unlock:
4672 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
4673 if (ret)
4674 goto out;
4675
4676 GF_OPTION_INIT ("use-xattr", priv->xattr_supported, bool, out)do { int val_ret = 0; val_ret = xlator_option_init_bool ((*__glusterfs_this_location
()), (*__glusterfs_this_location())->options, "use-xattr",
&(priv->xattr_supported)); if (val_ret) goto out; } while
(0)
;
4677 /* notify related */
4678 priv->nodes_down = priv->child_count;
4679
4680 GF_OPTION_INIT("coalesce", priv->coalesce, bool, out)do { int val_ret = 0; val_ret = xlator_option_init_bool ((*__glusterfs_this_location
()), (*__glusterfs_this_location())->options, "coalesce", &
(priv->coalesce)); if (val_ret) goto out; } while (0)
;
4681
4682 this->local_pool = mem_pool_new (stripe_local_t, 128)mem_pool_new_fn (sizeof(stripe_local_t), 128, "stripe_local_t"
)
;
4683 if (!this->local_pool) {
4684 ret = -1;
4685 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to create local_t's memory pool"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4686, GF_LOG_ERROR, "failed to create local_t's memory pool"
); } while (0)
4686 "failed to create local_t's memory pool")do { do { if (0) printf ("failed to create local_t's memory pool"
); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4686, GF_LOG_ERROR, "failed to create local_t's memory pool"
); } while (0)
;
4687 goto out;
4688 }
4689
4690 this->private = priv;
4691
4692 ret = 0;
4693out:
4694 if (ret) {
4695 if (priv) {
4696 GF_FREE (priv->xl_array)__gf_free (priv->xl_array);
4697 GF_FREE (priv)__gf_free (priv);
4698 }
4699 }
4700 return ret;
4701}
4702
4703/**
4704 * fini - Free all the private variables
4705 * @this -
4706 */
4707void
4708fini (xlator_t *this)
4709{
4710 stripe_private_t *priv = NULL((void*)0);
4711 struct stripe_options *prev = NULL((void*)0);
4712 struct stripe_options *trav = NULL((void*)0);
4713
4714 if (!this)
4715 goto out;
4716
4717 priv = this->private;
4718 if (priv) {
4719 this->private = NULL((void*)0);
4720 GF_FREE (priv->xl_array)__gf_free (priv->xl_array);
4721
4722 trav = priv->pattern;
4723 while (trav) {
4724 prev = trav;
4725 trav = trav->next;
4726 GF_FREE (prev)__gf_free (prev);
4727 }
4728 GF_FREE (priv->last_event)__gf_free (priv->last_event);
4729 LOCK_DESTROY (&priv->lock)pthread_spin_destroy (&priv->lock);
4730 GF_FREE (priv)__gf_free (priv);
4731 }
4732
4733out:
4734 return;
4735}
4736
4737int32_t
4738stripe_getxattr_unwind (call_frame_t *frame,
4739 int op_ret, int op_errno, dict_t *dict, dict_t *xdata)
4740
4741{
4742 STRIPE_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_getxattr_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", "stripe.c", __FUNCTION__
, 4742, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_getxattr_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, op_ret, op_errno, dict, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
4743 return 0;
4744}
4745
4746int
4747stripe_internal_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
4748 int op_ret, int op_errno, dict_t *xattr,
4749 dict_t *xdata)
4750{
4751
4752 char size_key[256] = {0,};
4753 char index_key[256] = {0,};
4754 char count_key[256] = {0,};
4755 char coalesce_key[256] = {0,};
4756
4757 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!)"), "stripe.c"
, __FUNCTION__, 4757, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
4758 VALIDATE_OR_GOTO (frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do {
do { if (0) printf ("invalid argument: " "frame->local");
} while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 4758, GF_LOG_WARNING, "invalid argument: "
"frame->local"); } while (0); goto out; } } while (0)
;
4759
4760 if (!xattr || (op_ret == -1))
4761 goto out;
4762
4763 sprintf (size_key, "trusted.%s.stripe-size", this->name);
4764 sprintf (count_key, "trusted.%s.stripe-count", this->name);
4765 sprintf (index_key, "trusted.%s.stripe-index", this->name);
4766 sprintf (coalesce_key, "trusted.%s.stripe-coalesce", this->name);
4767
4768 dict_del (xattr, size_key);
4769 dict_del (xattr, count_key);
4770 dict_del (xattr, index_key);
4771 dict_del (xattr, coalesce_key);
4772
4773out:
4774 STRIPE_STACK_UNWIND (getxattr, frame, op_ret, op_errno, xattr, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_getxattr_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", "stripe.c", __FUNCTION__
, 4774, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_getxattr_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, op_ret, op_errno, xattr, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
4775
4776 return 0;
4777
4778}
4779
4780int
4781stripe_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
4782 int op_ret, int op_errno, dict_t *xattr, dict_t *xdata)
4783{
4784 int call_cnt = 0;
4785 stripe_local_t *local = NULL((void*)0);
1
'local' initialized to a null pointer value
4786
4787 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!)"), "stripe.c"
, __FUNCTION__, 4787, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
4788 VALIDATE_OR_GOTO (frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do {
do { if (0) printf ("invalid argument: " "frame->local");
} while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 4788, GF_LOG_WARNING, "invalid argument: "
"frame->local"); } while (0); goto out; } } while (0)
;
4789
4790 local = frame->local;
4791
4792 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
4793 {
4794 call_cnt = --local->wind_count;
4795 }
4796 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
4797
4798 if (!xattr || (op_ret < 0))
4799 goto out;
4800
4801 local->op_ret = 0;
4802
4803 if (!local->xattr) {
4804 local->xattr = dict_ref (xattr);
4805 } else {
4806 stripe_aggregate_xattr (local->xattr, xattr);
4807 }
4808
4809out:
4810 if (!call_cnt) {
2
Taking true branch
4811 STRIPE_STACK_UNWIND (getxattr, frame, local->op_ret, op_errno,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_getxattr_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", "stripe.c", __FUNCTION__
, 4812, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_getxattr_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, op_errno, local->xattr, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0); if
(__local) { stripe_local_wipe(__local); mem_put (__local); }
} while (0)
3
Within the expansion of the macro 'STRIPE_STACK_UNWIND':
a
Access to field 'op_ret' results in a dereference of a null pointer (loaded from variable 'local')
4812 local->xattr, xdata)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_getxattr_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", "stripe.c", __FUNCTION__
, 4812, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_getxattr_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, op_errno, local->xattr, xdata
); (*__glusterfs_this_location()) = old_THIS; } while (0); if
(__local) { stripe_local_wipe(__local); mem_put (__local); }
} while (0)
;
4813 }
4814
4815 return 0;
4816}
4817
4818int32_t
4819stripe_vgetxattr_cbk (call_frame_t *frame, void *cookie,
4820 xlator_t *this, int32_t op_ret, int32_t op_errno,
4821 dict_t *dict, dict_t *xdata)
4822{
4823 stripe_local_t *local = NULL((void*)0);
4824 int32_t callcnt = 0;
4825 int32_t ret = -1;
4826 long cky = 0;
4827 void *xattr_val = NULL((void*)0);
4828 void *xattr_serz = NULL((void*)0);
4829 stripe_xattr_sort_t *xattr = NULL((void*)0);
4830 dict_t *stripe_xattr = NULL((void*)0);
4831
4832 if (!frame || !frame->local || !this) {
4833 gf_log ("", GF_LOG_ERROR, "Possible NULL deref")do { do { if (0) printf ("Possible NULL deref"); } while (0);
_gf_log ("", "stripe.c", __FUNCTION__, 4833, GF_LOG_ERROR, "Possible NULL deref"
); } while (0)
;
4834 return ret;
4835 }
4836
4837 local = frame->local;
4838 cky = (long) cookie;
4839
4840 if (local->xsel[0] == '\0') {
4841 gf_log (this->name, GF_LOG_ERROR, "Empty xattr in cbk")do { do { if (0) printf ("Empty xattr in cbk"); } while (0); _gf_log
(this->name, "stripe.c", __FUNCTION__, 4841, GF_LOG_ERROR
, "Empty xattr in cbk"); } while (0)
;
4842 return ret;
4843 }
4844
4845 LOCK (&frame->lock)pthread_spin_lock (&frame->lock);
4846 {
4847 callcnt = --local->wind_count;
4848
4849 if (!dict || (op_ret < 0))
4850 goto out;
4851
4852 if (!local->xattr_list)
4853 local->xattr_list = (stripe_xattr_sort_t *)
4854 GF_CALLOC (local->nallocs,__gf_calloc (local->nallocs, sizeof (stripe_xattr_sort_t),
gf_stripe_mt_xattr_sort_t)
4855 sizeof (stripe_xattr_sort_t),__gf_calloc (local->nallocs, sizeof (stripe_xattr_sort_t),
gf_stripe_mt_xattr_sort_t)
4856 gf_stripe_mt_xattr_sort_t)__gf_calloc (local->nallocs, sizeof (stripe_xattr_sort_t),
gf_stripe_mt_xattr_sort_t)
;
4857
4858 if (local->xattr_list) {
4859 xattr = local->xattr_list + (int32_t) cky;
4860
4861 ret = dict_get_ptr_and_len (dict, local->xsel,
4862 &xattr_val,
4863 &xattr->xattr_len);
4864 if (xattr->xattr_len == 0)
4865 goto out;
4866
4867 xattr->pos = cky;
4868 xattr->xattr_value = gf_memdup (xattr_val,
4869 xattr->xattr_value,
4870 xattr->xattr_len);
4871
4872 local->xattr_total_len += xattr->xattr_len + 1;
4873 }
4874 }
4875 out:
4876 UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock);
4877
4878 if (!callcnt) {
4879 if (!local->xattr_total_len)
4880 goto unwind;
4881
4882 stripe_xattr = dict_new ();
4883 if (!stripe_xattr)
4884 goto unwind;
4885
4886 /* select filler based on ->xsel */
4887 if (XATTR_IS_PATHINFO (local->xsel)(strncmp (local->xsel, "trusted.glusterfs.pathinfo", strlen
("trusted.glusterfs.pathinfo")) == 0)
)
4888 ret = stripe_fill_pathinfo_xattr (this, local,
4889 (char **)&xattr_serz);
4890 else if (XATTR_IS_LOCKINFO (local->xsel)(strncmp (local->xsel, "trusted.glusterfs.lockinfo", strlen
("trusted.glusterfs.lockinfo")) == 0)
) {
4891 ret = stripe_fill_lockinfo_xattr (this, local,
4892 &xattr_serz);
4893 } else {
4894 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Unknown xattr in xattr request"); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
4895, GF_LOG_WARNING, "Unknown xattr in xattr request"); } while
(0)
4895 "Unknown xattr in xattr request")do { do { if (0) printf ("Unknown xattr in xattr request"); }
while (0); _gf_log (this->name, "stripe.c", __FUNCTION__,
4895, GF_LOG_WARNING, "Unknown xattr in xattr request"); } while
(0)
;
4896 goto unwind;
4897 }
4898
4899 if (!ret) {
4900 ret = dict_set_dynptr (stripe_xattr, local->xsel,
4901 xattr_serz,
4902 local->xattr_total_len);
4903 if (ret)
4904 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Can't set %s key in dict", local->
xsel); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4906, GF_LOG_ERROR, "Can't set %s key in dict", local->xsel
); } while (0)
4905 "Can't set %s key in dict",do { do { if (0) printf ("Can't set %s key in dict", local->
xsel); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4906, GF_LOG_ERROR, "Can't set %s key in dict", local->xsel
); } while (0)
4906 local->xsel)do { do { if (0) printf ("Can't set %s key in dict", local->
xsel); } while (0); _gf_log (this->name, "stripe.c", __FUNCTION__
, 4906, GF_LOG_ERROR, "Can't set %s key in dict", local->xsel
); } while (0)
;
4907 }
4908
4909 unwind:
4910 STRIPE_STACK_UNWIND (getxattr, frame, op_ret, op_errno,do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_getxattr_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", "stripe.c", __FUNCTION__
, 4911, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_getxattr_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, op_ret, op_errno, stripe_xattr, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
4911 stripe_xattr, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_getxattr_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", "stripe.c", __FUNCTION__
, 4911, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_getxattr_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, op_ret, op_errno, stripe_xattr, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); if (__local) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
4912
4913 ret = stripe_free_xattr_str (local);
4914
4915 GF_FREE (local->xattr_list)__gf_free (local->xattr_list);
4916
4917 if (stripe_xattr)
4918 dict_unref (stripe_xattr);
4919 }
4920
4921 return ret;
4922}
4923
4924int32_t
4925stripe_getxattr (call_frame_t *frame, xlator_t *this,
4926 loc_t *loc, const char *name, dict_t *xdata)
4927{
4928 stripe_local_t *local = NULL((void*)0);
4929 xlator_list_t *trav = NULL((void*)0);
4930 stripe_private_t *priv = NULL((void*)0);
4931 int32_t op_errno = EINVAL22;
4932 int i = 0;
4933 xlator_t **sub_volumes;
4934 int ret = 0;
4935
4936 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4936, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
4937 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4937, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
4938 VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "stripe.c"
, __FUNCTION__, 4938, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto err; } } while (0)
;
4939 VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 4939, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto err; } } while (0)
;
4940 VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "stripe.c", __FUNCTION__, 4940, GF_LOG_WARNING, "invalid argument: "
"loc->inode"); } while (0); goto err; } } while (0)
;
4941
4942 priv = this->private;
4943 trav = this->children;
4944
4945 /* Initialization */
4946 local = mem_get0 (this->local_pool);
4947 if (!local) {
4948 op_errno = ENOMEM12;
4949 goto err;
4950 }
4951 local->op_ret = -1;
4952 frame->local = local;
4953 loc_copy (&local->loc, loc);
4954
4955
4956 if (name && (strcmp (GF_XATTR_MARKER_KEY"trusted.glusterfs" "." "volume-mark", name) == 0)
4957 && (GF_CLIENT_PID_GSYNCD == frame->root->pid)) {
4958 local->marker.call_count = priv->child_count;
4959
4960 sub_volumes = alloca ( priv->child_count *__builtin_alloca (priv->child_count * sizeof (xlator_t *))
4961 sizeof (xlator_t *))__builtin_alloca (priv->child_count * sizeof (xlator_t *));
4962 for (i = 0, trav = this->children; trav ;
4963 trav = trav->next, i++) {
4964
4965 *(sub_volumes + i) = trav->xlator;
4966
4967 }
4968
4969 if (cluster_getmarkerattr (frame, this, loc, name,
4970 local, stripe_getxattr_unwind,
4971 sub_volumes, priv->child_count,
4972 MARKER_UUID_TYPE1, priv->vol_uuid)) {
4973 op_errno = EINVAL22;
4974 goto err;
4975 }
4976
4977 return 0;
4978 }
4979
4980 if (name && strncmp (name, GF_XATTR_QUOTA_SIZE_KEY"trusted.glusterfs.quota.size",
4981 strlen (GF_XATTR_QUOTA_SIZE_KEY"trusted.glusterfs.quota.size")) == 0) {
4982 local->wind_count = priv->child_count;
4983
4984 for (i = 0, trav=this->children; i < priv->child_count; i++,
4985 trav = trav->next) {
4986 STACK_WIND (frame, stripe_getxattr_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", "stripe.c", __FUNCTION__, 4988, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->getxattr_cbk) tmp_cbk = stripe_getxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->getxattr"; _new->unwind_to
= "stripe_getxattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->getxattr); trav->xlator->
fops->getxattr (_new, trav->xlator, loc, name, xdata); (
*__glusterfs_this_location()) = old_THIS; } while (0)
4987 trav->xlator, trav->xlator->fops->getxattr,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", "stripe.c", __FUNCTION__, 4988, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->getxattr_cbk) tmp_cbk = stripe_getxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->getxattr"; _new->unwind_to
= "stripe_getxattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->getxattr); trav->xlator->
fops->getxattr (_new, trav->xlator, loc, name, xdata); (
*__glusterfs_this_location()) = old_THIS; } while (0)
4988 loc, name, 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", "stripe.c", __FUNCTION__, 4988, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->getxattr_cbk) tmp_cbk = stripe_getxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "trav->xlator->fops->getxattr"; _new->unwind_to
= "stripe_getxattr_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()) = trav->xlator; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, trav->xlator->fops->getxattr); trav->xlator->
fops->getxattr (_new, trav->xlator, loc, name, xdata); (
*__glusterfs_this_location()) = old_THIS; } while (0)
;
4989 }
4990
4991 return 0;
4992 }
4993
4994 if (name &&
4995 ((strncmp (name, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo",
4996 strlen (GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo")) == 0))) {
4997 if (IA_ISREG (loc->inode->ia_type)(loc->inode->ia_type == IA_IFREG)) {
4998 ret = inode_ctx_get (loc->inode, this,inode_ctx_get2(loc->inode,this,(uint64_t *) &local->
fctx,0)
4999 (uint64_t *) &local->fctx)inode_ctx_get2(loc->inode,this,(uint64_t *) &local->
fctx,0)
;
5000 if (ret)
5001 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("stripe size unavailable from fctx" " relying on pathinfo could lead to"
" wrong results"); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 5004, GF_LOG_ERROR, "stripe size unavailable from fctx"
" relying on pathinfo could lead to" " wrong results"); } while
(0)
5002 "stripe size unavailable from fctx"do { do { if (0) printf ("stripe size unavailable from fctx" " relying on pathinfo could lead to"
" wrong results"); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 5004, GF_LOG_ERROR, "stripe size unavailable from fctx"
" relying on pathinfo could lead to" " wrong results"); } while
(0)
5003 " relying on pathinfo could lead to"do { do { if (0) printf ("stripe size unavailable from fctx" " relying on pathinfo could lead to"
" wrong results"); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 5004, GF_LOG_ERROR, "stripe size unavailable from fctx"
" relying on pathinfo could lead to" " wrong results"); } while
(0)
5004 " wrong results")do { do { if (0) printf ("stripe size unavailable from fctx" " relying on pathinfo could lead to"
" wrong results"); } while (0); _gf_log (this->name, "stripe.c"
, __FUNCTION__, 5004, GF_LOG_ERROR, "stripe size unavailable from fctx"
" relying on pathinfo could lead to" " wrong results"); } while
(0)
;
5005 }
5006
5007 local->nallocs = local->wind_count = priv->child_count;
5008 (void) strncpy (local->xsel, name, strlen (name));
5009
5010 /**
5011 * for xattrs that need info from all childs, fill ->xsel
5012 * as above and call the filler function in cbk based on
5013 * it
5014 */
5015 for (i = 0, trav = this->children; i < priv->child_count; i++,
5016 trav = trav->next) {
5017 STACK_WIND_COOKIE (frame, stripe_vgetxattr_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", "stripe.c", __FUNCTION__, 5020, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->getxattr_cbk) tmp_cbk = stripe_vgetxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "trav->xlator->fops->getxattr";
_new->unwind_to = "stripe_vgetxattr_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
); trav->xlator->fops->getxattr_cbk = stripe_vgetxattr_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (trav->xlator->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->getxattr
); trav->xlator->fops->getxattr (_new, trav->xlator
, loc, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
5018 (void *) (long) i, trav->xlator,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", "stripe.c", __FUNCTION__, 5020, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->getxattr_cbk) tmp_cbk = stripe_vgetxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "trav->xlator->fops->getxattr";
_new->unwind_to = "stripe_vgetxattr_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
); trav->xlator->fops->getxattr_cbk = stripe_vgetxattr_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (trav->xlator->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->getxattr
); trav->xlator->fops->getxattr (_new, trav->xlator
, loc, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
5019 trav->xlator->fops->getxattr,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", "stripe.c", __FUNCTION__, 5020, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->getxattr_cbk) tmp_cbk = stripe_vgetxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "trav->xlator->fops->getxattr";
_new->unwind_to = "stripe_vgetxattr_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
); trav->xlator->fops->getxattr_cbk = stripe_vgetxattr_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (trav->xlator->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->getxattr
); trav->xlator->fops->getxattr (_new, trav->xlator
, loc, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
5020 loc, name, 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", "stripe.c", __FUNCTION__, 5020, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->getxattr_cbk) tmp_cbk = stripe_vgetxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "trav->xlator->fops->getxattr";
_new->unwind_to = "stripe_vgetxattr_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
); trav->xlator->fops->getxattr_cbk = stripe_vgetxattr_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (trav->xlator->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->getxattr
); trav->xlator->fops->getxattr (_new, trav->xlator
, loc, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
5021 }
5022
5023 return 0;
5024 }
5025
5026 if (name &&(*priv->vol_uuid)) {
5027 if ((match_uuid_local (name, priv->vol_uuid) == 0)
5028 && (GF_CLIENT_PID_GSYNCD == frame->root->pid)) {
5029
5030 if (!IA_FILE_OR_DIR (loc->inode->ia_type)((loc->inode->ia_type == IA_IFREG) || (loc->inode->
ia_type == IA_IFDIR))
)
5031 local->marker.call_count = 1;
5032 else
5033 local->marker.call_count = priv->child_count;
5034
5035 sub_volumes = alloca (local->marker.call_count *__builtin_alloca (local->marker.call_count * sizeof (xlator_t
*))
5036 sizeof (xlator_t *))__builtin_alloca (local->marker.call_count * sizeof (xlator_t
*))
;
5037
5038 for (i = 0, trav = this->children;
5039 i < local->marker.call_count;
5040 i++, trav = trav->next) {
5041 *(sub_volumes + i) = trav->xlator;
5042
5043 }
5044
5045 if (cluster_getmarkerattr (frame, this, loc, name,
5046 local,
5047 stripe_getxattr_unwind,
5048 sub_volumes,
5049 local->marker.call_count,
5050 MARKER_XTIME_TYPE2,
5051 priv->vol_uuid)) {
5052 op_errno = EINVAL22;
5053 goto err;
5054 }
5055
5056 return 0;
5057 }
5058 }
5059
5060
5061 STACK_WIND (frame, stripe_internal_getxattr_cbk, FIRST_CHILD(this),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", "stripe.c", __FUNCTION__, 5062, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->getxattr_cbk) tmp_cbk = stripe_internal_getxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->getxattr"
; _new->unwind_to = "stripe_internal_getxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->getxattr); (this->children->xlator
)->fops->getxattr (_new, (this->children->xlator)
, loc, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
5062 FIRST_CHILD(this)->fops->getxattr, loc, name, 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", "stripe.c", __FUNCTION__, 5062, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->getxattr_cbk) tmp_cbk = stripe_internal_getxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->getxattr"
; _new->unwind_to = "stripe_internal_getxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->getxattr); (this->children->xlator
)->fops->getxattr (_new, (this->children->xlator)
, loc, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
5063
5064 return 0;
5065
5066err:
5067 STRIPE_STACK_UNWIND (getxattr, frame, -1, op_errno, NULL, NULL)do { stripe_local_t *__local = ((void*)0); if (frame) { __local
= frame->local; frame->local = ((void*)0); } do { fop_getxattr_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", "stripe.c", __FUNCTION__
, 5067, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_getxattr_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) { stripe_local_wipe
(__local); mem_put (__local); } } while (0)
;
5068 return 0;
5069}
5070
5071inline gf_boolean_t
5072stripe_is_special_xattr (const char *name)
5073{
5074 gf_boolean_t is_spl = _gf_false;
5075
5076 if (!name) {
5077 goto out;
5078 }
5079
5080 if (!strncmp (name, GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo",
5081 strlen (GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo"))
5082 || !strncmp (name, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo",
5083 strlen (GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo")))
5084 is_spl = _gf_true;
5085out:
5086 return is_spl;
5087}
5088
5089int32_t
5090stripe_fgetxattr_from_everyone (call_frame_t *frame, xlator_t *this, fd_t *fd,
5091 const char *name, dict_t *xdata)
5092{
5093 stripe_local_t *local = NULL((void*)0);
5094 stripe_private_t *priv = NULL((void*)0);
5095 int32_t ret = -1, op_errno = 0;
5096 int i = 0;
5097 xlator_list_t *trav = NULL((void*)0);
5098
5099 priv = this->private;
5100
5101 local = mem_get0 (this->local_pool);
5102 if (!local) {
5103 op_errno = ENOMEM12;
5104 goto err;
5105 }
5106
5107 local->op_ret = -1;
5108 frame->local = local;
5109
5110 strncpy (local->xsel, name, strlen (name));
5111 local->nallocs = local->wind_count = priv->child_count;
5112
5113 for (i = 0, trav = this->children; i < priv->child_count; i++,
5114 trav = trav->next) {
5115 STACK_WIND_COOKIE (frame, stripe_vgetxattr_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", "stripe.c", __FUNCTION__, 5118, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fgetxattr_cbk) tmp_cbk = stripe_vgetxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "trav->xlator->fops->fgetxattr"
; _new->unwind_to = "stripe_vgetxattr_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
); trav->xlator->fops->fgetxattr_cbk = stripe_vgetxattr_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (trav->xlator->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->fgetxattr
); trav->xlator->fops->fgetxattr (_new, trav->xlator
, fd, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
5116 (void *) (long) i, trav->xlator,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", "stripe.c", __FUNCTION__, 5118, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fgetxattr_cbk) tmp_cbk = stripe_vgetxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "trav->xlator->fops->fgetxattr"
; _new->unwind_to = "stripe_vgetxattr_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
); trav->xlator->fops->fgetxattr_cbk = stripe_vgetxattr_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (trav->xlator->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->fgetxattr
); trav->xlator->fops->fgetxattr (_new, trav->xlator
, fd, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
5117 trav->xlator->fops->fgetxattr,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", "stripe.c", __FUNCTION__, 5118, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fgetxattr_cbk) tmp_cbk = stripe_vgetxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "trav->xlator->fops->fgetxattr"
; _new->unwind_to = "stripe_vgetxattr_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
); trav->xlator->fops->fgetxattr_cbk = stripe_vgetxattr_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (trav->xlator->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->fgetxattr
); trav->xlator->fops->fgetxattr (_new, trav->xlator
, fd, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
5118 fd, name, 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", "stripe.c", __FUNCTION__, 5118, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( trav->xlator
->fops->fgetxattr_cbk) tmp_cbk = stripe_vgetxattr_cbk; _new
->root = frame->root; _new->this = trav->xlator; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = (void *) (long) i; _new->wind_from = __FUNCTION__
; _new->wind_to = "trav->xlator->fops->fgetxattr"
; _new->unwind_to = "stripe_vgetxattr_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
); trav->xlator->fops->fgetxattr_cbk = stripe_vgetxattr_cbk
; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = trav->xlator; if (trav->xlator->ctx->measure_latency
) gf_latency_begin (_new, trav->xlator->fops->fgetxattr
); trav->xlator->fops->fgetxattr (_new, trav->xlator
, fd, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
5119 }
5120
5121 return 0;
5122
5123err:
5124 STACK_UNWIND_STRICT (fgetxattr, frame, -1, op_errno, NULL, NULL)do { fop_fgetxattr_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"
, "stripe.c", __FUNCTION__, 5124, GF_LOG_CRITICAL, "!frame");
} while (0); break; } fn = (fop_fgetxattr_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)
;
5125 return ret;
5126}
5127
5128int32_t
5129stripe_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
5130 const char *name, dict_t *xdata)
5131{
5132 if (stripe_is_special_xattr (name)) {
5133 stripe_fgetxattr_from_everyone (frame, this, fd, name, xdata);
5134 goto out;
5135 }
5136
5137 STACK_WIND (frame, stripe_internal_getxattr_cbk, FIRST_CHILD(this),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", "stripe.c", __FUNCTION__, 5138, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->fgetxattr_cbk) tmp_cbk = stripe_internal_getxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->fgetxattr"
; _new->unwind_to = "stripe_internal_getxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->fgetxattr); (this->children->
xlator)->fops->fgetxattr (_new, (this->children->
xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
5138 FIRST_CHILD(this)->fops->fgetxattr, fd, name, 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", "stripe.c", __FUNCTION__, 5138, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->fgetxattr_cbk) tmp_cbk = stripe_internal_getxattr_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->fgetxattr"
; _new->unwind_to = "stripe_internal_getxattr_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
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->fgetxattr); (this->children->
xlator)->fops->fgetxattr (_new, (this->children->
xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
5139
5140out:
5141 return 0;
5142}
5143
5144
5145
5146int32_t
5147stripe_priv_dump (xlator_t *this)
5148{
5149 char key[GF_DUMP_MAX_BUF_LEN4096];
5150 int i = 0;
5151 stripe_private_t *priv = NULL((void*)0);
5152 int ret = -1;
5153 struct stripe_options *options = NULL((void*)0);
5154
5155 GF_VALIDATE_OR_GOTO ("stripe", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
("stripe", "stripe.c", __FUNCTION__, 5155, GF_LOG_ERROR, "invalid argument: "
"this"); } while (0); goto out; } } while (0)
;
5156
5157 priv = this->private;
5158 if (!priv)
5159 goto out;
5160
5161 ret = TRY_LOCK (&priv->lock)pthread_spin_trylock (&priv->lock);
5162 if (ret != 0)
5163 goto out;
5164
5165 gf_proc_dump_add_section("xlator.cluster.stripe.%s.priv", this->name);
5166 gf_proc_dump_write("child_count","%d", priv->child_count);
5167
5168 for (i = 0; i < priv->child_count; i++) {
5169 sprintf (key, "subvolumes[%d]", i);
5170 gf_proc_dump_write (key, "%s.%s", priv->xl_array[i]->type,
5171 priv->xl_array[i]->name);
5172 }
5173
5174 options = priv->pattern;
5175 while (options != NULL((void*)0)) {
5176 gf_proc_dump_write ("path_pattern", "%s", priv->pattern->path_pattern);
5177 gf_proc_dump_write ("options_block_size", "%ul", options->block_size);
5178
5179 options = options->next;
5180 }
5181
5182 gf_proc_dump_write ("block_size", "%ul", priv->block_size);
5183 gf_proc_dump_write ("nodes-down", "%d", priv->nodes_down);
5184 gf_proc_dump_write ("first-child_down", "%d", priv->first_child_down);
5185 gf_proc_dump_write ("xattr_supported", "%d", priv->xattr_supported);
5186
5187 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
5188
5189out:
5190 return ret;
5191}
5192
5193struct xlator_fops fops = {
5194 .stat = stripe_stat,
5195 .unlink = stripe_unlink,
5196 .rename = stripe_rename,
5197 .link = stripe_link,
5198 .truncate = stripe_truncate,
5199 .create = stripe_create,
5200 .open = stripe_open,
5201 .readv = stripe_readv,
5202 .writev = stripe_writev,
5203 .statfs = stripe_statfs,
5204 .flush = stripe_flush,
5205 .fsync = stripe_fsync,
5206 .ftruncate = stripe_ftruncate,
5207 .fstat = stripe_fstat,
5208 .mkdir = stripe_mkdir,
5209 .rmdir = stripe_rmdir,
5210 .lk = stripe_lk,
5211 .opendir = stripe_opendir,
5212 .fsyncdir = stripe_fsyncdir,
5213 .setattr = stripe_setattr,
5214 .fsetattr = stripe_fsetattr,
5215 .lookup = stripe_lookup,
5216 .mknod = stripe_mknod,
5217 .setxattr = stripe_setxattr,
5218 .fsetxattr = stripe_fsetxattr,
5219 .getxattr = stripe_getxattr,
5220 .fgetxattr = stripe_fgetxattr,
5221 .removexattr = stripe_removexattr,
5222 .fremovexattr = stripe_fremovexattr,
5223 .readdirp = stripe_readdirp,
5224};
5225
5226struct xlator_cbks cbks = {
5227 .release = stripe_release,
5228 .forget = stripe_forget,
5229};
5230
5231struct xlator_dumpops dumpops = {
5232 .priv = stripe_priv_dump,
5233};
5234
5235struct volume_options options[] = {
5236 { .key = {"block-size"},
5237 .type = GF_OPTION_TYPE_SIZE_LIST,
5238 .default_value = "128KB",
5239 .min = STRIPE_MIN_BLOCK_SIZE(16*1024ULL),
5240 .description = "Size of the stripe unit that would be read "
5241 "from or written to the striped servers."
5242 },
5243 { .key = {"use-xattr"},
5244 .type = GF_OPTION_TYPE_BOOL,
5245 .default_value = "true"
5246 },
5247 { .key = {"coalesce"},
5248 .type = GF_OPTION_TYPE_BOOL,
5249 .default_value = "false",
5250 .description = "Enable coalesce mode to flatten striped files as "
5251 "stored on the server (i.e., eliminate holes caused "
5252 "by the traditional format)."
5253 },
5254 { .key = {NULL((void*)0)} },
5255};