File: | xlators/protocol/server/src/server-resolve.c |
Location: | line 203, column 17 |
Description: | Value stored to 'ret' is never read |
1 | /* |
2 | Copyright (c) 2010-2013 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 | #ifndef _CONFIG_H |
12 | #define _CONFIG_H |
13 | #include "config.h" |
14 | #endif |
15 | |
16 | #include "server.h" |
17 | #include "server-helpers.h" |
18 | |
19 | |
20 | int |
21 | server_resolve_all (call_frame_t *frame); |
22 | int |
23 | resolve_entry_simple (call_frame_t *frame); |
24 | int |
25 | resolve_inode_simple (call_frame_t *frame); |
26 | int |
27 | resolve_continue (call_frame_t *frame); |
28 | int |
29 | resolve_anonfd_simple (call_frame_t *frame); |
30 | |
31 | int |
32 | resolve_loc_touchup (call_frame_t *frame) |
33 | { |
34 | server_state_t *state = NULL((void*)0); |
35 | server_resolve_t *resolve = NULL((void*)0); |
36 | loc_t *loc = NULL((void*)0); |
37 | char *path = NULL((void*)0); |
38 | int ret = 0; |
39 | |
40 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
41 | |
42 | resolve = state->resolve_now; |
43 | loc = state->loc_now; |
44 | |
45 | if (!loc->path) { |
46 | if (loc->parent && resolve->bname) { |
47 | ret = inode_path (loc->parent, resolve->bname, &path); |
48 | } else if (loc->inode) { |
49 | ret = inode_path (loc->inode, NULL((void*)0), &path); |
50 | } |
51 | if (ret) |
52 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("return value inode_path %d", ret); } while (0); _gf_log (frame->this->name, "server-resolve.c" , __FUNCTION__, 53, GF_LOG_TRACE, "return value inode_path %d" , ret); } while (0) |
53 | "return value inode_path %d", ret)do { do { if (0) printf ("return value inode_path %d", ret); } while (0); _gf_log (frame->this->name, "server-resolve.c" , __FUNCTION__, 53, GF_LOG_TRACE, "return value inode_path %d" , ret); } while (0); |
54 | loc->path = path; |
55 | } |
56 | |
57 | return 0; |
58 | } |
59 | |
60 | |
61 | int |
62 | resolve_gfid_entry_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
63 | int op_ret, int op_errno, inode_t *inode, |
64 | struct iatt *buf, dict_t *xdata, |
65 | struct iatt *postparent) |
66 | { |
67 | server_state_t *state = NULL((void*)0); |
68 | server_resolve_t *resolve = NULL((void*)0); |
69 | inode_t *link_inode = NULL((void*)0); |
70 | loc_t *resolve_loc = NULL((void*)0); |
71 | |
72 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
73 | resolve = state->resolve_now; |
74 | resolve_loc = &resolve->resolve_loc; |
75 | |
76 | if (op_ret == -1) { |
77 | gf_log (this->name, ((op_errno == ENOENT) ? GF_LOG_DEBUG :do { do { if (0) printf ("%s/%s: failed to resolve (%s)", uuid_utoa (resolve_loc->pargfid), resolve_loc->name, strerror (op_errno )); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__ , 81, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "%s/%s: failed to resolve (%s)" , uuid_utoa (resolve_loc->pargfid), resolve_loc->name, strerror (op_errno)); } while (0) |
78 | GF_LOG_WARNING),do { do { if (0) printf ("%s/%s: failed to resolve (%s)", uuid_utoa (resolve_loc->pargfid), resolve_loc->name, strerror (op_errno )); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__ , 81, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "%s/%s: failed to resolve (%s)" , uuid_utoa (resolve_loc->pargfid), resolve_loc->name, strerror (op_errno)); } while (0) |
79 | "%s/%s: failed to resolve (%s)",do { do { if (0) printf ("%s/%s: failed to resolve (%s)", uuid_utoa (resolve_loc->pargfid), resolve_loc->name, strerror (op_errno )); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__ , 81, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "%s/%s: failed to resolve (%s)" , uuid_utoa (resolve_loc->pargfid), resolve_loc->name, strerror (op_errno)); } while (0) |
80 | uuid_utoa (resolve_loc->pargfid), resolve_loc->name,do { do { if (0) printf ("%s/%s: failed to resolve (%s)", uuid_utoa (resolve_loc->pargfid), resolve_loc->name, strerror (op_errno )); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__ , 81, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "%s/%s: failed to resolve (%s)" , uuid_utoa (resolve_loc->pargfid), resolve_loc->name, strerror (op_errno)); } while (0) |
81 | strerror (op_errno))do { do { if (0) printf ("%s/%s: failed to resolve (%s)", uuid_utoa (resolve_loc->pargfid), resolve_loc->name, strerror (op_errno )); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__ , 81, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "%s/%s: failed to resolve (%s)" , uuid_utoa (resolve_loc->pargfid), resolve_loc->name, strerror (op_errno)); } while (0); |
82 | goto out; |
83 | } |
84 | |
85 | link_inode = inode_link (inode, resolve_loc->parent, |
86 | resolve_loc->name, buf); |
87 | |
88 | if (!link_inode) |
89 | goto out; |
90 | |
91 | inode_lookup (link_inode); |
92 | |
93 | inode_unref (link_inode); |
94 | |
95 | out: |
96 | loc_wipe (resolve_loc); |
97 | |
98 | resolve_continue (frame); |
99 | return 0; |
100 | } |
101 | |
102 | |
103 | int |
104 | resolve_gfid_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
105 | int op_ret, int op_errno, inode_t *inode, struct iatt *buf, |
106 | dict_t *xdata, struct iatt *postparent) |
107 | { |
108 | server_state_t *state = NULL((void*)0); |
109 | server_resolve_t *resolve = NULL((void*)0); |
110 | inode_t *link_inode = NULL((void*)0); |
111 | loc_t *resolve_loc = NULL((void*)0); |
112 | |
113 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
114 | resolve = state->resolve_now; |
115 | resolve_loc = &resolve->resolve_loc; |
116 | |
117 | if (op_ret == -1) { |
118 | gf_log (this->name, ((op_errno == ENOENT) ? GF_LOG_DEBUG :do { do { if (0) printf ("%s: failed to resolve (%s)", uuid_utoa (resolve_loc->gfid), strerror (op_errno)); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__, 121, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "%s: failed to resolve (%s)" , uuid_utoa (resolve_loc->gfid), strerror (op_errno)); } while (0) |
119 | GF_LOG_WARNING),do { do { if (0) printf ("%s: failed to resolve (%s)", uuid_utoa (resolve_loc->gfid), strerror (op_errno)); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__, 121, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "%s: failed to resolve (%s)" , uuid_utoa (resolve_loc->gfid), strerror (op_errno)); } while (0) |
120 | "%s: failed to resolve (%s)",do { do { if (0) printf ("%s: failed to resolve (%s)", uuid_utoa (resolve_loc->gfid), strerror (op_errno)); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__, 121, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "%s: failed to resolve (%s)" , uuid_utoa (resolve_loc->gfid), strerror (op_errno)); } while (0) |
121 | uuid_utoa (resolve_loc->gfid), strerror (op_errno))do { do { if (0) printf ("%s: failed to resolve (%s)", uuid_utoa (resolve_loc->gfid), strerror (op_errno)); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__, 121, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "%s: failed to resolve (%s)" , uuid_utoa (resolve_loc->gfid), strerror (op_errno)); } while (0); |
122 | loc_wipe (&resolve->resolve_loc); |
123 | goto out; |
124 | } |
125 | |
126 | loc_wipe (resolve_loc); |
127 | |
128 | link_inode = inode_link (inode, NULL((void*)0), NULL((void*)0), buf); |
129 | |
130 | if (!link_inode) |
131 | goto out; |
132 | |
133 | inode_lookup (link_inode); |
134 | |
135 | if (uuid_is_null (resolve->pargfid)) { |
136 | inode_unref (link_inode); |
137 | goto out; |
138 | } |
139 | |
140 | resolve_loc->parent = link_inode; |
141 | uuid_copy (resolve_loc->pargfid, resolve_loc->parent->gfid); |
142 | |
143 | resolve_loc->name = resolve->bname; |
144 | |
145 | resolve_loc->inode = inode_new (state->itable); |
146 | inode_path (resolve_loc->parent, resolve_loc->name, |
147 | (char **) &resolve_loc->path); |
148 | |
149 | STACK_WIND (frame, resolve_gfid_entry_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", "server-resolve.c", __FUNCTION__, 151 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( ((xlator_t *) ((server_state_t *)frame->root->state)-> conn->bound_xl)->fops->lookup_cbk) tmp_cbk = resolve_gfid_entry_cbk ; _new->root = frame->root; _new->this = ((xlator_t * ) ((server_state_t *)frame->root->state)->conn->bound_xl ); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "BOUND_XL (frame)->fops->lookup"; _new-> unwind_to = "resolve_gfid_entry_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 ()) = ((xlator_t *) ((server_state_t *)frame->root->state )->conn->bound_xl); if (frame->this->ctx->measure_latency ) gf_latency_begin (_new, ((xlator_t *) ((server_state_t *)frame ->root->state)->conn->bound_xl)->fops->lookup ); ((xlator_t *) ((server_state_t *)frame->root->state) ->conn->bound_xl)->fops->lookup (_new, ((xlator_t *) ((server_state_t *)frame->root->state)->conn-> bound_xl), &resolve->resolve_loc, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
150 | BOUND_XL (frame), BOUND_XL (frame)->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", "server-resolve.c", __FUNCTION__, 151 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( ((xlator_t *) ((server_state_t *)frame->root->state)-> conn->bound_xl)->fops->lookup_cbk) tmp_cbk = resolve_gfid_entry_cbk ; _new->root = frame->root; _new->this = ((xlator_t * ) ((server_state_t *)frame->root->state)->conn->bound_xl ); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "BOUND_XL (frame)->fops->lookup"; _new-> unwind_to = "resolve_gfid_entry_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 ()) = ((xlator_t *) ((server_state_t *)frame->root->state )->conn->bound_xl); if (frame->this->ctx->measure_latency ) gf_latency_begin (_new, ((xlator_t *) ((server_state_t *)frame ->root->state)->conn->bound_xl)->fops->lookup ); ((xlator_t *) ((server_state_t *)frame->root->state) ->conn->bound_xl)->fops->lookup (_new, ((xlator_t *) ((server_state_t *)frame->root->state)->conn-> bound_xl), &resolve->resolve_loc, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
151 | &resolve->resolve_loc, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-resolve.c", __FUNCTION__, 151 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( ((xlator_t *) ((server_state_t *)frame->root->state)-> conn->bound_xl)->fops->lookup_cbk) tmp_cbk = resolve_gfid_entry_cbk ; _new->root = frame->root; _new->this = ((xlator_t * ) ((server_state_t *)frame->root->state)->conn->bound_xl ); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "BOUND_XL (frame)->fops->lookup"; _new-> unwind_to = "resolve_gfid_entry_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 ()) = ((xlator_t *) ((server_state_t *)frame->root->state )->conn->bound_xl); if (frame->this->ctx->measure_latency ) gf_latency_begin (_new, ((xlator_t *) ((server_state_t *)frame ->root->state)->conn->bound_xl)->fops->lookup ); ((xlator_t *) ((server_state_t *)frame->root->state) ->conn->bound_xl)->fops->lookup (_new, ((xlator_t *) ((server_state_t *)frame->root->state)->conn-> bound_xl), &resolve->resolve_loc, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
152 | return 0; |
153 | out: |
154 | resolve_continue (frame); |
155 | return 0; |
156 | } |
157 | |
158 | |
159 | int |
160 | resolve_gfid (call_frame_t *frame) |
161 | { |
162 | server_state_t *state = NULL((void*)0); |
163 | xlator_t *this = NULL((void*)0); |
164 | server_resolve_t *resolve = NULL((void*)0); |
165 | loc_t *resolve_loc = NULL((void*)0); |
166 | int ret = 0; |
167 | |
168 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
169 | this = frame->this; |
170 | resolve = state->resolve_now; |
171 | resolve_loc = &resolve->resolve_loc; |
172 | |
173 | if (!uuid_is_null (resolve->pargfid)) |
174 | uuid_copy (resolve_loc->gfid, resolve->pargfid); |
175 | else if (!uuid_is_null (resolve->gfid)) |
176 | uuid_copy (resolve_loc->gfid, resolve->gfid); |
177 | |
178 | resolve_loc->inode = inode_new (state->itable); |
179 | ret = loc_path (resolve_loc, NULL((void*)0)); |
180 | |
181 | STACK_WIND (frame, resolve_gfid_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", "server-resolve.c", __FUNCTION__, 183 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( ((xlator_t *) ((server_state_t *)frame->root->state)-> conn->bound_xl)->fops->lookup_cbk) tmp_cbk = resolve_gfid_cbk ; _new->root = frame->root; _new->this = ((xlator_t * ) ((server_state_t *)frame->root->state)->conn->bound_xl ); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "BOUND_XL (frame)->fops->lookup"; _new-> unwind_to = "resolve_gfid_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()) = ((xlator_t *) ((server_state_t *)frame->root->state)->conn->bound_xl); if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , ((xlator_t *) ((server_state_t *)frame->root->state)-> conn->bound_xl)->fops->lookup); ((xlator_t *) ((server_state_t *)frame->root->state)->conn->bound_xl)->fops-> lookup (_new, ((xlator_t *) ((server_state_t *)frame->root ->state)->conn->bound_xl), &resolve->resolve_loc , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) |
182 | BOUND_XL (frame), BOUND_XL (frame)->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", "server-resolve.c", __FUNCTION__, 183 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( ((xlator_t *) ((server_state_t *)frame->root->state)-> conn->bound_xl)->fops->lookup_cbk) tmp_cbk = resolve_gfid_cbk ; _new->root = frame->root; _new->this = ((xlator_t * ) ((server_state_t *)frame->root->state)->conn->bound_xl ); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "BOUND_XL (frame)->fops->lookup"; _new-> unwind_to = "resolve_gfid_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()) = ((xlator_t *) ((server_state_t *)frame->root->state)->conn->bound_xl); if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , ((xlator_t *) ((server_state_t *)frame->root->state)-> conn->bound_xl)->fops->lookup); ((xlator_t *) ((server_state_t *)frame->root->state)->conn->bound_xl)->fops-> lookup (_new, ((xlator_t *) ((server_state_t *)frame->root ->state)->conn->bound_xl), &resolve->resolve_loc , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) |
183 | &resolve->resolve_loc, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-resolve.c", __FUNCTION__, 183 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( ((xlator_t *) ((server_state_t *)frame->root->state)-> conn->bound_xl)->fops->lookup_cbk) tmp_cbk = resolve_gfid_cbk ; _new->root = frame->root; _new->this = ((xlator_t * ) ((server_state_t *)frame->root->state)->conn->bound_xl ); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "BOUND_XL (frame)->fops->lookup"; _new-> unwind_to = "resolve_gfid_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()) = ((xlator_t *) ((server_state_t *)frame->root->state)->conn->bound_xl); if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , ((xlator_t *) ((server_state_t *)frame->root->state)-> conn->bound_xl)->fops->lookup); ((xlator_t *) ((server_state_t *)frame->root->state)->conn->bound_xl)->fops-> lookup (_new, ((xlator_t *) ((server_state_t *)frame->root ->state)->conn->bound_xl), &resolve->resolve_loc , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); |
184 | return 0; |
185 | } |
186 | |
187 | int |
188 | resolve_continue (call_frame_t *frame) |
189 | { |
190 | server_state_t *state = NULL((void*)0); |
191 | xlator_t *this = NULL((void*)0); |
192 | server_resolve_t *resolve = NULL((void*)0); |
193 | int ret = 0; |
194 | |
195 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
196 | this = frame->this; |
197 | resolve = state->resolve_now; |
198 | |
199 | resolve->op_ret = 0; |
200 | resolve->op_errno = 0; |
201 | |
202 | if (resolve->fd_no != -1) { |
203 | ret = resolve_anonfd_simple (frame); |
Value stored to 'ret' is never read | |
204 | goto out; |
205 | } else if (!uuid_is_null (resolve->pargfid)) |
206 | ret = resolve_entry_simple (frame); |
207 | else if (!uuid_is_null (resolve->gfid)) |
208 | ret = resolve_inode_simple (frame); |
209 | if (ret) |
210 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("return value of resolve_*_simple %d" , ret); } while (0); _gf_log (this->name, "server-resolve.c" , __FUNCTION__, 211, GF_LOG_DEBUG, "return value of resolve_*_simple %d" , ret); } while (0) |
211 | "return value of resolve_*_simple %d", ret)do { do { if (0) printf ("return value of resolve_*_simple %d" , ret); } while (0); _gf_log (this->name, "server-resolve.c" , __FUNCTION__, 211, GF_LOG_DEBUG, "return value of resolve_*_simple %d" , ret); } while (0); |
212 | |
213 | resolve_loc_touchup (frame); |
214 | out: |
215 | server_resolve_all (frame); |
216 | |
217 | return 0; |
218 | } |
219 | |
220 | |
221 | /* |
222 | Check if the requirements are fulfilled by entries in the inode cache itself |
223 | Return value: |
224 | <= 0 - simple resolution was decisive and complete (either success or failure) |
225 | > 0 - indecisive, need to perform deep resolution |
226 | */ |
227 | |
228 | int |
229 | resolve_entry_simple (call_frame_t *frame) |
230 | { |
231 | server_state_t *state = NULL((void*)0); |
232 | xlator_t *this = NULL((void*)0); |
233 | server_resolve_t *resolve = NULL((void*)0); |
234 | inode_t *parent = NULL((void*)0); |
235 | inode_t *inode = NULL((void*)0); |
236 | int ret = 0; |
237 | |
238 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
239 | this = frame->this; |
240 | resolve = state->resolve_now; |
241 | |
242 | parent = inode_find (state->itable, resolve->pargfid); |
243 | if (!parent) { |
244 | /* simple resolution is indecisive. need to perform |
245 | deep resolution */ |
246 | resolve->op_ret = -1; |
247 | resolve->op_errno = ENOENT2; |
248 | ret = 1; |
249 | goto out; |
250 | } |
251 | |
252 | /* expected @parent was found from the inode cache */ |
253 | uuid_copy (state->loc_now->pargfid, resolve->pargfid); |
254 | state->loc_now->parent = inode_ref (parent); |
255 | state->loc_now->name = resolve->bname; |
256 | |
257 | inode = inode_grep (state->itable, parent, resolve->bname); |
258 | if (!inode) { |
259 | switch (resolve->type) { |
260 | case RESOLVE_DONTCARE: |
261 | case RESOLVE_NOT: |
262 | ret = 0; |
263 | break; |
264 | case RESOLVE_MAY: |
265 | ret = 1; |
266 | break; |
267 | default: |
268 | resolve->op_ret = -1; |
269 | resolve->op_errno = ENOENT2; |
270 | ret = 1; |
271 | break; |
272 | } |
273 | |
274 | goto out; |
275 | } |
276 | |
277 | if (resolve->type == RESOLVE_NOT) { |
278 | gf_log (this->name, GF_LOG_DEBUG, "inode (pointer: %p gfid:%s"do { do { if (0) printf ("inode (pointer: %p gfid:%s" " found for path (%s) while type is RESOLVE_NOT" , inode, uuid_utoa (inode->gfid), resolve->path); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__ , 280, GF_LOG_DEBUG, "inode (pointer: %p gfid:%s" " found for path (%s) while type is RESOLVE_NOT" , inode, uuid_utoa (inode->gfid), resolve->path); } while (0) |
279 | " found for path (%s) while type is RESOLVE_NOT",do { do { if (0) printf ("inode (pointer: %p gfid:%s" " found for path (%s) while type is RESOLVE_NOT" , inode, uuid_utoa (inode->gfid), resolve->path); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__ , 280, GF_LOG_DEBUG, "inode (pointer: %p gfid:%s" " found for path (%s) while type is RESOLVE_NOT" , inode, uuid_utoa (inode->gfid), resolve->path); } while (0) |
280 | inode, uuid_utoa (inode->gfid), resolve->path)do { do { if (0) printf ("inode (pointer: %p gfid:%s" " found for path (%s) while type is RESOLVE_NOT" , inode, uuid_utoa (inode->gfid), resolve->path); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__ , 280, GF_LOG_DEBUG, "inode (pointer: %p gfid:%s" " found for path (%s) while type is RESOLVE_NOT" , inode, uuid_utoa (inode->gfid), resolve->path); } while (0); |
281 | resolve->op_ret = -1; |
282 | resolve->op_errno = EEXIST17; |
283 | ret = -1; |
284 | goto out; |
285 | } |
286 | |
287 | ret = 0; |
288 | |
289 | state->loc_now->inode = inode_ref (inode); |
290 | |
291 | out: |
292 | if (parent) |
293 | inode_unref (parent); |
294 | |
295 | if (inode) |
296 | inode_unref (inode); |
297 | |
298 | return ret; |
299 | } |
300 | |
301 | |
302 | int |
303 | server_resolve_entry (call_frame_t *frame) |
304 | { |
305 | server_state_t *state = NULL((void*)0); |
306 | int ret = 0; |
307 | loc_t *loc = NULL((void*)0); |
308 | |
309 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
310 | loc = state->loc_now; |
311 | |
312 | ret = resolve_entry_simple (frame); |
313 | |
314 | if (ret > 0) { |
315 | loc_wipe (loc); |
316 | resolve_gfid (frame); |
317 | return 0; |
318 | } |
319 | |
320 | if (ret == 0) |
321 | resolve_loc_touchup (frame); |
322 | |
323 | server_resolve_all (frame); |
324 | |
325 | return 0; |
326 | } |
327 | |
328 | |
329 | int |
330 | resolve_inode_simple (call_frame_t *frame) |
331 | { |
332 | server_state_t *state = NULL((void*)0); |
333 | server_resolve_t *resolve = NULL((void*)0); |
334 | inode_t *inode = NULL((void*)0); |
335 | int ret = 0; |
336 | |
337 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
338 | resolve = state->resolve_now; |
339 | |
340 | inode = inode_find (state->itable, resolve->gfid); |
341 | |
342 | if (!inode) { |
343 | resolve->op_ret = -1; |
344 | resolve->op_errno = ENOENT2; |
345 | ret = 1; |
346 | goto out; |
347 | } |
348 | |
349 | ret = 0; |
350 | |
351 | state->loc_now->inode = inode_ref (inode); |
352 | uuid_copy (state->loc_now->gfid, resolve->gfid); |
353 | |
354 | out: |
355 | if (inode) |
356 | inode_unref (inode); |
357 | |
358 | return ret; |
359 | } |
360 | |
361 | |
362 | int |
363 | server_resolve_inode (call_frame_t *frame) |
364 | { |
365 | server_state_t *state = NULL((void*)0); |
366 | int ret = 0; |
367 | loc_t *loc = NULL((void*)0); |
368 | |
369 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
370 | loc = state->loc_now; |
371 | |
372 | ret = resolve_inode_simple (frame); |
373 | |
374 | if (ret > 0) { |
375 | loc_wipe (loc); |
376 | resolve_gfid (frame); |
377 | return 0; |
378 | } |
379 | |
380 | if (ret == 0) |
381 | resolve_loc_touchup (frame); |
382 | |
383 | server_resolve_all (frame); |
384 | |
385 | return 0; |
386 | } |
387 | |
388 | |
389 | int |
390 | resolve_anonfd_simple (call_frame_t *frame) |
391 | { |
392 | server_state_t *state = NULL((void*)0); |
393 | server_resolve_t *resolve = NULL((void*)0); |
394 | inode_t *inode = NULL((void*)0); |
395 | int ret = 0; |
396 | |
397 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
398 | resolve = state->resolve_now; |
399 | |
400 | inode = inode_find (state->itable, resolve->gfid); |
401 | |
402 | if (!inode) { |
403 | resolve->op_ret = -1; |
404 | resolve->op_errno = ENOENT2; |
405 | ret = 1; |
406 | goto out; |
407 | } |
408 | |
409 | ret = 0; |
410 | |
411 | state->fd = fd_anonymous (inode); |
412 | out: |
413 | if (inode) |
414 | inode_unref (inode); |
415 | |
416 | if (ret != 0) |
417 | gf_log ("server", GF_LOG_WARNING, "inode for the gfid (%s) is "do { do { if (0) printf ("inode for the gfid (%s) is " "not found. anonymous fd creation failed" , uuid_utoa (resolve->gfid)); } while (0); _gf_log ("server" , "server-resolve.c", __FUNCTION__, 419, GF_LOG_WARNING, "inode for the gfid (%s) is " "not found. anonymous fd creation failed", uuid_utoa (resolve ->gfid)); } while (0) |
418 | "not found. anonymous fd creation failed",do { do { if (0) printf ("inode for the gfid (%s) is " "not found. anonymous fd creation failed" , uuid_utoa (resolve->gfid)); } while (0); _gf_log ("server" , "server-resolve.c", __FUNCTION__, 419, GF_LOG_WARNING, "inode for the gfid (%s) is " "not found. anonymous fd creation failed", uuid_utoa (resolve ->gfid)); } while (0) |
419 | uuid_utoa (resolve->gfid))do { do { if (0) printf ("inode for the gfid (%s) is " "not found. anonymous fd creation failed" , uuid_utoa (resolve->gfid)); } while (0); _gf_log ("server" , "server-resolve.c", __FUNCTION__, 419, GF_LOG_WARNING, "inode for the gfid (%s) is " "not found. anonymous fd creation failed", uuid_utoa (resolve ->gfid)); } while (0); |
420 | return ret; |
421 | } |
422 | |
423 | |
424 | int |
425 | server_resolve_anonfd (call_frame_t *frame) |
426 | { |
427 | server_state_t *state = NULL((void*)0); |
428 | int ret = 0; |
429 | loc_t *loc = NULL((void*)0); |
430 | |
431 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
432 | loc = state->loc_now; |
433 | |
434 | ret = resolve_anonfd_simple (frame); |
435 | |
436 | if (ret > 0) { |
437 | loc_wipe (loc); |
438 | resolve_gfid (frame); |
439 | return 0; |
440 | } |
441 | |
442 | server_resolve_all (frame); |
443 | |
444 | return 0; |
445 | |
446 | } |
447 | |
448 | |
449 | int |
450 | server_resolve_fd (call_frame_t *frame) |
451 | { |
452 | server_state_t *state = NULL((void*)0); |
453 | server_resolve_t *resolve = NULL((void*)0); |
454 | server_connection_t *conn = NULL((void*)0); |
455 | uint64_t fd_no = -1; |
456 | |
457 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
458 | resolve = state->resolve_now; |
459 | conn = SERVER_CONNECTION (frame)((server_connection_t *) ((server_state_t *)frame->root-> state)->conn); |
460 | |
461 | fd_no = resolve->fd_no; |
462 | |
463 | if (fd_no == GF_ANON_FD_NO-2) { |
464 | server_resolve_anonfd (frame); |
465 | return 0; |
466 | } |
467 | |
468 | state->fd = gf_fd_fdptr_get (conn->fdtable, fd_no); |
469 | |
470 | if (!state->fd) { |
471 | gf_log ("", GF_LOG_INFO, "fd not found in context")do { do { if (0) printf ("fd not found in context"); } while ( 0); _gf_log ("", "server-resolve.c", __FUNCTION__, 471, GF_LOG_INFO , "fd not found in context"); } while (0); |
472 | resolve->op_ret = -1; |
473 | resolve->op_errno = EBADF9; |
474 | } |
475 | |
476 | server_resolve_all (frame); |
477 | |
478 | return 0; |
479 | } |
480 | |
481 | |
482 | int |
483 | server_resolve (call_frame_t *frame) |
484 | { |
485 | server_state_t *state = NULL((void*)0); |
486 | server_resolve_t *resolve = NULL((void*)0); |
487 | |
488 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
489 | resolve = state->resolve_now; |
490 | |
491 | if (resolve->fd_no != -1) { |
492 | |
493 | server_resolve_fd (frame); |
494 | |
495 | } else if (!uuid_is_null (resolve->pargfid)) { |
496 | |
497 | server_resolve_entry (frame); |
498 | |
499 | } else if (!uuid_is_null (resolve->gfid)) { |
500 | |
501 | server_resolve_inode (frame); |
502 | |
503 | } else { |
504 | if (resolve == &state->resolve) |
505 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("no resolution type for %s (%s)", resolve ->path, gf_fop_list[frame->root->op]); } while (0); _gf_log (frame->this->name, "server-resolve.c", __FUNCTION__, 507 , GF_LOG_WARNING, "no resolution type for %s (%s)", resolve-> path, gf_fop_list[frame->root->op]); } while (0) |
506 | "no resolution type for %s (%s)",do { do { if (0) printf ("no resolution type for %s (%s)", resolve ->path, gf_fop_list[frame->root->op]); } while (0); _gf_log (frame->this->name, "server-resolve.c", __FUNCTION__, 507 , GF_LOG_WARNING, "no resolution type for %s (%s)", resolve-> path, gf_fop_list[frame->root->op]); } while (0) |
507 | resolve->path, gf_fop_list[frame->root->op])do { do { if (0) printf ("no resolution type for %s (%s)", resolve ->path, gf_fop_list[frame->root->op]); } while (0); _gf_log (frame->this->name, "server-resolve.c", __FUNCTION__, 507 , GF_LOG_WARNING, "no resolution type for %s (%s)", resolve-> path, gf_fop_list[frame->root->op]); } while (0); |
508 | |
509 | resolve->op_ret = -1; |
510 | resolve->op_errno = EINVAL22; |
511 | |
512 | server_resolve_all (frame); |
513 | } |
514 | |
515 | return 0; |
516 | } |
517 | |
518 | |
519 | int |
520 | server_resolve_done (call_frame_t *frame) |
521 | { |
522 | server_state_t *state = NULL((void*)0); |
523 | xlator_t *bound_xl = NULL((void*)0); |
524 | |
525 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
526 | bound_xl = BOUND_XL (frame)((xlator_t *) ((server_state_t *)frame->root->state)-> conn->bound_xl); |
527 | |
528 | server_print_request (frame); |
529 | |
530 | state->resume_fn (frame, bound_xl); |
531 | |
532 | return 0; |
533 | } |
534 | |
535 | |
536 | /* |
537 | * This function is called multiple times, once per resolving one location/fd. |
538 | * state->resolve_now is used to decide which location/fd is to be resolved now |
539 | */ |
540 | int |
541 | server_resolve_all (call_frame_t *frame) |
542 | { |
543 | server_state_t *state = NULL((void*)0); |
544 | xlator_t *this = NULL((void*)0); |
545 | |
546 | this = frame->this; |
547 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
548 | |
549 | if (state->resolve_now == NULL((void*)0)) { |
550 | |
551 | state->resolve_now = &state->resolve; |
552 | state->loc_now = &state->loc; |
553 | |
554 | server_resolve (frame); |
555 | |
556 | } else if (state->resolve_now == &state->resolve) { |
557 | |
558 | state->resolve_now = &state->resolve2; |
559 | state->loc_now = &state->loc2; |
560 | |
561 | server_resolve (frame); |
562 | |
563 | } else if (state->resolve_now == &state->resolve2) { |
564 | |
565 | server_resolve_done (frame); |
566 | |
567 | } else { |
568 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Invalid pointer for state->resolve_now" ); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__ , 569, GF_LOG_ERROR, "Invalid pointer for state->resolve_now" ); } while (0) |
569 | "Invalid pointer for state->resolve_now")do { do { if (0) printf ("Invalid pointer for state->resolve_now" ); } while (0); _gf_log (this->name, "server-resolve.c", __FUNCTION__ , 569, GF_LOG_ERROR, "Invalid pointer for state->resolve_now" ); } while (0); |
570 | } |
571 | |
572 | return 0; |
573 | } |
574 | |
575 | |
576 | int |
577 | resolve_and_resume (call_frame_t *frame, server_resume_fn_t fn) |
578 | { |
579 | server_state_t *state = NULL((void*)0); |
580 | |
581 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); |
582 | state->resume_fn = fn; |
583 | |
584 | server_resolve_all (frame); |
585 | |
586 | return 0; |
587 | } |