File: | xlators/protocol/server/src/server-helpers.c |
Location: | line 539, column 9 |
Description: | Access to field 'name' results in a dereference of a null pointer (loaded from variable 'this') |
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 | #include <fnmatch.h> | ||||||
20 | |||||||
21 | int | ||||||
22 | server_decode_groups (call_frame_t *frame, rpcsvc_request_t *req) | ||||||
23 | { | ||||||
24 | int i = 0; | ||||||
25 | |||||||
26 | GF_VALIDATE_OR_GOTO ("server", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 26, GF_LOG_ERROR , "invalid argument: " "frame"); } while (0); goto out; } } while (0); | ||||||
27 | GF_VALIDATE_OR_GOTO ("server", req, out)do { if (!req) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "req"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 27, GF_LOG_ERROR , "invalid argument: " "req"); } while (0); goto out; } } while (0); | ||||||
28 | |||||||
29 | frame->root->ngrps = req->auxgidcount; | ||||||
30 | if (frame->root->ngrps == 0) | ||||||
31 | return 0; | ||||||
32 | |||||||
33 | if (frame->root->ngrps > GF_MAX_AUX_GROUPS200) | ||||||
34 | return -1; | ||||||
35 | |||||||
36 | for (; i < frame->root->ngrps; ++i) | ||||||
37 | frame->root->groups[i] = req->auxgids[i]; | ||||||
38 | out: | ||||||
39 | return 0; | ||||||
40 | } | ||||||
41 | |||||||
42 | void | ||||||
43 | server_loc_wipe (loc_t *loc) | ||||||
44 | { | ||||||
45 | if (loc->parent) { | ||||||
46 | inode_unref (loc->parent); | ||||||
47 | loc->parent = NULL((void*)0); | ||||||
48 | } | ||||||
49 | |||||||
50 | if (loc->inode) { | ||||||
51 | inode_unref (loc->inode); | ||||||
52 | loc->inode = NULL((void*)0); | ||||||
53 | } | ||||||
54 | |||||||
55 | GF_FREE ((void *)loc->path)__gf_free ((void *)loc->path); | ||||||
56 | } | ||||||
57 | |||||||
58 | |||||||
59 | void | ||||||
60 | server_resolve_wipe (server_resolve_t *resolve) | ||||||
61 | { | ||||||
62 | GF_FREE ((void *)resolve->path)__gf_free ((void *)resolve->path); | ||||||
63 | |||||||
64 | GF_FREE ((void *)resolve->bname)__gf_free ((void *)resolve->bname); | ||||||
65 | |||||||
66 | loc_wipe (&resolve->resolve_loc); | ||||||
67 | } | ||||||
68 | |||||||
69 | |||||||
70 | void | ||||||
71 | free_state (server_state_t *state) | ||||||
72 | { | ||||||
73 | if (state->conn) { | ||||||
74 | //xprt_svc_unref (state->conn); | ||||||
75 | state->conn = NULL((void*)0); | ||||||
76 | } | ||||||
77 | |||||||
78 | if (state->xprt) { | ||||||
79 | rpc_transport_unref (state->xprt); | ||||||
80 | state->xprt = NULL((void*)0); | ||||||
81 | } | ||||||
82 | if (state->fd) { | ||||||
83 | fd_unref (state->fd); | ||||||
84 | state->fd = NULL((void*)0); | ||||||
85 | } | ||||||
86 | |||||||
87 | if (state->params) { | ||||||
88 | dict_unref (state->params); | ||||||
89 | state->params = NULL((void*)0); | ||||||
90 | } | ||||||
91 | |||||||
92 | if (state->iobref) { | ||||||
93 | iobref_unref (state->iobref); | ||||||
94 | state->iobref = NULL((void*)0); | ||||||
95 | } | ||||||
96 | |||||||
97 | if (state->iobuf) { | ||||||
98 | iobuf_unref (state->iobuf); | ||||||
99 | state->iobuf = NULL((void*)0); | ||||||
100 | } | ||||||
101 | |||||||
102 | if (state->dict) { | ||||||
103 | dict_unref (state->dict); | ||||||
104 | state->dict = NULL((void*)0); | ||||||
105 | } | ||||||
106 | |||||||
107 | if (state->xdata) { | ||||||
108 | dict_unref (state->xdata); | ||||||
109 | state->xdata = NULL((void*)0); | ||||||
110 | } | ||||||
111 | |||||||
112 | GF_FREE ((void *)state->volume)__gf_free ((void *)state->volume); | ||||||
113 | |||||||
114 | GF_FREE ((void *)state->name)__gf_free ((void *)state->name); | ||||||
115 | |||||||
116 | server_loc_wipe (&state->loc); | ||||||
117 | server_loc_wipe (&state->loc2); | ||||||
118 | |||||||
119 | server_resolve_wipe (&state->resolve); | ||||||
120 | server_resolve_wipe (&state->resolve2); | ||||||
121 | |||||||
122 | GF_FREE (state)__gf_free (state); | ||||||
123 | } | ||||||
124 | |||||||
125 | |||||||
126 | int | ||||||
127 | gf_add_locker (server_connection_t *conn, const char *volume, | ||||||
128 | loc_t *loc, fd_t *fd, pid_t pid, gf_lkowner_t *owner, | ||||||
129 | glusterfs_fop_t type) | ||||||
130 | { | ||||||
131 | int32_t ret = -1; | ||||||
132 | struct _locker *new = NULL((void*)0); | ||||||
133 | struct _lock_table *table = NULL((void*)0); | ||||||
134 | |||||||
135 | GF_VALIDATE_OR_GOTO ("server", volume, out)do { if (!volume) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "volume"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 135, GF_LOG_ERROR , "invalid argument: " "volume"); } while (0); goto out; } } while (0); | ||||||
136 | |||||||
137 | new = GF_CALLOC (1, sizeof (struct _locker), gf_server_mt_locker_t)__gf_calloc (1, sizeof (struct _locker), gf_server_mt_locker_t ); | ||||||
138 | if (new == NULL((void*)0)) { | ||||||
139 | goto out; | ||||||
140 | } | ||||||
141 | INIT_LIST_HEAD (&new->lockers)do { (&new->lockers)->next = (&new->lockers) ->prev = &new->lockers; } while (0); | ||||||
142 | |||||||
143 | new->volume = gf_strdup (volume); | ||||||
144 | |||||||
145 | if (fd == NULL((void*)0)) { | ||||||
146 | loc_copy (&new->loc, loc); | ||||||
147 | } else { | ||||||
148 | new->fd = fd_ref (fd); | ||||||
149 | } | ||||||
150 | |||||||
151 | new->pid = pid; | ||||||
152 | new->owner = *owner; | ||||||
153 | |||||||
154 | pthread_mutex_lock (&conn->lock); | ||||||
155 | { | ||||||
156 | table = conn->ltable; | ||||||
157 | if (type == GF_FOP_ENTRYLK) | ||||||
158 | list_add_tail (&new->lockers, &table->entrylk_lockers); | ||||||
159 | else | ||||||
160 | list_add_tail (&new->lockers, &table->inodelk_lockers); | ||||||
161 | } | ||||||
162 | pthread_mutex_unlock (&conn->lock); | ||||||
163 | out: | ||||||
164 | return ret; | ||||||
165 | } | ||||||
166 | |||||||
167 | |||||||
168 | int | ||||||
169 | gf_del_locker (server_connection_t *conn, const char *volume, | ||||||
170 | loc_t *loc, fd_t *fd, gf_lkowner_t *owner, | ||||||
171 | glusterfs_fop_t type) | ||||||
172 | { | ||||||
173 | struct _locker *locker = NULL((void*)0); | ||||||
174 | struct _locker *tmp = NULL((void*)0); | ||||||
175 | int32_t ret = -1; | ||||||
176 | struct list_head *head = NULL((void*)0); | ||||||
177 | struct _lock_table *table = NULL((void*)0); | ||||||
178 | int found = 0; | ||||||
179 | |||||||
180 | GF_VALIDATE_OR_GOTO ("server", volume, out)do { if (!volume) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "volume"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 180, GF_LOG_ERROR , "invalid argument: " "volume"); } while (0); goto out; } } while (0); | ||||||
181 | |||||||
182 | pthread_mutex_lock (&conn->lock); | ||||||
183 | { | ||||||
184 | table = conn->ltable; | ||||||
185 | if (type == GF_FOP_ENTRYLK) { | ||||||
186 | head = &table->entrylk_lockers; | ||||||
187 | } else { | ||||||
188 | head = &table->inodelk_lockers; | ||||||
189 | } | ||||||
190 | |||||||
191 | list_for_each_entry_safe (locker, tmp, head, lockers)for (locker = ((typeof(*locker) *)((char *)((head)->next)- (unsigned long)(&((typeof(*locker) *)0)->lockers))), tmp = ((typeof(*locker) *)((char *)(locker->lockers.next)-(unsigned long)(&((typeof(*locker) *)0)->lockers))); &locker ->lockers != (head); locker = tmp, tmp = ((typeof(*tmp) *) ((char *)(tmp->lockers.next)-(unsigned long)(&((typeof (*tmp) *)0)->lockers)))) { | ||||||
192 | if (!is_same_lkowner (&locker->owner, owner) || | ||||||
193 | strcmp (locker->volume, volume)) | ||||||
194 | continue; | ||||||
195 | |||||||
196 | if (locker->fd && fd && (locker->fd == fd)) | ||||||
197 | found = 1; | ||||||
198 | else if (locker->loc.inode && loc && | ||||||
199 | (locker->loc.inode == loc->inode)) | ||||||
200 | found = 1; | ||||||
201 | if (found) { | ||||||
202 | list_del_init (&locker->lockers); | ||||||
203 | break; | ||||||
204 | } | ||||||
205 | } | ||||||
206 | if (!found) | ||||||
207 | locker = NULL((void*)0); | ||||||
208 | } | ||||||
209 | pthread_mutex_unlock (&conn->lock); | ||||||
210 | |||||||
211 | if (locker) { | ||||||
212 | if (locker->fd) | ||||||
213 | fd_unref (locker->fd); | ||||||
214 | else | ||||||
215 | loc_wipe (&locker->loc); | ||||||
216 | |||||||
217 | GF_FREE (locker->volume)__gf_free (locker->volume); | ||||||
218 | GF_FREE (locker)__gf_free (locker); | ||||||
219 | } | ||||||
220 | |||||||
221 | ret = 0; | ||||||
222 | out: | ||||||
223 | return ret; | ||||||
224 | } | ||||||
225 | |||||||
226 | static struct _lock_table * | ||||||
227 | gf_lock_table_new (void) | ||||||
228 | { | ||||||
229 | struct _lock_table *new = NULL((void*)0); | ||||||
230 | |||||||
231 | new = GF_CALLOC (1, sizeof (struct _lock_table), gf_server_mt_lock_table_t)__gf_calloc (1, sizeof (struct _lock_table), gf_server_mt_lock_table_t ); | ||||||
232 | if (new == NULL((void*)0)) { | ||||||
233 | goto out; | ||||||
234 | } | ||||||
235 | INIT_LIST_HEAD (&new->entrylk_lockers)do { (&new->entrylk_lockers)->next = (&new-> entrylk_lockers)->prev = &new->entrylk_lockers; } while (0); | ||||||
236 | INIT_LIST_HEAD (&new->inodelk_lockers)do { (&new->inodelk_lockers)->next = (&new-> inodelk_lockers)->prev = &new->inodelk_lockers; } while (0); | ||||||
237 | out: | ||||||
238 | return new; | ||||||
239 | } | ||||||
240 | |||||||
241 | static int | ||||||
242 | server_nop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | ||||||
243 | int32_t op_ret, int32_t op_errno, dict_t *xdata) | ||||||
244 | { | ||||||
245 | int ret = -1; | ||||||
246 | server_state_t *state = NULL((void*)0); | ||||||
247 | |||||||
248 | GF_VALIDATE_OR_GOTO ("server", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 248, GF_LOG_ERROR , "invalid argument: " "frame"); } while (0); goto out; } } while (0); | ||||||
249 | GF_VALIDATE_OR_GOTO ("server", cookie, out)do { if (!cookie) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "cookie"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 249, GF_LOG_ERROR , "invalid argument: " "cookie"); } while (0); goto out; } } while (0); | ||||||
250 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 250, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
251 | |||||||
252 | if (frame->root->trans) | ||||||
253 | server_conn_unref (frame->root->trans); | ||||||
254 | state = CALL_STATE(frame)((server_state_t *)frame->root->state); | ||||||
255 | |||||||
256 | if (state) | ||||||
257 | free_state (state); | ||||||
258 | STACK_DESTROY (frame->root); | ||||||
259 | |||||||
260 | ret = 0; | ||||||
261 | out: | ||||||
262 | return ret; | ||||||
263 | } | ||||||
264 | |||||||
265 | int | ||||||
266 | do_lock_table_cleanup (xlator_t *this, server_connection_t *conn, | ||||||
267 | call_frame_t *frame, struct _lock_table *ltable) | ||||||
268 | { | ||||||
269 | struct list_head inodelk_lockers, entrylk_lockers; | ||||||
270 | call_frame_t *tmp_frame = NULL((void*)0); | ||||||
271 | struct gf_flock flock = {0, }; | ||||||
272 | xlator_t *bound_xl = NULL((void*)0); | ||||||
273 | struct _locker *locker = NULL((void*)0), *tmp = NULL((void*)0); | ||||||
274 | int ret = -1; | ||||||
275 | char *path = NULL((void*)0); | ||||||
276 | |||||||
277 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 277, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
278 | GF_VALIDATE_OR_GOTO ("server", conn, out)do { if (!conn) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conn"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 278, GF_LOG_ERROR , "invalid argument: " "conn"); } while (0); goto out; } } while (0); | ||||||
279 | GF_VALIDATE_OR_GOTO ("server", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 279, GF_LOG_ERROR , "invalid argument: " "frame"); } while (0); goto out; } } while (0); | ||||||
280 | GF_VALIDATE_OR_GOTO ("server", ltable, out)do { if (!ltable) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "ltable"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 280, GF_LOG_ERROR , "invalid argument: " "ltable"); } while (0); goto out; } } while (0); | ||||||
281 | |||||||
282 | bound_xl = conn->bound_xl; | ||||||
283 | INIT_LIST_HEAD (&inodelk_lockers)do { (&inodelk_lockers)->next = (&inodelk_lockers) ->prev = &inodelk_lockers; } while (0); | ||||||
284 | INIT_LIST_HEAD (&entrylk_lockers)do { (&entrylk_lockers)->next = (&entrylk_lockers) ->prev = &entrylk_lockers; } while (0); | ||||||
285 | |||||||
286 | list_splice_init (<able->inodelk_lockers, | ||||||
287 | &inodelk_lockers); | ||||||
288 | |||||||
289 | list_splice_init (<able->entrylk_lockers, &entrylk_lockers); | ||||||
290 | GF_FREE (ltable)__gf_free (ltable); | ||||||
291 | |||||||
292 | flock.l_type = F_UNLCK2; | ||||||
293 | flock.l_start = 0; | ||||||
294 | flock.l_len = 0; | ||||||
295 | list_for_each_entry_safe (locker,for (locker = ((typeof(*locker) *)((char *)((&inodelk_lockers )->next)-(unsigned long)(&((typeof(*locker) *)0)->lockers ))), tmp = ((typeof(*locker) *)((char *)(locker->lockers.next )-(unsigned long)(&((typeof(*locker) *)0)->lockers))); &locker->lockers != (&inodelk_lockers); locker = tmp , tmp = ((typeof(*tmp) *)((char *)(tmp->lockers.next)-(unsigned long)(&((typeof(*tmp) *)0)->lockers)))) | ||||||
296 | tmp, &inodelk_lockers, lockers)for (locker = ((typeof(*locker) *)((char *)((&inodelk_lockers )->next)-(unsigned long)(&((typeof(*locker) *)0)->lockers ))), tmp = ((typeof(*locker) *)((char *)(locker->lockers.next )-(unsigned long)(&((typeof(*locker) *)0)->lockers))); &locker->lockers != (&inodelk_lockers); locker = tmp , tmp = ((typeof(*tmp) *)((char *)(tmp->lockers.next)-(unsigned long)(&((typeof(*tmp) *)0)->lockers)))) { | ||||||
297 | tmp_frame = copy_frame (frame); | ||||||
298 | if (tmp_frame == NULL((void*)0)) { | ||||||
299 | goto out; | ||||||
300 | } | ||||||
301 | /* | ||||||
302 | lock owner = 0 is a special case that tells posix-locks | ||||||
303 | to release all locks from this transport | ||||||
304 | */ | ||||||
305 | tmp_frame->root->pid = 0; | ||||||
306 | tmp_frame->root->trans = server_conn_ref (conn); | ||||||
307 | memset (&tmp_frame->root->lk_owner, 0, sizeof (gf_lkowner_t)); | ||||||
308 | |||||||
309 | if (locker->fd) { | ||||||
310 | GF_ASSERT (locker->fd->inode)do { if (!(locker->fd->inode)) { do { do { if (0) printf ("Assertion failed: " "locker->fd->inode"); } while (0 ); _gf_log_callingfn ("", "server-helpers.c", __FUNCTION__, 310 , GF_LOG_ERROR, "Assertion failed: " "locker->fd->inode" ); } while (0); } } while (0); | ||||||
311 | |||||||
312 | ret = inode_path (locker->fd->inode, NULL((void*)0), &path); | ||||||
313 | |||||||
314 | if (ret > 0) { | ||||||
315 | gf_log (this->name, GF_LOG_INFO, "finodelk "do { do { if (0) printf ("finodelk " "released on %s", path); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__ , 316, GF_LOG_INFO, "finodelk " "released on %s", path); } while (0) | ||||||
316 | "released on %s", path)do { do { if (0) printf ("finodelk " "released on %s", path); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__ , 316, GF_LOG_INFO, "finodelk " "released on %s", path); } while (0); | ||||||
317 | GF_FREE (path)__gf_free (path); | ||||||
318 | } else { | ||||||
319 | |||||||
320 | gf_log (this->name, GF_LOG_INFO, "finodelk "do { do { if (0) printf ("finodelk " "released on inode with gfid %s" , uuid_utoa (locker->fd->inode->gfid)); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 322 , GF_LOG_INFO, "finodelk " "released on inode with gfid %s", uuid_utoa (locker->fd->inode->gfid)); } while (0) | ||||||
321 | "released on inode with gfid %s",do { do { if (0) printf ("finodelk " "released on inode with gfid %s" , uuid_utoa (locker->fd->inode->gfid)); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 322 , GF_LOG_INFO, "finodelk " "released on inode with gfid %s", uuid_utoa (locker->fd->inode->gfid)); } while (0) | ||||||
322 | uuid_utoa (locker->fd->inode->gfid))do { do { if (0) printf ("finodelk " "released on inode with gfid %s" , uuid_utoa (locker->fd->inode->gfid)); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 322 , GF_LOG_INFO, "finodelk " "released on inode with gfid %s", uuid_utoa (locker->fd->inode->gfid)); } while (0); | ||||||
323 | } | ||||||
324 | |||||||
325 | STACK_WIND (tmp_frame, server_nop_cbk, bound_xl,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 328 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->finodelk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->finodelk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->finodelk); bound_xl->fops->finodelk (_new , bound_xl, locker->volume, locker->fd, 13, &flock, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
326 | bound_xl->fops->finodelk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 328 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->finodelk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->finodelk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->finodelk); bound_xl->fops->finodelk (_new , bound_xl, locker->volume, locker->fd, 13, &flock, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
327 | locker->volume,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 328 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->finodelk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->finodelk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->finodelk); bound_xl->fops->finodelk (_new , bound_xl, locker->volume, locker->fd, 13, &flock, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
328 | locker->fd, F_SETLK, &flock, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 328 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->finodelk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->finodelk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->finodelk); bound_xl->fops->finodelk (_new , bound_xl, locker->volume, locker->fd, 13, &flock, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | ||||||
329 | fd_unref (locker->fd); | ||||||
330 | } else { | ||||||
331 | gf_log (this->name, GF_LOG_INFO, "inodelk released "do { do { if (0) printf ("inodelk released " "on %s", locker-> loc.path); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 332, GF_LOG_INFO, "inodelk released " "on %s" , locker->loc.path); } while (0) | ||||||
332 | "on %s", locker->loc.path)do { do { if (0) printf ("inodelk released " "on %s", locker-> loc.path); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 332, GF_LOG_INFO, "inodelk released " "on %s" , locker->loc.path); } while (0); | ||||||
333 | |||||||
334 | STACK_WIND (tmp_frame, server_nop_cbk, bound_xl,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 337 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->inodelk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->inodelk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->inodelk); bound_xl->fops->inodelk (_new, bound_xl , locker->volume, &(locker->loc), 13, &flock, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
335 | bound_xl->fops->inodelk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 337 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->inodelk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->inodelk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->inodelk); bound_xl->fops->inodelk (_new, bound_xl , locker->volume, &(locker->loc), 13, &flock, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
336 | locker->volume,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 337 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->inodelk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->inodelk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->inodelk); bound_xl->fops->inodelk (_new, bound_xl , locker->volume, &(locker->loc), 13, &flock, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
337 | &(locker->loc), F_SETLK, &flock, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 337 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->inodelk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->inodelk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->inodelk); bound_xl->fops->inodelk (_new, bound_xl , locker->volume, &(locker->loc), 13, &flock, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | ||||||
338 | loc_wipe (&locker->loc); | ||||||
339 | } | ||||||
340 | |||||||
341 | GF_FREE (locker->volume)__gf_free (locker->volume); | ||||||
342 | |||||||
343 | list_del_init (&locker->lockers); | ||||||
344 | GF_FREE (locker)__gf_free (locker); | ||||||
345 | } | ||||||
346 | |||||||
347 | tmp = NULL((void*)0); | ||||||
348 | locker = NULL((void*)0); | ||||||
349 | list_for_each_entry_safe (locker, tmp, &entrylk_lockers, lockers)for (locker = ((typeof(*locker) *)((char *)((&entrylk_lockers )->next)-(unsigned long)(&((typeof(*locker) *)0)->lockers ))), tmp = ((typeof(*locker) *)((char *)(locker->lockers.next )-(unsigned long)(&((typeof(*locker) *)0)->lockers))); &locker->lockers != (&entrylk_lockers); locker = tmp , tmp = ((typeof(*tmp) *)((char *)(tmp->lockers.next)-(unsigned long)(&((typeof(*tmp) *)0)->lockers)))) { | ||||||
350 | tmp_frame = copy_frame (frame); | ||||||
351 | |||||||
352 | tmp_frame->root->pid = 0; | ||||||
353 | tmp_frame->root->trans = server_conn_ref (conn); | ||||||
354 | memset (&tmp_frame->root->lk_owner, 0, sizeof (gf_lkowner_t)); | ||||||
355 | |||||||
356 | if (locker->fd) { | ||||||
357 | GF_ASSERT (locker->fd->inode)do { if (!(locker->fd->inode)) { do { do { if (0) printf ("Assertion failed: " "locker->fd->inode"); } while (0 ); _gf_log_callingfn ("", "server-helpers.c", __FUNCTION__, 357 , GF_LOG_ERROR, "Assertion failed: " "locker->fd->inode" ); } while (0); } } while (0); | ||||||
358 | |||||||
359 | ret = inode_path (locker->fd->inode, NULL((void*)0), &path); | ||||||
360 | |||||||
361 | if (ret > 0) { | ||||||
362 | gf_log (this->name, GF_LOG_INFO, "fentrylk "do { do { if (0) printf ("fentrylk " "released on %s", path); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__ , 363, GF_LOG_INFO, "fentrylk " "released on %s", path); } while (0) | ||||||
363 | "released on %s", path)do { do { if (0) printf ("fentrylk " "released on %s", path); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__ , 363, GF_LOG_INFO, "fentrylk " "released on %s", path); } while (0); | ||||||
364 | GF_FREE (path)__gf_free (path); | ||||||
365 | } else { | ||||||
366 | |||||||
367 | gf_log (this->name, GF_LOG_INFO, "fentrylk "do { do { if (0) printf ("fentrylk " "released on inode with gfid %s" , uuid_utoa (locker->fd->inode->gfid)); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 369 , GF_LOG_INFO, "fentrylk " "released on inode with gfid %s", uuid_utoa (locker->fd->inode->gfid)); } while (0) | ||||||
368 | "released on inode with gfid %s",do { do { if (0) printf ("fentrylk " "released on inode with gfid %s" , uuid_utoa (locker->fd->inode->gfid)); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 369 , GF_LOG_INFO, "fentrylk " "released on inode with gfid %s", uuid_utoa (locker->fd->inode->gfid)); } while (0) | ||||||
369 | uuid_utoa (locker->fd->inode->gfid))do { do { if (0) printf ("fentrylk " "released on inode with gfid %s" , uuid_utoa (locker->fd->inode->gfid)); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 369 , GF_LOG_INFO, "fentrylk " "released on inode with gfid %s", uuid_utoa (locker->fd->inode->gfid)); } while (0); | ||||||
370 | } | ||||||
371 | |||||||
372 | STACK_WIND (tmp_frame, server_nop_cbk, bound_xl,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 376 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->fentrylk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->fentrylk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->fentrylk); bound_xl->fops->fentrylk (_new , bound_xl, locker->volume, locker->fd, ((void*)0), ENTRYLK_UNLOCK , ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
373 | bound_xl->fops->fentrylk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 376 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->fentrylk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->fentrylk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->fentrylk); bound_xl->fops->fentrylk (_new , bound_xl, locker->volume, locker->fd, ((void*)0), ENTRYLK_UNLOCK , ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
374 | locker->volume,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 376 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->fentrylk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->fentrylk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->fentrylk); bound_xl->fops->fentrylk (_new , bound_xl, locker->volume, locker->fd, ((void*)0), ENTRYLK_UNLOCK , ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
375 | locker->fd, NULL,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 376 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->fentrylk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->fentrylk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->fentrylk); bound_xl->fops->fentrylk (_new , bound_xl, locker->volume, locker->fd, ((void*)0), ENTRYLK_UNLOCK , ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
376 | ENTRYLK_UNLOCK, ENTRYLK_WRLCK, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 376 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->fentrylk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->fentrylk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->fentrylk); bound_xl->fops->fentrylk (_new , bound_xl, locker->volume, locker->fd, ((void*)0), ENTRYLK_UNLOCK , ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | ||||||
377 | fd_unref (locker->fd); | ||||||
378 | } else { | ||||||
379 | gf_log (this->name, GF_LOG_INFO, "entrylk released "do { do { if (0) printf ("entrylk released " "on %s", locker-> loc.path); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 380, GF_LOG_INFO, "entrylk released " "on %s" , locker->loc.path); } while (0) | ||||||
380 | "on %s", locker->loc.path)do { do { if (0) printf ("entrylk released " "on %s", locker-> loc.path); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 380, GF_LOG_INFO, "entrylk released " "on %s" , locker->loc.path); } while (0); | ||||||
381 | |||||||
382 | STACK_WIND (tmp_frame, server_nop_cbk, bound_xl,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 386 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->entrylk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->entrylk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->entrylk); bound_xl->fops->entrylk (_new, bound_xl , locker->volume, &(locker->loc), ((void*)0), ENTRYLK_UNLOCK , ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
383 | bound_xl->fops->entrylk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 386 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->entrylk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->entrylk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->entrylk); bound_xl->fops->entrylk (_new, bound_xl , locker->volume, &(locker->loc), ((void*)0), ENTRYLK_UNLOCK , ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
384 | locker->volume,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 386 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->entrylk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->entrylk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->entrylk); bound_xl->fops->entrylk (_new, bound_xl , locker->volume, &(locker->loc), ((void*)0), ENTRYLK_UNLOCK , ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
385 | &(locker->loc), NULL,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 386 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->entrylk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->entrylk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->entrylk); bound_xl->fops->entrylk (_new, bound_xl , locker->volume, &(locker->loc), ((void*)0), ENTRYLK_UNLOCK , ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | ||||||
386 | ENTRYLK_UNLOCK, ENTRYLK_WRLCK, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 386 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->entrylk_cbk) tmp_cbk = server_nop_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->entrylk"; _new->unwind_to = "server_nop_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&tmp_frame->root->stack_lock) ; { _new->next = tmp_frame->root->frames.next; _new-> prev = &tmp_frame->root->frames; if (tmp_frame-> root->frames.next) tmp_frame->root->frames.next-> prev = _new; tmp_frame->root->frames.next = _new; tmp_frame ->ref_count++; } pthread_spin_unlock (&tmp_frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = bound_xl; if (tmp_frame->this ->ctx->measure_latency) gf_latency_begin (_new, bound_xl ->fops->entrylk); bound_xl->fops->entrylk (_new, bound_xl , locker->volume, &(locker->loc), ((void*)0), ENTRYLK_UNLOCK , ENTRYLK_WRLCK, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | ||||||
387 | loc_wipe (&locker->loc); | ||||||
388 | } | ||||||
389 | |||||||
390 | GF_FREE (locker->volume)__gf_free (locker->volume); | ||||||
391 | |||||||
392 | list_del_init (&locker->lockers); | ||||||
393 | GF_FREE (locker)__gf_free (locker); | ||||||
394 | } | ||||||
395 | ret = 0; | ||||||
396 | |||||||
397 | out: | ||||||
398 | return ret; | ||||||
399 | } | ||||||
400 | |||||||
401 | |||||||
402 | static int | ||||||
403 | server_connection_cleanup_flush_cbk (call_frame_t *frame, void *cookie, | ||||||
404 | xlator_t *this, int32_t op_ret, | ||||||
405 | int32_t op_errno, dict_t *xdata) | ||||||
406 | { | ||||||
407 | int32_t ret = -1; | ||||||
408 | fd_t *fd = NULL((void*)0); | ||||||
409 | |||||||
410 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 410, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
411 | GF_VALIDATE_OR_GOTO ("server", cookie, out)do { if (!cookie) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "cookie"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 411, GF_LOG_ERROR , "invalid argument: " "cookie"); } while (0); goto out; } } while (0); | ||||||
412 | GF_VALIDATE_OR_GOTO ("server", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 412, GF_LOG_ERROR , "invalid argument: " "frame"); } while (0); goto out; } } while (0); | ||||||
413 | |||||||
414 | fd = frame->local; | ||||||
415 | |||||||
416 | fd_unref (fd); | ||||||
417 | frame->local = NULL((void*)0); | ||||||
418 | |||||||
419 | if (frame->root->trans) | ||||||
420 | server_conn_unref (frame->root->trans); | ||||||
421 | STACK_DESTROY (frame->root); | ||||||
422 | |||||||
423 | ret = 0; | ||||||
424 | out: | ||||||
425 | return ret; | ||||||
426 | } | ||||||
427 | |||||||
428 | |||||||
429 | int | ||||||
430 | do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame, | ||||||
431 | fdentry_t *fdentries, int fd_count) | ||||||
432 | { | ||||||
433 | fd_t *fd = NULL((void*)0); | ||||||
434 | int i = 0, ret = -1; | ||||||
435 | call_frame_t *tmp_frame = NULL((void*)0); | ||||||
436 | xlator_t *bound_xl = NULL((void*)0); | ||||||
437 | char *path = NULL((void*)0); | ||||||
438 | |||||||
439 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 439, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
440 | GF_VALIDATE_OR_GOTO ("server", conn, out)do { if (!conn) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conn"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 440, GF_LOG_ERROR , "invalid argument: " "conn"); } while (0); goto out; } } while (0); | ||||||
441 | GF_VALIDATE_OR_GOTO ("server", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 441, GF_LOG_ERROR , "invalid argument: " "frame"); } while (0); goto out; } } while (0); | ||||||
442 | GF_VALIDATE_OR_GOTO ("server", fdentries, out)do { if (!fdentries) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fdentries"); } while (0 ); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__ , 442, GF_LOG_ERROR, "invalid argument: " "fdentries"); } while (0); goto out; } } while (0); | ||||||
443 | |||||||
444 | bound_xl = conn->bound_xl; | ||||||
445 | for (i = 0;i < fd_count; i++) { | ||||||
446 | fd = fdentries[i].fd; | ||||||
447 | |||||||
448 | if (fd != NULL((void*)0)) { | ||||||
449 | tmp_frame = copy_frame (frame); | ||||||
450 | if (tmp_frame == NULL((void*)0)) { | ||||||
451 | goto out; | ||||||
452 | } | ||||||
453 | |||||||
454 | GF_ASSERT (fd->inode)do { if (!(fd->inode)) { do { do { if (0) printf ("Assertion failed: " "fd->inode"); } while (0); _gf_log_callingfn ("", "server-helpers.c" , __FUNCTION__, 454, GF_LOG_ERROR, "Assertion failed: " "fd->inode" ); } while (0); } } while (0); | ||||||
455 | |||||||
456 | ret = inode_path (fd->inode, NULL((void*)0), &path); | ||||||
457 | |||||||
458 | if (ret > 0) { | ||||||
459 | gf_log (this->name, GF_LOG_INFO, "fd cleanup on "do { do { if (0) printf ("fd cleanup on " "%s", path); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__ , 460, GF_LOG_INFO, "fd cleanup on " "%s", path); } while (0) | ||||||
460 | "%s", path)do { do { if (0) printf ("fd cleanup on " "%s", path); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__ , 460, GF_LOG_INFO, "fd cleanup on " "%s", path); } while (0); | ||||||
461 | GF_FREE (path)__gf_free (path); | ||||||
462 | } else { | ||||||
463 | |||||||
464 | gf_log (this->name, GF_LOG_INFO, "fd cleanup on"do { do { if (0) printf ("fd cleanup on" " inode with gfid %s" , uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this ->name, "server-helpers.c", __FUNCTION__, 466, GF_LOG_INFO , "fd cleanup on" " inode with gfid %s", uuid_utoa (fd->inode ->gfid)); } while (0) | ||||||
465 | " inode with gfid %s",do { do { if (0) printf ("fd cleanup on" " inode with gfid %s" , uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this ->name, "server-helpers.c", __FUNCTION__, 466, GF_LOG_INFO , "fd cleanup on" " inode with gfid %s", uuid_utoa (fd->inode ->gfid)); } while (0) | ||||||
466 | uuid_utoa (fd->inode->gfid))do { do { if (0) printf ("fd cleanup on" " inode with gfid %s" , uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this ->name, "server-helpers.c", __FUNCTION__, 466, GF_LOG_INFO , "fd cleanup on" " inode with gfid %s", uuid_utoa (fd->inode ->gfid)); } while (0); | ||||||
467 | } | ||||||
468 | |||||||
469 | tmp_frame->local = fd; | ||||||
470 | |||||||
471 | tmp_frame->root->pid = 0; | ||||||
472 | tmp_frame->root->trans = server_conn_ref (conn); | ||||||
473 | memset (&tmp_frame->root->lk_owner, 0, | ||||||
474 | sizeof (gf_lkowner_t)); | ||||||
475 | |||||||
476 | STACK_WIND (tmp_frame,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 478 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->flush_cbk) tmp_cbk = server_connection_cleanup_flush_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->flush"; _new->unwind_to = "server_connection_cleanup_flush_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&tmp_frame-> root->stack_lock); { _new->next = tmp_frame->root-> frames.next; _new->prev = &tmp_frame->root->frames ; if (tmp_frame->root->frames.next) tmp_frame->root-> frames.next->prev = _new; tmp_frame->root->frames.next = _new; tmp_frame->ref_count++; } pthread_spin_unlock (& tmp_frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = bound_xl; if (tmp_frame ->this->ctx->measure_latency) gf_latency_begin (_new , bound_xl->fops->flush); bound_xl->fops->flush ( _new, bound_xl, fd, ((void*)0)); (*__glusterfs_this_location( )) = old_THIS; } while (0) | ||||||
477 | server_connection_cleanup_flush_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 478 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->flush_cbk) tmp_cbk = server_connection_cleanup_flush_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->flush"; _new->unwind_to = "server_connection_cleanup_flush_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&tmp_frame-> root->stack_lock); { _new->next = tmp_frame->root-> frames.next; _new->prev = &tmp_frame->root->frames ; if (tmp_frame->root->frames.next) tmp_frame->root-> frames.next->prev = _new; tmp_frame->root->frames.next = _new; tmp_frame->ref_count++; } pthread_spin_unlock (& tmp_frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = bound_xl; if (tmp_frame ->this->ctx->measure_latency) gf_latency_begin (_new , bound_xl->fops->flush); bound_xl->fops->flush ( _new, bound_xl, fd, ((void*)0)); (*__glusterfs_this_location( )) = old_THIS; } while (0) | ||||||
478 | bound_xl, bound_xl->fops->flush, fd, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (tmp_frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "server-helpers.c", __FUNCTION__, 478 , GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( bound_xl->fops->flush_cbk) tmp_cbk = server_connection_cleanup_flush_cbk ; _new->root = tmp_frame->root; _new->this = bound_xl ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = tmp_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "bound_xl->fops->flush"; _new->unwind_to = "server_connection_cleanup_flush_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&tmp_frame-> root->stack_lock); { _new->next = tmp_frame->root-> frames.next; _new->prev = &tmp_frame->root->frames ; if (tmp_frame->root->frames.next) tmp_frame->root-> frames.next->prev = _new; tmp_frame->root->frames.next = _new; tmp_frame->ref_count++; } pthread_spin_unlock (& tmp_frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = bound_xl; if (tmp_frame ->this->ctx->measure_latency) gf_latency_begin (_new , bound_xl->fops->flush); bound_xl->fops->flush ( _new, bound_xl, fd, ((void*)0)); (*__glusterfs_this_location( )) = old_THIS; } while (0); | ||||||
479 | } | ||||||
480 | } | ||||||
481 | |||||||
482 | GF_FREE (fdentries)__gf_free (fdentries); | ||||||
483 | ret = 0; | ||||||
484 | |||||||
485 | out: | ||||||
486 | return ret; | ||||||
487 | } | ||||||
488 | |||||||
489 | int | ||||||
490 | do_connection_cleanup (xlator_t *this, server_connection_t *conn, | ||||||
491 | struct _lock_table *ltable, fdentry_t *fdentries, int fd_count) | ||||||
492 | { | ||||||
493 | int ret = 0; | ||||||
494 | int saved_ret = 0; | ||||||
495 | call_frame_t *frame = NULL((void*)0); | ||||||
496 | server_state_t *state = NULL((void*)0); | ||||||
497 | |||||||
498 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 498, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
499 | GF_VALIDATE_OR_GOTO ("server", conn, out)do { if (!conn) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conn"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 499, GF_LOG_ERROR , "invalid argument: " "conn"); } while (0); goto out; } } while (0); | ||||||
500 | |||||||
501 | if (!ltable && !fdentries) | ||||||
502 | goto out; | ||||||
503 | |||||||
504 | frame = create_frame (this, this->ctx->pool); | ||||||
505 | if (frame == NULL((void*)0)) { | ||||||
506 | goto out; | ||||||
507 | } | ||||||
508 | |||||||
509 | if (ltable) | ||||||
510 | saved_ret = do_lock_table_cleanup (this, conn, frame, ltable); | ||||||
511 | |||||||
512 | if (fdentries != NULL((void*)0)) { | ||||||
513 | ret = do_fd_cleanup (this, conn, frame, fdentries, fd_count); | ||||||
514 | } | ||||||
515 | |||||||
516 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); | ||||||
517 | GF_FREE (state)__gf_free (state); | ||||||
518 | |||||||
519 | STACK_DESTROY (frame->root); | ||||||
520 | |||||||
521 | if (saved_ret || ret) { | ||||||
522 | ret = -1; | ||||||
523 | } | ||||||
524 | |||||||
525 | out: | ||||||
526 | return ret; | ||||||
527 | } | ||||||
528 | |||||||
529 | |||||||
530 | int | ||||||
531 | server_connection_cleanup (xlator_t *this, server_connection_t *conn, | ||||||
532 | int32_t flags) | ||||||
533 | { | ||||||
534 | struct _lock_table *ltable = NULL((void*)0); | ||||||
535 | fdentry_t *fdentries = NULL((void*)0); | ||||||
536 | uint32_t fd_count = 0; | ||||||
537 | int ret = 0; | ||||||
538 | |||||||
539 | GF_VALIDATE_OR_GOTO (this->name, this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn (this->name, "server-helpers.c", __FUNCTION__, 539, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
Within the expansion of the macro 'GF_VALIDATE_OR_GOTO':
| |||||||
540 | GF_VALIDATE_OR_GOTO (this->name, conn, out)do { if (!conn) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conn"); } while (0); _gf_log_callingfn (this->name, "server-helpers.c", __FUNCTION__, 540, GF_LOG_ERROR , "invalid argument: " "conn"); } while (0); goto out; } } while (0); | ||||||
541 | GF_VALIDATE_OR_GOTO (this->name, flags, out)do { if (!flags) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "flags"); } while (0); _gf_log_callingfn (this->name, "server-helpers.c", __FUNCTION__, 541, GF_LOG_ERROR , "invalid argument: " "flags"); } while (0); goto out; } } while (0); | ||||||
542 | |||||||
543 | pthread_mutex_lock (&conn->lock); | ||||||
544 | { | ||||||
545 | if (conn->ltable && (flags & INTERNAL_LOCKS)) { | ||||||
546 | ltable = conn->ltable; | ||||||
547 | conn->ltable = gf_lock_table_new (); | ||||||
548 | } | ||||||
549 | |||||||
550 | if (conn->fdtable && (flags & POSIX_LOCKS)) | ||||||
551 | fdentries = gf_fd_fdtable_get_all_fds (conn->fdtable, | ||||||
552 | &fd_count); | ||||||
553 | } | ||||||
554 | pthread_mutex_unlock (&conn->lock); | ||||||
555 | |||||||
556 | if (conn->bound_xl) | ||||||
557 | ret = do_connection_cleanup (this, conn, ltable, | ||||||
558 | fdentries, fd_count); | ||||||
559 | |||||||
560 | out: | ||||||
561 | return ret; | ||||||
562 | } | ||||||
563 | |||||||
564 | |||||||
565 | int | ||||||
566 | server_connection_destroy (xlator_t *this, server_connection_t *conn) | ||||||
567 | { | ||||||
568 | xlator_t *bound_xl = NULL((void*)0); | ||||||
569 | int32_t ret = -1; | ||||||
570 | struct list_head inodelk_lockers; | ||||||
571 | struct list_head entrylk_lockers; | ||||||
572 | struct _lock_table *ltable = NULL((void*)0); | ||||||
573 | fdtable_t *fdtable = NULL((void*)0); | ||||||
574 | |||||||
575 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 575, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
576 | GF_VALIDATE_OR_GOTO ("server", conn, out)do { if (!conn) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conn"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 576, GF_LOG_ERROR , "invalid argument: " "conn"); } while (0); goto out; } } while (0); | ||||||
577 | |||||||
578 | bound_xl = (xlator_t *) (conn->bound_xl); | ||||||
579 | |||||||
580 | if (bound_xl) { | ||||||
581 | pthread_mutex_lock (&(conn->lock)); | ||||||
582 | { | ||||||
583 | if (conn->ltable) { | ||||||
584 | ltable = conn->ltable; | ||||||
585 | conn->ltable = NULL((void*)0); | ||||||
586 | } | ||||||
587 | if (conn->fdtable) { | ||||||
588 | fdtable = conn->fdtable; | ||||||
589 | conn->fdtable = NULL((void*)0); | ||||||
590 | } | ||||||
591 | } | ||||||
592 | pthread_mutex_unlock (&conn->lock); | ||||||
593 | |||||||
594 | INIT_LIST_HEAD (&inodelk_lockers)do { (&inodelk_lockers)->next = (&inodelk_lockers) ->prev = &inodelk_lockers; } while (0); | ||||||
595 | INIT_LIST_HEAD (&entrylk_lockers)do { (&entrylk_lockers)->next = (&entrylk_lockers) ->prev = &entrylk_lockers; } while (0); | ||||||
596 | |||||||
597 | if (ltable) { | ||||||
598 | list_splice_init (<able->inodelk_lockers, | ||||||
599 | &inodelk_lockers); | ||||||
600 | |||||||
601 | list_splice_init (<able->entrylk_lockers, | ||||||
602 | &entrylk_lockers); | ||||||
603 | GF_FREE (ltable)__gf_free (ltable); | ||||||
604 | } | ||||||
605 | |||||||
606 | GF_ASSERT (list_empty (&inodelk_lockers))do { if (!(list_empty (&inodelk_lockers))) { do { do { if (0) printf ("Assertion failed: " "list_empty (&inodelk_lockers)" ); } while (0); _gf_log_callingfn ("", "server-helpers.c", __FUNCTION__ , 606, GF_LOG_ERROR, "Assertion failed: " "list_empty (&inodelk_lockers)" ); } while (0); } } while (0); | ||||||
607 | GF_ASSERT (list_empty (&entrylk_lockers))do { if (!(list_empty (&entrylk_lockers))) { do { do { if (0) printf ("Assertion failed: " "list_empty (&entrylk_lockers)" ); } while (0); _gf_log_callingfn ("", "server-helpers.c", __FUNCTION__ , 607, GF_LOG_ERROR, "Assertion failed: " "list_empty (&entrylk_lockers)" ); } while (0); } } while (0); | ||||||
608 | |||||||
609 | if (fdtable) | ||||||
610 | gf_fd_fdtable_destroy (fdtable); | ||||||
611 | } | ||||||
612 | |||||||
613 | gf_log (this->name, GF_LOG_INFO, "destroyed connection of %s",do { do { if (0) printf ("destroyed connection of %s", conn-> id); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 614, GF_LOG_INFO, "destroyed connection of %s" , conn->id); } while (0) | ||||||
614 | conn->id)do { do { if (0) printf ("destroyed connection of %s", conn-> id); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 614, GF_LOG_INFO, "destroyed connection of %s" , conn->id); } while (0); | ||||||
615 | |||||||
616 | pthread_mutex_destroy (&conn->lock); | ||||||
617 | GF_FREE (conn->id)__gf_free (conn->id); | ||||||
618 | GF_FREE (conn)__gf_free (conn); | ||||||
619 | ret = 0; | ||||||
620 | out: | ||||||
621 | return ret; | ||||||
622 | } | ||||||
623 | |||||||
624 | server_connection_t* | ||||||
625 | server_conn_unref (server_connection_t *conn) | ||||||
626 | { | ||||||
627 | server_connection_t *todel = NULL((void*)0); | ||||||
628 | xlator_t *this = NULL((void*)0); | ||||||
629 | |||||||
630 | pthread_mutex_lock (&conn->lock); | ||||||
631 | { | ||||||
632 | conn->ref--; | ||||||
633 | |||||||
634 | if (!conn->ref) { | ||||||
635 | todel = conn; | ||||||
636 | } | ||||||
637 | } | ||||||
638 | pthread_mutex_unlock (&conn->lock); | ||||||
639 | |||||||
640 | if (todel) { | ||||||
641 | this = THIS(*__glusterfs_this_location()); | ||||||
642 | server_connection_destroy (this, todel); | ||||||
643 | conn = NULL((void*)0); | ||||||
644 | } | ||||||
645 | return conn; | ||||||
646 | } | ||||||
647 | |||||||
648 | server_connection_t* | ||||||
649 | server_conn_ref (server_connection_t *conn) | ||||||
650 | { | ||||||
651 | pthread_mutex_lock (&conn->lock); | ||||||
652 | { | ||||||
653 | conn->ref++; | ||||||
654 | } | ||||||
655 | pthread_mutex_unlock (&conn->lock); | ||||||
656 | |||||||
657 | return conn; | ||||||
658 | } | ||||||
659 | |||||||
660 | server_connection_t * | ||||||
661 | server_connection_get (xlator_t *this, const char *id) | ||||||
662 | { | ||||||
663 | server_connection_t *conn = NULL((void*)0); | ||||||
664 | server_connection_t *trav = NULL((void*)0); | ||||||
665 | server_conf_t *conf = NULL((void*)0); | ||||||
666 | |||||||
667 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 667, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
668 | GF_VALIDATE_OR_GOTO ("server", id, out)do { if (!id) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "id"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 668, GF_LOG_ERROR , "invalid argument: " "id"); } while (0); goto out; } } while (0); | ||||||
669 | |||||||
670 | conf = this->private; | ||||||
671 | |||||||
672 | pthread_mutex_lock (&conf->mutex); | ||||||
673 | { | ||||||
674 | list_for_each_entry (trav, &conf->conns, list)for (trav = ((typeof(*trav) *)((char *)((&conf->conns) ->next)-(unsigned long)(&((typeof(*trav) *)0)->list ))); &trav->list != (&conf->conns); trav = ((typeof (*trav) *)((char *)(trav->list.next)-(unsigned long)(& ((typeof(*trav) *)0)->list)))) { | ||||||
675 | if (!strcmp (trav->id, id)) { | ||||||
676 | conn = trav; | ||||||
677 | conn->bind_ref++; | ||||||
678 | goto unlock; | ||||||
679 | } | ||||||
680 | } | ||||||
681 | |||||||
682 | conn = (void *) GF_CALLOC (1, sizeof (*conn),__gf_calloc (1, sizeof (*conn), gf_server_mt_conn_t) | ||||||
683 | gf_server_mt_conn_t)__gf_calloc (1, sizeof (*conn), gf_server_mt_conn_t); | ||||||
684 | if (!conn) | ||||||
685 | goto unlock; | ||||||
686 | |||||||
687 | conn->id = gf_strdup (id); | ||||||
688 | /*'0' denotes uninitialised lock state*/ | ||||||
689 | conn->lk_version = 0; | ||||||
690 | conn->fdtable = gf_fd_fdtable_alloc (); | ||||||
691 | conn->ltable = gf_lock_table_new (); | ||||||
692 | conn->this = this; | ||||||
693 | conn->bind_ref = 1; | ||||||
694 | conn->ref = 1;//when bind_ref becomes 0 it calls conn_unref | ||||||
695 | pthread_mutex_init (&conn->lock, NULL((void*)0)); | ||||||
696 | list_add (&conn->list, &conf->conns); | ||||||
697 | |||||||
698 | } | ||||||
699 | unlock: | ||||||
700 | pthread_mutex_unlock (&conf->mutex); | ||||||
701 | out: | ||||||
702 | return conn; | ||||||
703 | } | ||||||
704 | |||||||
705 | server_connection_t* | ||||||
706 | server_connection_put (xlator_t *this, server_connection_t *conn, | ||||||
707 | gf_boolean_t *detached) | ||||||
708 | { | ||||||
709 | server_conf_t *conf = NULL((void*)0); | ||||||
710 | gf_boolean_t unref = _gf_false; | ||||||
711 | |||||||
712 | if (detached) | ||||||
713 | *detached = _gf_false; | ||||||
714 | conf = this->private; | ||||||
715 | pthread_mutex_lock (&conf->mutex); | ||||||
716 | { | ||||||
717 | conn->bind_ref--; | ||||||
718 | if (!conn->bind_ref) { | ||||||
719 | list_del_init (&conn->list); | ||||||
720 | unref = _gf_true; | ||||||
721 | } | ||||||
722 | } | ||||||
723 | pthread_mutex_unlock (&conf->mutex); | ||||||
724 | if (unref) { | ||||||
725 | gf_log (this->name, GF_LOG_INFO, "Shutting down connection %s",do { do { if (0) printf ("Shutting down connection %s", conn-> id); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 726, GF_LOG_INFO, "Shutting down connection %s" , conn->id); } while (0) | ||||||
726 | conn->id)do { do { if (0) printf ("Shutting down connection %s", conn-> id); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 726, GF_LOG_INFO, "Shutting down connection %s" , conn->id); } while (0); | ||||||
727 | if (detached) | ||||||
728 | *detached = _gf_true; | ||||||
729 | server_conn_unref (conn); | ||||||
730 | conn = NULL((void*)0); | ||||||
731 | } | ||||||
732 | return conn; | ||||||
733 | } | ||||||
734 | |||||||
735 | static call_frame_t * | ||||||
736 | server_alloc_frame (rpcsvc_request_t *req) | ||||||
737 | { | ||||||
738 | call_frame_t *frame = NULL((void*)0); | ||||||
739 | server_state_t *state = NULL((void*)0); | ||||||
740 | server_connection_t *conn = NULL((void*)0); | ||||||
741 | |||||||
742 | GF_VALIDATE_OR_GOTO ("server", req, out)do { if (!req) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "req"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 742, GF_LOG_ERROR , "invalid argument: " "req"); } while (0); goto out; } } while (0); | ||||||
743 | GF_VALIDATE_OR_GOTO ("server", req->trans, out)do { if (!req->trans) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "req->trans"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__ , 743, GF_LOG_ERROR, "invalid argument: " "req->trans"); } while (0); goto out; } } while (0); | ||||||
744 | GF_VALIDATE_OR_GOTO ("server", req->svc, out)do { if (!req->svc) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "req->svc"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__ , 744, GF_LOG_ERROR, "invalid argument: " "req->svc"); } while (0); goto out; } } while (0); | ||||||
745 | GF_VALIDATE_OR_GOTO ("server", req->svc->ctx, out)do { if (!req->svc->ctx) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "req->svc->ctx" ); } while (0); _gf_log_callingfn ("server", "server-helpers.c" , __FUNCTION__, 745, GF_LOG_ERROR, "invalid argument: " "req->svc->ctx" ); } while (0); goto out; } } while (0); | ||||||
746 | |||||||
747 | conn = (server_connection_t *)req->trans->xl_private; | ||||||
748 | GF_VALIDATE_OR_GOTO ("server", conn, out)do { if (!conn) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conn"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 748, GF_LOG_ERROR , "invalid argument: " "conn"); } while (0); goto out; } } while (0); | ||||||
749 | |||||||
750 | frame = create_frame (conn->this, req->svc->ctx->pool); | ||||||
751 | if (!frame) | ||||||
752 | goto out; | ||||||
753 | |||||||
754 | state = GF_CALLOC (1, sizeof (*state), gf_server_mt_state_t)__gf_calloc (1, sizeof (*state), gf_server_mt_state_t); | ||||||
755 | if (!state) | ||||||
756 | goto out; | ||||||
757 | |||||||
758 | if (conn->bound_xl) | ||||||
759 | state->itable = conn->bound_xl->itable; | ||||||
760 | |||||||
761 | state->xprt = rpc_transport_ref (req->trans); | ||||||
762 | state->conn = conn; | ||||||
763 | |||||||
764 | state->resolve.fd_no = -1; | ||||||
765 | state->resolve2.fd_no = -1; | ||||||
766 | |||||||
767 | frame->root->state = state; /* which socket */ | ||||||
768 | frame->root->unique = 0; /* which call */ | ||||||
769 | |||||||
770 | frame->this = conn->this; | ||||||
771 | out: | ||||||
772 | return frame; | ||||||
773 | } | ||||||
774 | |||||||
775 | |||||||
776 | |||||||
777 | call_frame_t * | ||||||
778 | get_frame_from_request (rpcsvc_request_t *req) | ||||||
779 | { | ||||||
780 | call_frame_t *frame = NULL((void*)0); | ||||||
781 | |||||||
782 | GF_VALIDATE_OR_GOTO ("server", req, out)do { if (!req) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "req"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 782, GF_LOG_ERROR , "invalid argument: " "req"); } while (0); goto out; } } while (0); | ||||||
783 | |||||||
784 | frame = server_alloc_frame (req); | ||||||
785 | if (!frame) | ||||||
786 | goto out; | ||||||
787 | |||||||
788 | frame->root->op = req->procnum; | ||||||
789 | frame->root->type = req->type; | ||||||
790 | |||||||
791 | frame->root->unique = req->xid; | ||||||
792 | |||||||
793 | frame->root->uid = req->uid; | ||||||
794 | frame->root->gid = req->gid; | ||||||
795 | frame->root->pid = req->pid; | ||||||
796 | frame->root->trans = server_conn_ref (req->trans->xl_private); | ||||||
797 | frame->root->lk_owner = req->lk_owner; | ||||||
798 | |||||||
799 | server_decode_groups (frame, req); | ||||||
800 | |||||||
801 | frame->local = req; | ||||||
802 | out: | ||||||
803 | return frame; | ||||||
804 | } | ||||||
805 | |||||||
806 | |||||||
807 | int | ||||||
808 | server_build_config (xlator_t *this, server_conf_t *conf) | ||||||
809 | { | ||||||
810 | data_t *data = NULL((void*)0); | ||||||
811 | int ret = -1; | ||||||
812 | struct stat buf = {0,}; | ||||||
813 | |||||||
814 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 814, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
815 | GF_VALIDATE_OR_GOTO ("server", conf, out)do { if (!conf) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conf"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 815, GF_LOG_ERROR , "invalid argument: " "conf"); } while (0); goto out; } } while (0); | ||||||
816 | |||||||
817 | ret = dict_get_int32 (this->options, "inode-lru-limit", | ||||||
818 | &conf->inode_lru_limit); | ||||||
819 | if (ret < 0) { | ||||||
820 | conf->inode_lru_limit = 16384; | ||||||
821 | } | ||||||
822 | |||||||
823 | conf->verify_volfile = 1; | ||||||
824 | data = dict_get (this->options, "verify-volfile-checksum"); | ||||||
825 | if (data) { | ||||||
826 | ret = gf_string2boolean(data->data, &conf->verify_volfile); | ||||||
827 | if (ret != 0) { | ||||||
828 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("wrong value for 'verify-volfile-checksum', " "Neglecting option"); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 830, GF_LOG_WARNING, "wrong value for 'verify-volfile-checksum', " "Neglecting option"); } while (0) | ||||||
829 | "wrong value for 'verify-volfile-checksum', "do { do { if (0) printf ("wrong value for 'verify-volfile-checksum', " "Neglecting option"); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 830, GF_LOG_WARNING, "wrong value for 'verify-volfile-checksum', " "Neglecting option"); } while (0) | ||||||
830 | "Neglecting option")do { do { if (0) printf ("wrong value for 'verify-volfile-checksum', " "Neglecting option"); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 830, GF_LOG_WARNING, "wrong value for 'verify-volfile-checksum', " "Neglecting option"); } while (0); | ||||||
831 | } | ||||||
832 | } | ||||||
833 | |||||||
834 | data = dict_get (this->options, "trace"); | ||||||
835 | if (data) { | ||||||
836 | ret = gf_string2boolean (data->data, &conf->trace); | ||||||
837 | if (ret != 0) { | ||||||
838 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("'trace' takes on only boolean values. " "Neglecting option"); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 840, GF_LOG_WARNING, "'trace' takes on only boolean values. " "Neglecting option"); } while (0) | ||||||
839 | "'trace' takes on only boolean values. "do { do { if (0) printf ("'trace' takes on only boolean values. " "Neglecting option"); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 840, GF_LOG_WARNING, "'trace' takes on only boolean values. " "Neglecting option"); } while (0) | ||||||
840 | "Neglecting option")do { do { if (0) printf ("'trace' takes on only boolean values. " "Neglecting option"); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 840, GF_LOG_WARNING, "'trace' takes on only boolean values. " "Neglecting option"); } while (0); | ||||||
841 | } | ||||||
842 | } | ||||||
843 | |||||||
844 | /* TODO: build_rpc_config (); */ | ||||||
845 | ret = dict_get_int32 (this->options, "limits.transaction-size", | ||||||
846 | &conf->rpc_conf.max_block_size); | ||||||
847 | if (ret < 0) { | ||||||
848 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("defaulting limits.transaction-size to %d" , 4194304); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 850, GF_LOG_TRACE, "defaulting limits.transaction-size to %d" , 4194304); } while (0) | ||||||
849 | "defaulting limits.transaction-size to %d",do { do { if (0) printf ("defaulting limits.transaction-size to %d" , 4194304); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 850, GF_LOG_TRACE, "defaulting limits.transaction-size to %d" , 4194304); } while (0) | ||||||
850 | DEFAULT_BLOCK_SIZE)do { do { if (0) printf ("defaulting limits.transaction-size to %d" , 4194304); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 850, GF_LOG_TRACE, "defaulting limits.transaction-size to %d" , 4194304); } while (0); | ||||||
851 | conf->rpc_conf.max_block_size = DEFAULT_BLOCK_SIZE4194304; | ||||||
852 | } | ||||||
853 | |||||||
854 | data = dict_get (this->options, "config-directory"); | ||||||
855 | if (data) { | ||||||
856 | /* Check whether the specified directory exists, | ||||||
857 | or directory specified is non standard */ | ||||||
858 | ret = stat (data->data, &buf); | ||||||
859 | if ((ret != 0) || !S_ISDIR (buf.st_mode)((((buf.st_mode)) & 0170000) == (0040000))) { | ||||||
860 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Directory '%s' doesn't exist, exiting." , data->data); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 862, GF_LOG_ERROR, "Directory '%s' doesn't exist, exiting." , data->data); } while (0) | ||||||
861 | "Directory '%s' doesn't exist, exiting.",do { do { if (0) printf ("Directory '%s' doesn't exist, exiting." , data->data); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 862, GF_LOG_ERROR, "Directory '%s' doesn't exist, exiting." , data->data); } while (0) | ||||||
862 | data->data)do { do { if (0) printf ("Directory '%s' doesn't exist, exiting." , data->data); } while (0); _gf_log (this->name, "server-helpers.c" , __FUNCTION__, 862, GF_LOG_ERROR, "Directory '%s' doesn't exist, exiting." , data->data); } while (0); | ||||||
863 | ret = -1; | ||||||
864 | goto out; | ||||||
865 | } | ||||||
866 | /* Make sure that conf-dir doesn't contain ".." in path */ | ||||||
867 | if ((gf_strstr (data->data, "/", "..")) == -1) { | ||||||
868 | ret = -1; | ||||||
869 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("%s: invalid conf_dir", data->data ); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__ , 870, GF_LOG_ERROR, "%s: invalid conf_dir", data->data); } while (0) | ||||||
870 | "%s: invalid conf_dir", data->data)do { do { if (0) printf ("%s: invalid conf_dir", data->data ); } while (0); _gf_log (this->name, "server-helpers.c", __FUNCTION__ , 870, GF_LOG_ERROR, "%s: invalid conf_dir", data->data); } while (0); | ||||||
871 | goto out; | ||||||
872 | } | ||||||
873 | |||||||
874 | conf->conf_dir = gf_strdup (data->data); | ||||||
875 | } | ||||||
876 | ret = 0; | ||||||
877 | out: | ||||||
878 | return ret; | ||||||
879 | } | ||||||
880 | |||||||
881 | void | ||||||
882 | put_server_conn_state (xlator_t *this, rpc_transport_t *xprt) | ||||||
883 | { | ||||||
884 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 884, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
885 | GF_VALIDATE_OR_GOTO ("server", xprt, out)do { if (!xprt) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "xprt"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 885, GF_LOG_ERROR , "invalid argument: " "xprt"); } while (0); goto out; } } while (0); | ||||||
886 | |||||||
887 | xprt->xl_private = NULL((void*)0); | ||||||
888 | out: | ||||||
889 | return; | ||||||
890 | } | ||||||
891 | |||||||
892 | server_connection_t * | ||||||
893 | get_server_conn_state (xlator_t *this, rpc_transport_t *xprt) | ||||||
894 | { | ||||||
895 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 895, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
896 | GF_VALIDATE_OR_GOTO ("server", xprt, out)do { if (!xprt) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "xprt"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 896, GF_LOG_ERROR , "invalid argument: " "xprt"); } while (0); goto out; } } while (0); | ||||||
897 | |||||||
898 | return (server_connection_t *)xprt->xl_private; | ||||||
899 | out: | ||||||
900 | return NULL((void*)0); | ||||||
901 | } | ||||||
902 | |||||||
903 | server_connection_t * | ||||||
904 | create_server_conn_state (xlator_t *this, rpc_transport_t *xprt) | ||||||
905 | { | ||||||
906 | server_connection_t *conn = NULL((void*)0); | ||||||
907 | int ret = -1; | ||||||
908 | |||||||
909 | GF_VALIDATE_OR_GOTO ("server", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 909, GF_LOG_ERROR , "invalid argument: " "this"); } while (0); goto out; } } while (0); | ||||||
910 | GF_VALIDATE_OR_GOTO ("server", xprt, out)do { if (!xprt) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "xprt"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 910, GF_LOG_ERROR , "invalid argument: " "xprt"); } while (0); goto out; } } while (0); | ||||||
911 | |||||||
912 | conn = GF_CALLOC (1, sizeof (*conn), gf_server_mt_conn_t)__gf_calloc (1, sizeof (*conn), gf_server_mt_conn_t); | ||||||
913 | if (!conn) | ||||||
914 | goto out; | ||||||
915 | |||||||
916 | pthread_mutex_init (&conn->lock, NULL((void*)0)); | ||||||
917 | |||||||
918 | conn->fdtable = gf_fd_fdtable_alloc (); | ||||||
919 | if (!conn->fdtable) | ||||||
920 | goto out; | ||||||
921 | |||||||
922 | conn->ltable = gf_lock_table_new (); | ||||||
923 | if (!conn->ltable) | ||||||
924 | goto out; | ||||||
925 | |||||||
926 | conn->this = this; | ||||||
927 | |||||||
928 | xprt->xl_private = conn; | ||||||
929 | |||||||
930 | ret = 0; | ||||||
931 | out: | ||||||
932 | if (ret) | ||||||
933 | destroy_server_conn_state (conn); | ||||||
934 | |||||||
935 | return conn; | ||||||
936 | } | ||||||
937 | |||||||
938 | void | ||||||
939 | destroy_server_conn_state (server_connection_t *conn) | ||||||
940 | { | ||||||
941 | GF_VALIDATE_OR_GOTO ("server", conn, out)do { if (!conn) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conn"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 941, GF_LOG_ERROR , "invalid argument: " "conn"); } while (0); goto out; } } while (0); | ||||||
942 | |||||||
943 | if (conn->ltable) { | ||||||
944 | /* TODO */ | ||||||
945 | //FREE (conn->ltable); | ||||||
946 | ; | ||||||
947 | } | ||||||
948 | |||||||
949 | if (conn->fdtable) | ||||||
950 | gf_fd_fdtable_destroy (conn->fdtable); | ||||||
951 | |||||||
952 | pthread_mutex_destroy (&conn->lock); | ||||||
953 | |||||||
954 | GF_FREE (conn)__gf_free (conn); | ||||||
955 | out: | ||||||
956 | return; | ||||||
957 | } | ||||||
958 | |||||||
959 | |||||||
960 | void | ||||||
961 | print_caller (char *str, int size, call_frame_t *frame) | ||||||
962 | { | ||||||
963 | server_state_t *state = NULL((void*)0); | ||||||
964 | |||||||
965 | GF_VALIDATE_OR_GOTO ("server", str, out)do { if (!str) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "str"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 965, GF_LOG_ERROR , "invalid argument: " "str"); } while (0); goto out; } } while (0); | ||||||
966 | GF_VALIDATE_OR_GOTO ("server", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 966, GF_LOG_ERROR , "invalid argument: " "frame"); } while (0); goto out; } } while (0); | ||||||
967 | |||||||
968 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); | ||||||
969 | |||||||
970 | snprintf (str, size, | ||||||
971 | " Callid=%"PRId64"ll" "d"", Client=%s", | ||||||
972 | frame->root->unique, | ||||||
973 | state->xprt->peerinfo.identifier); | ||||||
974 | |||||||
975 | out: | ||||||
976 | return; | ||||||
977 | } | ||||||
978 | |||||||
979 | |||||||
980 | void | ||||||
981 | server_print_resolve (char *str, int size, server_resolve_t *resolve) | ||||||
982 | { | ||||||
983 | int filled = 0; | ||||||
984 | |||||||
985 | GF_VALIDATE_OR_GOTO ("server", str, out)do { if (!str) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "str"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 985, GF_LOG_ERROR , "invalid argument: " "str"); } while (0); goto out; } } while (0); | ||||||
986 | |||||||
987 | if (!resolve) { | ||||||
988 | snprintf (str, size, "<nul>"); | ||||||
989 | return; | ||||||
990 | } | ||||||
991 | |||||||
992 | filled += snprintf (str + filled, size - filled, | ||||||
993 | " Resolve={"); | ||||||
994 | if (resolve->fd_no != -1) | ||||||
995 | filled += snprintf (str + filled, size - filled, | ||||||
996 | "fd=%"PRId64"ll" "d"",", (uint64_t) resolve->fd_no); | ||||||
997 | if (resolve->bname) | ||||||
998 | filled += snprintf (str + filled, size - filled, | ||||||
999 | "bname=%s,", resolve->bname); | ||||||
1000 | if (resolve->path) | ||||||
1001 | filled += snprintf (str + filled, size - filled, | ||||||
1002 | "path=%s", resolve->path); | ||||||
1003 | |||||||
1004 | snprintf (str + filled, size - filled, "}"); | ||||||
1005 | out: | ||||||
1006 | return; | ||||||
1007 | } | ||||||
1008 | |||||||
1009 | |||||||
1010 | void | ||||||
1011 | server_print_loc (char *str, int size, loc_t *loc) | ||||||
1012 | { | ||||||
1013 | int filled = 0; | ||||||
1014 | |||||||
1015 | GF_VALIDATE_OR_GOTO ("server", str, out)do { if (!str) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "str"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 1015, GF_LOG_ERROR , "invalid argument: " "str"); } while (0); goto out; } } while (0); | ||||||
1016 | |||||||
1017 | if (!loc) { | ||||||
1018 | snprintf (str, size, "<nul>"); | ||||||
1019 | return; | ||||||
1020 | } | ||||||
1021 | |||||||
1022 | filled += snprintf (str + filled, size - filled, | ||||||
1023 | " Loc={"); | ||||||
1024 | |||||||
1025 | if (loc->path) | ||||||
1026 | filled += snprintf (str + filled, size - filled, | ||||||
1027 | "path=%s,", loc->path); | ||||||
1028 | if (loc->inode) | ||||||
1029 | filled += snprintf (str + filled, size - filled, | ||||||
1030 | "inode=%p,", loc->inode); | ||||||
1031 | if (loc->parent) | ||||||
1032 | filled += snprintf (str + filled, size - filled, | ||||||
1033 | "parent=%p", loc->parent); | ||||||
1034 | |||||||
1035 | snprintf (str + filled, size - filled, "}"); | ||||||
1036 | out: | ||||||
1037 | return; | ||||||
1038 | } | ||||||
1039 | |||||||
1040 | |||||||
1041 | void | ||||||
1042 | server_print_params (char *str, int size, server_state_t *state) | ||||||
1043 | { | ||||||
1044 | int filled = 0; | ||||||
1045 | |||||||
1046 | GF_VALIDATE_OR_GOTO ("server", str, out)do { if (!str) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "str"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 1046, GF_LOG_ERROR , "invalid argument: " "str"); } while (0); goto out; } } while (0); | ||||||
1047 | |||||||
1048 | filled += snprintf (str + filled, size - filled, | ||||||
1049 | " Params={"); | ||||||
1050 | |||||||
1051 | if (state->fd) | ||||||
1052 | filled += snprintf (str + filled, size - filled, | ||||||
1053 | "fd=%p,", state->fd); | ||||||
1054 | if (state->valid) | ||||||
1055 | filled += snprintf (str + filled, size - filled, | ||||||
1056 | "valid=%d,", state->valid); | ||||||
1057 | if (state->flags) | ||||||
1058 | filled += snprintf (str + filled, size - filled, | ||||||
1059 | "flags=%d,", state->flags); | ||||||
1060 | if (state->wbflags) | ||||||
1061 | filled += snprintf (str + filled, size - filled, | ||||||
1062 | "wbflags=%d,", state->wbflags); | ||||||
1063 | if (state->size) | ||||||
1064 | filled += snprintf (str + filled, size - filled, | ||||||
1065 | "size=%zu,", state->size); | ||||||
1066 | if (state->offset) | ||||||
1067 | filled += snprintf (str + filled, size - filled, | ||||||
1068 | "offset=%"PRId64"ll" "d"",", state->offset); | ||||||
1069 | if (state->cmd) | ||||||
1070 | filled += snprintf (str + filled, size - filled, | ||||||
1071 | "cmd=%d,", state->cmd); | ||||||
1072 | if (state->type) | ||||||
1073 | filled += snprintf (str + filled, size - filled, | ||||||
1074 | "type=%d,", state->type); | ||||||
1075 | if (state->name) | ||||||
1076 | filled += snprintf (str + filled, size - filled, | ||||||
1077 | "name=%s,", state->name); | ||||||
1078 | if (state->mask) | ||||||
1079 | filled += snprintf (str + filled, size - filled, | ||||||
1080 | "mask=%d,", state->mask); | ||||||
1081 | if (state->volume) | ||||||
1082 | filled += snprintf (str + filled, size - filled, | ||||||
1083 | "volume=%s,", state->volume); | ||||||
1084 | |||||||
1085 | snprintf (str + filled, size - filled, | ||||||
1086 | "bound_xl=%s}", state->conn->bound_xl->name); | ||||||
1087 | out: | ||||||
1088 | return; | ||||||
1089 | } | ||||||
1090 | |||||||
1091 | int | ||||||
1092 | server_resolve_is_empty (server_resolve_t *resolve) | ||||||
1093 | { | ||||||
1094 | if (resolve->fd_no != -1) | ||||||
1095 | return 0; | ||||||
1096 | |||||||
1097 | if (resolve->path != 0) | ||||||
1098 | return 0; | ||||||
1099 | |||||||
1100 | if (resolve->bname != 0) | ||||||
1101 | return 0; | ||||||
1102 | |||||||
1103 | return 1; | ||||||
1104 | } | ||||||
1105 | |||||||
1106 | void | ||||||
1107 | server_print_reply (call_frame_t *frame, int op_ret, int op_errno) | ||||||
1108 | { | ||||||
1109 | server_conf_t *conf = NULL((void*)0); | ||||||
1110 | server_state_t *state = NULL((void*)0); | ||||||
1111 | xlator_t *this = NULL((void*)0); | ||||||
1112 | char caller[512]; | ||||||
1113 | char fdstr[32]; | ||||||
1114 | char *op = "UNKNOWN"; | ||||||
1115 | |||||||
1116 | GF_VALIDATE_OR_GOTO ("server", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 1116, GF_LOG_ERROR , "invalid argument: " "frame"); } while (0); goto out; } } while (0); | ||||||
1117 | |||||||
1118 | this = frame->this; | ||||||
1119 | conf = this->private; | ||||||
1120 | |||||||
1121 | GF_VALIDATE_OR_GOTO ("server", conf, out)do { if (!conf) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conf"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 1121, GF_LOG_ERROR , "invalid argument: " "conf"); } while (0); goto out; } } while (0); | ||||||
1122 | GF_VALIDATE_OR_GOTO ("server", conf->trace, out)do { if (!conf->trace) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "conf->trace"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__ , 1122, GF_LOG_ERROR, "invalid argument: " "conf->trace"); } while (0); goto out; } } while (0); | ||||||
1123 | |||||||
1124 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); | ||||||
1125 | |||||||
1126 | print_caller (caller, 256, frame); | ||||||
1127 | |||||||
1128 | switch (frame->root->type) { | ||||||
1129 | case GF_OP_TYPE_FOP: | ||||||
1130 | op = (char *)gf_fop_list[frame->root->op]; | ||||||
1131 | break; | ||||||
1132 | default: | ||||||
1133 | op = ""; | ||||||
1134 | } | ||||||
1135 | |||||||
1136 | fdstr[0] = '\0'; | ||||||
1137 | if (state->fd) | ||||||
1138 | snprintf (fdstr, 32, " fd=%p", state->fd); | ||||||
1139 | |||||||
1140 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("%s%s => (%d, %d)%s", op, caller, op_ret, op_errno, fdstr); } while (0); _gf_log (this->name , "server-helpers.c", __FUNCTION__, 1142, GF_LOG_INFO, "%s%s => (%d, %d)%s" , op, caller, op_ret, op_errno, fdstr); } while (0) | ||||||
1141 | "%s%s => (%d, %d)%s",do { do { if (0) printf ("%s%s => (%d, %d)%s", op, caller, op_ret, op_errno, fdstr); } while (0); _gf_log (this->name , "server-helpers.c", __FUNCTION__, 1142, GF_LOG_INFO, "%s%s => (%d, %d)%s" , op, caller, op_ret, op_errno, fdstr); } while (0) | ||||||
1142 | op, caller, op_ret, op_errno, fdstr)do { do { if (0) printf ("%s%s => (%d, %d)%s", op, caller, op_ret, op_errno, fdstr); } while (0); _gf_log (this->name , "server-helpers.c", __FUNCTION__, 1142, GF_LOG_INFO, "%s%s => (%d, %d)%s" , op, caller, op_ret, op_errno, fdstr); } while (0); | ||||||
1143 | out: | ||||||
1144 | return; | ||||||
1145 | } | ||||||
1146 | |||||||
1147 | |||||||
1148 | void | ||||||
1149 | server_print_request (call_frame_t *frame) | ||||||
1150 | { | ||||||
1151 | server_conf_t *conf = NULL((void*)0); | ||||||
1152 | xlator_t *this = NULL((void*)0); | ||||||
1153 | server_state_t *state = NULL((void*)0); | ||||||
1154 | char resolve_vars[256]; | ||||||
1155 | char resolve2_vars[256]; | ||||||
1156 | char loc_vars[256]; | ||||||
1157 | char loc2_vars[256]; | ||||||
1158 | char other_vars[512]; | ||||||
1159 | char caller[512]; | ||||||
1160 | char *op = "UNKNOWN"; | ||||||
1161 | |||||||
1162 | GF_VALIDATE_OR_GOTO ("server", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 1162, GF_LOG_ERROR , "invalid argument: " "frame"); } while (0); goto out; } } while (0); | ||||||
1163 | |||||||
1164 | this = frame->this; | ||||||
1165 | conf = this->private; | ||||||
1166 | |||||||
1167 | GF_VALIDATE_OR_GOTO ("server", conf, out)do { if (!conf) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conf"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 1167, GF_LOG_ERROR , "invalid argument: " "conf"); } while (0); goto out; } } while (0); | ||||||
1168 | |||||||
1169 | if (!conf->trace) | ||||||
1170 | goto out; | ||||||
1171 | |||||||
1172 | state = CALL_STATE (frame)((server_state_t *)frame->root->state); | ||||||
1173 | |||||||
1174 | memset (resolve_vars, '\0', 256); | ||||||
1175 | memset (resolve2_vars, '\0', 256); | ||||||
1176 | memset (loc_vars, '\0', 256); | ||||||
1177 | memset (loc2_vars, '\0', 256); | ||||||
1178 | memset (other_vars, '\0', 256); | ||||||
1179 | |||||||
1180 | print_caller (caller, 256, frame); | ||||||
1181 | |||||||
1182 | if (!server_resolve_is_empty (&state->resolve)) { | ||||||
1183 | server_print_resolve (resolve_vars, 256, &state->resolve); | ||||||
1184 | server_print_loc (loc_vars, 256, &state->loc); | ||||||
1185 | } | ||||||
1186 | |||||||
1187 | if (!server_resolve_is_empty (&state->resolve2)) { | ||||||
1188 | server_print_resolve (resolve2_vars, 256, &state->resolve2); | ||||||
1189 | server_print_loc (loc2_vars, 256, &state->loc2); | ||||||
1190 | } | ||||||
1191 | |||||||
1192 | server_print_params (other_vars, 512, state); | ||||||
1193 | |||||||
1194 | switch (frame->root->type) { | ||||||
1195 | case GF_OP_TYPE_FOP: | ||||||
1196 | op = (char *)gf_fop_list[frame->root->op]; | ||||||
1197 | break; | ||||||
1198 | default: | ||||||
1199 | op = ""; | ||||||
1200 | break; | ||||||
1201 | } | ||||||
1202 | |||||||
1203 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("%s%s%s%s%s%s%s", op, caller, resolve_vars , loc_vars, resolve2_vars, loc2_vars, other_vars); } while (0 ); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 1206 , GF_LOG_INFO, "%s%s%s%s%s%s%s", op, caller, resolve_vars, loc_vars , resolve2_vars, loc2_vars, other_vars); } while (0) | ||||||
1204 | "%s%s%s%s%s%s%s",do { do { if (0) printf ("%s%s%s%s%s%s%s", op, caller, resolve_vars , loc_vars, resolve2_vars, loc2_vars, other_vars); } while (0 ); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 1206 , GF_LOG_INFO, "%s%s%s%s%s%s%s", op, caller, resolve_vars, loc_vars , resolve2_vars, loc2_vars, other_vars); } while (0) | ||||||
1205 | op, caller,do { do { if (0) printf ("%s%s%s%s%s%s%s", op, caller, resolve_vars , loc_vars, resolve2_vars, loc2_vars, other_vars); } while (0 ); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 1206 , GF_LOG_INFO, "%s%s%s%s%s%s%s", op, caller, resolve_vars, loc_vars , resolve2_vars, loc2_vars, other_vars); } while (0) | ||||||
1206 | resolve_vars, loc_vars, resolve2_vars, loc2_vars, other_vars)do { do { if (0) printf ("%s%s%s%s%s%s%s", op, caller, resolve_vars , loc_vars, resolve2_vars, loc2_vars, other_vars); } while (0 ); _gf_log (this->name, "server-helpers.c", __FUNCTION__, 1206 , GF_LOG_INFO, "%s%s%s%s%s%s%s", op, caller, resolve_vars, loc_vars , resolve2_vars, loc2_vars, other_vars); } while (0); | ||||||
1207 | out: | ||||||
1208 | return; | ||||||
1209 | } | ||||||
1210 | |||||||
1211 | int | ||||||
1212 | serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp) | ||||||
1213 | { | ||||||
1214 | gf_dirent_t *entry = NULL((void*)0); | ||||||
1215 | gfs3_dirplist *trav = NULL((void*)0); | ||||||
1216 | gfs3_dirplist *prev = NULL((void*)0); | ||||||
1217 | int ret = -1; | ||||||
1218 | |||||||
1219 | GF_VALIDATE_OR_GOTO ("server", entries, out)do { if (!entries) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "entries"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 1219, GF_LOG_ERROR , "invalid argument: " "entries"); } while (0); goto out; } } while (0); | ||||||
1220 | GF_VALIDATE_OR_GOTO ("server", rsp, out)do { if (!rsp) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "rsp"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 1220, GF_LOG_ERROR , "invalid argument: " "rsp"); } while (0); goto out; } } while (0); | ||||||
1221 | |||||||
1222 | list_for_each_entry (entry, &entries->list, list)for (entry = ((typeof(*entry) *)((char *)((&entries->list )->next)-(unsigned long)(&((typeof(*entry) *)0)->list ))); &entry->list != (&entries->list); entry = ( (typeof(*entry) *)((char *)(entry->list.next)-(unsigned long )(&((typeof(*entry) *)0)->list)))) { | ||||||
1223 | trav = GF_CALLOC (1, sizeof (*trav), gf_server_mt_dirent_rsp_t)__gf_calloc (1, sizeof (*trav), gf_server_mt_dirent_rsp_t); | ||||||
1224 | if (!trav) | ||||||
1225 | goto out; | ||||||
1226 | |||||||
1227 | trav->d_ino = entry->d_ino; | ||||||
1228 | trav->d_off = entry->d_off; | ||||||
1229 | trav->d_len = entry->d_len; | ||||||
1230 | trav->d_type = entry->d_type; | ||||||
1231 | trav->name = entry->d_name; | ||||||
1232 | |||||||
1233 | gf_stat_from_iatt (&trav->stat, &entry->d_stat); | ||||||
1234 | |||||||
1235 | /* if 'dict' is present, pack it */ | ||||||
1236 | if (entry->dict) { | ||||||
1237 | trav->dict.dict_len = dict_serialized_length (entry->dict); | ||||||
1238 | if (trav->dict.dict_len < 0) { | ||||||
1239 | gf_log (THIS->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to get serialized length " "of reply dict" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "server-helpers.c", __FUNCTION__, 1241, GF_LOG_ERROR, "failed to get serialized length " "of reply dict"); } while (0) | ||||||
1240 | "failed to get serialized length "do { do { if (0) printf ("failed to get serialized length " "of reply dict" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "server-helpers.c", __FUNCTION__, 1241, GF_LOG_ERROR, "failed to get serialized length " "of reply dict"); } while (0) | ||||||
1241 | "of reply dict")do { do { if (0) printf ("failed to get serialized length " "of reply dict" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "server-helpers.c", __FUNCTION__, 1241, GF_LOG_ERROR, "failed to get serialized length " "of reply dict"); } while (0); | ||||||
1242 | errno(*__errno_location ()) = EINVAL22; | ||||||
1243 | trav->dict.dict_len = 0; | ||||||
1244 | goto out; | ||||||
1245 | } | ||||||
1246 | |||||||
1247 | trav->dict.dict_val = GF_CALLOC (1, trav->dict.dict_len,__gf_calloc (1, trav->dict.dict_len, gf_server_mt_rsp_buf_t ) | ||||||
1248 | gf_server_mt_rsp_buf_t)__gf_calloc (1, trav->dict.dict_len, gf_server_mt_rsp_buf_t ); | ||||||
1249 | if (!trav->dict.dict_val) { | ||||||
1250 | errno(*__errno_location ()) = ENOMEM12; | ||||||
1251 | trav->dict.dict_len = 0; | ||||||
1252 | goto out; | ||||||
1253 | } | ||||||
1254 | |||||||
1255 | ret = dict_serialize (entry->dict, trav->dict.dict_val); | ||||||
1256 | if (ret < 0) { | ||||||
1257 | gf_log (THIS->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to serialize reply dict"); } while (0); _gf_log ((*__glusterfs_this_location())->name, "server-helpers.c", __FUNCTION__, 1258, GF_LOG_ERROR, "failed to serialize reply dict" ); } while (0) | ||||||
1258 | "failed to serialize reply dict")do { do { if (0) printf ("failed to serialize reply dict"); } while (0); _gf_log ((*__glusterfs_this_location())->name, "server-helpers.c", __FUNCTION__, 1258, GF_LOG_ERROR, "failed to serialize reply dict" ); } while (0); | ||||||
1259 | errno(*__errno_location ()) = -ret; | ||||||
1260 | trav->dict.dict_len = 0; | ||||||
1261 | goto out; | ||||||
1262 | } | ||||||
1263 | } | ||||||
1264 | |||||||
1265 | if (prev) | ||||||
1266 | prev->nextentry = trav; | ||||||
1267 | else | ||||||
1268 | rsp->reply = trav; | ||||||
1269 | |||||||
1270 | prev = trav; | ||||||
1271 | trav = NULL((void*)0); | ||||||
1272 | } | ||||||
1273 | |||||||
1274 | ret = 0; | ||||||
1275 | out: | ||||||
1276 | GF_FREE (trav)__gf_free (trav); | ||||||
1277 | |||||||
1278 | return ret; | ||||||
1279 | } | ||||||
1280 | |||||||
1281 | |||||||
1282 | int | ||||||
1283 | serialize_rsp_dirent (gf_dirent_t *entries, gfs3_readdir_rsp *rsp) | ||||||
1284 | { | ||||||
1285 | gf_dirent_t *entry = NULL((void*)0); | ||||||
1286 | gfs3_dirlist *trav = NULL((void*)0); | ||||||
1287 | gfs3_dirlist *prev = NULL((void*)0); | ||||||
1288 | int ret = -1; | ||||||
1289 | |||||||
1290 | GF_VALIDATE_OR_GOTO ("server", entries, out)do { if (!entries) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "entries"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 1290, GF_LOG_ERROR , "invalid argument: " "entries"); } while (0); goto out; } } while (0); | ||||||
1291 | GF_VALIDATE_OR_GOTO ("server", rsp, out)do { if (!rsp) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "rsp"); } while (0); _gf_log_callingfn ("server", "server-helpers.c", __FUNCTION__, 1291, GF_LOG_ERROR , "invalid argument: " "rsp"); } while (0); goto out; } } while (0); | ||||||
1292 | |||||||
1293 | list_for_each_entry (entry, &entries->list, list)for (entry = ((typeof(*entry) *)((char *)((&entries->list )->next)-(unsigned long)(&((typeof(*entry) *)0)->list ))); &entry->list != (&entries->list); entry = ( (typeof(*entry) *)((char *)(entry->list.next)-(unsigned long )(&((typeof(*entry) *)0)->list)))) { | ||||||
1294 | trav = GF_CALLOC (1, sizeof (*trav), gf_server_mt_dirent_rsp_t)__gf_calloc (1, sizeof (*trav), gf_server_mt_dirent_rsp_t); | ||||||
1295 | if (!trav) | ||||||
1296 | goto out; | ||||||
1297 | trav->d_ino = entry->d_ino; | ||||||
1298 | trav->d_off = entry->d_off; | ||||||
1299 | trav->d_len = entry->d_len; | ||||||
1300 | trav->d_type = entry->d_type; | ||||||
1301 | trav->name = entry->d_name; | ||||||
1302 | if (prev) | ||||||
1303 | prev->nextentry = trav; | ||||||
1304 | else | ||||||
1305 | rsp->reply = trav; | ||||||
1306 | |||||||
1307 | prev = trav; | ||||||
1308 | } | ||||||
1309 | |||||||
1310 | ret = 0; | ||||||
1311 | out: | ||||||
1312 | return ret; | ||||||
1313 | } | ||||||
1314 | |||||||
1315 | int | ||||||
1316 | readdir_rsp_cleanup (gfs3_readdir_rsp *rsp) | ||||||
1317 | { | ||||||
1318 | gfs3_dirlist *prev = NULL((void*)0); | ||||||
1319 | gfs3_dirlist *trav = NULL((void*)0); | ||||||
1320 | |||||||
1321 | trav = rsp->reply; | ||||||
1322 | prev = trav; | ||||||
1323 | while (trav) { | ||||||
1324 | trav = trav->nextentry; | ||||||
1325 | GF_FREE (prev)__gf_free (prev); | ||||||
1326 | prev = trav; | ||||||
1327 | } | ||||||
1328 | |||||||
1329 | return 0; | ||||||
1330 | } | ||||||
1331 | |||||||
1332 | int | ||||||
1333 | readdirp_rsp_cleanup (gfs3_readdirp_rsp *rsp) | ||||||
1334 | { | ||||||
1335 | gfs3_dirplist *prev = NULL((void*)0); | ||||||
1336 | gfs3_dirplist *trav = NULL((void*)0); | ||||||
1337 | |||||||
1338 | trav = rsp->reply; | ||||||
1339 | prev = trav; | ||||||
1340 | while (trav) { | ||||||
1341 | trav = trav->nextentry; | ||||||
1342 | GF_FREE (prev->dict.dict_val)__gf_free (prev->dict.dict_val); | ||||||
1343 | GF_FREE (prev)__gf_free (prev); | ||||||
1344 | prev = trav; | ||||||
1345 | } | ||||||
1346 | |||||||
1347 | return 0; | ||||||
1348 | } | ||||||
1349 | |||||||
1350 | int | ||||||
1351 | gf_server_check_getxattr_cmd (call_frame_t *frame, const char *key) | ||||||
1352 | { | ||||||
1353 | |||||||
1354 | server_conf_t *conf = NULL((void*)0); | ||||||
1355 | rpc_transport_t *xprt = NULL((void*)0); | ||||||
1356 | |||||||
1357 | conf = frame->this->private; | ||||||
1358 | if (!conf) | ||||||
1359 | return 0; | ||||||
1360 | |||||||
1361 | if (fnmatch ("*list*mount*point*", key, 0) == 0) { | ||||||
1362 | /* list all the client protocol connecting to this process */ | ||||||
1363 | pthread_mutex_lock (&conf->mutex); | ||||||
1364 | { | ||||||
1365 | list_for_each_entry (xprt, &conf->xprt_list, list)for (xprt = ((typeof(*xprt) *)((char *)((&conf->xprt_list )->next)-(unsigned long)(&((typeof(*xprt) *)0)->list ))); &xprt->list != (&conf->xprt_list); xprt = ( (typeof(*xprt) *)((char *)(xprt->list.next)-(unsigned long )(&((typeof(*xprt) *)0)->list)))) { | ||||||
1366 | gf_log ("mount-point-list", GF_LOG_INFO,do { do { if (0) printf ("%s", xprt->peerinfo.identifier); } while (0); _gf_log ("mount-point-list", "server-helpers.c" , __FUNCTION__, 1367, GF_LOG_INFO, "%s", xprt->peerinfo.identifier ); } while (0) | ||||||
1367 | "%s", xprt->peerinfo.identifier)do { do { if (0) printf ("%s", xprt->peerinfo.identifier); } while (0); _gf_log ("mount-point-list", "server-helpers.c" , __FUNCTION__, 1367, GF_LOG_INFO, "%s", xprt->peerinfo.identifier ); } while (0); | ||||||
1368 | } | ||||||
1369 | } | ||||||
1370 | pthread_mutex_unlock (&conf->mutex); | ||||||
1371 | } | ||||||
1372 | |||||||
1373 | /* Add more options/keys here */ | ||||||
1374 | |||||||
1375 | return 0; | ||||||
1376 | } | ||||||
1377 | |||||||
1378 | int | ||||||
1379 | gf_server_check_setxattr_cmd (call_frame_t *frame, dict_t *dict) | ||||||
1380 | { | ||||||
1381 | |||||||
1382 | server_conf_t *conf = NULL((void*)0); | ||||||
1383 | rpc_transport_t *xprt = NULL((void*)0); | ||||||
1384 | uint64_t total_read = 0; | ||||||
1385 | uint64_t total_write = 0; | ||||||
1386 | |||||||
1387 | conf = frame->this->private; | ||||||
1388 | if (!conf || !dict) | ||||||
1389 | return 0; | ||||||
1390 | |||||||
1391 | if (dict_foreach_fnmatch (dict, "*io*stat*dump", | ||||||
1392 | dict_null_foreach_fn, NULL((void*)0) ) > 0) { | ||||||
1393 | list_for_each_entry (xprt, &conf->xprt_list, list)for (xprt = ((typeof(*xprt) *)((char *)((&conf->xprt_list )->next)-(unsigned long)(&((typeof(*xprt) *)0)->list ))); &xprt->list != (&conf->xprt_list); xprt = ( (typeof(*xprt) *)((char *)(xprt->list.next)-(unsigned long )(&((typeof(*xprt) *)0)->list)))) { | ||||||
1394 | total_read += xprt->total_bytes_read; | ||||||
1395 | total_write += xprt->total_bytes_write; | ||||||
1396 | } | ||||||
1397 | gf_log ("stats", GF_LOG_INFO,do { do { if (0) printf ("total-read %""ll" "u"", total-write %" "ll" "u", total_read, total_write); } while (0); _gf_log ("stats" , "server-helpers.c", __FUNCTION__, 1399, GF_LOG_INFO, "total-read %" "ll" "u"", total-write %""ll" "u", total_read, total_write); } while (0) | ||||||
1398 | "total-read %"PRIu64", total-write %"PRIu64,do { do { if (0) printf ("total-read %""ll" "u"", total-write %" "ll" "u", total_read, total_write); } while (0); _gf_log ("stats" , "server-helpers.c", __FUNCTION__, 1399, GF_LOG_INFO, "total-read %" "ll" "u"", total-write %""ll" "u", total_read, total_write); } while (0) | ||||||
1399 | total_read, total_write)do { do { if (0) printf ("total-read %""ll" "u"", total-write %" "ll" "u", total_read, total_write); } while (0); _gf_log ("stats" , "server-helpers.c", __FUNCTION__, 1399, GF_LOG_INFO, "total-read %" "ll" "u"", total-write %""ll" "u", total_read, total_write); } while (0); | ||||||
1400 | } | ||||||
1401 | |||||||
1402 | return 0; | ||||||
1403 | } | ||||||
1404 | |||||||
1405 | gf_boolean_t | ||||||
1406 | server_cancel_conn_timer (xlator_t *this, server_connection_t *conn) | ||||||
1407 | { | ||||||
1408 | gf_timer_t *timer = NULL((void*)0); | ||||||
1409 | gf_boolean_t cancelled = _gf_false; | ||||||
1410 | |||||||
1411 | if (!this || !conn) { | ||||||
1412 | gf_log (THIS->name, GF_LOG_ERROR, "Invalid arguments to "do { do { if (0) printf ("Invalid arguments to " "cancel connection timer" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "server-helpers.c", __FUNCTION__, 1413, GF_LOG_ERROR, "Invalid arguments to " "cancel connection timer"); } while (0) | ||||||
1413 | "cancel connection timer")do { do { if (0) printf ("Invalid arguments to " "cancel connection timer" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "server-helpers.c", __FUNCTION__, 1413, GF_LOG_ERROR, "Invalid arguments to " "cancel connection timer"); } while (0); | ||||||
1414 | return cancelled; | ||||||
1415 | } | ||||||
1416 | |||||||
1417 | pthread_mutex_lock (&conn->lock); | ||||||
1418 | { | ||||||
1419 | if (!conn->timer) | ||||||
1420 | goto unlock; | ||||||
1421 | |||||||
1422 | timer = conn->timer; | ||||||
1423 | conn->timer = NULL((void*)0); | ||||||
1424 | } | ||||||
1425 | unlock: | ||||||
1426 | pthread_mutex_unlock (&conn->lock); | ||||||
1427 | |||||||
1428 | if (timer) { | ||||||
1429 | gf_timer_call_cancel (this->ctx, timer); | ||||||
1430 | cancelled = _gf_true; | ||||||
1431 | } | ||||||
1432 | return cancelled; | ||||||
1433 | } |