File: | xlators/cluster/afr/src/afr-inode-read.c |
Location: | line 1157, column 9 |
Description: | Null pointer passed as an argument to a 'nonnull' parameter |
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 | #include <libgen.h> | |||||
13 | #include <unistd.h> | |||||
14 | #include <fnmatch.h> | |||||
15 | #include <sys/time.h> | |||||
16 | #include <stdlib.h> | |||||
17 | #include <signal.h> | |||||
18 | ||||||
19 | #ifndef _CONFIG_H | |||||
20 | #define _CONFIG_H | |||||
21 | #include "config.h" | |||||
22 | #endif | |||||
23 | ||||||
24 | #include "glusterfs.h" | |||||
25 | #include "afr.h" | |||||
26 | #include "dict.h" | |||||
27 | #include "xlator.h" | |||||
28 | #include "hashfn.h" | |||||
29 | #include "logging.h" | |||||
30 | #include "stack.h" | |||||
31 | #include "list.h" | |||||
32 | #include "call-stub.h" | |||||
33 | #include "defaults.h" | |||||
34 | #include "common-utils.h" | |||||
35 | #include "compat-errno.h" | |||||
36 | #include "compat.h" | |||||
37 | ||||||
38 | /** | |||||
39 | * Common algorithm for inode read calls: | |||||
40 | * | |||||
41 | * - Try the fop on the first child that is up | |||||
42 | * - if we have failed due to ENOTCONN: | |||||
43 | * try the next child | |||||
44 | * | |||||
45 | * Applicable to: access, stat, fstat, readlink, getxattr | |||||
46 | */ | |||||
47 | ||||||
48 | /* {{{ access */ | |||||
49 | ||||||
50 | int32_t | |||||
51 | afr_access_cbk (call_frame_t *frame, void *cookie, | |||||
52 | xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) | |||||
53 | { | |||||
54 | afr_private_t * priv = NULL((void*)0); | |||||
55 | afr_local_t * local = NULL((void*)0); | |||||
56 | xlator_t ** children = NULL((void*)0); | |||||
57 | int unwind = 1; | |||||
58 | int32_t *last_index = NULL((void*)0); | |||||
59 | int32_t next_call_child = -1; | |||||
60 | int32_t read_child = -1; | |||||
61 | int32_t *fresh_children = NULL((void*)0); | |||||
62 | ||||||
63 | priv = this->private; | |||||
64 | children = priv->children; | |||||
65 | ||||||
66 | local = frame->local; | |||||
67 | ||||||
68 | read_child = (long) cookie; | |||||
69 | ||||||
70 | if (op_ret == -1) { | |||||
71 | last_index = &local->cont.access.last_index; | |||||
72 | fresh_children = local->fresh_children; | |||||
73 | next_call_child = afr_next_call_child (fresh_children, | |||||
74 | local->child_up, | |||||
75 | priv->child_count, | |||||
76 | last_index, read_child); | |||||
77 | if (next_call_child < 0) | |||||
78 | goto out; | |||||
79 | ||||||
80 | unwind = 0; | |||||
81 | ||||||
82 | STACK_WIND_COOKIE (frame, afr_access_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 87, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof( children[next_call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[next_call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->access); children[next_call_child ]->fops->access (_new, children[next_call_child], & local->loc, local->cont.access.mask, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
83 | (void *) (long) read_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 87, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof( children[next_call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[next_call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->access); children[next_call_child ]->fops->access (_new, children[next_call_child], & local->loc, local->cont.access.mask, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
84 | children[next_call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 87, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof( children[next_call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[next_call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->access); children[next_call_child ]->fops->access (_new, children[next_call_child], & local->loc, local->cont.access.mask, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
85 | children[next_call_child]->fops->access,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 87, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof( children[next_call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[next_call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->access); children[next_call_child ]->fops->access (_new, children[next_call_child], & local->loc, local->cont.access.mask, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
86 | &local->loc, local->cont.access.mask,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 87, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof( children[next_call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[next_call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->access); children[next_call_child ]->fops->access (_new, children[next_call_child], & local->loc, local->cont.access.mask, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
87 | NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 87, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof( children[next_call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[next_call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->access); children[next_call_child ]->fops->access (_new, children[next_call_child], & local->loc, local->cont.access.mask, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
88 | } | |||||
89 | ||||||
90 | out: | |||||
91 | if (unwind) { | |||||
92 | AFR_STACK_UNWIND (access, frame, op_ret, op_errno, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_access_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "afr-inode-read.c" , __FUNCTION__, 92, GF_LOG_CRITICAL, "!frame"); } while (0); break ; } fn = (fop_access_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) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
93 | } | |||||
94 | ||||||
95 | return 0; | |||||
96 | } | |||||
97 | ||||||
98 | ||||||
99 | int32_t | |||||
100 | afr_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask, | |||||
101 | dict_t *xdata) | |||||
102 | { | |||||
103 | afr_private_t *priv = NULL((void*)0); | |||||
104 | xlator_t **children = NULL((void*)0); | |||||
105 | int call_child = 0; | |||||
106 | afr_local_t *local = NULL((void*)0); | |||||
107 | int32_t op_errno = 0; | |||||
108 | int32_t read_child = -1; | |||||
109 | int ret = -1; | |||||
110 | ||||||
111 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 111, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||||
112 | VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 112, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto out; } } while (0); | |||||
113 | VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 113, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto out; } } while (0); | |||||
114 | ||||||
115 | priv = this->private; | |||||
116 | VALIDATE_OR_GOTO (priv->children, out)do { if (!priv->children) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "priv->children" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 116, GF_LOG_WARNING, "invalid argument: " "priv->children"); } while (0); goto out; } } while (0); | |||||
117 | ||||||
118 | children = priv->children; | |||||
119 | ||||||
120 | AFR_LOCAL_ALLOC_OR_GOTO (frame->local, out)do { frame->local = mem_get0 ((*__glusterfs_this_location( ))->local_pool); if (!frame->local) { do { do { if (0) printf ("out of memory :("); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 120, GF_LOG_ERROR, "out of memory :("); } while (0); op_errno = 12; goto out; } } while (0);; | |||||
121 | local = frame->local; | |||||
122 | ||||||
123 | ret = afr_local_init (local, priv, &op_errno); | |||||
124 | if (ret < 0) | |||||
125 | goto out; | |||||
126 | ||||||
127 | local->fresh_children = afr_children_create (priv->child_count); | |||||
128 | if (!local->fresh_children) { | |||||
129 | op_errno = ENOMEM12; | |||||
130 | goto out; | |||||
131 | } | |||||
132 | ||||||
133 | ||||||
134 | read_child = afr_inode_get_read_ctx (this, loc->inode, | |||||
135 | local->fresh_children); | |||||
136 | ret = afr_get_call_child (this, local->child_up, read_child, | |||||
137 | local->fresh_children, | |||||
138 | &call_child, | |||||
139 | &local->cont.access.last_index); | |||||
140 | if (ret < 0) { | |||||
141 | op_errno = -ret; | |||||
142 | goto out; | |||||
143 | } | |||||
144 | ||||||
145 | loc_copy (&local->loc, loc); | |||||
146 | local->cont.access.mask = mask; | |||||
147 | ||||||
148 | STACK_WIND_COOKIE (frame, afr_access_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 152 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->access); children[call_child]->fops->access (_new, children[call_child], loc, mask, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
149 | (void *) (long) call_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 152 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->access); children[call_child]->fops->access (_new, children[call_child], loc, mask, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
150 | children[call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 152 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->access); children[call_child]->fops->access (_new, children[call_child], loc, mask, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
151 | children[call_child]->fops->access,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 152 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->access); children[call_child]->fops->access (_new, children[call_child], loc, mask, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
152 | loc, mask, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 152 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->access_cbk) tmp_cbk = afr_access_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->access" ; _new->unwind_to = "afr_access_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 ); children[call_child]->fops->access_cbk = afr_access_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->access); children[call_child]->fops->access (_new, children[call_child], loc, mask, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
153 | ||||||
154 | ret = 0; | |||||
155 | out: | |||||
156 | if (ret < 0) | |||||
157 | AFR_STACK_UNWIND (access, frame, -1, op_errno, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_access_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "afr-inode-read.c" , __FUNCTION__, 157, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_access_cbk_t )frame->ret; _parent = frame ->parent; pthread_spin_lock (&frame->root->stack_lock ); { _parent->ref_count--; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
158 | return 0; | |||||
159 | } | |||||
160 | ||||||
161 | ||||||
162 | /* }}} */ | |||||
163 | ||||||
164 | /* {{{ stat */ | |||||
165 | ||||||
166 | int32_t | |||||
167 | afr_stat_cbk (call_frame_t *frame, void *cookie, | |||||
168 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
169 | struct iatt *buf, dict_t *xdata) | |||||
170 | { | |||||
171 | afr_private_t * priv = NULL((void*)0); | |||||
172 | afr_local_t * local = NULL((void*)0); | |||||
173 | xlator_t ** children = NULL((void*)0); | |||||
174 | int unwind = 1; | |||||
175 | int32_t *last_index = NULL((void*)0); | |||||
176 | int32_t next_call_child = -1; | |||||
177 | int32_t read_child = -1; | |||||
178 | int32_t *fresh_children = NULL((void*)0); | |||||
179 | ||||||
180 | priv = this->private; | |||||
181 | children = priv->children; | |||||
182 | ||||||
183 | read_child = (long) cookie; | |||||
184 | ||||||
185 | local = frame->local; | |||||
186 | ||||||
187 | if (op_ret == -1) { | |||||
188 | last_index = &local->cont.stat.last_index; | |||||
189 | fresh_children = local->fresh_children; | |||||
190 | next_call_child = afr_next_call_child (fresh_children, | |||||
191 | local->child_up, | |||||
192 | priv->child_count, | |||||
193 | last_index, read_child); | |||||
194 | if (next_call_child < 0) | |||||
195 | goto out; | |||||
196 | ||||||
197 | unwind = 0; | |||||
198 | ||||||
199 | STACK_WIND_COOKIE (frame, afr_stat_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 203 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->stat_cbk) tmp_cbk = afr_stat_cbk ; _new->root = frame->root; _new->this = children[next_call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) read_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->stat" ; _new->unwind_to = "afr_stat_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 ); children[next_call_child]->fops->stat_cbk = afr_stat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->stat); children[next_call_child ]->fops->stat (_new, children[next_call_child], &local ->loc, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||||
200 | (void *) (long) read_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 203 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->stat_cbk) tmp_cbk = afr_stat_cbk ; _new->root = frame->root; _new->this = children[next_call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) read_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->stat" ; _new->unwind_to = "afr_stat_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 ); children[next_call_child]->fops->stat_cbk = afr_stat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->stat); children[next_call_child ]->fops->stat (_new, children[next_call_child], &local ->loc, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||||
201 | children[next_call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 203 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->stat_cbk) tmp_cbk = afr_stat_cbk ; _new->root = frame->root; _new->this = children[next_call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) read_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->stat" ; _new->unwind_to = "afr_stat_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 ); children[next_call_child]->fops->stat_cbk = afr_stat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->stat); children[next_call_child ]->fops->stat (_new, children[next_call_child], &local ->loc, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||||
202 | children[next_call_child]->fops->stat,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 203 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->stat_cbk) tmp_cbk = afr_stat_cbk ; _new->root = frame->root; _new->this = children[next_call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) read_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->stat" ; _new->unwind_to = "afr_stat_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 ); children[next_call_child]->fops->stat_cbk = afr_stat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->stat); children[next_call_child ]->fops->stat (_new, children[next_call_child], &local ->loc, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||||
203 | &local->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", "afr-inode-read.c", __FUNCTION__, 203 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->stat_cbk) tmp_cbk = afr_stat_cbk ; _new->root = frame->root; _new->this = children[next_call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) read_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->stat" ; _new->unwind_to = "afr_stat_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 ); children[next_call_child]->fops->stat_cbk = afr_stat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->stat); children[next_call_child ]->fops->stat (_new, children[next_call_child], &local ->loc, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||||
204 | } | |||||
205 | ||||||
206 | out: | |||||
207 | if (unwind) { | |||||
208 | AFR_STACK_UNWIND (stat, frame, op_ret, op_errno, buf, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 208, 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, op_ret , op_errno, buf, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
209 | } | |||||
210 | ||||||
211 | return 0; | |||||
212 | } | |||||
213 | ||||||
214 | ||||||
215 | int32_t | |||||
216 | afr_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) | |||||
217 | { | |||||
218 | afr_private_t *priv = NULL((void*)0); | |||||
219 | afr_local_t *local = NULL((void*)0); | |||||
220 | xlator_t **children = NULL((void*)0); | |||||
221 | int call_child = 0; | |||||
222 | int32_t op_errno = 0; | |||||
223 | int32_t read_child = -1; | |||||
224 | int ret = -1; | |||||
225 | ||||||
226 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 226, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||||
227 | VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 227, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto out; } } while (0); | |||||
228 | VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 228, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto out; } } while (0); | |||||
229 | ||||||
230 | priv = this->private; | |||||
231 | VALIDATE_OR_GOTO (priv->children, out)do { if (!priv->children) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "priv->children" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 231, GF_LOG_WARNING, "invalid argument: " "priv->children"); } while (0); goto out; } } while (0); | |||||
232 | ||||||
233 | children = priv->children; | |||||
234 | ||||||
235 | AFR_LOCAL_ALLOC_OR_GOTO (frame->local, out)do { frame->local = mem_get0 ((*__glusterfs_this_location( ))->local_pool); if (!frame->local) { do { do { if (0) printf ("out of memory :("); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 235, GF_LOG_ERROR, "out of memory :("); } while (0); op_errno = 12; goto out; } } while (0);; | |||||
236 | local = frame->local; | |||||
237 | ||||||
238 | ret = afr_local_init (local, priv, &op_errno); | |||||
239 | if (ret < 0) | |||||
240 | goto out; | |||||
241 | ||||||
242 | local->fresh_children = afr_children_create (priv->child_count); | |||||
243 | if (!local->fresh_children) { | |||||
244 | op_errno = ENOMEM12; | |||||
245 | goto out; | |||||
246 | } | |||||
247 | ||||||
248 | read_child = afr_inode_get_read_ctx (this, loc->inode, | |||||
249 | local->fresh_children); | |||||
250 | ret = afr_get_call_child (this, local->child_up, read_child, | |||||
251 | local->fresh_children, | |||||
252 | &call_child, | |||||
253 | &local->cont.stat.last_index); | |||||
254 | if (ret < 0) { | |||||
255 | op_errno = -ret; | |||||
256 | goto out; | |||||
257 | } | |||||
258 | loc_copy (&local->loc, loc); | |||||
259 | ||||||
260 | STACK_WIND_COOKIE (frame, afr_stat_cbk, (void *) (long) call_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 263 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->stat_cbk) tmp_cbk = afr_stat_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->stat" ; _new->unwind_to = "afr_stat_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 ); children[call_child]->fops->stat_cbk = afr_stat_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->stat); children[call_child]->fops->stat ( _new, children[call_child], loc, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
261 | children[call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 263 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->stat_cbk) tmp_cbk = afr_stat_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->stat" ; _new->unwind_to = "afr_stat_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 ); children[call_child]->fops->stat_cbk = afr_stat_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->stat); children[call_child]->fops->stat ( _new, children[call_child], loc, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
262 | children[call_child]->fops->stat,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 263 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->stat_cbk) tmp_cbk = afr_stat_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->stat" ; _new->unwind_to = "afr_stat_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 ); children[call_child]->fops->stat_cbk = afr_stat_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->stat); children[call_child]->fops->stat ( _new, children[call_child], loc, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
263 | loc, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 263 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->stat_cbk) tmp_cbk = afr_stat_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->stat" ; _new->unwind_to = "afr_stat_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 ); children[call_child]->fops->stat_cbk = afr_stat_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->stat); children[call_child]->fops->stat ( _new, children[call_child], loc, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
264 | ||||||
265 | ret = 0; | |||||
266 | out: | |||||
267 | if (ret < 0) | |||||
268 | AFR_STACK_UNWIND (stat, frame, -1, op_errno, NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 268, 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) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0); | |||||
269 | ||||||
270 | return 0; | |||||
271 | } | |||||
272 | ||||||
273 | ||||||
274 | /* }}} */ | |||||
275 | ||||||
276 | /* {{{ fstat */ | |||||
277 | ||||||
278 | int32_t | |||||
279 | afr_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||||
280 | int32_t op_ret, int32_t op_errno, struct iatt *buf, | |||||
281 | dict_t *xdata) | |||||
282 | { | |||||
283 | afr_private_t *priv = NULL((void*)0); | |||||
284 | afr_local_t *local = NULL((void*)0); | |||||
285 | xlator_t **children = NULL((void*)0); | |||||
286 | int unwind = 1; | |||||
287 | int32_t *last_index = NULL((void*)0); | |||||
288 | int32_t next_call_child = -1; | |||||
289 | int32_t read_child = -1; | |||||
290 | int32_t *fresh_children = NULL((void*)0); | |||||
291 | ||||||
292 | priv = this->private; | |||||
293 | children = priv->children; | |||||
294 | ||||||
295 | local = frame->local; | |||||
296 | ||||||
297 | read_child = (long) cookie; | |||||
298 | ||||||
299 | if (op_ret == -1) { | |||||
300 | last_index = &local->cont.fstat.last_index; | |||||
301 | fresh_children = local->fresh_children; | |||||
302 | next_call_child = afr_next_call_child (fresh_children, | |||||
303 | local->child_up, | |||||
304 | priv->child_count, | |||||
305 | last_index, read_child); | |||||
306 | if (next_call_child < 0) | |||||
307 | goto out; | |||||
308 | ||||||
309 | unwind = 0; | |||||
310 | ||||||
311 | STACK_WIND_COOKIE (frame, afr_fstat_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 315 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fstat_cbk) tmp_cbk = afr_fstat_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fstat" ; _new->unwind_to = "afr_fstat_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 ); children[next_call_child]->fops->fstat_cbk = afr_fstat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fstat); children[next_call_child ]->fops->fstat (_new, children[next_call_child], local-> fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||||
312 | (void *) (long) read_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 315 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fstat_cbk) tmp_cbk = afr_fstat_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fstat" ; _new->unwind_to = "afr_fstat_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 ); children[next_call_child]->fops->fstat_cbk = afr_fstat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fstat); children[next_call_child ]->fops->fstat (_new, children[next_call_child], local-> fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||||
313 | children[next_call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 315 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fstat_cbk) tmp_cbk = afr_fstat_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fstat" ; _new->unwind_to = "afr_fstat_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 ); children[next_call_child]->fops->fstat_cbk = afr_fstat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fstat); children[next_call_child ]->fops->fstat (_new, children[next_call_child], local-> fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||||
314 | children[next_call_child]->fops->fstat,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 315 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fstat_cbk) tmp_cbk = afr_fstat_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fstat" ; _new->unwind_to = "afr_fstat_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 ); children[next_call_child]->fops->fstat_cbk = afr_fstat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fstat); children[next_call_child ]->fops->fstat (_new, children[next_call_child], local-> fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||||
315 | local->fd, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 315 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fstat_cbk) tmp_cbk = afr_fstat_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fstat" ; _new->unwind_to = "afr_fstat_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 ); children[next_call_child]->fops->fstat_cbk = afr_fstat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fstat); children[next_call_child ]->fops->fstat (_new, children[next_call_child], local-> fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||||
316 | } | |||||
317 | ||||||
318 | out: | |||||
319 | if (unwind) { | |||||
320 | AFR_STACK_UNWIND (fstat, frame, op_ret, op_errno, buf, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 320, 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, op_ret , op_errno, buf, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
321 | } | |||||
322 | ||||||
323 | return 0; | |||||
324 | } | |||||
325 | ||||||
326 | ||||||
327 | int32_t | |||||
328 | afr_fstat (call_frame_t *frame, xlator_t *this, | |||||
329 | fd_t *fd, dict_t *xdata) | |||||
330 | { | |||||
331 | afr_private_t *priv = NULL((void*)0); | |||||
332 | afr_local_t *local = NULL((void*)0); | |||||
333 | xlator_t **children = NULL((void*)0); | |||||
334 | int call_child = 0; | |||||
335 | int32_t op_errno = 0; | |||||
336 | int32_t read_child = 0; | |||||
337 | int ret = -1; | |||||
338 | ||||||
339 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 339, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||||
340 | VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 340, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto out; } } while (0); | |||||
341 | VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 341, GF_LOG_WARNING, "invalid argument: " "fd" ); } while (0); goto out; } } while (0); | |||||
342 | VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 342, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto out; } } while (0); | |||||
343 | ||||||
344 | priv = this->private; | |||||
345 | VALIDATE_OR_GOTO (priv->children, out)do { if (!priv->children) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "priv->children" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 345, GF_LOG_WARNING, "invalid argument: " "priv->children"); } while (0); goto out; } } while (0); | |||||
346 | ||||||
347 | children = priv->children; | |||||
348 | ||||||
349 | VALIDATE_OR_GOTO (fd->inode, out)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!)" ), "afr-inode-read.c", __FUNCTION__, 349, GF_LOG_WARNING, "invalid argument: " "fd->inode"); } while (0); goto out; } } while (0); | |||||
350 | ||||||
351 | if (afr_is_split_brain (this, fd->inode)) { | |||||
352 | op_errno = EIO5; | |||||
353 | goto out; | |||||
354 | } | |||||
355 | ||||||
356 | AFR_LOCAL_ALLOC_OR_GOTO (frame->local, out)do { frame->local = mem_get0 ((*__glusterfs_this_location( ))->local_pool); if (!frame->local) { do { do { if (0) printf ("out of memory :("); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 356, GF_LOG_ERROR, "out of memory :("); } while (0); op_errno = 12; goto out; } } while (0);; | |||||
357 | local = frame->local; | |||||
358 | ||||||
359 | ret = afr_local_init (local, priv, &op_errno); | |||||
360 | if (ret < 0) | |||||
361 | goto out; | |||||
362 | ||||||
363 | local->fresh_children = afr_children_create (priv->child_count); | |||||
364 | if (!local->fresh_children) { | |||||
365 | op_errno = ENOMEM12; | |||||
366 | goto out; | |||||
367 | } | |||||
368 | ||||||
369 | read_child = afr_inode_get_read_ctx (this, fd->inode, | |||||
370 | local->fresh_children); | |||||
371 | ||||||
372 | ||||||
373 | ||||||
374 | ret = afr_get_call_child (this, local->child_up, read_child, | |||||
375 | local->fresh_children, | |||||
376 | &call_child, | |||||
377 | &local->cont.fstat.last_index); | |||||
378 | if (ret < 0) { | |||||
379 | op_errno = -ret; | |||||
380 | goto out; | |||||
381 | } | |||||
382 | ||||||
383 | local->fd = fd_ref (fd); | |||||
384 | ||||||
385 | afr_open_fd_fix (fd, this); | |||||
386 | ||||||
387 | STACK_WIND_COOKIE (frame, afr_fstat_cbk, (void *) (long) call_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 390 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->fstat_cbk) tmp_cbk = afr_fstat_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->fstat" ; _new->unwind_to = "afr_fstat_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 ); children[call_child]->fops->fstat_cbk = afr_fstat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->fstat); children[call_child]->fops->fstat (_new, children[call_child], fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
388 | children[call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 390 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->fstat_cbk) tmp_cbk = afr_fstat_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->fstat" ; _new->unwind_to = "afr_fstat_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 ); children[call_child]->fops->fstat_cbk = afr_fstat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->fstat); children[call_child]->fops->fstat (_new, children[call_child], fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
389 | children[call_child]->fops->fstat,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 390 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->fstat_cbk) tmp_cbk = afr_fstat_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->fstat" ; _new->unwind_to = "afr_fstat_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 ); children[call_child]->fops->fstat_cbk = afr_fstat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->fstat); children[call_child]->fops->fstat (_new, children[call_child], fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
390 | fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 390 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->fstat_cbk) tmp_cbk = afr_fstat_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->fstat" ; _new->unwind_to = "afr_fstat_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 ); children[call_child]->fops->fstat_cbk = afr_fstat_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->fstat); children[call_child]->fops->fstat (_new, children[call_child], fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
391 | ||||||
392 | ret = 0; | |||||
393 | out: | |||||
394 | if (ret < 0) | |||||
395 | AFR_STACK_UNWIND (fstat, frame, -1, op_errno, NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 395, 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) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0); | |||||
396 | ||||||
397 | return 0; | |||||
398 | } | |||||
399 | ||||||
400 | /* }}} */ | |||||
401 | ||||||
402 | /* {{{ readlink */ | |||||
403 | ||||||
404 | int32_t | |||||
405 | afr_readlink_cbk (call_frame_t *frame, void *cookie, | |||||
406 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
407 | const char *buf, struct iatt *sbuf, dict_t *xdata) | |||||
408 | { | |||||
409 | afr_private_t * priv = NULL((void*)0); | |||||
410 | afr_local_t * local = NULL((void*)0); | |||||
411 | xlator_t ** children = NULL((void*)0); | |||||
412 | int unwind = 1; | |||||
413 | int32_t *last_index = NULL((void*)0); | |||||
414 | int32_t next_call_child = -1; | |||||
415 | int32_t read_child = -1; | |||||
416 | int32_t *fresh_children = NULL((void*)0); | |||||
417 | ||||||
418 | priv = this->private; | |||||
419 | children = priv->children; | |||||
420 | ||||||
421 | local = frame->local; | |||||
422 | ||||||
423 | read_child = (long) cookie; | |||||
424 | ||||||
425 | if (op_ret == -1) { | |||||
426 | last_index = &local->cont.readlink.last_index; | |||||
427 | fresh_children = local->fresh_children; | |||||
428 | next_call_child = afr_next_call_child (fresh_children, | |||||
429 | local->child_up, | |||||
430 | priv->child_count, | |||||
431 | last_index, read_child); | |||||
432 | if (next_call_child < 0) | |||||
433 | goto out; | |||||
434 | ||||||
435 | unwind = 0; | |||||
436 | STACK_WIND_COOKIE (frame, afr_readlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 441 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[next_call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readlink); children[next_call_child ]->fops->readlink (_new, children[next_call_child], & local->loc, local->cont.readlink.size, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
437 | (void *) (long) read_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 441 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[next_call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readlink); children[next_call_child ]->fops->readlink (_new, children[next_call_child], & local->loc, local->cont.readlink.size, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
438 | children[next_call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 441 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[next_call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readlink); children[next_call_child ]->fops->readlink (_new, children[next_call_child], & local->loc, local->cont.readlink.size, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
439 | children[next_call_child]->fops->readlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 441 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[next_call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readlink); children[next_call_child ]->fops->readlink (_new, children[next_call_child], & local->loc, local->cont.readlink.size, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
440 | &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 441 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[next_call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readlink); children[next_call_child ]->fops->readlink (_new, children[next_call_child], & local->loc, local->cont.readlink.size, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
441 | local->cont.readlink.size, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 441 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[next_call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readlink); children[next_call_child ]->fops->readlink (_new, children[next_call_child], & local->loc, local->cont.readlink.size, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
442 | } | |||||
443 | ||||||
444 | out: | |||||
445 | if (unwind) { | |||||
446 | AFR_STACK_UNWIND (readlink, frame, op_ret, op_errno, buf, sbuf,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_readlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "afr-inode-read.c" , __FUNCTION__, 447, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readlink_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, buf, sbuf, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local , __this); mem_put (__local); } } while (0) | |||||
447 | xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_readlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "afr-inode-read.c" , __FUNCTION__, 447, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readlink_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, buf, sbuf, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local , __this); mem_put (__local); } } while (0); | |||||
448 | } | |||||
449 | ||||||
450 | return 0; | |||||
451 | } | |||||
452 | ||||||
453 | ||||||
454 | int32_t | |||||
455 | afr_readlink (call_frame_t *frame, xlator_t *this, | |||||
456 | loc_t *loc, size_t size, dict_t *xdata) | |||||
457 | { | |||||
458 | afr_private_t *priv = NULL((void*)0); | |||||
459 | xlator_t **children = NULL((void*)0); | |||||
460 | int call_child = 0; | |||||
461 | afr_local_t *local = NULL((void*)0); | |||||
462 | int32_t op_errno = 0; | |||||
463 | int32_t read_child = -1; | |||||
464 | int ret = -1; | |||||
465 | ||||||
466 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 466, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||||
467 | VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 467, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto out; } } while (0); | |||||
468 | VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 468, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto out; } } while (0); | |||||
469 | ||||||
470 | priv = this->private; | |||||
471 | VALIDATE_OR_GOTO (priv->children, out)do { if (!priv->children) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "priv->children" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 471, GF_LOG_WARNING, "invalid argument: " "priv->children"); } while (0); goto out; } } while (0); | |||||
472 | ||||||
473 | children = priv->children; | |||||
474 | ||||||
475 | AFR_LOCAL_ALLOC_OR_GOTO (frame->local, out)do { frame->local = mem_get0 ((*__glusterfs_this_location( ))->local_pool); if (!frame->local) { do { do { if (0) printf ("out of memory :("); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 475, GF_LOG_ERROR, "out of memory :("); } while (0); op_errno = 12; goto out; } } while (0);; | |||||
476 | local = frame->local; | |||||
477 | ||||||
478 | ret = afr_local_init (local, priv, &op_errno); | |||||
479 | if (ret < 0) | |||||
480 | goto out; | |||||
481 | ||||||
482 | local->fresh_children = afr_children_create (priv->child_count); | |||||
483 | if (!local->fresh_children) { | |||||
484 | op_errno = ENOMEM12; | |||||
485 | goto out; | |||||
486 | } | |||||
487 | read_child = afr_inode_get_read_ctx (this, loc->inode, | |||||
488 | local->fresh_children); | |||||
489 | ret = afr_get_call_child (this, local->child_up, read_child, | |||||
490 | local->fresh_children, | |||||
491 | &call_child, | |||||
492 | &local->cont.readlink.last_index); | |||||
493 | if (ret < 0) { | |||||
494 | op_errno = -ret; | |||||
495 | goto out; | |||||
496 | } | |||||
497 | ||||||
498 | loc_copy (&local->loc, loc); | |||||
499 | ||||||
500 | local->cont.readlink.size = size; | |||||
501 | ||||||
502 | STACK_WIND_COOKIE (frame, afr_readlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 506 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->readlink); children[call_child]->fops->readlink (_new, children[call_child], loc, size, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
503 | (void *) (long) call_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 506 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->readlink); children[call_child]->fops->readlink (_new, children[call_child], loc, size, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
504 | children[call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 506 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->readlink); children[call_child]->fops->readlink (_new, children[call_child], loc, size, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
505 | children[call_child]->fops->readlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 506 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->readlink); children[call_child]->fops->readlink (_new, children[call_child], loc, size, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
506 | loc, size, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 506 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->readlink_cbk) tmp_cbk = afr_readlink_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->readlink" ; _new->unwind_to = "afr_readlink_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 ); children[call_child]->fops->readlink_cbk = afr_readlink_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->readlink); children[call_child]->fops->readlink (_new, children[call_child], loc, size, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
507 | ||||||
508 | ret = 0; | |||||
509 | out: | |||||
510 | if (ret < 0) | |||||
511 | AFR_STACK_UNWIND (readlink, frame, -1, op_errno, NULL, NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_readlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "afr-inode-read.c" , __FUNCTION__, 511, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readlink_cbk_t )frame->ret; _parent = frame ->parent; pthread_spin_lock (&frame->root->stack_lock ); { _parent->ref_count--; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0); | |||||
512 | return 0; | |||||
513 | } | |||||
514 | ||||||
515 | ||||||
516 | /* }}} */ | |||||
517 | ||||||
518 | /* {{{ getxattr */ | |||||
519 | ||||||
520 | struct _xattr_key { | |||||
521 | char *key; | |||||
522 | struct list_head list; | |||||
523 | }; | |||||
524 | ||||||
525 | ||||||
526 | int | |||||
527 | __gather_xattr_keys (dict_t *dict, char *key, data_t *value, | |||||
528 | void *data) | |||||
529 | { | |||||
530 | struct list_head * list = data; | |||||
531 | struct _xattr_key * xkey = NULL((void*)0); | |||||
532 | ||||||
533 | if (!strncmp (key, AFR_XATTR_PREFIX"trusted.afr", | |||||
534 | strlen (AFR_XATTR_PREFIX"trusted.afr"))) { | |||||
535 | ||||||
536 | xkey = GF_CALLOC (1, sizeof (*xkey), gf_afr_mt_xattr_key)__gf_calloc (1, sizeof (*xkey), gf_afr_mt_xattr_key); | |||||
537 | if (!xkey) | |||||
538 | return -1; | |||||
539 | ||||||
540 | xkey->key = key; | |||||
541 | INIT_LIST_HEAD (&xkey->list)do { (&xkey->list)->next = (&xkey->list)-> prev = &xkey->list; } while (0); | |||||
542 | ||||||
543 | list_add_tail (&xkey->list, list); | |||||
544 | } | |||||
545 | return 0; | |||||
546 | } | |||||
547 | ||||||
548 | ||||||
549 | void | |||||
550 | __filter_xattrs (dict_t *dict) | |||||
551 | { | |||||
552 | struct list_head keys = {0,}; | |||||
553 | struct _xattr_key *key = NULL((void*)0); | |||||
554 | struct _xattr_key *tmp = NULL((void*)0); | |||||
555 | ||||||
556 | INIT_LIST_HEAD (&keys)do { (&keys)->next = (&keys)->prev = &keys; } while (0); | |||||
557 | ||||||
558 | dict_foreach (dict, __gather_xattr_keys, | |||||
559 | (void *) &keys); | |||||
560 | ||||||
561 | list_for_each_entry_safe (key, tmp, &keys, list)for (key = ((typeof(*key) *)((char *)((&keys)->next)-( unsigned long)(&((typeof(*key) *)0)->list))), tmp = (( typeof(*key) *)((char *)(key->list.next)-(unsigned long)(& ((typeof(*key) *)0)->list))); &key->list != (&keys ); key = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->list.next )-(unsigned long)(&((typeof(*tmp) *)0)->list)))) { | |||||
562 | dict_del (dict, key->key); | |||||
563 | ||||||
564 | list_del_init (&key->list); | |||||
565 | ||||||
566 | GF_FREE (key)__gf_free (key); | |||||
567 | } | |||||
568 | } | |||||
569 | ||||||
570 | ||||||
571 | ||||||
572 | int32_t | |||||
573 | afr_getxattr_cbk (call_frame_t *frame, void *cookie, | |||||
574 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
575 | dict_t *dict, dict_t *xdata) | |||||
576 | { | |||||
577 | afr_private_t * priv = NULL((void*)0); | |||||
578 | afr_local_t * local = NULL((void*)0); | |||||
579 | xlator_t ** children = NULL((void*)0); | |||||
580 | int unwind = 1; | |||||
581 | int32_t *last_index = NULL((void*)0); | |||||
582 | int32_t next_call_child = -1; | |||||
583 | int32_t read_child = -1; | |||||
584 | int32_t *fresh_children = NULL((void*)0); | |||||
585 | ||||||
586 | priv = this->private; | |||||
587 | children = priv->children; | |||||
588 | ||||||
589 | local = frame->local; | |||||
590 | ||||||
591 | read_child = (long) cookie; | |||||
592 | ||||||
593 | if (op_ret == -1) { | |||||
594 | last_index = &local->cont.getxattr.last_index; | |||||
595 | fresh_children = local->fresh_children; | |||||
596 | next_call_child = afr_next_call_child (fresh_children, | |||||
597 | local->child_up, | |||||
598 | priv->child_count, | |||||
599 | last_index, read_child); | |||||
600 | if (next_call_child < 0) | |||||
601 | goto out; | |||||
602 | ||||||
603 | unwind = 0; | |||||
604 | STACK_WIND_COOKIE (frame, afr_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", "afr-inode-read.c", __FUNCTION__, 610 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[next_call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->getxattr); children[next_call_child ]->fops->getxattr (_new, children[next_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
605 | (void *) (long) read_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 610 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[next_call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->getxattr); children[next_call_child ]->fops->getxattr (_new, children[next_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
606 | children[next_call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 610 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[next_call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->getxattr); children[next_call_child ]->fops->getxattr (_new, children[next_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
607 | children[next_call_child]->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", "afr-inode-read.c", __FUNCTION__, 610 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[next_call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->getxattr); children[next_call_child ]->fops->getxattr (_new, children[next_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
608 | &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 610 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[next_call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->getxattr); children[next_call_child ]->fops->getxattr (_new, children[next_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
609 | local->cont.getxattr.name,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 610 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[next_call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->getxattr); children[next_call_child ]->fops->getxattr (_new, children[next_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
610 | NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 610 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[next_call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->getxattr); children[next_call_child ]->fops->getxattr (_new, children[next_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
611 | } | |||||
612 | ||||||
613 | out: | |||||
614 | if (unwind) { | |||||
615 | if (op_ret >= 0 && dict) | |||||
616 | __filter_xattrs (dict); | |||||
617 | ||||||
618 | AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 618, 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) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
619 | } | |||||
620 | ||||||
621 | return 0; | |||||
622 | } | |||||
623 | ||||||
624 | int32_t | |||||
625 | afr_getxattr_unwind (call_frame_t *frame, int op_ret, int op_errno, | |||||
626 | dict_t *dict, dict_t *xdata) | |||||
627 | ||||||
628 | { | |||||
629 | AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 629, 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) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
630 | return 0; | |||||
631 | } | |||||
632 | ||||||
633 | int32_t | |||||
634 | afr_fgetxattr_clrlk_cbk (call_frame_t *frame, void *cookie, | |||||
635 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
636 | dict_t *dict, dict_t *xdata) | |||||
637 | { | |||||
638 | afr_local_t *local = NULL((void*)0); | |||||
639 | afr_private_t *priv = NULL((void*)0); | |||||
640 | xlator_t **children = NULL((void*)0); | |||||
641 | dict_t *xattr = NULL((void*)0); | |||||
642 | char *tmp_report = NULL((void*)0); | |||||
643 | char lk_summary[1024] = {0,}; | |||||
644 | int serz_len = 0; | |||||
645 | int32_t callcnt = 0; | |||||
646 | long int cky = 0; | |||||
647 | int ret = 0; | |||||
648 | ||||||
649 | priv = this->private; | |||||
650 | children = priv->children; | |||||
651 | ||||||
652 | local = frame->local; | |||||
653 | cky = (long) cookie; | |||||
654 | ||||||
655 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||||
656 | { | |||||
657 | callcnt = --local->call_count; | |||||
658 | if (op_ret == -1) | |||||
659 | local->child_errno[cky] = op_errno; | |||||
660 | ||||||
661 | if (!local->dict) | |||||
662 | local->dict = dict_new (); | |||||
663 | if (local->dict) { | |||||
664 | ret = dict_get_str (dict, local->cont.getxattr.name, | |||||
665 | &tmp_report); | |||||
666 | if (ret) | |||||
667 | goto unlock; | |||||
668 | ret = dict_set_dynstr (local->dict, | |||||
669 | children[cky]->name, | |||||
670 | gf_strdup (tmp_report)); | |||||
671 | if (ret) | |||||
672 | goto unlock; | |||||
673 | } | |||||
674 | } | |||||
675 | unlock: | |||||
676 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||||
677 | ||||||
678 | if (!callcnt) { | |||||
679 | xattr = dict_new (); | |||||
680 | if (!xattr) { | |||||
681 | op_ret = -1; | |||||
682 | op_errno = ENOMEM12; | |||||
683 | goto unwind; | |||||
684 | } | |||||
685 | ret = dict_serialize_value_with_delim (local->dict, | |||||
686 | lk_summary, | |||||
687 | &serz_len, '\n'); | |||||
688 | if (ret) { | |||||
689 | op_ret = -1; | |||||
690 | op_errno = ENOMEM12; | |||||
691 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Error serializing dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 692, GF_LOG_ERROR, "Error serializing dictionary"); } while (0) | |||||
692 | "Error serializing dictionary")do { do { if (0) printf ("Error serializing dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 692, GF_LOG_ERROR, "Error serializing dictionary"); } while (0); | |||||
693 | goto unwind; | |||||
694 | } | |||||
695 | if (serz_len == -1) | |||||
696 | snprintf (lk_summary, sizeof (lk_summary), | |||||
697 | "No locks cleared."); | |||||
698 | ret = dict_set_dynstr (xattr, local->cont.getxattr.name, | |||||
699 | gf_strdup (lk_summary)); | |||||
700 | if (ret) { | |||||
701 | op_ret = -1; | |||||
702 | op_errno = ENOMEM12; | |||||
703 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Error setting dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 704, GF_LOG_ERROR, "Error setting dictionary"); } while (0) | |||||
704 | "Error setting dictionary")do { do { if (0) printf ("Error setting dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 704, GF_LOG_ERROR, "Error setting dictionary"); } while (0); | |||||
705 | goto unwind; | |||||
706 | } | |||||
707 | ||||||
708 | unwind: | |||||
709 | // Updating child_errno with more recent 'events' | |||||
710 | local->child_errno[cky] = op_errno; | |||||
711 | op_errno = afr_resultant_errno_get (NULL((void*)0), local->child_errno, | |||||
712 | priv->child_count); | |||||
713 | AFR_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, xattr,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 714, 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, op_ret , op_errno, xattr, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0) | |||||
714 | xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 714, 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, op_ret , op_errno, xattr, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
715 | ||||||
716 | if (xattr) | |||||
717 | dict_unref (xattr); | |||||
718 | } | |||||
719 | ||||||
720 | return ret; | |||||
721 | } | |||||
722 | ||||||
723 | int32_t | |||||
724 | afr_getxattr_clrlk_cbk (call_frame_t *frame, void *cookie, | |||||
725 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
726 | dict_t *dict, dict_t *xdata) | |||||
727 | { | |||||
728 | afr_local_t *local = NULL((void*)0); | |||||
729 | afr_private_t *priv = NULL((void*)0); | |||||
730 | xlator_t **children = NULL((void*)0); | |||||
731 | dict_t *xattr = NULL((void*)0); | |||||
732 | char *tmp_report = NULL((void*)0); | |||||
733 | char lk_summary[1024] = {0,}; | |||||
734 | int serz_len = 0; | |||||
735 | int32_t callcnt = 0; | |||||
736 | long int cky = 0; | |||||
737 | int ret = 0; | |||||
738 | ||||||
739 | priv = this->private; | |||||
740 | children = priv->children; | |||||
741 | ||||||
742 | local = frame->local; | |||||
743 | cky = (long) cookie; | |||||
744 | ||||||
745 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||||
746 | { | |||||
747 | callcnt = --local->call_count; | |||||
748 | if (op_ret == -1) | |||||
749 | local->child_errno[cky] = op_errno; | |||||
750 | ||||||
751 | if (!local->dict) | |||||
752 | local->dict = dict_new (); | |||||
753 | if (local->dict) { | |||||
754 | ret = dict_get_str (dict, local->cont.getxattr.name, | |||||
755 | &tmp_report); | |||||
756 | if (ret) | |||||
757 | goto unlock; | |||||
758 | ret = dict_set_dynstr (local->dict, | |||||
759 | children[cky]->name, | |||||
760 | gf_strdup (tmp_report)); | |||||
761 | if (ret) | |||||
762 | goto unlock; | |||||
763 | } | |||||
764 | } | |||||
765 | unlock: | |||||
766 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||||
767 | ||||||
768 | if (!callcnt) { | |||||
769 | xattr = dict_new (); | |||||
770 | if (!xattr) { | |||||
771 | op_ret = -1; | |||||
772 | op_errno = ENOMEM12; | |||||
773 | goto unwind; | |||||
774 | } | |||||
775 | ret = dict_serialize_value_with_delim (local->dict, | |||||
776 | lk_summary, | |||||
777 | &serz_len, '\n'); | |||||
778 | if (ret) { | |||||
779 | op_ret = -1; | |||||
780 | op_errno = ENOMEM12; | |||||
781 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Error serializing dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 782, GF_LOG_ERROR, "Error serializing dictionary"); } while (0) | |||||
782 | "Error serializing dictionary")do { do { if (0) printf ("Error serializing dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 782, GF_LOG_ERROR, "Error serializing dictionary"); } while (0); | |||||
783 | goto unwind; | |||||
784 | } | |||||
785 | if (serz_len == -1) | |||||
786 | snprintf (lk_summary, sizeof (lk_summary), | |||||
787 | "No locks cleared."); | |||||
788 | ret = dict_set_dynstr (xattr, local->cont.getxattr.name, | |||||
789 | gf_strdup (lk_summary)); | |||||
790 | if (ret) { | |||||
791 | op_ret = -1; | |||||
792 | op_errno = ENOMEM12; | |||||
793 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Error setting dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 794, GF_LOG_ERROR, "Error setting dictionary"); } while (0) | |||||
794 | "Error setting dictionary")do { do { if (0) printf ("Error setting dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 794, GF_LOG_ERROR, "Error setting dictionary"); } while (0); | |||||
795 | goto unwind; | |||||
796 | } | |||||
797 | ||||||
798 | unwind: | |||||
799 | // Updating child_errno with more recent 'events' | |||||
800 | local->child_errno[cky] = op_errno; | |||||
801 | op_errno = afr_resultant_errno_get (NULL((void*)0), local->child_errno, | |||||
802 | priv->child_count); | |||||
803 | AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, xattr, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 803, 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) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
804 | ||||||
805 | if (xattr) | |||||
806 | dict_unref (xattr); | |||||
807 | } | |||||
808 | ||||||
809 | return ret; | |||||
810 | } | |||||
811 | ||||||
812 | /** | |||||
813 | * node-uuid cbk uses next child querying mechanism | |||||
814 | */ | |||||
815 | int32_t | |||||
816 | afr_getxattr_node_uuid_cbk (call_frame_t *frame, void *cookie, | |||||
817 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
818 | dict_t *dict, dict_t *xdata) | |||||
819 | { | |||||
820 | afr_private_t *priv = NULL((void*)0); | |||||
821 | afr_local_t *local = NULL((void*)0); | |||||
822 | xlator_t **children = NULL((void*)0); | |||||
823 | int unwind = 1; | |||||
824 | int curr_call_child = 0; | |||||
825 | ||||||
826 | priv = this->private; | |||||
827 | children = priv->children; | |||||
828 | ||||||
829 | local = frame->local; | |||||
830 | ||||||
831 | if (op_ret == -1) { /** query the _next_ child */ | |||||
832 | ||||||
833 | /** | |||||
834 | * _current_ becomes _next_ | |||||
835 | * If done with all childs and yet no success; give up ! | |||||
836 | */ | |||||
837 | curr_call_child = (int) ((long)cookie); | |||||
838 | if (++curr_call_child == priv->child_count) | |||||
839 | goto unwind; | |||||
840 | ||||||
841 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("op_ret (-1): Re-querying afr-child (%d/%d)" , curr_call_child, priv->child_count); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__, 843, GF_LOG_WARNING , "op_ret (-1): Re-querying afr-child (%d/%d)", curr_call_child , priv->child_count); } while (0) | |||||
842 | "op_ret (-1): Re-querying afr-child (%d/%d)",do { do { if (0) printf ("op_ret (-1): Re-querying afr-child (%d/%d)" , curr_call_child, priv->child_count); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__, 843, GF_LOG_WARNING , "op_ret (-1): Re-querying afr-child (%d/%d)", curr_call_child , priv->child_count); } while (0) | |||||
843 | curr_call_child, priv->child_count)do { do { if (0) printf ("op_ret (-1): Re-querying afr-child (%d/%d)" , curr_call_child, priv->child_count); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__, 843, GF_LOG_WARNING , "op_ret (-1): Re-querying afr-child (%d/%d)", curr_call_child , priv->child_count); } while (0); | |||||
844 | ||||||
845 | unwind = 0; | |||||
846 | STACK_WIND_COOKIE (frame, afr_getxattr_node_uuid_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 852 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[curr_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk; _new->root = frame->root ; _new->this = children[curr_call_child]; _new->ret = ( ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) curr_call_child; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[curr_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_node_uuid_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 ); children[curr_call_child]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[curr_call_child]; if (children[curr_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [curr_call_child]->fops->getxattr); children[curr_call_child ]->fops->getxattr (_new, children[curr_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
847 | (void *) (long) curr_call_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 852 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[curr_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk; _new->root = frame->root ; _new->this = children[curr_call_child]; _new->ret = ( ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) curr_call_child; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[curr_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_node_uuid_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 ); children[curr_call_child]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[curr_call_child]; if (children[curr_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [curr_call_child]->fops->getxattr); children[curr_call_child ]->fops->getxattr (_new, children[curr_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
848 | children[curr_call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 852 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[curr_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk; _new->root = frame->root ; _new->this = children[curr_call_child]; _new->ret = ( ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) curr_call_child; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[curr_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_node_uuid_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 ); children[curr_call_child]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[curr_call_child]; if (children[curr_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [curr_call_child]->fops->getxattr); children[curr_call_child ]->fops->getxattr (_new, children[curr_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
849 | children[curr_call_child]->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", "afr-inode-read.c", __FUNCTION__, 852 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[curr_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk; _new->root = frame->root ; _new->this = children[curr_call_child]; _new->ret = ( ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) curr_call_child; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[curr_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_node_uuid_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 ); children[curr_call_child]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[curr_call_child]; if (children[curr_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [curr_call_child]->fops->getxattr); children[curr_call_child ]->fops->getxattr (_new, children[curr_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
850 | &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 852 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[curr_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk; _new->root = frame->root ; _new->this = children[curr_call_child]; _new->ret = ( ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) curr_call_child; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[curr_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_node_uuid_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 ); children[curr_call_child]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[curr_call_child]; if (children[curr_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [curr_call_child]->fops->getxattr); children[curr_call_child ]->fops->getxattr (_new, children[curr_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
851 | local->cont.getxattr.name,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 852 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[curr_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk; _new->root = frame->root ; _new->this = children[curr_call_child]; _new->ret = ( ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) curr_call_child; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[curr_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_node_uuid_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 ); children[curr_call_child]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[curr_call_child]; if (children[curr_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [curr_call_child]->fops->getxattr); children[curr_call_child ]->fops->getxattr (_new, children[curr_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
852 | NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 852 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[curr_call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk; _new->root = frame->root ; _new->this = children[curr_call_child]; _new->ret = ( ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) curr_call_child; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[curr_call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_node_uuid_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 ); children[curr_call_child]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[curr_call_child]; if (children[curr_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [curr_call_child]->fops->getxattr); children[curr_call_child ]->fops->getxattr (_new, children[curr_call_child], & local->loc, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
853 | } | |||||
854 | ||||||
855 | unwind: | |||||
856 | if (unwind) | |||||
857 | AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 858, 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, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local , __this); mem_put (__local); } } while (0) | |||||
858 | NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 858, 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, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local , __this); mem_put (__local); } } while (0); | |||||
859 | ||||||
860 | return 0; | |||||
861 | } | |||||
862 | ||||||
863 | int32_t | |||||
864 | afr_getxattr_lockinfo_cbk (call_frame_t *frame, void *cookie, | |||||
865 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
866 | dict_t *dict, dict_t *xdata) | |||||
867 | { | |||||
868 | int call_cnt = 0, len = 0; | |||||
869 | char *lockinfo_buf = NULL((void*)0); | |||||
870 | dict_t *lockinfo = NULL((void*)0), *newdict = NULL((void*)0); | |||||
871 | afr_local_t *local = NULL((void*)0); | |||||
872 | ||||||
873 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||||
874 | { | |||||
875 | local = frame->local; | |||||
876 | ||||||
877 | call_cnt = --local->call_count; | |||||
878 | ||||||
879 | if ((op_ret < 0) || (!dict && !xdata)) { | |||||
880 | goto unlock; | |||||
881 | } | |||||
882 | ||||||
883 | if (xdata) { | |||||
884 | if (!local->xdata_rsp) { | |||||
885 | local->xdata_rsp = dict_new (); | |||||
886 | if (!local->xdata_rsp) { | |||||
887 | local->op_ret = -1; | |||||
888 | local->op_errno = ENOMEM12; | |||||
889 | goto unlock; | |||||
890 | } | |||||
891 | } | |||||
892 | } | |||||
893 | ||||||
894 | if (!dict) { | |||||
895 | goto unlock; | |||||
896 | } | |||||
897 | ||||||
898 | op_ret = dict_get_ptr_and_len (dict, GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo", | |||||
899 | (void **)&lockinfo_buf, &len); | |||||
900 | ||||||
901 | if (!lockinfo_buf) { | |||||
902 | goto unlock; | |||||
903 | } | |||||
904 | ||||||
905 | if (!local->dict) { | |||||
906 | local->dict = dict_new (); | |||||
907 | if (!local->dict) { | |||||
908 | local->op_ret = -1; | |||||
909 | local->op_errno = ENOMEM12; | |||||
910 | goto unlock; | |||||
911 | } | |||||
912 | } | |||||
913 | } | |||||
914 | unlock: | |||||
915 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||||
916 | ||||||
917 | if (lockinfo_buf != NULL((void*)0)) { | |||||
918 | lockinfo = dict_new (); | |||||
919 | if (lockinfo == NULL((void*)0)) { | |||||
920 | local->op_ret = -1; | |||||
921 | local->op_errno = ENOMEM12; | |||||
922 | } else { | |||||
923 | op_ret = dict_unserialize (lockinfo_buf, len, | |||||
924 | &lockinfo); | |||||
925 | ||||||
926 | if (lockinfo && local->dict) { | |||||
927 | dict_copy (lockinfo, local->dict); | |||||
928 | } | |||||
929 | } | |||||
930 | } | |||||
931 | ||||||
932 | if (xdata && local->xdata_rsp) { | |||||
933 | dict_copy (xdata, local->xdata_rsp); | |||||
934 | } | |||||
935 | ||||||
936 | if (!call_cnt) { | |||||
937 | newdict = dict_new (); | |||||
938 | if (!newdict) { | |||||
939 | local->op_ret = -1; | |||||
940 | local->op_errno = ENOMEM12; | |||||
941 | goto unwind; | |||||
942 | } | |||||
943 | ||||||
944 | len = dict_serialized_length (local->dict); | |||||
945 | if (len == 0) { | |||||
946 | goto unwind; | |||||
947 | } | |||||
948 | ||||||
949 | lockinfo_buf = GF_CALLOC (1, len, gf_common_mt_char)__gf_calloc (1, len, gf_common_mt_char); | |||||
950 | if (!lockinfo_buf) { | |||||
951 | local->op_ret = -1; | |||||
952 | local->op_errno = ENOMEM12; | |||||
953 | goto unwind; | |||||
954 | } | |||||
955 | ||||||
956 | op_ret = dict_serialize (local->dict, lockinfo_buf); | |||||
957 | if (op_ret < 0) { | |||||
958 | local->op_ret = -1; | |||||
959 | local->op_errno = -op_ret; | |||||
960 | } | |||||
961 | ||||||
962 | op_ret = dict_set_dynptr (newdict, GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo", | |||||
963 | (void *)lockinfo_buf, len); | |||||
964 | if (op_ret < 0) { | |||||
965 | local->op_ret = -1; | |||||
966 | local->op_errno = -op_ret; | |||||
967 | goto unwind; | |||||
968 | } | |||||
969 | ||||||
970 | unwind: | |||||
971 | AFR_STACK_UNWIND (getxattr, frame, op_ret,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 973, 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, newdict, local->xdata_rsp); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0) | |||||
972 | op_errno, newdict,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 973, 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, newdict, local->xdata_rsp); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0) | |||||
973 | local->xdata_rsp)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 973, 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, newdict, local->xdata_rsp); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0); | |||||
974 | } | |||||
975 | ||||||
976 | dict_unref (lockinfo); | |||||
977 | ||||||
978 | return 0; | |||||
979 | } | |||||
980 | ||||||
981 | int32_t | |||||
982 | afr_fgetxattr_lockinfo_cbk (call_frame_t *frame, void *cookie, | |||||
983 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
984 | dict_t *dict, dict_t *xdata) | |||||
985 | { | |||||
986 | int call_cnt = 0, len = 0; | |||||
987 | char *lockinfo_buf = NULL((void*)0); | |||||
988 | dict_t *lockinfo = NULL((void*)0), *newdict = NULL((void*)0); | |||||
989 | afr_local_t *local = NULL((void*)0); | |||||
990 | ||||||
991 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||||
992 | { | |||||
993 | local = frame->local; | |||||
994 | ||||||
995 | call_cnt = --local->call_count; | |||||
996 | ||||||
997 | if ((op_ret < 0) || (!dict && !xdata)) { | |||||
998 | goto unlock; | |||||
999 | } | |||||
1000 | ||||||
1001 | if (xdata) { | |||||
1002 | if (!local->xdata_rsp) { | |||||
1003 | local->xdata_rsp = dict_new (); | |||||
1004 | if (!local->xdata_rsp) { | |||||
1005 | local->op_ret = -1; | |||||
1006 | local->op_errno = ENOMEM12; | |||||
1007 | goto unlock; | |||||
1008 | } | |||||
1009 | } | |||||
1010 | } | |||||
1011 | ||||||
1012 | if (!dict) { | |||||
1013 | goto unlock; | |||||
1014 | } | |||||
1015 | ||||||
1016 | op_ret = dict_get_ptr_and_len (dict, GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo", | |||||
1017 | (void **)&lockinfo_buf, &len); | |||||
1018 | ||||||
1019 | if (!lockinfo_buf) { | |||||
1020 | goto unlock; | |||||
1021 | } | |||||
1022 | ||||||
1023 | if (!local->dict) { | |||||
1024 | local->dict = dict_new (); | |||||
1025 | if (!local->dict) { | |||||
1026 | local->op_ret = -1; | |||||
1027 | local->op_errno = ENOMEM12; | |||||
1028 | goto unlock; | |||||
1029 | } | |||||
1030 | } | |||||
1031 | } | |||||
1032 | unlock: | |||||
1033 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||||
1034 | ||||||
1035 | if (lockinfo_buf != NULL((void*)0)) { | |||||
1036 | lockinfo = dict_new (); | |||||
1037 | if (lockinfo == NULL((void*)0)) { | |||||
1038 | local->op_ret = -1; | |||||
1039 | local->op_errno = ENOMEM12; | |||||
1040 | } else { | |||||
1041 | op_ret = dict_unserialize (lockinfo_buf, len, | |||||
1042 | &lockinfo); | |||||
1043 | ||||||
1044 | if (lockinfo && local->dict) { | |||||
1045 | dict_copy (lockinfo, local->dict); | |||||
1046 | } | |||||
1047 | } | |||||
1048 | } | |||||
1049 | ||||||
1050 | if (xdata && local->xdata_rsp) { | |||||
1051 | dict_copy (xdata, local->xdata_rsp); | |||||
1052 | } | |||||
1053 | ||||||
1054 | if (!call_cnt) { | |||||
1055 | newdict = dict_new (); | |||||
1056 | if (!newdict) { | |||||
1057 | local->op_ret = -1; | |||||
1058 | local->op_errno = ENOMEM12; | |||||
1059 | goto unwind; | |||||
1060 | } | |||||
1061 | ||||||
1062 | len = dict_serialized_length (local->dict); | |||||
1063 | if (len <= 0) { | |||||
1064 | goto unwind; | |||||
1065 | } | |||||
1066 | ||||||
1067 | lockinfo_buf = GF_CALLOC (1, len, gf_common_mt_char)__gf_calloc (1, len, gf_common_mt_char); | |||||
1068 | if (!lockinfo_buf) { | |||||
1069 | local->op_ret = -1; | |||||
1070 | local->op_errno = ENOMEM12; | |||||
1071 | goto unwind; | |||||
1072 | } | |||||
1073 | ||||||
1074 | op_ret = dict_serialize (local->dict, lockinfo_buf); | |||||
1075 | if (op_ret < 0) { | |||||
1076 | local->op_ret = -1; | |||||
1077 | local->op_errno = -op_ret; | |||||
1078 | } | |||||
1079 | ||||||
1080 | op_ret = dict_set_dynptr (newdict, GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo", | |||||
1081 | (void *)lockinfo_buf, len); | |||||
1082 | if (op_ret < 0) { | |||||
1083 | local->op_ret = -1; | |||||
1084 | local->op_errno = -op_ret; | |||||
1085 | goto unwind; | |||||
1086 | } | |||||
1087 | ||||||
1088 | unwind: | |||||
1089 | AFR_STACK_UNWIND (fgetxattr, frame, op_ret,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1091, 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, op_ret , op_errno, newdict, local->xdata_rsp); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0) | |||||
1090 | op_errno, newdict,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1091, 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, op_ret , op_errno, newdict, local->xdata_rsp); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0) | |||||
1091 | local->xdata_rsp)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1091, 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, op_ret , op_errno, newdict, local->xdata_rsp); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0); | |||||
1092 | } | |||||
1093 | ||||||
1094 | dict_unref (lockinfo); | |||||
1095 | ||||||
1096 | return 0; | |||||
1097 | } | |||||
1098 | ||||||
1099 | int32_t | |||||
1100 | afr_fgetxattr_pathinfo_cbk (call_frame_t *frame, void *cookie, | |||||
1101 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
1102 | dict_t *dict, dict_t *xdata) | |||||
1103 | { | |||||
1104 | afr_local_t *local = NULL((void*)0); | |||||
1105 | int32_t callcnt = 0; | |||||
1106 | int ret = 0; | |||||
1107 | char *xattr = NULL((void*)0); | |||||
1108 | char *xattr_serz = NULL((void*)0); | |||||
1109 | char xattr_cky[1024] = {0,}; | |||||
1110 | dict_t *nxattr = NULL((void*)0); | |||||
1111 | long cky = 0; | |||||
1112 | int32_t padding = 0; | |||||
1113 | int32_t tlen = 0; | |||||
1114 | ||||||
1115 | if (!frame || !frame->local || !this) { | |||||
| ||||||
1116 | gf_log ("", GF_LOG_ERROR, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0); _gf_log ("", "afr-inode-read.c", __FUNCTION__, 1116, GF_LOG_ERROR , "possible NULL deref"); } while (0); | |||||
1117 | goto out; | |||||
1118 | } | |||||
1119 | ||||||
1120 | local = frame->local; | |||||
1121 | cky = (long) cookie; | |||||
1122 | ||||||
1123 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||||
1124 | { | |||||
1125 | callcnt = --local->call_count; | |||||
1126 | ||||||
1127 | if (!dict || (op_ret < 0)) | |||||
1128 | goto out; | |||||
1129 | ||||||
1130 | if (!local->dict) | |||||
1131 | local->dict = dict_new (); | |||||
1132 | ||||||
1133 | if (local->dict) { | |||||
1134 | ret = dict_get_str (dict, | |||||
1135 | local->cont.getxattr.name, | |||||
1136 | &xattr); | |||||
1137 | if (ret) | |||||
1138 | goto out; | |||||
1139 | ||||||
1140 | xattr = gf_strdup (xattr); | |||||
1141 | ||||||
1142 | (void)snprintf (xattr_cky, 1024, "%s-%ld", | |||||
1143 | local->cont.getxattr.name, cky); | |||||
1144 | ret = dict_set_dynstr (local->dict, | |||||
1145 | xattr_cky, xattr); | |||||
1146 | if (ret) { | |||||
1147 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Cannot set xattr cookie key"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1148, GF_LOG_ERROR, "Cannot set xattr cookie key"); } while (0) | |||||
1148 | "Cannot set xattr cookie key")do { do { if (0) printf ("Cannot set xattr cookie key"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1148, GF_LOG_ERROR, "Cannot set xattr cookie key"); } while (0); | |||||
1149 | goto out; | |||||
1150 | } | |||||
1151 | ||||||
1152 | local->cont.getxattr.xattr_len | |||||
1153 | += strlen (xattr) + 1; | |||||
1154 | } | |||||
1155 | } | |||||
1156 | out: | |||||
1157 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||||
| ||||||
1158 | ||||||
1159 | if (!callcnt) { | |||||
1160 | if (!local->cont.getxattr.xattr_len) | |||||
1161 | goto unwind; | |||||
1162 | ||||||
1163 | nxattr = dict_new (); | |||||
1164 | if (!nxattr) | |||||
1165 | goto unwind; | |||||
1166 | ||||||
1167 | /* extra bytes for decorations (brackets and <>'s) */ | |||||
1168 | padding += strlen (this->name) | |||||
1169 | + strlen (AFR_PATHINFO_HEADER"REPLICATE:") + 4; | |||||
1170 | local->cont.getxattr.xattr_len += (padding + 2); | |||||
1171 | ||||||
1172 | xattr_serz = GF_CALLOC (local->cont.getxattr.xattr_len,__gf_calloc (local->cont.getxattr.xattr_len, sizeof (char) , gf_common_mt_char) | |||||
1173 | sizeof (char), gf_common_mt_char)__gf_calloc (local->cont.getxattr.xattr_len, sizeof (char) , gf_common_mt_char); | |||||
1174 | ||||||
1175 | if (!xattr_serz) | |||||
1176 | goto unwind; | |||||
1177 | ||||||
1178 | /* the xlator info */ | |||||
1179 | (void) sprintf (xattr_serz, "(<"AFR_PATHINFO_HEADER"REPLICATE:""%s> ", | |||||
1180 | this->name); | |||||
1181 | ||||||
1182 | /* actual series of pathinfo */ | |||||
1183 | ret = dict_serialize_value_with_delim (local->dict, | |||||
1184 | xattr_serz | |||||
1185 | + strlen (xattr_serz), | |||||
1186 | &tlen, ' '); | |||||
1187 | if (ret) { | |||||
1188 | gf_log (this->name, GF_LOG_ERROR, "Error serializing"do { do { if (0) printf ("Error serializing" " dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1189, GF_LOG_ERROR, "Error serializing" " dictionary"); } while (0) | |||||
1189 | " dictionary")do { do { if (0) printf ("Error serializing" " dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1189, GF_LOG_ERROR, "Error serializing" " dictionary"); } while (0); | |||||
1190 | goto unwind; | |||||
1191 | } | |||||
1192 | ||||||
1193 | /* closing part */ | |||||
1194 | *(xattr_serz + padding + tlen) = ')'; | |||||
1195 | *(xattr_serz + padding + tlen + 1) = '\0'; | |||||
1196 | ||||||
1197 | ret = dict_set_dynstr (nxattr, local->cont.getxattr.name, | |||||
1198 | xattr_serz); | |||||
1199 | if (ret) | |||||
1200 | gf_log (this->name, GF_LOG_ERROR, "Cannot set pathinfo"do { do { if (0) printf ("Cannot set pathinfo" " key in dict" ); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1201, GF_LOG_ERROR, "Cannot set pathinfo" " key in dict"); } while (0) | |||||
1201 | " key in dict")do { do { if (0) printf ("Cannot set pathinfo" " key in dict" ); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1201, GF_LOG_ERROR, "Cannot set pathinfo" " key in dict"); } while (0); | |||||
1202 | ||||||
1203 | unwind: | |||||
1204 | AFR_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, nxattr,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1205, 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, op_ret , op_errno, nxattr, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0) | |||||
1205 | xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1205, 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, op_ret , op_errno, nxattr, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
1206 | ||||||
1207 | if (nxattr) | |||||
1208 | dict_unref (nxattr); | |||||
1209 | } | |||||
1210 | ||||||
1211 | return ret; | |||||
1212 | } | |||||
1213 | ||||||
1214 | int32_t | |||||
1215 | afr_getxattr_pathinfo_cbk (call_frame_t *frame, void *cookie, | |||||
1216 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
1217 | dict_t *dict, dict_t *xdata) | |||||
1218 | { | |||||
1219 | afr_local_t *local = NULL((void*)0); | |||||
1220 | int32_t callcnt = 0; | |||||
1221 | int ret = 0; | |||||
1222 | char *xattr = NULL((void*)0); | |||||
1223 | char *xattr_serz = NULL((void*)0); | |||||
1224 | char xattr_cky[1024] = {0,}; | |||||
1225 | dict_t *nxattr = NULL((void*)0); | |||||
1226 | long cky = 0; | |||||
1227 | int32_t padding = 0; | |||||
1228 | int32_t tlen = 0; | |||||
1229 | ||||||
1230 | if (!frame || !frame->local || !this) { | |||||
1231 | gf_log ("", GF_LOG_ERROR, "possible NULL deref")do { do { if (0) printf ("possible NULL deref"); } while (0); _gf_log ("", "afr-inode-read.c", __FUNCTION__, 1231, GF_LOG_ERROR , "possible NULL deref"); } while (0); | |||||
1232 | goto out; | |||||
1233 | } | |||||
1234 | ||||||
1235 | local = frame->local; | |||||
1236 | cky = (long) cookie; | |||||
1237 | ||||||
1238 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||||
1239 | { | |||||
1240 | callcnt = --local->call_count; | |||||
1241 | ||||||
1242 | if (!dict || (op_ret < 0)) | |||||
1243 | goto out; | |||||
1244 | ||||||
1245 | if (!local->dict) | |||||
1246 | local->dict = dict_new (); | |||||
1247 | ||||||
1248 | if (local->dict) { | |||||
1249 | ret = dict_get_str (dict, | |||||
1250 | local->cont.getxattr.name, | |||||
1251 | &xattr); | |||||
1252 | if (ret) | |||||
1253 | goto out; | |||||
1254 | ||||||
1255 | xattr = gf_strdup (xattr); | |||||
1256 | ||||||
1257 | (void)snprintf (xattr_cky, 1024, "%s-%ld", | |||||
1258 | local->cont.getxattr.name, cky); | |||||
1259 | ret = dict_set_dynstr (local->dict, | |||||
1260 | xattr_cky, xattr); | |||||
1261 | if (ret) { | |||||
1262 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Cannot set xattr cookie key"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1263, GF_LOG_ERROR, "Cannot set xattr cookie key"); } while (0) | |||||
1263 | "Cannot set xattr cookie key")do { do { if (0) printf ("Cannot set xattr cookie key"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1263, GF_LOG_ERROR, "Cannot set xattr cookie key"); } while (0); | |||||
1264 | goto out; | |||||
1265 | } | |||||
1266 | ||||||
1267 | local->cont.getxattr.xattr_len += strlen (xattr) + 1; | |||||
1268 | } | |||||
1269 | } | |||||
1270 | out: | |||||
1271 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||||
1272 | ||||||
1273 | if (!callcnt) { | |||||
1274 | if (!local->cont.getxattr.xattr_len) | |||||
1275 | goto unwind; | |||||
1276 | ||||||
1277 | nxattr = dict_new (); | |||||
1278 | if (!nxattr) | |||||
1279 | goto unwind; | |||||
1280 | ||||||
1281 | /* extra bytes for decorations (brackets and <>'s) */ | |||||
1282 | padding += strlen (this->name) + strlen (AFR_PATHINFO_HEADER"REPLICATE:") + 4; | |||||
1283 | local->cont.getxattr.xattr_len += (padding + 2); | |||||
1284 | ||||||
1285 | xattr_serz = GF_CALLOC (local->cont.getxattr.xattr_len,__gf_calloc (local->cont.getxattr.xattr_len, sizeof (char) , gf_common_mt_char) | |||||
1286 | sizeof (char), gf_common_mt_char)__gf_calloc (local->cont.getxattr.xattr_len, sizeof (char) , gf_common_mt_char); | |||||
1287 | ||||||
1288 | if (!xattr_serz) | |||||
1289 | goto unwind; | |||||
1290 | ||||||
1291 | /* the xlator info */ | |||||
1292 | (void) sprintf (xattr_serz, "(<"AFR_PATHINFO_HEADER"REPLICATE:""%s> ", | |||||
1293 | this->name); | |||||
1294 | ||||||
1295 | /* actual series of pathinfo */ | |||||
1296 | ret = dict_serialize_value_with_delim (local->dict, | |||||
1297 | xattr_serz + strlen (xattr_serz), | |||||
1298 | &tlen, ' '); | |||||
1299 | if (ret) { | |||||
1300 | gf_log (this->name, GF_LOG_ERROR, "Error serializing"do { do { if (0) printf ("Error serializing" " dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1301, GF_LOG_ERROR, "Error serializing" " dictionary"); } while (0) | |||||
1301 | " dictionary")do { do { if (0) printf ("Error serializing" " dictionary"); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1301, GF_LOG_ERROR, "Error serializing" " dictionary"); } while (0); | |||||
1302 | goto unwind; | |||||
1303 | } | |||||
1304 | ||||||
1305 | /* closing part */ | |||||
1306 | *(xattr_serz + padding + tlen) = ')'; | |||||
1307 | *(xattr_serz + padding + tlen + 1) = '\0'; | |||||
1308 | ||||||
1309 | ret = dict_set_dynstr (nxattr, local->cont.getxattr.name, | |||||
1310 | xattr_serz); | |||||
1311 | if (ret) | |||||
1312 | gf_log (this->name, GF_LOG_ERROR, "Cannot set pathinfo"do { do { if (0) printf ("Cannot set pathinfo" " key in dict" ); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1313, GF_LOG_ERROR, "Cannot set pathinfo" " key in dict"); } while (0) | |||||
1313 | " key in dict")do { do { if (0) printf ("Cannot set pathinfo" " key in dict" ); } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1313, GF_LOG_ERROR, "Cannot set pathinfo" " key in dict"); } while (0); | |||||
1314 | ||||||
1315 | unwind: | |||||
1316 | AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, nxattr,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1317, 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, nxattr, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0) | |||||
1317 | xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1317, 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, nxattr, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
1318 | ||||||
1319 | if (nxattr) | |||||
1320 | dict_unref (nxattr); | |||||
1321 | } | |||||
1322 | ||||||
1323 | return ret; | |||||
1324 | } | |||||
1325 | ||||||
1326 | static gf_boolean_t | |||||
1327 | afr_is_special_xattr (const char *name, fop_getxattr_cbk_t *cbk, | |||||
1328 | gf_boolean_t is_fgetxattr) | |||||
1329 | { | |||||
1330 | gf_boolean_t is_spl = _gf_true; | |||||
1331 | ||||||
1332 | GF_ASSERT (cbk)do { if (!(cbk)) { do { do { if (0) printf ("Assertion failed: " "cbk"); } while (0); _gf_log_callingfn ("", "afr-inode-read.c" , __FUNCTION__, 1332, GF_LOG_ERROR, "Assertion failed: " "cbk" ); } while (0); } } while (0); | |||||
1333 | if (!cbk) { | |||||
1334 | is_spl = _gf_false; | |||||
1335 | goto out; | |||||
1336 | } | |||||
1337 | ||||||
1338 | if (!strcmp (name, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo")) { | |||||
1339 | if (is_fgetxattr) { | |||||
1340 | *cbk = afr_fgetxattr_pathinfo_cbk; | |||||
1341 | } else { | |||||
1342 | *cbk = afr_getxattr_pathinfo_cbk; | |||||
1343 | } | |||||
1344 | } else if (!strncmp (name, GF_XATTR_CLRLK_CMD"glusterfs.clrlk", | |||||
1345 | strlen (GF_XATTR_CLRLK_CMD"glusterfs.clrlk"))) { | |||||
1346 | if (is_fgetxattr) { | |||||
1347 | *cbk = afr_fgetxattr_clrlk_cbk; | |||||
1348 | } else { | |||||
1349 | *cbk = afr_getxattr_clrlk_cbk; | |||||
1350 | } | |||||
1351 | } else if (!strncmp (name, GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo", | |||||
1352 | strlen (GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo"))) { | |||||
1353 | if (is_fgetxattr) { | |||||
1354 | *cbk = afr_fgetxattr_lockinfo_cbk; | |||||
1355 | } else { | |||||
1356 | *cbk = afr_getxattr_lockinfo_cbk; | |||||
1357 | } | |||||
1358 | } else { | |||||
1359 | is_spl = _gf_false; | |||||
1360 | } | |||||
1361 | ||||||
1362 | out: | |||||
1363 | return is_spl; | |||||
1364 | } | |||||
1365 | ||||||
1366 | static void | |||||
1367 | afr_getxattr_frm_all_children (xlator_t *this, call_frame_t *frame, | |||||
1368 | const char *name, loc_t *loc, | |||||
1369 | fop_getxattr_cbk_t cbk) | |||||
1370 | { | |||||
1371 | afr_private_t *priv = NULL((void*)0); | |||||
1372 | afr_local_t *local = NULL((void*)0); | |||||
1373 | xlator_t **children = NULL((void*)0); | |||||
1374 | int i = 0; | |||||
1375 | ||||||
1376 | priv = this->private; | |||||
1377 | children = priv->children; | |||||
1378 | ||||||
1379 | local = frame->local; | |||||
1380 | local->call_count = priv->child_count; | |||||
1381 | ||||||
1382 | for (i = 0; i < priv->child_count; i++) { | |||||
1383 | STACK_WIND_COOKIE (frame, cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1386 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->getxattr_cbk) tmp_cbk = cbk; _new-> root = frame->root; _new->this = children[i]; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__; _new ->wind_to = "children[i]->fops->getxattr"; _new-> unwind_to = "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); children[i]->fops-> getxattr_cbk = cbk; old_THIS = (*__glusterfs_this_location()) ; (*__glusterfs_this_location()) = children[i]; if (children[ i]->ctx->measure_latency) gf_latency_begin (_new, children [i]->fops->getxattr); children[i]->fops->getxattr (_new, children[i], loc, name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1384 | (void *) (long) i,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1386 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->getxattr_cbk) tmp_cbk = cbk; _new-> root = frame->root; _new->this = children[i]; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__; _new ->wind_to = "children[i]->fops->getxattr"; _new-> unwind_to = "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); children[i]->fops-> getxattr_cbk = cbk; old_THIS = (*__glusterfs_this_location()) ; (*__glusterfs_this_location()) = children[i]; if (children[ i]->ctx->measure_latency) gf_latency_begin (_new, children [i]->fops->getxattr); children[i]->fops->getxattr (_new, children[i], loc, name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1385 | children[i], children[i]->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", "afr-inode-read.c", __FUNCTION__, 1386 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->getxattr_cbk) tmp_cbk = cbk; _new-> root = frame->root; _new->this = children[i]; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__; _new ->wind_to = "children[i]->fops->getxattr"; _new-> unwind_to = "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); children[i]->fops-> getxattr_cbk = cbk; old_THIS = (*__glusterfs_this_location()) ; (*__glusterfs_this_location()) = children[i]; if (children[ i]->ctx->measure_latency) gf_latency_begin (_new, children [i]->fops->getxattr); children[i]->fops->getxattr (_new, children[i], loc, name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1386 | loc, name, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1386 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->getxattr_cbk) tmp_cbk = cbk; _new-> root = frame->root; _new->this = children[i]; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__; _new ->wind_to = "children[i]->fops->getxattr"; _new-> unwind_to = "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); children[i]->fops-> getxattr_cbk = cbk; old_THIS = (*__glusterfs_this_location()) ; (*__glusterfs_this_location()) = children[i]; if (children[ i]->ctx->measure_latency) gf_latency_begin (_new, children [i]->fops->getxattr); children[i]->fops->getxattr (_new, children[i], loc, name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
1387 | } | |||||
1388 | return; | |||||
1389 | } | |||||
1390 | ||||||
1391 | int32_t | |||||
1392 | afr_getxattr (call_frame_t *frame, xlator_t *this, | |||||
1393 | loc_t *loc, const char *name, dict_t *xdata) | |||||
1394 | { | |||||
1395 | afr_private_t *priv = NULL((void*)0); | |||||
1396 | xlator_t **children = NULL((void*)0); | |||||
1397 | int call_child = 0; | |||||
1398 | afr_local_t *local = NULL((void*)0); | |||||
1399 | xlator_list_t *trav = NULL((void*)0); | |||||
1400 | xlator_t **sub_volumes = NULL((void*)0); | |||||
1401 | int i = 0; | |||||
1402 | int32_t op_errno = 0; | |||||
1403 | int32_t read_child = -1; | |||||
1404 | int ret = -1; | |||||
1405 | fop_getxattr_cbk_t cbk = NULL((void*)0); | |||||
1406 | ||||||
1407 | ||||||
1408 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 1408, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||||
1409 | VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 1409, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto out; } } while (0); | |||||
1410 | VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 1410, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto out; } } while (0); | |||||
1411 | ||||||
1412 | priv = this->private; | |||||
1413 | VALIDATE_OR_GOTO (priv->children, out)do { if (!priv->children) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "priv->children" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 1413, GF_LOG_WARNING, "invalid argument: " "priv->children"); } while (0); goto out; } } while (0); | |||||
1414 | ||||||
1415 | children = priv->children; | |||||
1416 | ||||||
1417 | AFR_LOCAL_ALLOC_OR_GOTO (frame->local, out)do { frame->local = mem_get0 ((*__glusterfs_this_location( ))->local_pool); if (!frame->local) { do { do { if (0) printf ("out of memory :("); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1417, GF_LOG_ERROR, "out of memory :("); } while (0); op_errno = 12; goto out; } } while (0);; | |||||
1418 | local = frame->local; | |||||
1419 | ||||||
1420 | ret = afr_local_init (local, priv, &op_errno); | |||||
1421 | if (ret < 0) | |||||
1422 | goto out; | |||||
1423 | ||||||
1424 | loc_copy (&local->loc, loc); | |||||
1425 | if (!name) | |||||
1426 | goto no_name; | |||||
1427 | ||||||
1428 | local->cont.getxattr.name = gf_strdup (name); | |||||
1429 | ||||||
1430 | if (!strncmp (name, AFR_XATTR_PREFIX"trusted.afr", | |||||
1431 | strlen (AFR_XATTR_PREFIX"trusted.afr"))) { | |||||
1432 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("%s: no data present for key %s", loc ->path, name); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1434, GF_LOG_INFO, "%s: no data present for key %s" , loc->path, name); } while (0) | |||||
1433 | "%s: no data present for key %s",do { do { if (0) printf ("%s: no data present for key %s", loc ->path, name); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1434, GF_LOG_INFO, "%s: no data present for key %s" , loc->path, name); } while (0) | |||||
1434 | loc->path, name)do { do { if (0) printf ("%s: no data present for key %s", loc ->path, name); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1434, GF_LOG_INFO, "%s: no data present for key %s" , loc->path, name); } while (0); | |||||
1435 | op_errno = ENODATA61; | |||||
1436 | goto out; | |||||
1437 | } | |||||
1438 | if ((strcmp (GF_XATTR_MARKER_KEY"trusted.glusterfs" "." "volume-mark", name) == 0) | |||||
1439 | && (GF_CLIENT_PID_GSYNCD == frame->root->pid)) { | |||||
1440 | ||||||
1441 | local->marker.call_count = priv->child_count; | |||||
1442 | ||||||
1443 | sub_volumes = alloca ( priv->child_count * sizeof (xlator_t *))__builtin_alloca (priv->child_count * sizeof (xlator_t *)); | |||||
1444 | for (i = 0, trav = this->children; trav ; | |||||
1445 | trav = trav->next, i++) { | |||||
1446 | ||||||
1447 | *(sub_volumes + i) = trav->xlator; | |||||
1448 | } | |||||
1449 | ||||||
1450 | if (cluster_getmarkerattr (frame, this, loc, name, | |||||
1451 | local, afr_getxattr_unwind, | |||||
1452 | sub_volumes, | |||||
1453 | priv->child_count, | |||||
1454 | MARKER_UUID_TYPE1, | |||||
1455 | priv->vol_uuid)) { | |||||
1456 | ||||||
1457 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("%s: failed to get marker attr (%s)" , loc->path, name); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1459, GF_LOG_INFO, "%s: failed to get marker attr (%s)" , loc->path, name); } while (0) | |||||
1458 | "%s: failed to get marker attr (%s)",do { do { if (0) printf ("%s: failed to get marker attr (%s)" , loc->path, name); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1459, GF_LOG_INFO, "%s: failed to get marker attr (%s)" , loc->path, name); } while (0) | |||||
1459 | loc->path, name)do { do { if (0) printf ("%s: failed to get marker attr (%s)" , loc->path, name); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1459, GF_LOG_INFO, "%s: failed to get marker attr (%s)" , loc->path, name); } while (0); | |||||
1460 | op_errno = EINVAL22; | |||||
1461 | goto out; | |||||
1462 | } | |||||
1463 | ||||||
1464 | return 0; | |||||
1465 | } | |||||
1466 | ||||||
1467 | /* | |||||
1468 | * if we are doing getxattr with pathinfo as the key then we | |||||
1469 | * collect information from all childs | |||||
1470 | */ | |||||
1471 | if (afr_is_special_xattr (name, &cbk, 0)) { | |||||
1472 | afr_getxattr_frm_all_children (this, frame, name, | |||||
1473 | loc, cbk); | |||||
1474 | return 0; | |||||
1475 | } | |||||
1476 | ||||||
1477 | if (XATTR_IS_NODE_UUID (name)(strncmp (name, "trusted.glusterfs.node-uuid", strlen ("trusted.glusterfs.node-uuid" )) == 0)) { | |||||
1478 | i = 0; | |||||
1479 | STACK_WIND_COOKIE (frame, afr_getxattr_node_uuid_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1483 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk ; _new->root = frame->root; _new->this = children[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[i]->fops->getxattr"; _new ->unwind_to = "afr_getxattr_node_uuid_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 ); children[i]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[i]; if (children[i]->ctx->measure_latency ) gf_latency_begin (_new, children[i]->fops->getxattr); children[i]->fops->getxattr (_new, children[i], loc, name , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||||
1480 | (void *) (long) i,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1483 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk ; _new->root = frame->root; _new->this = children[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[i]->fops->getxattr"; _new ->unwind_to = "afr_getxattr_node_uuid_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 ); children[i]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[i]; if (children[i]->ctx->measure_latency ) gf_latency_begin (_new, children[i]->fops->getxattr); children[i]->fops->getxattr (_new, children[i], loc, name , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||||
1481 | children[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1483 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk ; _new->root = frame->root; _new->this = children[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[i]->fops->getxattr"; _new ->unwind_to = "afr_getxattr_node_uuid_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 ); children[i]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[i]; if (children[i]->ctx->measure_latency ) gf_latency_begin (_new, children[i]->fops->getxattr); children[i]->fops->getxattr (_new, children[i], loc, name , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||||
1482 | children[i]->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", "afr-inode-read.c", __FUNCTION__, 1483 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk ; _new->root = frame->root; _new->this = children[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[i]->fops->getxattr"; _new ->unwind_to = "afr_getxattr_node_uuid_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 ); children[i]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[i]; if (children[i]->ctx->measure_latency ) gf_latency_begin (_new, children[i]->fops->getxattr); children[i]->fops->getxattr (_new, children[i], loc, name , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||||
1483 | 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", "afr-inode-read.c", __FUNCTION__, 1483 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_node_uuid_cbk ; _new->root = frame->root; _new->this = children[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *) (long) i; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[i]->fops->getxattr"; _new ->unwind_to = "afr_getxattr_node_uuid_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 ); children[i]->fops->getxattr_cbk = afr_getxattr_node_uuid_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[i]; if (children[i]->ctx->measure_latency ) gf_latency_begin (_new, children[i]->fops->getxattr); children[i]->fops->getxattr (_new, children[i], loc, name , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); | |||||
1484 | return 0; | |||||
1485 | } | |||||
1486 | ||||||
1487 | if (*priv->vol_uuid) { | |||||
1488 | if ((match_uuid_local (name, priv->vol_uuid) == 0) | |||||
1489 | && (GF_CLIENT_PID_GSYNCD == frame->root->pid)) { | |||||
1490 | local->marker.call_count = priv->child_count; | |||||
1491 | ||||||
1492 | sub_volumes = alloca ( priv->child_count__builtin_alloca (priv->child_count * sizeof (xlator_t *)) | |||||
1493 | * sizeof (xlator_t *))__builtin_alloca (priv->child_count * sizeof (xlator_t *)); | |||||
1494 | for (i = 0, trav = this->children; trav ; | |||||
1495 | trav = trav->next, i++) { | |||||
1496 | ||||||
1497 | *(sub_volumes + i) = trav->xlator; | |||||
1498 | ||||||
1499 | } | |||||
1500 | ||||||
1501 | if (cluster_getmarkerattr (frame, this, loc, | |||||
1502 | name, local, | |||||
1503 | afr_getxattr_unwind, | |||||
1504 | sub_volumes, | |||||
1505 | priv->child_count, | |||||
1506 | MARKER_XTIME_TYPE2, | |||||
1507 | priv->vol_uuid)) { | |||||
1508 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("%s: failed to get marker attr (%s)" , loc->path, name); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1510, GF_LOG_INFO, "%s: failed to get marker attr (%s)" , loc->path, name); } while (0) | |||||
1509 | "%s: failed to get marker attr (%s)",do { do { if (0) printf ("%s: failed to get marker attr (%s)" , loc->path, name); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1510, GF_LOG_INFO, "%s: failed to get marker attr (%s)" , loc->path, name); } while (0) | |||||
1510 | loc->path, name)do { do { if (0) printf ("%s: failed to get marker attr (%s)" , loc->path, name); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1510, GF_LOG_INFO, "%s: failed to get marker attr (%s)" , loc->path, name); } while (0); | |||||
1511 | op_errno = EINVAL22; | |||||
1512 | goto out; | |||||
1513 | } | |||||
1514 | ||||||
1515 | return 0; | |||||
1516 | } | |||||
1517 | } | |||||
1518 | ||||||
1519 | no_name: | |||||
1520 | local->fresh_children = afr_children_create (priv->child_count); | |||||
1521 | if (!local->fresh_children) { | |||||
1522 | op_errno = ENOMEM12; | |||||
1523 | goto out; | |||||
1524 | } | |||||
1525 | ||||||
1526 | read_child = afr_inode_get_read_ctx (this, loc->inode, | |||||
1527 | local->fresh_children); | |||||
1528 | ret = afr_get_call_child (this, local->child_up, read_child, | |||||
1529 | local->fresh_children, | |||||
1530 | &call_child, | |||||
1531 | &local->cont.getxattr.last_index); | |||||
1532 | if (ret < 0) { | |||||
1533 | op_errno = -ret; | |||||
1534 | goto out; | |||||
1535 | } | |||||
1536 | ||||||
1537 | STACK_WIND_COOKIE (frame, afr_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", "afr-inode-read.c", __FUNCTION__, 1541 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->getxattr); children[call_child]->fops->getxattr (_new, children[call_child], loc, name, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1538 | (void *) (long) call_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1541 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->getxattr); children[call_child]->fops->getxattr (_new, children[call_child], loc, name, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1539 | children[call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1541 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->getxattr); children[call_child]->fops->getxattr (_new, children[call_child], loc, name, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1540 | children[call_child]->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", "afr-inode-read.c", __FUNCTION__, 1541 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->getxattr); children[call_child]->fops->getxattr (_new, children[call_child], loc, name, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1541 | 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", "afr-inode-read.c", __FUNCTION__, 1541 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->getxattr_cbk) tmp_cbk = afr_getxattr_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->getxattr" ; _new->unwind_to = "afr_getxattr_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 ); children[call_child]->fops->getxattr_cbk = afr_getxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->getxattr); children[call_child]->fops->getxattr (_new, children[call_child], loc, name, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
1542 | ||||||
1543 | ret = 0; | |||||
1544 | out: | |||||
1545 | if (ret < 0) | |||||
1546 | AFR_STACK_UNWIND (getxattr, frame, -1, op_errno, NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1546, 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) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0); | |||||
1547 | return 0; | |||||
1548 | } | |||||
1549 | ||||||
1550 | /* {{{ fgetxattr */ | |||||
1551 | ||||||
1552 | ||||||
1553 | int32_t | |||||
1554 | afr_fgetxattr_cbk (call_frame_t *frame, void *cookie, | |||||
1555 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
1556 | dict_t *dict, dict_t *xdata) | |||||
1557 | { | |||||
1558 | afr_private_t * priv = NULL((void*)0); | |||||
1559 | afr_local_t * local = NULL((void*)0); | |||||
1560 | xlator_t ** children = NULL((void*)0); | |||||
1561 | int unwind = 1; | |||||
1562 | int32_t *last_index = NULL((void*)0); | |||||
1563 | int32_t next_call_child = -1; | |||||
1564 | int32_t read_child = -1; | |||||
1565 | int32_t *fresh_children = NULL((void*)0); | |||||
1566 | ||||||
1567 | priv = this->private; | |||||
1568 | children = priv->children; | |||||
1569 | ||||||
1570 | local = frame->local; | |||||
1571 | ||||||
1572 | read_child = (long) cookie; | |||||
1573 | ||||||
1574 | if (op_ret == -1) { | |||||
1575 | last_index = &local->cont.getxattr.last_index; | |||||
1576 | fresh_children = local->fresh_children; | |||||
1577 | next_call_child = afr_next_call_child (fresh_children, | |||||
1578 | local->child_up, | |||||
1579 | priv->child_count, | |||||
1580 | last_index, read_child); | |||||
1581 | if (next_call_child < 0) | |||||
1582 | goto out; | |||||
1583 | ||||||
1584 | unwind = 0; | |||||
1585 | STACK_WIND_COOKIE (frame, afr_fgetxattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1591 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[next_call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fgetxattr); children[next_call_child ]->fops->fgetxattr (_new, children[next_call_child], local ->fd, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1586 | (void *) (long) read_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1591 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[next_call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fgetxattr); children[next_call_child ]->fops->fgetxattr (_new, children[next_call_child], local ->fd, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1587 | children[next_call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1591 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[next_call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fgetxattr); children[next_call_child ]->fops->fgetxattr (_new, children[next_call_child], local ->fd, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1588 | children[next_call_child]->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", "afr-inode-read.c", __FUNCTION__, 1591 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[next_call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fgetxattr); children[next_call_child ]->fops->fgetxattr (_new, children[next_call_child], local ->fd, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1589 | local->fd,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1591 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[next_call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fgetxattr); children[next_call_child ]->fops->fgetxattr (_new, children[next_call_child], local ->fd, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1590 | local->cont.getxattr.name,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1591 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[next_call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fgetxattr); children[next_call_child ]->fops->fgetxattr (_new, children[next_call_child], local ->fd, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1591 | NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1591 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk; _new->root = frame->root; _new-> this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[next_call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->fgetxattr); children[next_call_child ]->fops->fgetxattr (_new, children[next_call_child], local ->fd, local->cont.getxattr.name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
1592 | } | |||||
1593 | ||||||
1594 | out: | |||||
1595 | if (unwind) { | |||||
1596 | if (op_ret >= 0 && dict) | |||||
1597 | __filter_xattrs (dict); | |||||
1598 | ||||||
1599 | AFR_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, dict,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1600, 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, op_ret , op_errno, dict, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0) | |||||
1600 | xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1600, 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, op_ret , op_errno, dict, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
1601 | } | |||||
1602 | ||||||
1603 | return 0; | |||||
1604 | } | |||||
1605 | ||||||
1606 | int32_t | |||||
1607 | afr_fgetxattr_unwind (call_frame_t *frame, | |||||
1608 | int op_ret, int op_errno, dict_t *dict, dict_t *xdata) | |||||
1609 | ||||||
1610 | { | |||||
1611 | AFR_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, dict, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1611, 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, op_ret , op_errno, dict, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); if (__local) { afr_local_cleanup (__local, __this ); mem_put (__local); } } while (0); | |||||
1612 | return 0; | |||||
1613 | } | |||||
1614 | ||||||
1615 | static void | |||||
1616 | afr_fgetxattr_frm_all_children (xlator_t *this, call_frame_t *frame, | |||||
1617 | const char *name, fd_t *fd, | |||||
1618 | fop_fgetxattr_cbk_t cbk) | |||||
1619 | { | |||||
1620 | afr_private_t *priv = NULL((void*)0); | |||||
1621 | afr_local_t *local = NULL((void*)0); | |||||
1622 | xlator_t **children = NULL((void*)0); | |||||
1623 | int i = 0; | |||||
1624 | ||||||
1625 | priv = this->private; | |||||
1626 | children = priv->children; | |||||
1627 | ||||||
1628 | local = frame->local; | |||||
1629 | local->call_count = priv->child_count; | |||||
1630 | ||||||
1631 | for (i = 0; i < priv->child_count; i++) { | |||||
1632 | STACK_WIND_COOKIE (frame, cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1635 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->fgetxattr_cbk) tmp_cbk = cbk; _new ->root = frame->root; _new->this = children[i]; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = (void *) (long) i; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[i]->fops->fgetxattr"; _new ->unwind_to = "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); children[i]->fops-> fgetxattr_cbk = cbk; old_THIS = (*__glusterfs_this_location() ); (*__glusterfs_this_location()) = children[i]; if (children [i]->ctx->measure_latency) gf_latency_begin (_new, children [i]->fops->fgetxattr); children[i]->fops->fgetxattr (_new, children[i], fd, name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1633 | (void *) (long) i,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1635 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->fgetxattr_cbk) tmp_cbk = cbk; _new ->root = frame->root; _new->this = children[i]; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = (void *) (long) i; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[i]->fops->fgetxattr"; _new ->unwind_to = "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); children[i]->fops-> fgetxattr_cbk = cbk; old_THIS = (*__glusterfs_this_location() ); (*__glusterfs_this_location()) = children[i]; if (children [i]->ctx->measure_latency) gf_latency_begin (_new, children [i]->fops->fgetxattr); children[i]->fops->fgetxattr (_new, children[i], fd, name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1634 | children[i], children[i]->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", "afr-inode-read.c", __FUNCTION__, 1635 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->fgetxattr_cbk) tmp_cbk = cbk; _new ->root = frame->root; _new->this = children[i]; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = (void *) (long) i; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[i]->fops->fgetxattr"; _new ->unwind_to = "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); children[i]->fops-> fgetxattr_cbk = cbk; old_THIS = (*__glusterfs_this_location() ); (*__glusterfs_this_location()) = children[i]; if (children [i]->ctx->measure_latency) gf_latency_begin (_new, children [i]->fops->fgetxattr); children[i]->fops->fgetxattr (_new, children[i], fd, name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1635 | fd, name, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1635 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[i]->fops->fgetxattr_cbk) tmp_cbk = cbk; _new ->root = frame->root; _new->this = children[i]; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = (void *) (long) i; _new->wind_from = __FUNCTION__ ; _new->wind_to = "children[i]->fops->fgetxattr"; _new ->unwind_to = "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); children[i]->fops-> fgetxattr_cbk = cbk; old_THIS = (*__glusterfs_this_location() ); (*__glusterfs_this_location()) = children[i]; if (children [i]->ctx->measure_latency) gf_latency_begin (_new, children [i]->fops->fgetxattr); children[i]->fops->fgetxattr (_new, children[i], fd, name, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
1636 | } | |||||
1637 | ||||||
1638 | return; | |||||
1639 | } | |||||
1640 | ||||||
1641 | int32_t | |||||
1642 | afr_fgetxattr (call_frame_t *frame, xlator_t *this, | |||||
1643 | fd_t *fd, const char *name, dict_t *xdata) | |||||
1644 | { | |||||
1645 | afr_private_t *priv = NULL((void*)0); | |||||
1646 | xlator_t **children = NULL((void*)0); | |||||
1647 | int call_child = 0; | |||||
1648 | afr_local_t *local = NULL((void*)0); | |||||
1649 | int32_t op_ret = -1; | |||||
1650 | int32_t op_errno = 0; | |||||
1651 | int32_t read_child = -1; | |||||
1652 | fop_fgetxattr_cbk_t cbk = NULL((void*)0); | |||||
1653 | ||||||
1654 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 1654, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||||
1655 | VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 1655, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto out; } } while (0); | |||||
1656 | VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 1656, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto out; } } while (0); | |||||
1657 | ||||||
1658 | priv = this->private; | |||||
1659 | VALIDATE_OR_GOTO (priv->children, out)do { if (!priv->children) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "priv->children" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 1659, GF_LOG_WARNING, "invalid argument: " "priv->children"); } while (0); goto out; } } while (0); | |||||
1660 | ||||||
1661 | children = priv->children; | |||||
1662 | ||||||
1663 | if (afr_is_split_brain (this, fd->inode)) { | |||||
1664 | op_errno = EIO5; | |||||
1665 | goto out; | |||||
1666 | } | |||||
1667 | AFR_LOCAL_ALLOC_OR_GOTO (local, out)do { local = mem_get0 ((*__glusterfs_this_location())->local_pool ); if (!local) { do { do { if (0) printf ("out of memory :(") ; } while (0); _gf_log (this->name, "afr-inode-read.c", __FUNCTION__ , 1667, GF_LOG_ERROR, "out of memory :("); } while (0); op_errno = 12; goto out; } } while (0);; | |||||
1668 | frame->local = local; | |||||
1669 | ||||||
1670 | op_ret = afr_local_init (local, priv, &op_errno); | |||||
1671 | if (op_ret < 0) { | |||||
1672 | op_errno = -op_ret; | |||||
1673 | goto out; | |||||
1674 | } | |||||
1675 | ||||||
1676 | local->fd = fd_ref (fd); | |||||
1677 | if (name) | |||||
1678 | local->cont.getxattr.name = gf_strdup (name); | |||||
1679 | ||||||
1680 | /* pathinfo gets handled only in getxattr(), but we need to handle | |||||
1681 | * lockinfo. | |||||
1682 | * If we are doing fgetxattr with lockinfo as the key then we | |||||
1683 | * collect information from all children. | |||||
1684 | */ | |||||
1685 | if (afr_is_special_xattr (name, &cbk, 1)) { | |||||
1686 | afr_fgetxattr_frm_all_children (this, frame, name, | |||||
1687 | fd, cbk); | |||||
1688 | return 0; | |||||
1689 | } | |||||
1690 | ||||||
1691 | ||||||
1692 | local->fresh_children = afr_children_create (priv->child_count); | |||||
1693 | if (!local->fresh_children) { | |||||
1694 | op_errno = ENOMEM12; | |||||
1695 | goto out; | |||||
1696 | } | |||||
1697 | ||||||
1698 | read_child = afr_inode_get_read_ctx (this, fd->inode, | |||||
1699 | local->fresh_children); | |||||
1700 | op_ret = afr_get_call_child (this, local->child_up, read_child, | |||||
1701 | local->fresh_children, | |||||
1702 | &call_child, | |||||
1703 | &local->cont.getxattr.last_index); | |||||
1704 | if (op_ret < 0) { | |||||
1705 | op_errno = -op_ret; | |||||
1706 | op_ret = -1; | |||||
1707 | goto out; | |||||
1708 | } | |||||
1709 | ||||||
1710 | STACK_WIND_COOKIE (frame, afr_fgetxattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1714 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->fgetxattr); children[call_child]->fops->fgetxattr (_new, children[call_child], fd, name, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1711 | (void *) (long) call_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1714 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->fgetxattr); children[call_child]->fops->fgetxattr (_new, children[call_child], fd, name, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1712 | children[call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1714 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->fgetxattr); children[call_child]->fops->fgetxattr (_new, children[call_child], fd, name, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1713 | children[call_child]->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", "afr-inode-read.c", __FUNCTION__, 1714 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->fgetxattr); children[call_child]->fops->fgetxattr (_new, children[call_child], fd, name, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1714 | 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", "afr-inode-read.c", __FUNCTION__, 1714 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->fgetxattr_cbk) tmp_cbk = afr_fgetxattr_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->fgetxattr" ; _new->unwind_to = "afr_fgetxattr_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 ); children[call_child]->fops->fgetxattr_cbk = afr_fgetxattr_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->fgetxattr); children[call_child]->fops->fgetxattr (_new, children[call_child], fd, name, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
1715 | ||||||
1716 | op_ret = 0; | |||||
1717 | out: | |||||
1718 | if (op_ret == -1) { | |||||
1719 | AFR_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, NULL,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1720, 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, op_ret , op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0) | |||||
1720 | NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1720, 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, op_ret , op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0); | |||||
1721 | } | |||||
1722 | return 0; | |||||
1723 | } | |||||
1724 | ||||||
1725 | ||||||
1726 | /* }}} */ | |||||
1727 | ||||||
1728 | /* {{{ readv */ | |||||
1729 | ||||||
1730 | /** | |||||
1731 | * read algorithm: | |||||
1732 | * | |||||
1733 | * if the user has specified a read subvolume, use it | |||||
1734 | * otherwise - | |||||
1735 | * use the inode number to hash it to one of the subvolumes, and | |||||
1736 | * read from there (to balance read load) | |||||
1737 | * | |||||
1738 | * if any of the above read's fail, try the children in sequence | |||||
1739 | * beginning at the beginning | |||||
1740 | */ | |||||
1741 | ||||||
1742 | int32_t | |||||
1743 | afr_readv_cbk (call_frame_t *frame, void *cookie, | |||||
1744 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||||
1745 | struct iovec *vector, int32_t count, struct iatt *buf, | |||||
1746 | struct iobref *iobref, dict_t *xdata) | |||||
1747 | { | |||||
1748 | afr_private_t * priv = NULL((void*)0); | |||||
1749 | afr_local_t * local = NULL((void*)0); | |||||
1750 | xlator_t ** children = NULL((void*)0); | |||||
1751 | int unwind = 1; | |||||
1752 | int32_t *last_index = NULL((void*)0); | |||||
1753 | int32_t next_call_child = -1; | |||||
1754 | int32_t *fresh_children = NULL((void*)0); | |||||
1755 | int32_t read_child = -1; | |||||
1756 | ||||||
1757 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 1757, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||||
1758 | VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 1758, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto out; } } while (0); | |||||
1759 | VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 1759, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto out; } } while (0); | |||||
1760 | ||||||
1761 | priv = this->private; | |||||
1762 | VALIDATE_OR_GOTO (priv->children, out)do { if (!priv->children) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "priv->children" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 1762, GF_LOG_WARNING, "invalid argument: " "priv->children"); } while (0); goto out; } } while (0); | |||||
1763 | ||||||
1764 | children = priv->children; | |||||
1765 | ||||||
1766 | local = frame->local; | |||||
1767 | ||||||
1768 | read_child = (long) cookie; | |||||
1769 | ||||||
1770 | if (op_ret == -1) { | |||||
1771 | last_index = &local->cont.readv.last_index; | |||||
1772 | fresh_children = local->fresh_children; | |||||
1773 | next_call_child = afr_next_call_child (fresh_children, | |||||
1774 | local->child_up, | |||||
1775 | priv->child_count, | |||||
1776 | last_index, read_child); | |||||
1777 | if (next_call_child < 0) | |||||
1778 | goto out; | |||||
1779 | ||||||
1780 | unwind = 0; | |||||
1781 | ||||||
1782 | STACK_WIND_COOKIE (frame, afr_readv_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1789 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[next_call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readv); children[next_call_child ]->fops->readv (_new, children[next_call_child], local-> fd, local->cont.readv.size, local->cont.readv.offset, local ->cont.readv.flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1783 | (void *) (long) read_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1789 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[next_call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readv); children[next_call_child ]->fops->readv (_new, children[next_call_child], local-> fd, local->cont.readv.size, local->cont.readv.offset, local ->cont.readv.flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1784 | children[next_call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1789 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[next_call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readv); children[next_call_child ]->fops->readv (_new, children[next_call_child], local-> fd, local->cont.readv.size, local->cont.readv.offset, local ->cont.readv.flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1785 | children[next_call_child]->fops->readv,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1789 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[next_call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readv); children[next_call_child ]->fops->readv (_new, children[next_call_child], local-> fd, local->cont.readv.size, local->cont.readv.offset, local ->cont.readv.flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1786 | local->fd, local->cont.readv.size,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1789 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[next_call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readv); children[next_call_child ]->fops->readv (_new, children[next_call_child], local-> fd, local->cont.readv.size, local->cont.readv.offset, local ->cont.readv.flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1787 | local->cont.readv.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", "afr-inode-read.c", __FUNCTION__, 1789 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[next_call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readv); children[next_call_child ]->fops->readv (_new, children[next_call_child], local-> fd, local->cont.readv.size, local->cont.readv.offset, local ->cont.readv.flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1788 | local->cont.readv.flags,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1789 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[next_call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readv); children[next_call_child ]->fops->readv (_new, children[next_call_child], local-> fd, local->cont.readv.size, local->cont.readv.offset, local ->cont.readv.flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||||
1789 | NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1789 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[next_call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk; _new->root = frame->root; _new->this = children[next_call_child]; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *) (long) read_child ; _new->wind_from = __FUNCTION__; _new->wind_to = "children[next_call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[next_call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[next_call_child]; if (children[next_call_child ]->ctx->measure_latency) gf_latency_begin (_new, children [next_call_child]->fops->readv); children[next_call_child ]->fops->readv (_new, children[next_call_child], local-> fd, local->cont.readv.size, local->cont.readv.offset, local ->cont.readv.flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||||
1790 | } | |||||
1791 | ||||||
1792 | out: | |||||
1793 | if (unwind) { | |||||
1794 | AFR_STACK_UNWIND (readv, frame, op_ret, op_errno,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1795, 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, vector, count, buf, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0) | |||||
1795 | vector, count, buf, iobref, xdata)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1795, 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, vector, count, buf, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); if (__local) { afr_local_cleanup (__local, __this); mem_put (__local); } } while (0); | |||||
1796 | } | |||||
1797 | ||||||
1798 | return 0; | |||||
1799 | } | |||||
1800 | ||||||
1801 | ||||||
1802 | int32_t | |||||
1803 | afr_readv (call_frame_t *frame, xlator_t *this, | |||||
1804 | fd_t *fd, size_t size, off_t offset, uint32_t flags, dict_t *xdata) | |||||
1805 | { | |||||
1806 | afr_private_t * priv = NULL((void*)0); | |||||
1807 | afr_local_t * local = NULL((void*)0); | |||||
1808 | xlator_t ** children = NULL((void*)0); | |||||
1809 | int call_child = 0; | |||||
1810 | int32_t op_errno = 0; | |||||
1811 | int32_t read_child = -1; | |||||
1812 | int ret = -1; | |||||
1813 | ||||||
1814 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 1814, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||||
1815 | VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 1815, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto out; } } while (0); | |||||
1816 | VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "afr-inode-read.c", __FUNCTION__, 1816, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto out; } } while (0); | |||||
1817 | VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "afr-inode-read.c" , __FUNCTION__, 1817, GF_LOG_WARNING, "invalid argument: " "fd" ); } while (0); goto out; } } while (0); | |||||
1818 | ||||||
1819 | priv = this->private; | |||||
1820 | children = priv->children; | |||||
1821 | ||||||
1822 | if (afr_is_split_brain (this, fd->inode)) { | |||||
1823 | op_errno = EIO5; | |||||
1824 | goto out; | |||||
1825 | } | |||||
1826 | ||||||
1827 | AFR_LOCAL_ALLOC_OR_GOTO (frame->local, out)do { frame->local = mem_get0 ((*__glusterfs_this_location( ))->local_pool); if (!frame->local) { do { do { if (0) printf ("out of memory :("); } while (0); _gf_log (this->name, "afr-inode-read.c" , __FUNCTION__, 1827, GF_LOG_ERROR, "out of memory :("); } while (0); op_errno = 12; goto out; } } while (0);; | |||||
1828 | local = frame->local; | |||||
1829 | ||||||
1830 | ret = afr_local_init (local, priv, &op_errno); | |||||
1831 | if (ret < 0) | |||||
1832 | goto out; | |||||
1833 | ||||||
1834 | local->fresh_children = afr_children_create (priv->child_count); | |||||
1835 | if (!local->fresh_children) { | |||||
1836 | op_errno = ENOMEM12; | |||||
1837 | goto out; | |||||
1838 | } | |||||
1839 | ||||||
1840 | read_child = afr_inode_get_read_ctx (this, fd->inode, local->fresh_children); | |||||
1841 | ret = afr_get_call_child (this, local->child_up, read_child, | |||||
1842 | local->fresh_children, | |||||
1843 | &call_child, | |||||
1844 | &local->cont.readv.last_index); | |||||
1845 | if (ret < 0) { | |||||
1846 | op_errno = -ret; | |||||
1847 | goto out; | |||||
1848 | } | |||||
1849 | ||||||
1850 | local->fd = fd_ref (fd); | |||||
1851 | ||||||
1852 | local->cont.readv.size = size; | |||||
1853 | local->cont.readv.offset = offset; | |||||
1854 | local->cont.readv.flags = flags; | |||||
1855 | ||||||
1856 | afr_open_fd_fix (fd, this); | |||||
1857 | ||||||
1858 | STACK_WIND_COOKIE (frame, afr_readv_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1862 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->readv); children[call_child]->fops->readv (_new, children[call_child], fd, size, offset, flags, xdata) ; (*__glusterfs_this_location()) = old_THIS; } while (0) | |||||
1859 | (void *) (long) call_child,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1862 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->readv); children[call_child]->fops->readv (_new, children[call_child], fd, size, offset, flags, xdata) ; (*__glusterfs_this_location()) = old_THIS; } while (0) | |||||
1860 | children[call_child],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1862 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->readv); children[call_child]->fops->readv (_new, children[call_child], fd, size, offset, flags, xdata) ; (*__glusterfs_this_location()) = old_THIS; } while (0) | |||||
1861 | children[call_child]->fops->readv,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "afr-inode-read.c", __FUNCTION__, 1862 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->readv); children[call_child]->fops->readv (_new, children[call_child], fd, size, offset, flags, xdata) ; (*__glusterfs_this_location()) = old_THIS; } while (0) | |||||
1862 | fd, size, offset, 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", "afr-inode-read.c", __FUNCTION__, 1862 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( children[call_child]->fops->readv_cbk) tmp_cbk = afr_readv_cbk ; _new->root = frame->root; _new->this = children[call_child ]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = (void *) (long) call_child; _new->wind_from = __FUNCTION__; _new->wind_to = "children[call_child]->fops->readv" ; _new->unwind_to = "afr_readv_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 ); children[call_child]->fops->readv_cbk = afr_readv_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = children[call_child]; if (children[call_child]->ctx-> measure_latency) gf_latency_begin (_new, children[call_child] ->fops->readv); children[call_child]->fops->readv (_new, children[call_child], fd, size, offset, flags, xdata) ; (*__glusterfs_this_location()) = old_THIS; } while (0); | |||||
1863 | ||||||
1864 | ret = 0; | |||||
1865 | out: | |||||
1866 | if (ret < 0) { | |||||
1867 | AFR_STACK_UNWIND (readv, frame, -1, op_errno, NULL, 0, NULL,do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1868, 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) { afr_local_cleanup (__local, __this); mem_put (__local ); } } while (0) | |||||
1868 | NULL, NULL)do { afr_local_t *__local = ((void*)0); xlator_t *__this = (( void*)0); if (frame) { __local = frame->local; __this = frame ->this; frame->local = ((void*)0); } do { fop_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", "afr-inode-read.c" , __FUNCTION__, 1868, 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) { afr_local_cleanup (__local, __this); mem_put (__local ); } } while (0); | |||||
1869 | } | |||||
1870 | return 0; | |||||
1871 | } | |||||
1872 | ||||||
1873 | /* }}} */ |