File: | xlators/cluster/dht/src/switch.c |
Location: | line 264, column 9 |
Description: | Value stored to 'cached_subvol' is never read |
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 | #ifndef _CONFIG_H |
13 | #define _CONFIG_H |
14 | #include "config.h" |
15 | #endif |
16 | |
17 | #include "dht-common.h" |
18 | #include "dht-mem-types.h" |
19 | |
20 | #include <sys/time.h> |
21 | #include <stdlib.h> |
22 | #include <fnmatch.h> |
23 | #include <string.h> |
24 | |
25 | extern struct volume_options options[]; |
26 | |
27 | struct switch_sched_array { |
28 | xlator_t *xl; |
29 | int32_t eligible; |
30 | int32_t considered; |
31 | }; |
32 | |
33 | /* Select one of this struct based on the path's pattern match */ |
34 | struct switch_struct { |
35 | struct switch_struct *next; |
36 | struct switch_sched_array *array; |
37 | int32_t node_index; /* Index of the node in |
38 | this pattern. */ |
39 | int32_t num_child; /* Total num of child nodes |
40 | with this pattern. */ |
41 | char path_pattern[256]; |
42 | }; |
43 | |
44 | /* TODO: all 'TODO's in dht.c holds good */ |
45 | /* This function should return child node as '*:subvolumes' is inserterd */ |
46 | |
47 | static int32_t |
48 | gf_switch_valid_child (xlator_t *this, const char *child) |
49 | { |
50 | xlator_list_t *children = NULL((void*)0); |
51 | int32_t ret = 0; |
52 | |
53 | children = this->children; |
54 | while (children) { |
55 | if (!strcmp (child, children->xlator->name)) { |
56 | ret = 1; |
57 | break; |
58 | } |
59 | children = children->next; |
60 | } |
61 | |
62 | return ret; |
63 | } |
64 | |
65 | static xlator_t * |
66 | get_switch_matching_subvol (const char *path, dht_conf_t *conf, |
67 | xlator_t *hashed_subvol) |
68 | { |
69 | struct switch_struct *cond = NULL((void*)0); |
70 | struct switch_struct *trav = NULL((void*)0); |
71 | char *pathname = NULL((void*)0); |
72 | int idx = 0; |
73 | xlator_t *subvol = NULL((void*)0); |
74 | |
75 | cond = conf->private; |
76 | subvol = hashed_subvol; |
77 | if (!cond) |
78 | goto out; |
79 | |
80 | pathname = gf_strdup (path); |
81 | if (!pathname) |
82 | goto out; |
83 | |
84 | trav = cond; |
85 | while (trav) { |
86 | if (fnmatch (trav->path_pattern, |
87 | pathname, FNM_NOESCAPE(1 << 1)) == 0) { |
88 | for (idx = 0; idx < trav->num_child; idx++) { |
89 | if (trav->array[idx].xl == hashed_subvol) |
90 | goto out; |
91 | } |
92 | idx = trav->node_index++; |
93 | trav->node_index %= trav->num_child; |
94 | subvol = trav->array[idx].xl; |
95 | goto out; |
96 | } |
97 | trav = trav->next; |
98 | } |
99 | out: |
100 | GF_FREE (pathname)__gf_free (pathname); |
101 | |
102 | return subvol; |
103 | } |
104 | |
105 | |
106 | int |
107 | switch_local_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
108 | int op_ret, int op_errno, |
109 | inode_t *inode, struct iatt *stbuf, dict_t *xattr, |
110 | struct iatt *postparent) |
111 | { |
112 | xlator_t *subvol = NULL((void*)0); |
113 | char is_linkfile = 0; |
114 | char is_dir = 0; |
115 | dht_conf_t *conf = NULL((void*)0); |
116 | dht_local_t *local = NULL((void*)0); |
117 | loc_t *loc = NULL((void*)0); |
118 | int i = 0; |
119 | call_frame_t *prev = NULL((void*)0); |
120 | int call_cnt = 0; |
121 | int ret = 0; |
122 | |
123 | conf = this->private; |
124 | |
125 | prev = cookie; |
126 | local = frame->local; |
127 | loc = &local->loc; |
128 | |
129 | if (ENTRY_MISSING (op_ret, op_errno)(op_ret == -1 && op_errno == 2)) { |
130 | if (conf->search_unhashed) { |
131 | local->op_errno = ENOENT2; |
132 | dht_lookup_everywhere (frame, this, loc); |
133 | return 0; |
134 | } |
135 | } |
136 | |
137 | if (op_ret == -1) |
138 | goto out; |
139 | |
140 | is_linkfile = check_is_linkfile (inode, stbuf, xattr,( ((st_mode_from_ia ((stbuf)->ia_prot, (stbuf)->ia_type ) & ~0170000) == (01000)) && dict_get (xattr, conf ->link_xattr_name)) |
141 | conf->link_xattr_name)( ((st_mode_from_ia ((stbuf)->ia_prot, (stbuf)->ia_type ) & ~0170000) == (01000)) && dict_get (xattr, conf ->link_xattr_name)); |
142 | is_dir = check_is_dir (inode, stbuf, xattr)((stbuf->ia_type == IA_IFDIR)); |
143 | |
144 | if (!is_dir && !is_linkfile) { |
145 | /* non-directory and not a linkfile */ |
146 | |
147 | ret = dht_layout_preset (this, prev->this, inode); |
148 | if (ret < 0) { |
149 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("could not set pre-set layout for subvol %s" , prev->this->name); } while (0); _gf_log (this->name , "switch.c", __FUNCTION__, 151, GF_LOG_DEBUG, "could not set pre-set layout for subvol %s" , prev->this->name); } while (0) |
150 | "could not set pre-set layout for subvol %s",do { do { if (0) printf ("could not set pre-set layout for subvol %s" , prev->this->name); } while (0); _gf_log (this->name , "switch.c", __FUNCTION__, 151, GF_LOG_DEBUG, "could not set pre-set layout for subvol %s" , prev->this->name); } while (0) |
151 | prev->this->name)do { do { if (0) printf ("could not set pre-set layout for subvol %s" , prev->this->name); } while (0); _gf_log (this->name , "switch.c", __FUNCTION__, 151, GF_LOG_DEBUG, "could not set pre-set layout for subvol %s" , prev->this->name); } while (0); |
152 | op_ret = -1; |
153 | op_errno = EINVAL22; |
154 | goto err; |
155 | } |
156 | |
157 | goto out; |
158 | } |
159 | |
160 | if (is_dir) { |
161 | call_cnt = conf->subvolume_cnt; |
162 | local->call_cnt = call_cnt; |
163 | |
164 | local->inode = inode_ref (inode); |
165 | local->xattr = dict_ref (xattr); |
166 | |
167 | local->op_ret = 0; |
168 | local->op_errno = 0; |
169 | |
170 | local->layout = dht_layout_new (this, conf->subvolume_cnt); |
171 | if (!local->layout) { |
172 | op_ret = -1; |
173 | op_errno = ENOMEM12; |
174 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("memory allocation failed :("); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__, 175, GF_LOG_DEBUG , "memory allocation failed :("); } while (0) |
175 | "memory allocation failed :(")do { do { if (0) printf ("memory allocation failed :("); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__, 175, GF_LOG_DEBUG , "memory allocation failed :("); } while (0); |
176 | goto err; |
177 | } |
178 | |
179 | for (i = 0; i < call_cnt; i++) { |
180 | STACK_WIND (frame, dht_lookup_dir_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", "switch.c", __FUNCTION__, 183, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) |
181 | conf->subvolumes[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", "switch.c", __FUNCTION__, 183, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) |
182 | conf->subvolumes[i]->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 183, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) |
183 | &local->loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 183, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0); |
184 | } |
185 | } |
186 | |
187 | if (is_linkfile) { |
188 | subvol = dht_linkfile_subvol (this, inode, stbuf, xattr); |
189 | |
190 | if (!subvol) { |
191 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("linkfile not having link subvolume. path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 193, GF_LOG_DEBUG, "linkfile not having link subvolume. path=%s" , loc->path); } while (0) |
192 | "linkfile not having link subvolume. path=%s",do { do { if (0) printf ("linkfile not having link subvolume. path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 193, GF_LOG_DEBUG, "linkfile not having link subvolume. path=%s" , loc->path); } while (0) |
193 | loc->path)do { do { if (0) printf ("linkfile not having link subvolume. path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 193, GF_LOG_DEBUG, "linkfile not having link subvolume. path=%s" , loc->path); } while (0); |
194 | dht_lookup_everywhere (frame, this, loc); |
195 | return 0; |
196 | } |
197 | |
198 | STACK_WIND (frame, dht_lookup_linkfile_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", "switch.c", __FUNCTION__, 200, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_lookup_linkfile_cbk; _new-> root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup"; _new->unwind_to = "dht_lookup_linkfile_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = subvol; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, subvol-> fops->lookup); subvol->fops->lookup (_new, subvol, & local->loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
199 | subvol, subvol->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 200, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_lookup_linkfile_cbk; _new-> root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup"; _new->unwind_to = "dht_lookup_linkfile_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = subvol; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, subvol-> fops->lookup); subvol->fops->lookup (_new, subvol, & local->loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
200 | &local->loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 200, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_lookup_linkfile_cbk; _new-> root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup"; _new->unwind_to = "dht_lookup_linkfile_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = subvol; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, subvol-> fops->lookup); subvol->fops->lookup (_new, subvol, & local->loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
201 | } |
202 | |
203 | return 0; |
204 | |
205 | out: |
206 | if (!local->hashed_subvol) { |
207 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no subvolume in layout for path=%s" , local->loc.path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 209, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , local->loc.path); } while (0) |
208 | "no subvolume in layout for path=%s",do { do { if (0) printf ("no subvolume in layout for path=%s" , local->loc.path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 209, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , local->loc.path); } while (0) |
209 | local->loc.path)do { do { if (0) printf ("no subvolume in layout for path=%s" , local->loc.path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 209, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , local->loc.path); } while (0); |
210 | local->op_errno = ENOENT2; |
211 | dht_lookup_everywhere (frame, this, loc); |
212 | return 0; |
213 | } |
214 | |
215 | STACK_WIND (frame, dht_lookup_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 217, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->hashed_subvol ->fops->lookup_cbk) tmp_cbk = dht_lookup_cbk; _new-> root = frame->root; _new->this = local->hashed_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->hashed_subvol->fops->lookup"; _new->unwind_to = "dht_lookup_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->hashed_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->hashed_subvol ->fops->lookup); local->hashed_subvol->fops->lookup (_new, local->hashed_subvol, &local->loc, local-> xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) |
216 | local->hashed_subvol, local->hashed_subvol->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 217, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->hashed_subvol ->fops->lookup_cbk) tmp_cbk = dht_lookup_cbk; _new-> root = frame->root; _new->this = local->hashed_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->hashed_subvol->fops->lookup"; _new->unwind_to = "dht_lookup_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->hashed_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->hashed_subvol ->fops->lookup); local->hashed_subvol->fops->lookup (_new, local->hashed_subvol, &local->loc, local-> xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) |
217 | &local->loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 217, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->hashed_subvol ->fops->lookup_cbk) tmp_cbk = dht_lookup_cbk; _new-> root = frame->root; _new->this = local->hashed_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->hashed_subvol->fops->lookup"; _new->unwind_to = "dht_lookup_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->hashed_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->hashed_subvol ->fops->lookup); local->hashed_subvol->fops->lookup (_new, local->hashed_subvol, &local->loc, local-> xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0); |
218 | |
219 | return 0; |
220 | |
221 | err: |
222 | DHT_STACK_UNWIND (lookup, frame, op_ret, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 223, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, xattr, ((void*)0)) ; (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) |
223 | inode, stbuf, xattr, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 223, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, xattr, ((void*)0)) ; (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); |
224 | return 0; |
225 | } |
226 | |
227 | int |
228 | switch_lookup (call_frame_t *frame, xlator_t *this, |
229 | loc_t *loc, dict_t *xattr_req) |
230 | { |
231 | xlator_t *hashed_subvol = NULL((void*)0); |
232 | xlator_t *cached_subvol = NULL((void*)0); |
233 | xlator_t *subvol = NULL((void*)0); |
234 | dht_local_t *local = NULL((void*)0); |
235 | dht_conf_t *conf = NULL((void*)0); |
236 | int ret = -1; |
237 | int op_errno = -1; |
238 | dht_layout_t *layout = NULL((void*)0); |
239 | int i = 0; |
240 | int call_cnt = 0; |
241 | |
242 | |
243 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "switch.c" , __FUNCTION__, 243, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); |
244 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "switch.c" , __FUNCTION__, 244, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); |
245 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "switch.c" , __FUNCTION__, 245, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); |
246 | VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "switch.c", __FUNCTION__, 246, GF_LOG_WARNING, "invalid argument: " "loc->inode"); } while (0); goto err; } } while (0); |
247 | VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->path"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "switch.c", __FUNCTION__, 247, GF_LOG_WARNING, "invalid argument: " "loc->path"); } while (0); goto err; } } while (0); |
248 | |
249 | conf = this->private; |
250 | |
251 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_LOOKUP); |
252 | if (!local) { |
253 | op_errno = ENOMEM12; |
254 | goto err; |
255 | } |
256 | |
257 | if (xattr_req) { |
258 | local->xattr_req = dict_ref (xattr_req); |
259 | } else { |
260 | local->xattr_req = dict_new (); |
261 | } |
262 | |
263 | hashed_subvol = dht_subvol_get_hashed (this, &local->loc); |
264 | cached_subvol = local->cached_subvol; |
Value stored to 'cached_subvol' is never read | |
265 | |
266 | local->hashed_subvol = hashed_subvol; |
267 | |
268 | if (is_revalidate (loc)(dht_inode_ctx_layout_get (loc->inode, this, ((void*)0)) == 0)) { |
269 | layout = local->layout; |
270 | if (!layout) { |
271 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("revalidate without cache. path=%s", loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 273, GF_LOG_DEBUG, "revalidate without cache. path=%s" , loc->path); } while (0) |
272 | "revalidate without cache. path=%s",do { do { if (0) printf ("revalidate without cache. path=%s", loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 273, GF_LOG_DEBUG, "revalidate without cache. path=%s" , loc->path); } while (0) |
273 | loc->path)do { do { if (0) printf ("revalidate without cache. path=%s", loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 273, GF_LOG_DEBUG, "revalidate without cache. path=%s" , loc->path); } while (0); |
274 | op_errno = EINVAL22; |
275 | goto err; |
276 | } |
277 | |
278 | if (layout->gen && (layout->gen < conf->gen)) { |
279 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("incomplete layout failure for path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 281, GF_LOG_DEBUG, "incomplete layout failure for path=%s" , loc->path); } while (0) |
280 | "incomplete layout failure for path=%s",do { do { if (0) printf ("incomplete layout failure for path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 281, GF_LOG_DEBUG, "incomplete layout failure for path=%s" , loc->path); } while (0) |
281 | loc->path)do { do { if (0) printf ("incomplete layout failure for path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 281, GF_LOG_DEBUG, "incomplete layout failure for path=%s" , loc->path); } while (0); |
282 | dht_layout_unref (this, local->layout); |
283 | goto do_fresh_lookup; |
284 | } |
285 | |
286 | local->inode = inode_ref (loc->inode); |
287 | |
288 | local->call_cnt = layout->cnt; |
289 | call_cnt = local->call_cnt; |
290 | |
291 | /* NOTE: we don't require 'trusted.glusterfs.dht.linkto' |
292 | * attribute, revalidates directly go to the cached-subvolume. |
293 | */ |
294 | ret = dict_set_uint32 (local->xattr_req, |
295 | conf->xattr_name, 4 * 4); |
296 | if (ret < 0) |
297 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set dict value for %s", conf ->xattr_name); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 299, GF_LOG_WARNING, "failed to set dict value for %s" , conf->xattr_name); } while (0) |
298 | "failed to set dict value for %s",do { do { if (0) printf ("failed to set dict value for %s", conf ->xattr_name); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 299, GF_LOG_WARNING, "failed to set dict value for %s" , conf->xattr_name); } while (0) |
299 | conf->xattr_name)do { do { if (0) printf ("failed to set dict value for %s", conf ->xattr_name); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 299, GF_LOG_WARNING, "failed to set dict value for %s" , conf->xattr_name); } while (0); |
300 | |
301 | for (i = 0; i < layout->cnt; i++) { |
302 | subvol = layout->list[i].xlator; |
303 | |
304 | STACK_WIND (frame, dht_revalidate_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", "switch.c", __FUNCTION__, 306, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_revalidate_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup" ; _new->unwind_to = "dht_revalidate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->lookup); subvol-> fops->lookup (_new, subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
305 | subvol, subvol->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 306, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_revalidate_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup" ; _new->unwind_to = "dht_revalidate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->lookup); subvol-> fops->lookup (_new, subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
306 | loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 306, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_revalidate_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup" ; _new->unwind_to = "dht_revalidate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->lookup); subvol-> fops->lookup (_new, subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
307 | |
308 | if (!--call_cnt) |
309 | break; |
310 | } |
311 | } else { |
312 | do_fresh_lookup: |
313 | ret = dict_set_uint32 (local->xattr_req, |
314 | conf->xattr_name, 4 * 4); |
315 | if (ret < 0) |
316 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set dict value for %s", conf ->xattr_name); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 318, GF_LOG_WARNING, "failed to set dict value for %s" , conf->xattr_name); } while (0) |
317 | "failed to set dict value for %s",do { do { if (0) printf ("failed to set dict value for %s", conf ->xattr_name); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 318, GF_LOG_WARNING, "failed to set dict value for %s" , conf->xattr_name); } while (0) |
318 | conf->xattr_name)do { do { if (0) printf ("failed to set dict value for %s", conf ->xattr_name); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 318, GF_LOG_WARNING, "failed to set dict value for %s" , conf->xattr_name); } while (0); |
319 | |
320 | ret = dict_set_uint32 (local->xattr_req, |
321 | conf->link_xattr_name, 256); |
322 | if (ret < 0) |
323 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set dict value for %s", conf ->link_xattr_name); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 325, GF_LOG_WARNING, "failed to set dict value for %s" , conf->link_xattr_name); } while (0) |
324 | "failed to set dict value for %s",do { do { if (0) printf ("failed to set dict value for %s", conf ->link_xattr_name); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 325, GF_LOG_WARNING, "failed to set dict value for %s" , conf->link_xattr_name); } while (0) |
325 | conf->link_xattr_name)do { do { if (0) printf ("failed to set dict value for %s", conf ->link_xattr_name); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 325, GF_LOG_WARNING, "failed to set dict value for %s" , conf->link_xattr_name); } while (0); |
326 | |
327 | if (!hashed_subvol) { |
328 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 331, GF_LOG_DEBUG, "no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0) |
329 | "no subvolume in layout for path=%s, "do { do { if (0) printf ("no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 331, GF_LOG_DEBUG, "no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0) |
330 | "checking on all the subvols to see if "do { do { if (0) printf ("no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 331, GF_LOG_DEBUG, "no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0) |
331 | "it is a directory", loc->path)do { do { if (0) printf ("no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 331, GF_LOG_DEBUG, "no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0); |
332 | call_cnt = conf->subvolume_cnt; |
333 | local->call_cnt = call_cnt; |
334 | |
335 | local->layout = dht_layout_new (this, |
336 | conf->subvolume_cnt); |
337 | if (!local->layout) { |
338 | op_errno = ENOMEM12; |
339 | goto err; |
340 | } |
341 | |
342 | for (i = 0; i < call_cnt; i++) { |
343 | STACK_WIND (frame, dht_lookup_dir_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", "switch.c", __FUNCTION__, 346, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) |
344 | conf->subvolumes[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", "switch.c", __FUNCTION__, 346, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) |
345 | conf->subvolumes[i]->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 346, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) |
346 | &local->loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 346, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0); |
347 | } |
348 | return 0; |
349 | } |
350 | |
351 | /* */ |
352 | cached_subvol = get_switch_matching_subvol (loc->path, conf, |
353 | hashed_subvol); |
354 | if (cached_subvol == hashed_subvol) { |
355 | STACK_WIND (frame, dht_lookup_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 358, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->lookup_cbk) tmp_cbk = dht_lookup_cbk; _new-> root = frame->root; _new->this = hashed_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->lookup"; _new->unwind_to = "dht_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->lookup); hashed_subvol->fops-> lookup (_new, hashed_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
356 | hashed_subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 358, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->lookup_cbk) tmp_cbk = dht_lookup_cbk; _new-> root = frame->root; _new->this = hashed_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->lookup"; _new->unwind_to = "dht_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->lookup); hashed_subvol->fops-> lookup (_new, hashed_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
357 | hashed_subvol->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 358, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->lookup_cbk) tmp_cbk = dht_lookup_cbk; _new-> root = frame->root; _new->this = hashed_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->lookup"; _new->unwind_to = "dht_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->lookup); hashed_subvol->fops-> lookup (_new, hashed_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
358 | loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 358, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->lookup_cbk) tmp_cbk = dht_lookup_cbk; _new-> root = frame->root; _new->this = hashed_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->lookup"; _new->unwind_to = "dht_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->lookup); hashed_subvol->fops-> lookup (_new, hashed_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
359 | } else { |
360 | STACK_WIND (frame, switch_local_lookup_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 363, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->lookup_cbk) tmp_cbk = switch_local_lookup_cbk; _new ->root = frame->root; _new->this = cached_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->lookup"; _new->unwind_to = "switch_local_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->lookup); cached_subvol->fops-> lookup (_new, cached_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
361 | cached_subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 363, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->lookup_cbk) tmp_cbk = switch_local_lookup_cbk; _new ->root = frame->root; _new->this = cached_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->lookup"; _new->unwind_to = "switch_local_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->lookup); cached_subvol->fops-> lookup (_new, cached_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
362 | cached_subvol->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 363, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->lookup_cbk) tmp_cbk = switch_local_lookup_cbk; _new ->root = frame->root; _new->this = cached_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->lookup"; _new->unwind_to = "switch_local_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->lookup); cached_subvol->fops-> lookup (_new, cached_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
363 | loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 363, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->lookup_cbk) tmp_cbk = switch_local_lookup_cbk; _new ->root = frame->root; _new->this = cached_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->lookup"; _new->unwind_to = "switch_local_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->lookup); cached_subvol->fops-> lookup (_new, cached_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
364 | } |
365 | } |
366 | |
367 | return 0; |
368 | |
369 | err: |
370 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; |
371 | DHT_STACK_UNWIND (lookup, frame, -1, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 372, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) |
372 | NULL, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 372, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); |
373 | return 0; |
374 | } |
375 | |
376 | int |
377 | switch_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, |
378 | xlator_t *this, int op_ret, int op_errno, |
379 | inode_t *inode, struct iatt *stbuf, |
380 | struct iatt *preparent, |
381 | struct iatt *postparent, dict_t *xdata) |
382 | { |
383 | dht_local_t *local = NULL((void*)0); |
384 | |
385 | local = frame->local; |
386 | |
387 | if (op_ret == -1) |
388 | goto err; |
389 | |
390 | STACK_WIND (frame, dht_create_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", "switch.c", __FUNCTION__, 393, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->cached_subvol ->fops->create_cbk) tmp_cbk = dht_create_cbk; _new-> root = frame->root; _new->this = local->cached_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->cached_subvol->fops->create"; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->cached_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->cached_subvol ->fops->create); local->cached_subvol->fops->create (_new, local->cached_subvol, &local->loc, local-> flags, local->mode, local->umask, local->fd, local-> params); (*__glusterfs_this_location()) = old_THIS; } while ( 0) |
391 | local->cached_subvol, local->cached_subvol->fops->create,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 393, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->cached_subvol ->fops->create_cbk) tmp_cbk = dht_create_cbk; _new-> root = frame->root; _new->this = local->cached_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->cached_subvol->fops->create"; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->cached_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->cached_subvol ->fops->create); local->cached_subvol->fops->create (_new, local->cached_subvol, &local->loc, local-> flags, local->mode, local->umask, local->fd, local-> params); (*__glusterfs_this_location()) = old_THIS; } while ( 0) |
392 | &local->loc, local->flags, local->mode, local->umask,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 393, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->cached_subvol ->fops->create_cbk) tmp_cbk = dht_create_cbk; _new-> root = frame->root; _new->this = local->cached_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->cached_subvol->fops->create"; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->cached_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->cached_subvol ->fops->create); local->cached_subvol->fops->create (_new, local->cached_subvol, &local->loc, local-> flags, local->mode, local->umask, local->fd, local-> params); (*__glusterfs_this_location()) = old_THIS; } while ( 0) |
393 | local->fd, local->params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 393, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->cached_subvol ->fops->create_cbk) tmp_cbk = dht_create_cbk; _new-> root = frame->root; _new->this = local->cached_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->cached_subvol->fops->create"; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->cached_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->cached_subvol ->fops->create); local->cached_subvol->fops->create (_new, local->cached_subvol, &local->loc, local-> flags, local->mode, local->umask, local->fd, local-> params); (*__glusterfs_this_location()) = old_THIS; } while ( 0); |
394 | |
395 | return 0; |
396 | |
397 | err: |
398 | DHT_STACK_UNWIND (create, frame, -1, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 399, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) |
399 | NULL, NULL, NULL, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 399, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); |
400 | return 0; |
401 | } |
402 | |
403 | int |
404 | switch_create (call_frame_t *frame, xlator_t *this, |
405 | loc_t *loc, int32_t flags, mode_t mode, |
406 | mode_t umask, fd_t *fd, dict_t *params) |
407 | { |
408 | dht_local_t *local = NULL((void*)0); |
409 | dht_conf_t *conf = NULL((void*)0); |
410 | xlator_t *subvol = NULL((void*)0); |
411 | xlator_t *avail_subvol = NULL((void*)0); |
412 | int op_errno = -1; |
413 | |
414 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "switch.c" , __FUNCTION__, 414, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); |
415 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "switch.c" , __FUNCTION__, 415, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); |
416 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "switch.c" , __FUNCTION__, 416, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); |
417 | |
418 | conf = this->private; |
419 | |
420 | dht_get_du_info (frame, this, loc); |
421 | |
422 | local = dht_local_init (frame, loc, fd, GF_FOP_CREATE); |
423 | if (!local) { |
424 | op_errno = ENOMEM12; |
425 | goto err; |
426 | } |
427 | |
428 | subvol = dht_subvol_get_hashed (this, loc); |
429 | if (!subvol) { |
430 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 432, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) |
431 | "no subvolume in layout for path=%s",do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 432, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) |
432 | loc->path)do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 432, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0); |
433 | op_errno = ENOENT2; |
434 | goto err; |
435 | } |
436 | |
437 | avail_subvol = get_switch_matching_subvol (loc->path, conf, subvol); |
438 | if (dht_is_subvol_filled (this, avail_subvol)) { |
439 | avail_subvol = |
440 | dht_free_disk_available_subvol (this, avail_subvol); |
441 | } |
442 | |
443 | if (subvol != avail_subvol) { |
444 | /* create a link file instead of actual file */ |
445 | local->mode = mode; |
446 | local->flags = flags; |
447 | local->umask = umask; |
448 | local->cached_subvol = avail_subvol; |
449 | dht_linkfile_create (frame, switch_create_linkfile_create_cbk, |
450 | this, avail_subvol, subvol, loc); |
451 | return 0; |
452 | } |
453 | |
454 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__ , 455, GF_LOG_TRACE, "creating %s on %s", loc->path, subvol ->name); } while (0) |
455 | "creating %s on %s", loc->path, subvol->name)do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__ , 455, GF_LOG_TRACE, "creating %s on %s", loc->path, subvol ->name); } while (0); |
456 | |
457 | STACK_WIND (frame, dht_create_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", "switch.c", __FUNCTION__, 459, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, loc, flags, mode, umask, fd, params ); (*__glusterfs_this_location()) = old_THIS; } while (0) |
458 | subvol, subvol->fops->create,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 459, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, loc, flags, mode, umask, fd, params ); (*__glusterfs_this_location()) = old_THIS; } while (0) |
459 | loc, flags, mode, umask, fd, params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 459, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, loc, flags, mode, umask, fd, params ); (*__glusterfs_this_location()) = old_THIS; } while (0); |
460 | |
461 | return 0; |
462 | |
463 | err: |
464 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; |
465 | DHT_STACK_UNWIND (create, frame, -1, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 466, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) |
466 | NULL, NULL, NULL, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 466, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); |
467 | |
468 | return 0; |
469 | } |
470 | |
471 | int |
472 | switch_mknod_linkfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
473 | int op_ret, int op_errno, inode_t *inode, |
474 | struct iatt *stbuf, struct iatt *preparent, |
475 | struct iatt *postparent, dict_t *xdata) |
476 | { |
477 | dht_local_t *local = NULL((void*)0); |
478 | |
479 | local = frame->local; |
480 | if (!local || !local->cached_subvol) { |
481 | op_errno = EINVAL22; |
482 | op_ret = -1; |
483 | goto err; |
484 | } |
485 | |
486 | if (op_ret >= 0) { |
487 | STACK_WIND_COOKIE (frame, dht_newfile_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", "switch.c", __FUNCTION__, 491, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->cached_subvol ->fops->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new-> root = frame->root; _new->this = local->cached_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *)local->cached_subvol; _new-> wind_from = __FUNCTION__; _new->wind_to = "local->cached_subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_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 ); local->cached_subvol->fops->mknod_cbk = dht_newfile_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->cached_subvol; if (local->cached_subvol-> ctx->measure_latency) gf_latency_begin (_new, local->cached_subvol ->fops->mknod); local->cached_subvol->fops->mknod (_new, local->cached_subvol, &local->loc, local-> mode, local->rdev, local->umask, local->params); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
488 | (void *)local->cached_subvol, local->cached_subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 491, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->cached_subvol ->fops->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new-> root = frame->root; _new->this = local->cached_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *)local->cached_subvol; _new-> wind_from = __FUNCTION__; _new->wind_to = "local->cached_subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_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 ); local->cached_subvol->fops->mknod_cbk = dht_newfile_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->cached_subvol; if (local->cached_subvol-> ctx->measure_latency) gf_latency_begin (_new, local->cached_subvol ->fops->mknod); local->cached_subvol->fops->mknod (_new, local->cached_subvol, &local->loc, local-> mode, local->rdev, local->umask, local->params); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
489 | local->cached_subvol->fops->mknod,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 491, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->cached_subvol ->fops->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new-> root = frame->root; _new->this = local->cached_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *)local->cached_subvol; _new-> wind_from = __FUNCTION__; _new->wind_to = "local->cached_subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_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 ); local->cached_subvol->fops->mknod_cbk = dht_newfile_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->cached_subvol; if (local->cached_subvol-> ctx->measure_latency) gf_latency_begin (_new, local->cached_subvol ->fops->mknod); local->cached_subvol->fops->mknod (_new, local->cached_subvol, &local->loc, local-> mode, local->rdev, local->umask, local->params); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
490 | &local->loc, local->mode, local->rdev,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 491, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->cached_subvol ->fops->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new-> root = frame->root; _new->this = local->cached_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *)local->cached_subvol; _new-> wind_from = __FUNCTION__; _new->wind_to = "local->cached_subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_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 ); local->cached_subvol->fops->mknod_cbk = dht_newfile_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->cached_subvol; if (local->cached_subvol-> ctx->measure_latency) gf_latency_begin (_new, local->cached_subvol ->fops->mknod); local->cached_subvol->fops->mknod (_new, local->cached_subvol, &local->loc, local-> mode, local->rdev, local->umask, local->params); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
491 | local->umask, local->params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 491, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->cached_subvol ->fops->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new-> root = frame->root; _new->this = local->cached_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *)local->cached_subvol; _new-> wind_from = __FUNCTION__; _new->wind_to = "local->cached_subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_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 ); local->cached_subvol->fops->mknod_cbk = dht_newfile_cbk ; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->cached_subvol; if (local->cached_subvol-> ctx->measure_latency) gf_latency_begin (_new, local->cached_subvol ->fops->mknod); local->cached_subvol->fops->mknod (_new, local->cached_subvol, &local->loc, local-> mode, local->rdev, local->umask, local->params); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
492 | |
493 | return 0; |
494 | } |
495 | err: |
496 | DHT_STACK_UNWIND (link, frame, op_ret, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 497, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, preparent, postparent , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); dht_local_wipe (__xl, __local); } while (0) |
497 | inode, stbuf, preparent, postparent, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 497, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, preparent, postparent , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); dht_local_wipe (__xl, __local); } while (0); |
498 | return 0; |
499 | } |
500 | |
501 | |
502 | int |
503 | switch_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, |
504 | dev_t rdev, mode_t umask, dict_t *params) |
505 | { |
506 | dht_local_t *local = NULL((void*)0); |
507 | dht_conf_t *conf = NULL((void*)0); |
508 | xlator_t *subvol = NULL((void*)0); |
509 | xlator_t *avail_subvol = NULL((void*)0); |
510 | int op_errno = -1; |
511 | |
512 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "switch.c" , __FUNCTION__, 512, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); |
513 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "switch.c" , __FUNCTION__, 513, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); |
514 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "switch.c" , __FUNCTION__, 514, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); |
515 | |
516 | conf = this->private; |
517 | |
518 | dht_get_du_info (frame, this, loc); |
519 | |
520 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_MKNOD); |
521 | if (!local) { |
522 | op_errno = ENOMEM12; |
523 | goto err; |
524 | } |
525 | |
526 | subvol = dht_subvol_get_hashed (this, loc); |
527 | if (!subvol) { |
528 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 530, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) |
529 | "no subvolume in layout for path=%s",do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 530, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) |
530 | loc->path)do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "switch.c" , __FUNCTION__, 530, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0); |
531 | op_errno = ENOENT2; |
532 | goto err; |
533 | } |
534 | |
535 | /* Consider the disksize in consideration */ |
536 | avail_subvol = get_switch_matching_subvol (loc->path, conf, subvol); |
537 | if (dht_is_subvol_filled (this, avail_subvol)) { |
538 | avail_subvol = |
539 | dht_free_disk_available_subvol (this, avail_subvol); |
540 | } |
541 | |
542 | if (avail_subvol != subvol) { |
543 | /* Create linkfile first */ |
544 | |
545 | local->params = dict_ref (params); |
546 | local->mode = mode; |
547 | local->umask = umask; |
548 | local->rdev = rdev; |
549 | local->cached_subvol = avail_subvol; |
550 | |
551 | dht_linkfile_create (frame, switch_mknod_linkfile_cbk, |
552 | this, avail_subvol, subvol, loc); |
553 | return 0; |
554 | } |
555 | |
556 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__ , 557, GF_LOG_TRACE, "creating %s on %s", loc->path, subvol ->name); } while (0) |
557 | "creating %s on %s", loc->path, subvol->name)do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__ , 557, GF_LOG_TRACE, "creating %s on %s", loc->path, subvol ->name); } while (0); |
558 | |
559 | STACK_WIND_COOKIE (frame, dht_newfile_cbk, (void *)subvol, subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 561, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_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 ); subvol->fops->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location( )) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->mknod); subvol->fops->mknod (_new, subvol, loc, mode, rdev, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
560 | subvol->fops->mknod, loc, mode, rdev, umask,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 561, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_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 ); subvol->fops->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location( )) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->mknod); subvol->fops->mknod (_new, subvol, loc, mode, rdev, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
561 | params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__, 561, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_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 ); subvol->fops->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location( )) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->mknod); subvol->fops->mknod (_new, subvol, loc, mode, rdev, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
562 | |
563 | return 0; |
564 | |
565 | err: |
566 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; |
567 | DHT_STACK_UNWIND (mknod, frame, -1, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 568, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0) |
568 | NULL, NULL, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "switch.c", __FUNCTION__ , 568, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0); |
569 | |
570 | return 0; |
571 | } |
572 | |
573 | |
574 | void |
575 | switch_fini (xlator_t *this) |
576 | { |
577 | dht_conf_t *conf = NULL((void*)0); |
578 | struct switch_struct *trav = NULL((void*)0); |
579 | struct switch_struct *prev = NULL((void*)0); |
580 | |
581 | conf = this->private; |
582 | |
583 | if (conf) { |
584 | trav = (struct switch_struct *)conf->private; |
585 | conf->private = NULL((void*)0); |
586 | while (trav) { |
587 | GF_FREE (trav->array)__gf_free (trav->array); |
588 | prev = trav; |
589 | trav = trav->next; |
590 | GF_FREE (prev)__gf_free (prev); |
591 | } |
592 | } |
593 | |
594 | dht_fini(this); |
595 | } |
596 | |
597 | int |
598 | set_switch_pattern (xlator_t *this, dht_conf_t *conf, |
599 | const char *pattern_str) |
600 | { |
601 | int flag = 0; |
602 | int idx = 0; |
603 | int index = 0; |
604 | int child_count = 0; |
605 | char *tmp = NULL((void*)0); |
606 | char *tmp1 = NULL((void*)0); |
607 | char *child = NULL((void*)0); |
608 | char *tmp_str = NULL((void*)0); |
609 | char *tmp_str1 = NULL((void*)0); |
610 | char *dup_str = NULL((void*)0); |
611 | char *dup_childs = NULL((void*)0); |
612 | char *switch_str = NULL((void*)0); |
613 | char *pattern = NULL((void*)0); |
614 | char *childs = NULL((void*)0); |
615 | char *option_string = NULL((void*)0); |
616 | struct switch_struct *switch_buf = NULL((void*)0); |
617 | struct switch_struct *switch_opt = NULL((void*)0); |
618 | struct switch_struct *trav = NULL((void*)0); |
619 | struct switch_sched_array *switch_buf_array = NULL((void*)0); |
620 | xlator_list_t *trav_xl = NULL((void*)0); |
621 | |
622 | trav_xl = this->children; |
623 | while (trav_xl) { |
624 | index++; |
625 | trav_xl = trav_xl->next; |
626 | } |
627 | child_count = index; |
628 | switch_buf_array = GF_CALLOC ((index + 1),__gf_calloc ((index + 1), sizeof (struct switch_sched_array), gf_switch_mt_switch_sched_array) |
629 | sizeof (struct switch_sched_array),__gf_calloc ((index + 1), sizeof (struct switch_sched_array), gf_switch_mt_switch_sched_array) |
630 | gf_switch_mt_switch_sched_array)__gf_calloc ((index + 1), sizeof (struct switch_sched_array), gf_switch_mt_switch_sched_array); |
631 | if (!switch_buf_array) |
632 | goto err; |
633 | |
634 | trav_xl = this->children; |
635 | index = 0; |
636 | |
637 | while (trav_xl) { |
638 | switch_buf_array[index].xl = trav_xl->xlator; |
639 | switch_buf_array[index].eligible = 1; |
640 | trav_xl = trav_xl->next; |
641 | index++; |
642 | } |
643 | |
644 | /* *jpg:child1,child2;*mpg:child3;*:child4,child5,child6 */ |
645 | |
646 | /* Get the pattern for considering switch case. |
647 | "option block-size *avi:10MB" etc */ |
648 | option_string = gf_strdup (pattern_str); |
649 | switch_str = strtok_r (option_string, ";", &tmp_str); |
650 | while (switch_str) { |
651 | dup_str = gf_strdup (switch_str); |
652 | switch_opt = GF_CALLOC (1, sizeof (struct switch_struct),__gf_calloc (1, sizeof (struct switch_struct), gf_switch_mt_switch_struct ) |
653 | gf_switch_mt_switch_struct)__gf_calloc (1, sizeof (struct switch_struct), gf_switch_mt_switch_struct ); |
654 | if (!switch_opt) { |
655 | GF_FREE (dup_str)__gf_free (dup_str); |
656 | goto err; |
657 | } |
658 | |
659 | pattern = strtok_r (dup_str, ":", &tmp_str1); |
660 | childs = strtok_r (NULL((void*)0), ":", &tmp_str1); |
661 | if (strncmp (pattern, "*", 2) == 0) { |
662 | gf_log ("switch", GF_LOG_INFO,do { do { if (0) printf ("'*' pattern will be taken by default " "for all the unconfigured child nodes," " hence neglecting current option" ); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__, 665 , GF_LOG_INFO, "'*' pattern will be taken by default " "for all the unconfigured child nodes," " hence neglecting current option"); } while (0) |
663 | "'*' pattern will be taken by default "do { do { if (0) printf ("'*' pattern will be taken by default " "for all the unconfigured child nodes," " hence neglecting current option" ); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__, 665 , GF_LOG_INFO, "'*' pattern will be taken by default " "for all the unconfigured child nodes," " hence neglecting current option"); } while (0) |
664 | "for all the unconfigured child nodes,"do { do { if (0) printf ("'*' pattern will be taken by default " "for all the unconfigured child nodes," " hence neglecting current option" ); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__, 665 , GF_LOG_INFO, "'*' pattern will be taken by default " "for all the unconfigured child nodes," " hence neglecting current option"); } while (0) |
665 | " hence neglecting current option")do { do { if (0) printf ("'*' pattern will be taken by default " "for all the unconfigured child nodes," " hence neglecting current option" ); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__, 665 , GF_LOG_INFO, "'*' pattern will be taken by default " "for all the unconfigured child nodes," " hence neglecting current option"); } while (0); |
666 | switch_str = strtok_r (NULL((void*)0), ";", &tmp_str); |
667 | GF_FREE (switch_opt)__gf_free (switch_opt); |
668 | GF_FREE (dup_str)__gf_free (dup_str); |
669 | continue; |
670 | } |
671 | memcpy (switch_opt->path_pattern, pattern, strlen (pattern)); |
672 | if (childs) { |
673 | dup_childs = gf_strdup (childs); |
674 | child = strtok_r (dup_childs, ",", &tmp); |
675 | while (child) { |
676 | if (gf_switch_valid_child (this, child)) { |
677 | idx++; |
678 | child = strtok_r (NULL((void*)0), ",", &tmp); |
679 | } else { |
680 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("%s is not a subvolume of %s. " "pattern can only be scheduled " "only to a subvolume of %s", child, this->name, this-> name); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__ , 684, GF_LOG_ERROR, "%s is not a subvolume of %s. " "pattern can only be scheduled " "only to a subvolume of %s", child, this->name, this-> name); } while (0) |
681 | "%s is not a subvolume of %s. "do { do { if (0) printf ("%s is not a subvolume of %s. " "pattern can only be scheduled " "only to a subvolume of %s", child, this->name, this-> name); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__ , 684, GF_LOG_ERROR, "%s is not a subvolume of %s. " "pattern can only be scheduled " "only to a subvolume of %s", child, this->name, this-> name); } while (0) |
682 | "pattern can only be scheduled "do { do { if (0) printf ("%s is not a subvolume of %s. " "pattern can only be scheduled " "only to a subvolume of %s", child, this->name, this-> name); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__ , 684, GF_LOG_ERROR, "%s is not a subvolume of %s. " "pattern can only be scheduled " "only to a subvolume of %s", child, this->name, this-> name); } while (0) |
683 | "only to a subvolume of %s",do { do { if (0) printf ("%s is not a subvolume of %s. " "pattern can only be scheduled " "only to a subvolume of %s", child, this->name, this-> name); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__ , 684, GF_LOG_ERROR, "%s is not a subvolume of %s. " "pattern can only be scheduled " "only to a subvolume of %s", child, this->name, this-> name); } while (0) |
684 | child, this->name, this->name)do { do { if (0) printf ("%s is not a subvolume of %s. " "pattern can only be scheduled " "only to a subvolume of %s", child, this->name, this-> name); } while (0); _gf_log (this->name, "switch.c", __FUNCTION__ , 684, GF_LOG_ERROR, "%s is not a subvolume of %s. " "pattern can only be scheduled " "only to a subvolume of %s", child, this->name, this-> name); } while (0); |
685 | goto err; |
686 | } |
687 | } |
688 | GF_FREE (dup_childs)__gf_free (dup_childs); |
689 | child = strtok_r (childs, ",", &tmp1); |
690 | switch_opt->num_child = idx; |
691 | switch_opt->array = GF_CALLOC (1, (idx *__gf_calloc (1, (idx * sizeof (struct switch_sched_array)), gf_switch_mt_switch_sched_array ) |
692 | sizeof (struct switch_sched_array)),__gf_calloc (1, (idx * sizeof (struct switch_sched_array)), gf_switch_mt_switch_sched_array ) |
693 | gf_switch_mt_switch_sched_array)__gf_calloc (1, (idx * sizeof (struct switch_sched_array)), gf_switch_mt_switch_sched_array ); |
694 | if (!switch_opt->array) |
695 | goto err; |
696 | idx = 0; |
697 | while (child) { |
698 | for (index = 0; index < child_count; index++) { |
699 | if (strcmp (switch_buf_array[index].xl->name, |
700 | child) == 0) { |
701 | gf_log ("switch", GF_LOG_DEBUG,do { do { if (0) printf ("'%s' pattern will be " "scheduled to \"%s\"" , switch_opt->path_pattern, child); } while (0); _gf_log ( "switch", "switch.c", __FUNCTION__, 704, GF_LOG_DEBUG, "'%s' pattern will be " "scheduled to \"%s\"", switch_opt->path_pattern, child); } while (0) |
702 | "'%s' pattern will be "do { do { if (0) printf ("'%s' pattern will be " "scheduled to \"%s\"" , switch_opt->path_pattern, child); } while (0); _gf_log ( "switch", "switch.c", __FUNCTION__, 704, GF_LOG_DEBUG, "'%s' pattern will be " "scheduled to \"%s\"", switch_opt->path_pattern, child); } while (0) |
703 | "scheduled to \"%s\"",do { do { if (0) printf ("'%s' pattern will be " "scheduled to \"%s\"" , switch_opt->path_pattern, child); } while (0); _gf_log ( "switch", "switch.c", __FUNCTION__, 704, GF_LOG_DEBUG, "'%s' pattern will be " "scheduled to \"%s\"", switch_opt->path_pattern, child); } while (0) |
704 | switch_opt->path_pattern, child)do { do { if (0) printf ("'%s' pattern will be " "scheduled to \"%s\"" , switch_opt->path_pattern, child); } while (0); _gf_log ( "switch", "switch.c", __FUNCTION__, 704, GF_LOG_DEBUG, "'%s' pattern will be " "scheduled to \"%s\"", switch_opt->path_pattern, child); } while (0); |
705 | /* |
706 | if (switch_buf_array[index-1].considered) { |
707 | gf_log ("switch", GF_LOG_DEBUG, |
708 | "ambiguity found, exiting"); |
709 | return -1; |
710 | } |
711 | */ |
712 | switch_opt->array[idx].xl = switch_buf_array[index].xl; |
713 | switch_buf_array[index].considered = 1; |
714 | idx++; |
715 | break; |
716 | } |
717 | } |
718 | child = strtok_r (NULL((void*)0), ",", &tmp1); |
719 | } |
720 | } else { |
721 | /* error */ |
722 | gf_log ("switch", GF_LOG_ERROR,do { do { if (0) printf ("Check \"scheduler.switch.case\" " "option in unify volume. Exiting" ); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__, 724 , GF_LOG_ERROR, "Check \"scheduler.switch.case\" " "option in unify volume. Exiting" ); } while (0) |
723 | "Check \"scheduler.switch.case\" "do { do { if (0) printf ("Check \"scheduler.switch.case\" " "option in unify volume. Exiting" ); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__, 724 , GF_LOG_ERROR, "Check \"scheduler.switch.case\" " "option in unify volume. Exiting" ); } while (0) |
724 | "option in unify volume. Exiting")do { do { if (0) printf ("Check \"scheduler.switch.case\" " "option in unify volume. Exiting" ); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__, 724 , GF_LOG_ERROR, "Check \"scheduler.switch.case\" " "option in unify volume. Exiting" ); } while (0); |
725 | goto err; |
726 | } |
727 | GF_FREE (dup_str)__gf_free (dup_str); |
728 | |
729 | /* Link it to the main structure */ |
730 | if (switch_buf) { |
731 | /* there are already few entries */ |
732 | trav = switch_buf; |
733 | while (trav->next) |
734 | trav = trav->next; |
735 | trav->next = switch_opt; |
736 | } else { |
737 | /* First entry */ |
738 | switch_buf = switch_opt; |
739 | } |
740 | switch_opt = NULL((void*)0); |
741 | switch_str = strtok_r (NULL((void*)0), ";", &tmp_str); |
742 | } |
743 | |
744 | /* Now, all the pattern based considerations done, so for all the |
745 | * remaining pattern, '*' to all the remaining child nodes |
746 | */ |
747 | { |
748 | for (index=0; index < child_count; index++) { |
749 | /* check for considered flag */ |
750 | if (switch_buf_array[index].considered) |
751 | continue; |
752 | flag++; |
753 | } |
754 | if (!flag) { |
755 | gf_log ("switch", GF_LOG_ERROR,do { do { if (0) printf ("No nodes left for pattern '*'. Exiting" ); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__, 756 , GF_LOG_ERROR, "No nodes left for pattern '*'. Exiting"); } while (0) |
756 | "No nodes left for pattern '*'. Exiting")do { do { if (0) printf ("No nodes left for pattern '*'. Exiting" ); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__, 756 , GF_LOG_ERROR, "No nodes left for pattern '*'. Exiting"); } while (0); |
757 | goto err; |
758 | } |
759 | switch_opt = GF_CALLOC (1, sizeof (struct switch_struct),__gf_calloc (1, sizeof (struct switch_struct), gf_switch_mt_switch_struct ) |
760 | gf_switch_mt_switch_struct)__gf_calloc (1, sizeof (struct switch_struct), gf_switch_mt_switch_struct ); |
761 | if (!switch_opt) |
762 | goto err; |
763 | |
764 | /* Add the '*' pattern to the array */ |
765 | memcpy (switch_opt->path_pattern, "*", 2); |
766 | switch_opt->num_child = flag; |
767 | switch_opt->array = |
768 | GF_CALLOC (1,__gf_calloc (1, flag * sizeof (struct switch_sched_array), gf_switch_mt_switch_sched_array ) |
769 | flag * sizeof (struct switch_sched_array),__gf_calloc (1, flag * sizeof (struct switch_sched_array), gf_switch_mt_switch_sched_array ) |
770 | gf_switch_mt_switch_sched_array)__gf_calloc (1, flag * sizeof (struct switch_sched_array), gf_switch_mt_switch_sched_array ); |
771 | if (!switch_opt->array) |
772 | goto err; |
773 | flag = 0; |
774 | for (index=0; index < child_count; index++) { |
775 | /* check for considered flag */ |
776 | if (switch_buf_array[index].considered) |
777 | continue; |
778 | gf_log ("switch", GF_LOG_DEBUG,do { do { if (0) printf ("'%s' pattern will be scheduled to \"%s\"" , switch_opt->path_pattern, switch_buf_array[index].xl-> name); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__ , 781, GF_LOG_DEBUG, "'%s' pattern will be scheduled to \"%s\"" , switch_opt->path_pattern, switch_buf_array[index].xl-> name); } while (0) |
779 | "'%s' pattern will be scheduled to \"%s\"",do { do { if (0) printf ("'%s' pattern will be scheduled to \"%s\"" , switch_opt->path_pattern, switch_buf_array[index].xl-> name); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__ , 781, GF_LOG_DEBUG, "'%s' pattern will be scheduled to \"%s\"" , switch_opt->path_pattern, switch_buf_array[index].xl-> name); } while (0) |
780 | switch_opt->path_pattern,do { do { if (0) printf ("'%s' pattern will be scheduled to \"%s\"" , switch_opt->path_pattern, switch_buf_array[index].xl-> name); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__ , 781, GF_LOG_DEBUG, "'%s' pattern will be scheduled to \"%s\"" , switch_opt->path_pattern, switch_buf_array[index].xl-> name); } while (0) |
781 | switch_buf_array[index].xl->name)do { do { if (0) printf ("'%s' pattern will be scheduled to \"%s\"" , switch_opt->path_pattern, switch_buf_array[index].xl-> name); } while (0); _gf_log ("switch", "switch.c", __FUNCTION__ , 781, GF_LOG_DEBUG, "'%s' pattern will be scheduled to \"%s\"" , switch_opt->path_pattern, switch_buf_array[index].xl-> name); } while (0); |
782 | switch_opt->array[flag].xl = |
783 | switch_buf_array[index].xl; |
784 | switch_buf_array[index].considered = 1; |
785 | flag++; |
786 | } |
787 | if (switch_buf) { |
788 | /* there are already few entries */ |
789 | trav = switch_buf; |
790 | while (trav->next) |
791 | trav = trav->next; |
792 | trav->next = switch_opt; |
793 | } else { |
794 | /* First entry */ |
795 | switch_buf = switch_opt; |
796 | } |
797 | switch_opt = NULL((void*)0); |
798 | } |
799 | /* */ |
800 | conf->private = switch_buf; |
801 | |
802 | return 0; |
803 | err: |
804 | GF_FREE (switch_buf_array)__gf_free (switch_buf_array); |
805 | GF_FREE (switch_opt)__gf_free (switch_opt); |
806 | |
807 | if (switch_buf) { |
808 | trav = switch_buf; |
809 | while (trav) { |
810 | GF_FREE (trav->array)__gf_free (trav->array); |
811 | switch_opt = trav; |
812 | trav = trav->next; |
813 | GF_FREE (switch_opt)__gf_free (switch_opt); |
814 | } |
815 | } |
816 | return -1; |
817 | } |
818 | |
819 | |
820 | int32_t |
821 | switch_init (xlator_t *this) |
822 | { |
823 | dht_conf_t *conf = NULL((void*)0); |
824 | data_t *data = NULL((void*)0); |
825 | int ret = -1; |
826 | |
827 | ret = dht_init(this); |
828 | if (ret) { |
829 | return ret; |
830 | } |
831 | conf = this->private; |
832 | |
833 | data = dict_get (this->options, "pattern.switch.case"); |
834 | if (data) { |
835 | /* TODO: */ |
836 | ret = set_switch_pattern (this, conf, data->data); |
837 | if (ret) { |
838 | goto err; |
839 | } |
840 | } |
841 | |
842 | this->private = conf; |
843 | return 0; |
844 | |
845 | err: |
846 | dht_fini(this); |
847 | return -1; |
848 | } |
849 | |
850 | |
851 | class_methods_t class_methods = { |
852 | .init = switch_init, |
853 | .fini = switch_fini, |
854 | .reconfigure = dht_reconfigure, |
855 | .notify = dht_notify |
856 | }; |
857 | |
858 | |
859 | struct xlator_fops fops = { |
860 | .lookup = switch_lookup, |
861 | .create = switch_create, |
862 | .mknod = switch_mknod, |
863 | |
864 | .stat = dht_stat, |
865 | .fstat = dht_fstat, |
866 | .truncate = dht_truncate, |
867 | .ftruncate = dht_ftruncate, |
868 | .access = dht_access, |
869 | .readlink = dht_readlink, |
870 | .setxattr = dht_setxattr, |
871 | .getxattr = dht_getxattr, |
872 | .removexattr = dht_removexattr, |
873 | .open = dht_open, |
874 | .readv = dht_readv, |
875 | .writev = dht_writev, |
876 | .flush = dht_flush, |
877 | .fsync = dht_fsync, |
878 | .statfs = dht_statfs, |
879 | .lk = dht_lk, |
880 | .opendir = dht_opendir, |
881 | .readdir = dht_readdir, |
882 | .readdirp = dht_readdirp, |
883 | .fsyncdir = dht_fsyncdir, |
884 | .symlink = dht_symlink, |
885 | .unlink = dht_unlink, |
886 | .link = dht_link, |
887 | .mkdir = dht_mkdir, |
888 | .rmdir = dht_rmdir, |
889 | .rename = dht_rename, |
890 | .inodelk = dht_inodelk, |
891 | .finodelk = dht_finodelk, |
892 | .entrylk = dht_entrylk, |
893 | .fentrylk = dht_fentrylk, |
894 | .xattrop = dht_xattrop, |
895 | .fxattrop = dht_fxattrop, |
896 | .setattr = dht_setattr, |
897 | }; |
898 | |
899 | |
900 | struct xlator_cbks cbks = { |
901 | .forget = dht_forget |
902 | }; |