File: | xlators/features/locks/src/posix.c |
Location: | line 1122, column 17 |
Description: | Function call argument is an uninitialized value |
1 | /* | |||
2 | Copyright (c) 2006-2012 Red Hat, Inc. <http://www.redhat.com> | |||
3 | This file is part of GlusterFS. | |||
4 | ||||
5 | This file is licensed to you under your choice of the GNU Lesser | |||
6 | General Public License, version 3 or any later version (LGPLv3 or | |||
7 | later), or the GNU General Public License, version 2 (GPLv2), in all | |||
8 | cases as published by the Free Software Foundation. | |||
9 | */ | |||
10 | #include <unistd.h> | |||
11 | #include <fcntl.h> | |||
12 | #include <limits.h> | |||
13 | #include <pthread.h> | |||
14 | ||||
15 | #ifndef _CONFIG_H | |||
16 | #define _CONFIG_H | |||
17 | #include "config.h" | |||
18 | #endif | |||
19 | ||||
20 | #include "glusterfs.h" | |||
21 | #include "compat.h" | |||
22 | #include "xlator.h" | |||
23 | #include "inode.h" | |||
24 | #include "logging.h" | |||
25 | #include "common-utils.h" | |||
26 | ||||
27 | #include "locks.h" | |||
28 | #include "common.h" | |||
29 | #include "statedump.h" | |||
30 | #include "clear.h" | |||
31 | #include "defaults.h" | |||
32 | #include "syncop.h" | |||
33 | ||||
34 | #ifndef LLONG_MAX9223372036854775807LL | |||
35 | #define LLONG_MAX9223372036854775807LL LONG_LONG_MAX9223372036854775807LL /* compat with old gcc */ | |||
36 | #endif /* LLONG_MAX */ | |||
37 | ||||
38 | /* Forward declarations */ | |||
39 | ||||
40 | ||||
41 | void do_blocked_rw (pl_inode_t *); | |||
42 | static int __rw_allowable (pl_inode_t *, posix_lock_t *, glusterfs_fop_t); | |||
43 | static int format_brickname(char *); | |||
44 | int pl_lockinfo_get_brickname (xlator_t *, inode_t *, int32_t *); | |||
45 | static int fetch_pathinfo(xlator_t *, inode_t *, int32_t *, char **); | |||
46 | ||||
47 | static pl_fdctx_t * | |||
48 | pl_new_fdctx () | |||
49 | { | |||
50 | pl_fdctx_t *fdctx = NULL((void*)0); | |||
51 | ||||
52 | fdctx = GF_CALLOC (1, sizeof (*fdctx),__gf_calloc (1, sizeof (*fdctx), gf_locks_mt_pl_fdctx_t) | |||
53 | gf_locks_mt_pl_fdctx_t)__gf_calloc (1, sizeof (*fdctx), gf_locks_mt_pl_fdctx_t); | |||
54 | GF_VALIDATE_OR_GOTO (POSIX_LOCKS, fdctx, out)do { if (!fdctx) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "fdctx"); } while (0); _gf_log_callingfn ("posix-locks", "posix.c", __FUNCTION__, 54, GF_LOG_ERROR, "invalid argument: " "fdctx"); } while (0); goto out; } } while (0); | |||
55 | ||||
56 | INIT_LIST_HEAD (&fdctx->locks_list)do { (&fdctx->locks_list)->next = (&fdctx->locks_list )->prev = &fdctx->locks_list; } while (0); | |||
57 | ||||
58 | out: | |||
59 | return fdctx; | |||
60 | } | |||
61 | ||||
62 | static pl_fdctx_t * | |||
63 | pl_check_n_create_fdctx (xlator_t *this, fd_t *fd) | |||
64 | { | |||
65 | int ret = 0; | |||
66 | uint64_t tmp = 0; | |||
67 | pl_fdctx_t *fdctx = NULL((void*)0); | |||
68 | ||||
69 | GF_VALIDATE_OR_GOTO (POSIX_LOCKS, this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("posix-locks", "posix.c", __FUNCTION__, 69, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
70 | GF_VALIDATE_OR_GOTO (this->name, fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn (this->name, "posix.c", __FUNCTION__, 70, GF_LOG_ERROR, "invalid argument: " "fd"); } while (0); goto out; } } while (0); | |||
71 | ||||
72 | LOCK (&fd->lock)pthread_spin_lock (&fd->lock); | |||
73 | { | |||
74 | ret = __fd_ctx_get (fd, this, &tmp); | |||
75 | if ((ret != 0) || (tmp == 0)) { | |||
76 | fdctx = pl_new_fdctx (); | |||
77 | if (fdctx == NULL((void*)0)) { | |||
78 | goto unlock; | |||
79 | } | |||
80 | } | |||
81 | ||||
82 | ret = __fd_ctx_set (fd, this, (uint64_t)(long)fdctx); | |||
83 | if (ret != 0) { | |||
84 | GF_FREE (fdctx)__gf_free (fdctx); | |||
85 | fdctx = NULL((void*)0); | |||
86 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set fd ctx"); } while (0) ; _gf_log (this->name, "posix.c", __FUNCTION__, 87, GF_LOG_DEBUG , "failed to set fd ctx"); } while (0) | |||
87 | "failed to set fd ctx")do { do { if (0) printf ("failed to set fd ctx"); } while (0) ; _gf_log (this->name, "posix.c", __FUNCTION__, 87, GF_LOG_DEBUG , "failed to set fd ctx"); } while (0); | |||
88 | } | |||
89 | } | |||
90 | unlock: | |||
91 | UNLOCK (&fd->lock)pthread_spin_unlock (&fd->lock); | |||
92 | ||||
93 | out: | |||
94 | return fdctx; | |||
95 | } | |||
96 | ||||
97 | int | |||
98 | pl_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
99 | int32_t op_ret, int32_t op_errno, struct iatt *prebuf, | |||
100 | struct iatt *postbuf, dict_t *xdata) | |||
101 | { | |||
102 | pl_local_t *local = NULL((void*)0); | |||
103 | ||||
104 | local = frame->local; | |||
105 | ||||
106 | if (local->op == TRUNCATE) | |||
107 | loc_wipe (&local->loc); | |||
108 | ||||
109 | if (local->xdata) | |||
110 | dict_unref (local->xdata); | |||
111 | if (local->fd) | |||
112 | fd_unref (local->fd); | |||
113 | ||||
114 | STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno,do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 115, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_truncate_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
115 | prebuf, postbuf, xdata)do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 115, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_truncate_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
116 | return 0; | |||
117 | } | |||
118 | ||||
119 | ||||
120 | static int | |||
121 | truncate_allowed (pl_inode_t *pl_inode, | |||
122 | void *transport, pid_t client_pid, | |||
123 | gf_lkowner_t *owner, off_t offset) | |||
124 | { | |||
125 | posix_lock_t *l = NULL((void*)0); | |||
126 | posix_lock_t region = {.list = {0, }, }; | |||
127 | int ret = 1; | |||
128 | ||||
129 | region.fl_start = offset; | |||
130 | region.fl_end = LLONG_MAX9223372036854775807LL; | |||
131 | region.transport = transport; | |||
132 | region.client_pid = client_pid; | |||
133 | region.owner = *owner; | |||
134 | ||||
135 | pthread_mutex_lock (&pl_inode->mutex); | |||
136 | { | |||
137 | list_for_each_entry (l, &pl_inode->ext_list, list)for (l = ((typeof(*l) *)((char *)((&pl_inode->ext_list )->next)-(unsigned long)(&((typeof(*l) *)0)->list)) ); &l->list != (&pl_inode->ext_list); l = ((typeof (*l) *)((char *)(l->list.next)-(unsigned long)(&((typeof (*l) *)0)->list)))) { | |||
138 | if (!l->blocked | |||
139 | && locks_overlap (®ion, l) | |||
140 | && !same_owner (®ion, l)) { | |||
141 | ret = 0; | |||
142 | gf_log (POSIX_LOCKS, GF_LOG_TRACE, "Truncate "do { do { if (0) printf ("Truncate " "allowed"); } while (0); _gf_log ("posix-locks", "posix.c", __FUNCTION__, 143, GF_LOG_TRACE , "Truncate " "allowed"); } while (0) | |||
143 | "allowed")do { do { if (0) printf ("Truncate " "allowed"); } while (0); _gf_log ("posix-locks", "posix.c", __FUNCTION__, 143, GF_LOG_TRACE , "Truncate " "allowed"); } while (0); | |||
144 | break; | |||
145 | } | |||
146 | } | |||
147 | } | |||
148 | pthread_mutex_unlock (&pl_inode->mutex); | |||
149 | ||||
150 | return ret; | |||
151 | } | |||
152 | ||||
153 | ||||
154 | static int | |||
155 | truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
156 | int32_t op_ret, int32_t op_errno, struct iatt *buf, | |||
157 | dict_t *xdata) | |||
158 | { | |||
159 | posix_locks_private_t *priv = NULL((void*)0); | |||
160 | pl_local_t *local = NULL((void*)0); | |||
161 | inode_t *inode = NULL((void*)0); | |||
162 | pl_inode_t *pl_inode = NULL((void*)0); | |||
163 | ||||
164 | ||||
165 | priv = this->private; | |||
166 | local = frame->local; | |||
167 | ||||
168 | if (op_ret != 0) { | |||
169 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("got error (errno=%d, stderror=%s) from child" , op_errno, strerror (op_errno)); } while (0); _gf_log (this-> name, "posix.c", __FUNCTION__, 171, GF_LOG_ERROR, "got error (errno=%d, stderror=%s) from child" , op_errno, strerror (op_errno)); } while (0) | |||
170 | "got error (errno=%d, stderror=%s) from child",do { do { if (0) printf ("got error (errno=%d, stderror=%s) from child" , op_errno, strerror (op_errno)); } while (0); _gf_log (this-> name, "posix.c", __FUNCTION__, 171, GF_LOG_ERROR, "got error (errno=%d, stderror=%s) from child" , op_errno, strerror (op_errno)); } while (0) | |||
171 | op_errno, strerror (op_errno))do { do { if (0) printf ("got error (errno=%d, stderror=%s) from child" , op_errno, strerror (op_errno)); } while (0); _gf_log (this-> name, "posix.c", __FUNCTION__, 171, GF_LOG_ERROR, "got error (errno=%d, stderror=%s) from child" , op_errno, strerror (op_errno)); } while (0); | |||
172 | goto unwind; | |||
173 | } | |||
174 | ||||
175 | if (local->op == TRUNCATE) | |||
176 | inode = local->loc.inode; | |||
177 | else | |||
178 | inode = local->fd->inode; | |||
179 | ||||
180 | pl_inode = pl_inode_get (this, inode); | |||
181 | if (!pl_inode) { | |||
182 | op_ret = -1; | |||
183 | op_errno = ENOMEM12; | |||
184 | goto unwind; | |||
185 | } | |||
186 | ||||
187 | if (priv->mandatory | |||
188 | && pl_inode->mandatory | |||
189 | && !truncate_allowed (pl_inode, frame->root->trans, | |||
190 | frame->root->pid, &frame->root->lk_owner, | |||
191 | local->offset)) { | |||
192 | op_ret = -1; | |||
193 | op_errno = EAGAIN11; | |||
194 | goto unwind; | |||
195 | } | |||
196 | ||||
197 | switch (local->op) { | |||
198 | case TRUNCATE: | |||
199 | STACK_WIND (frame, pl_truncate_cbk, FIRST_CHILD (this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 201, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->truncate_cbk) tmp_cbk = pl_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->truncate" ; _new->unwind_to = "pl_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->truncate); (this->children->xlator )->fops->truncate (_new, (this->children->xlator) , &local->loc, local->offset, local->xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
200 | FIRST_CHILD (this)->fops->truncate,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 201, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->truncate_cbk) tmp_cbk = pl_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->truncate" ; _new->unwind_to = "pl_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->truncate); (this->children->xlator )->fops->truncate (_new, (this->children->xlator) , &local->loc, local->offset, local->xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
201 | &local->loc, local->offset, local->xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 201, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->truncate_cbk) tmp_cbk = pl_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->truncate" ; _new->unwind_to = "pl_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->truncate); (this->children->xlator )->fops->truncate (_new, (this->children->xlator) , &local->loc, local->offset, local->xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
202 | break; | |||
203 | case FTRUNCATE: | |||
204 | STACK_WIND (frame, pl_truncate_cbk, FIRST_CHILD (this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 206, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->ftruncate_cbk) tmp_cbk = pl_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->ftruncate" ; _new->unwind_to = "pl_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->ftruncate); (this->children-> xlator)->fops->ftruncate (_new, (this->children-> xlator), local->fd, local->offset, local->xdata); (* __glusterfs_this_location()) = old_THIS; } while (0) | |||
205 | FIRST_CHILD (this)->fops->ftruncate,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 206, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->ftruncate_cbk) tmp_cbk = pl_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->ftruncate" ; _new->unwind_to = "pl_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->ftruncate); (this->children-> xlator)->fops->ftruncate (_new, (this->children-> xlator), local->fd, local->offset, local->xdata); (* __glusterfs_this_location()) = old_THIS; } while (0) | |||
206 | local->fd, local->offset, local->xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 206, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->ftruncate_cbk) tmp_cbk = pl_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->ftruncate" ; _new->unwind_to = "pl_truncate_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->ftruncate); (this->children-> xlator)->fops->ftruncate (_new, (this->children-> xlator), local->fd, local->offset, local->xdata); (* __glusterfs_this_location()) = old_THIS; } while (0); | |||
207 | break; | |||
208 | } | |||
209 | ||||
210 | return 0; | |||
211 | ||||
212 | unwind: | |||
213 | gf_log (this->name, GF_LOG_ERROR, "truncate failed with ret: %d, "do { do { if (0) printf ("truncate failed with ret: %d, " "error: %s" , op_ret, strerror (op_errno)); } while (0); _gf_log (this-> name, "posix.c", __FUNCTION__, 214, GF_LOG_ERROR, "truncate failed with ret: %d, " "error: %s", op_ret, strerror (op_errno)); } while (0) | |||
214 | "error: %s", op_ret, strerror (op_errno))do { do { if (0) printf ("truncate failed with ret: %d, " "error: %s" , op_ret, strerror (op_errno)); } while (0); _gf_log (this-> name, "posix.c", __FUNCTION__, 214, GF_LOG_ERROR, "truncate failed with ret: %d, " "error: %s", op_ret, strerror (op_errno)); } while (0); | |||
215 | if (local->op == TRUNCATE) | |||
216 | loc_wipe (&local->loc); | |||
217 | if (local->xdata) | |||
218 | dict_unref (local->xdata); | |||
219 | if (local->fd) | |||
220 | fd_unref (local->fd); | |||
221 | ||||
222 | STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno, buf, NULL, xdata)do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 222, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_truncate_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, buf, ((void*)0), xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
223 | return 0; | |||
224 | } | |||
225 | ||||
226 | ||||
227 | int | |||
228 | pl_truncate (call_frame_t *frame, xlator_t *this, | |||
229 | loc_t *loc, off_t offset, dict_t *xdata) | |||
230 | { | |||
231 | pl_local_t *local = NULL((void*)0); | |||
232 | ||||
233 | local = mem_get0 (this->local_pool); | |||
234 | GF_VALIDATE_OR_GOTO (this->name, local, unwind)do { if (!local) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "local"); } while (0); _gf_log_callingfn (this->name, "posix.c", __FUNCTION__, 234, GF_LOG_ERROR, "invalid argument: " "local"); } while (0); goto unwind; } } while (0); | |||
235 | ||||
236 | local->op = TRUNCATE; | |||
237 | local->offset = offset; | |||
238 | loc_copy (&local->loc, loc); | |||
239 | if (xdata) | |||
240 | local->xdata = dict_ref (xdata); | |||
241 | ||||
242 | frame->local = local; | |||
243 | ||||
244 | STACK_WIND (frame, truncate_stat_cbk, FIRST_CHILD (this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 245, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->stat_cbk) tmp_cbk = truncate_stat_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->stat"; _new ->unwind_to = "truncate_stat_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->stat); (this->children->xlator )->fops->stat (_new, (this->children->xlator), loc , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
245 | FIRST_CHILD (this)->fops->stat, loc, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 245, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->stat_cbk) tmp_cbk = truncate_stat_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->stat"; _new ->unwind_to = "truncate_stat_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->stat); (this->children->xlator )->fops->stat (_new, (this->children->xlator), loc , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
246 | ||||
247 | return 0; | |||
248 | ||||
249 | unwind: | |||
250 | gf_log (this->name, GF_LOG_ERROR, "truncate for %s failed with ret: %d, "do { do { if (0) printf ("truncate for %s failed with ret: %d, " "error: %s", loc->path, -1, strerror (12)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 251, GF_LOG_ERROR, "truncate for %s failed with ret: %d, " "error: %s", loc->path, -1, strerror (12)); } while (0) | |||
251 | "error: %s", loc->path, -1, strerror (ENOMEM))do { do { if (0) printf ("truncate for %s failed with ret: %d, " "error: %s", loc->path, -1, strerror (12)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 251, GF_LOG_ERROR, "truncate for %s failed with ret: %d, " "error: %s", loc->path, -1, strerror (12)); } while (0); | |||
252 | STACK_UNWIND_STRICT (truncate, frame, -1, ENOMEM, NULL, NULL, NULL)do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 252, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_truncate_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 12, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
253 | ||||
254 | return 0; | |||
255 | } | |||
256 | ||||
257 | ||||
258 | int | |||
259 | pl_ftruncate (call_frame_t *frame, xlator_t *this, | |||
260 | fd_t *fd, off_t offset, dict_t *xdata) | |||
261 | { | |||
262 | pl_local_t *local = NULL((void*)0); | |||
263 | ||||
264 | local = mem_get0 (this->local_pool); | |||
265 | GF_VALIDATE_OR_GOTO (this->name, local, unwind)do { if (!local) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "local"); } while (0); _gf_log_callingfn (this->name, "posix.c", __FUNCTION__, 265, GF_LOG_ERROR, "invalid argument: " "local"); } while (0); goto unwind; } } while (0); | |||
266 | ||||
267 | local->op = FTRUNCATE; | |||
268 | local->offset = offset; | |||
269 | local->fd = fd_ref (fd); | |||
270 | if (xdata) | |||
271 | local->xdata = dict_ref (xdata); | |||
272 | ||||
273 | frame->local = local; | |||
274 | ||||
275 | STACK_WIND (frame, truncate_stat_cbk, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 276, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fstat_cbk) tmp_cbk = truncate_stat_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fstat"; _new ->unwind_to = "truncate_stat_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fstat); (this->children->xlator )->fops->fstat (_new, (this->children->xlator), fd , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||
276 | FIRST_CHILD(this)->fops->fstat, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 276, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fstat_cbk) tmp_cbk = truncate_stat_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fstat"; _new ->unwind_to = "truncate_stat_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fstat); (this->children->xlator )->fops->fstat (_new, (this->children->xlator), fd , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); | |||
277 | return 0; | |||
278 | ||||
279 | unwind: | |||
280 | gf_log (this->name, GF_LOG_ERROR, "ftruncate failed with ret: %d, "do { do { if (0) printf ("ftruncate failed with ret: %d, " "error: %s" , -1, strerror (12)); } while (0); _gf_log (this->name, "posix.c" , __FUNCTION__, 281, GF_LOG_ERROR, "ftruncate failed with ret: %d, " "error: %s", -1, strerror (12)); } while (0) | |||
281 | "error: %s", -1, strerror (ENOMEM))do { do { if (0) printf ("ftruncate failed with ret: %d, " "error: %s" , -1, strerror (12)); } while (0); _gf_log (this->name, "posix.c" , __FUNCTION__, 281, GF_LOG_ERROR, "ftruncate failed with ret: %d, " "error: %s", -1, strerror (12)); } while (0); | |||
282 | STACK_UNWIND_STRICT (ftruncate, frame, -1, ENOMEM, NULL, NULL, NULL)do { fop_ftruncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 282, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_ftruncate_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 12, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
283 | ||||
284 | return 0; | |||
285 | } | |||
286 | ||||
287 | int | |||
288 | pl_locks_by_fd (pl_inode_t *pl_inode, fd_t *fd) | |||
289 | { | |||
290 | posix_lock_t *l = NULL((void*)0); | |||
291 | int found = 0; | |||
292 | ||||
293 | pthread_mutex_lock (&pl_inode->mutex); | |||
294 | { | |||
295 | ||||
296 | list_for_each_entry (l, &pl_inode->ext_list, list)for (l = ((typeof(*l) *)((char *)((&pl_inode->ext_list )->next)-(unsigned long)(&((typeof(*l) *)0)->list)) ); &l->list != (&pl_inode->ext_list); l = ((typeof (*l) *)((char *)(l->list.next)-(unsigned long)(&((typeof (*l) *)0)->list)))) { | |||
297 | if ((l->fd_num == fd_to_fdnum(fd))) { | |||
298 | found = 1; | |||
299 | break; | |||
300 | } | |||
301 | } | |||
302 | ||||
303 | } | |||
304 | pthread_mutex_unlock (&pl_inode->mutex); | |||
305 | return found; | |||
306 | } | |||
307 | ||||
308 | static void | |||
309 | delete_locks_of_fd (xlator_t *this, pl_inode_t *pl_inode, fd_t *fd) | |||
310 | { | |||
311 | posix_lock_t *tmp = NULL((void*)0); | |||
312 | posix_lock_t *l = NULL((void*)0); | |||
313 | ||||
314 | struct list_head blocked_list; | |||
315 | ||||
316 | INIT_LIST_HEAD (&blocked_list)do { (&blocked_list)->next = (&blocked_list)->prev = &blocked_list; } while (0); | |||
317 | ||||
318 | pthread_mutex_lock (&pl_inode->mutex); | |||
319 | { | |||
320 | ||||
321 | list_for_each_entry_safe (l, tmp, &pl_inode->ext_list, list)for (l = ((typeof(*l) *)((char *)((&pl_inode->ext_list )->next)-(unsigned long)(&((typeof(*l) *)0)->list)) ), tmp = ((typeof(*l) *)((char *)(l->list.next)-(unsigned long )(&((typeof(*l) *)0)->list))); &l->list != (& pl_inode->ext_list); l = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->list.next)-(unsigned long)(&((typeof(*tmp) *) 0)->list)))) { | |||
322 | if ((l->fd_num == fd_to_fdnum(fd))) { | |||
323 | if (l->blocked) { | |||
324 | list_move_tail (&l->list, &blocked_list); | |||
325 | continue; | |||
326 | } | |||
327 | __delete_lock (pl_inode, l); | |||
328 | __destroy_lock (l); | |||
329 | } | |||
330 | } | |||
331 | ||||
332 | } | |||
333 | pthread_mutex_unlock (&pl_inode->mutex); | |||
334 | ||||
335 | list_for_each_entry_safe (l, tmp, &blocked_list, list)for (l = ((typeof(*l) *)((char *)((&blocked_list)->next )-(unsigned long)(&((typeof(*l) *)0)->list))), tmp = ( (typeof(*l) *)((char *)(l->list.next)-(unsigned long)(& ((typeof(*l) *)0)->list))); &l->list != (&blocked_list ); l = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->list.next )-(unsigned long)(&((typeof(*tmp) *)0)->list)))) { | |||
336 | list_del_init(&l->list); | |||
337 | STACK_UNWIND_STRICT (lk, l->frame, -1, EAGAIN, &l->user_flock,do { fop_lk_cbk_t fn = ((void*)0); call_frame_t *_parent = (( void*)0); xlator_t *old_THIS = ((void*)0); if (!l->frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 338, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lk_cbk_t )l->frame->ret; _parent = l->frame->parent; pthread_spin_lock (&l-> frame->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&l->frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; l-> frame->complete = _gf_true; l->frame->unwind_from = __FUNCTION__ ; if (l->frame->this->ctx->measure_latency) gf_latency_end (l->frame); fn (_parent, l->frame->cookie, _parent-> this, -1, 11, &l->user_flock, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
338 | NULL)do { fop_lk_cbk_t fn = ((void*)0); call_frame_t *_parent = (( void*)0); xlator_t *old_THIS = ((void*)0); if (!l->frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 338, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lk_cbk_t )l->frame->ret; _parent = l->frame->parent; pthread_spin_lock (&l-> frame->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&l->frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; l-> frame->complete = _gf_true; l->frame->unwind_from = __FUNCTION__ ; if (l->frame->this->ctx->measure_latency) gf_latency_end (l->frame); fn (_parent, l->frame->cookie, _parent-> this, -1, 11, &l->user_flock, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
339 | __destroy_lock (l); | |||
340 | } | |||
341 | ||||
342 | grant_blocked_locks (this, pl_inode); | |||
343 | ||||
344 | do_blocked_rw (pl_inode); | |||
345 | ||||
346 | } | |||
347 | ||||
348 | static void | |||
349 | __delete_locks_of_owner (pl_inode_t *pl_inode, | |||
350 | void *transport, gf_lkowner_t *owner) | |||
351 | { | |||
352 | posix_lock_t *tmp = NULL((void*)0); | |||
353 | posix_lock_t *l = NULL((void*)0); | |||
354 | ||||
355 | /* TODO: what if it is a blocked lock with pending l->frame */ | |||
356 | ||||
357 | list_for_each_entry_safe (l, tmp, &pl_inode->ext_list, list)for (l = ((typeof(*l) *)((char *)((&pl_inode->ext_list )->next)-(unsigned long)(&((typeof(*l) *)0)->list)) ), tmp = ((typeof(*l) *)((char *)(l->list.next)-(unsigned long )(&((typeof(*l) *)0)->list))); &l->list != (& pl_inode->ext_list); l = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->list.next)-(unsigned long)(&((typeof(*tmp) *) 0)->list)))) { | |||
358 | if (l->blocked) | |||
359 | continue; | |||
360 | if ((l->transport == transport) && | |||
361 | is_same_lkowner (&l->owner, owner)) { | |||
362 | gf_log ("posix-locks", GF_LOG_TRACE,do { do { if (0) printf (" Flushing lock" "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" state: %s", l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock.l_len, l->blocked == 1 ? "Blocked" : "Active"); } while (0); _gf_log ("posix-locks" , "posix.c", __FUNCTION__, 370, GF_LOG_TRACE, " Flushing lock" "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %""ll" "d"" state: %s" , l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock .l_len, l->blocked == 1 ? "Blocked" : "Active"); } while ( 0) | |||
363 | " Flushing lock"do { do { if (0) printf (" Flushing lock" "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" state: %s", l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock.l_len, l->blocked == 1 ? "Blocked" : "Active"); } while (0); _gf_log ("posix-locks" , "posix.c", __FUNCTION__, 370, GF_LOG_TRACE, " Flushing lock" "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %""ll" "d"" state: %s" , l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock .l_len, l->blocked == 1 ? "Blocked" : "Active"); } while ( 0) | |||
364 | "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" state: %s",do { do { if (0) printf (" Flushing lock" "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" state: %s", l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock.l_len, l->blocked == 1 ? "Blocked" : "Active"); } while (0); _gf_log ("posix-locks" , "posix.c", __FUNCTION__, 370, GF_LOG_TRACE, " Flushing lock" "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %""ll" "d"" state: %s" , l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock .l_len, l->blocked == 1 ? "Blocked" : "Active"); } while ( 0) | |||
365 | l->fl_type == F_UNLCK ? "Unlock" : "Lock",do { do { if (0) printf (" Flushing lock" "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" state: %s", l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock.l_len, l->blocked == 1 ? "Blocked" : "Active"); } while (0); _gf_log ("posix-locks" , "posix.c", __FUNCTION__, 370, GF_LOG_TRACE, " Flushing lock" "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %""ll" "d"" state: %s" , l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock .l_len, l->blocked == 1 ? "Blocked" : "Active"); } while ( 0) | |||
366 | l->client_pid,do { do { if (0) printf (" Flushing lock" "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" state: %s", l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock.l_len, l->blocked == 1 ? "Blocked" : "Active"); } while (0); _gf_log ("posix-locks" , "posix.c", __FUNCTION__, 370, GF_LOG_TRACE, " Flushing lock" "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %""ll" "d"" state: %s" , l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock .l_len, l->blocked == 1 ? "Blocked" : "Active"); } while ( 0) | |||
367 | lkowner_utoa (&l->owner),do { do { if (0) printf (" Flushing lock" "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" state: %s", l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock.l_len, l->blocked == 1 ? "Blocked" : "Active"); } while (0); _gf_log ("posix-locks" , "posix.c", __FUNCTION__, 370, GF_LOG_TRACE, " Flushing lock" "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %""ll" "d"" state: %s" , l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock .l_len, l->blocked == 1 ? "Blocked" : "Active"); } while ( 0) | |||
368 | l->user_flock.l_start,do { do { if (0) printf (" Flushing lock" "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" state: %s", l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock.l_len, l->blocked == 1 ? "Blocked" : "Active"); } while (0); _gf_log ("posix-locks" , "posix.c", __FUNCTION__, 370, GF_LOG_TRACE, " Flushing lock" "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %""ll" "d"" state: %s" , l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock .l_len, l->blocked == 1 ? "Blocked" : "Active"); } while ( 0) | |||
369 | l->user_flock.l_len,do { do { if (0) printf (" Flushing lock" "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" state: %s", l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock.l_len, l->blocked == 1 ? "Blocked" : "Active"); } while (0); _gf_log ("posix-locks" , "posix.c", __FUNCTION__, 370, GF_LOG_TRACE, " Flushing lock" "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %""ll" "d"" state: %s" , l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock .l_len, l->blocked == 1 ? "Blocked" : "Active"); } while ( 0) | |||
370 | l->blocked == 1 ? "Blocked" : "Active")do { do { if (0) printf (" Flushing lock" "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" state: %s", l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock.l_len, l->blocked == 1 ? "Blocked" : "Active"); } while (0); _gf_log ("posix-locks" , "posix.c", __FUNCTION__, 370, GF_LOG_TRACE, " Flushing lock" "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %""ll" "d"" state: %s" , l->fl_type == 2 ? "Unlock" : "Lock", l->client_pid, lkowner_utoa (&l->owner), l->user_flock.l_start, l->user_flock .l_len, l->blocked == 1 ? "Blocked" : "Active"); } while ( 0); | |||
371 | ||||
372 | __delete_lock (pl_inode, l); | |||
373 | __destroy_lock (l); | |||
374 | } | |||
375 | } | |||
376 | ||||
377 | return; | |||
378 | } | |||
379 | ||||
380 | ||||
381 | int32_t | |||
382 | pl_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
383 | int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) | |||
384 | { | |||
385 | STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict, xdata)do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 385, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, dict, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
386 | return 0; | |||
387 | ||||
388 | } | |||
389 | ||||
390 | int32_t | |||
391 | pl_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, | |||
392 | const char *name, dict_t *xdata) | |||
393 | { | |||
394 | int32_t op_errno = EINVAL22; | |||
395 | int op_ret = -1; | |||
396 | int32_t bcount = 0; | |||
397 | int32_t gcount = 0; | |||
398 | char key[PATH_MAX4096] = {0, }; | |||
399 | char *lk_summary = NULL((void*)0); | |||
400 | pl_inode_t *pl_inode = NULL((void*)0); | |||
401 | dict_t *dict = NULL((void*)0); | |||
402 | clrlk_args args = {0,}; | |||
403 | char *brickname = NULL((void*)0); | |||
404 | ||||
405 | if (!name) | |||
406 | goto usual; | |||
407 | ||||
408 | if (strncmp (name, GF_XATTR_CLRLK_CMD"glusterfs.clrlk", strlen (GF_XATTR_CLRLK_CMD"glusterfs.clrlk"))) | |||
409 | goto usual; | |||
410 | ||||
411 | if (clrlk_parse_args (name, &args)) { | |||
412 | op_errno = EINVAL22; | |||
413 | goto out; | |||
414 | } | |||
415 | ||||
416 | dict = dict_new (); | |||
417 | if (!dict) { | |||
418 | op_errno = ENOMEM12; | |||
419 | goto out; | |||
420 | } | |||
421 | ||||
422 | pl_inode = pl_inode_get (this, loc->inode); | |||
423 | if (!pl_inode) { | |||
424 | op_errno = ENOMEM12; | |||
425 | goto out; | |||
426 | } | |||
427 | ||||
428 | switch (args.type) { | |||
429 | case CLRLK_INODE: | |||
430 | case CLRLK_ENTRY: | |||
431 | op_ret = clrlk_clear_lks_in_all_domains (this, pl_inode, | |||
432 | &args, &bcount, | |||
433 | &gcount, | |||
434 | &op_errno); | |||
435 | if (op_ret) | |||
436 | goto out; | |||
437 | break; | |||
438 | case CLRLK_POSIX: | |||
439 | op_ret = clrlk_clear_posixlk (this, pl_inode, &args, | |||
440 | &bcount, &gcount, | |||
441 | &op_errno); | |||
442 | if (op_ret) | |||
443 | goto out; | |||
444 | break; | |||
445 | case CLRLK_TYPE_MAX: | |||
446 | op_errno = EINVAL22; | |||
447 | goto out; | |||
448 | } | |||
449 | ||||
450 | op_ret = fetch_pathinfo (this, loc->inode, &op_errno, &brickname); | |||
451 | if (op_ret) { | |||
452 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Couldn't get brickname"); } while ( 0); _gf_log (this->name, "posix.c", __FUNCTION__, 453, GF_LOG_WARNING , "Couldn't get brickname"); } while (0) | |||
453 | "Couldn't get brickname")do { do { if (0) printf ("Couldn't get brickname"); } while ( 0); _gf_log (this->name, "posix.c", __FUNCTION__, 453, GF_LOG_WARNING , "Couldn't get brickname"); } while (0); | |||
454 | } else { | |||
455 | op_ret = format_brickname(brickname); | |||
456 | if (op_ret) { | |||
457 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Couldn't format brickname"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 458, GF_LOG_WARNING , "Couldn't format brickname"); } while (0) | |||
458 | "Couldn't format brickname")do { do { if (0) printf ("Couldn't format brickname"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 458, GF_LOG_WARNING , "Couldn't format brickname"); } while (0); | |||
459 | GF_FREE(brickname)__gf_free (brickname); | |||
460 | brickname = NULL((void*)0); | |||
461 | } | |||
462 | } | |||
463 | ||||
464 | if (!gcount && !bcount) { | |||
465 | if (gf_asprintf (&lk_summary, "No locks cleared.") == -1) { | |||
466 | op_ret = -1; | |||
467 | op_errno = ENOMEM12; | |||
468 | goto out; | |||
469 | } | |||
470 | } else if (gf_asprintf (&lk_summary, "%s: %s blocked locks=%d " | |||
471 | "granted locks=%d", | |||
472 | (brickname == NULL((void*)0))? this->name : brickname, | |||
473 | (args.type == CLRLK_INODE)? "inode": | |||
474 | (args.type == CLRLK_ENTRY)? "entry": | |||
475 | (args.type == CLRLK_POSIX)? "posix": " ", | |||
476 | bcount, gcount) == -1) { | |||
477 | op_ret = -1; | |||
478 | op_errno = ENOMEM12; | |||
479 | goto out; | |||
480 | } | |||
481 | ||||
482 | strncpy (key, name, strlen (name)); | |||
483 | if (dict_set_dynstr (dict, key, lk_summary)) { | |||
484 | op_ret = -1; | |||
485 | op_errno = ENOMEM12; | |||
486 | goto out; | |||
487 | } | |||
488 | ||||
489 | op_ret = 0; | |||
490 | out: | |||
491 | GF_FREE(brickname)__gf_free (brickname); | |||
492 | STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict, xdata)do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 492, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, dict, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
493 | ||||
494 | GF_FREE (args.opts)__gf_free (args.opts); | |||
495 | if (op_ret && lk_summary) | |||
496 | GF_FREE (lk_summary)__gf_free (lk_summary); | |||
497 | if (dict) | |||
498 | dict_unref (dict); | |||
499 | return 0; | |||
500 | ||||
501 | usual: | |||
502 | STACK_WIND (frame, pl_getxattr_cbk, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 503, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->getxattr_cbk) tmp_cbk = pl_getxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->getxattr" ; _new->unwind_to = "pl_getxattr_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->getxattr); (this->children->xlator )->fops->getxattr (_new, (this->children->xlator) , loc, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
503 | FIRST_CHILD(this)->fops->getxattr, loc, name, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 503, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->getxattr_cbk) tmp_cbk = pl_getxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->getxattr" ; _new->unwind_to = "pl_getxattr_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->getxattr); (this->children->xlator )->fops->getxattr (_new, (this->children->xlator) , loc, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
504 | return 0; | |||
505 | } | |||
506 | ||||
507 | static int | |||
508 | format_brickname(char *brickname) | |||
509 | { | |||
510 | int ret = -1; | |||
511 | char *hostname = NULL((void*)0); | |||
512 | char *volume = NULL((void*)0); | |||
513 | char *saveptr = NULL((void*)0); | |||
514 | ||||
515 | if (!brickname) | |||
516 | goto out; | |||
517 | ||||
518 | strtok_r(brickname, ":", &saveptr); | |||
519 | hostname = gf_strdup(strtok_r(NULL((void*)0), ":", &saveptr)); | |||
520 | if (hostname == NULL((void*)0)) | |||
521 | goto out; | |||
522 | volume = gf_strdup(strtok_r(NULL((void*)0), ".", &saveptr)); | |||
523 | if (volume == NULL((void*)0)) | |||
524 | goto out; | |||
525 | ||||
526 | sprintf(brickname, "%s:%s", hostname, volume); | |||
527 | ||||
528 | ret = 0; | |||
529 | out: | |||
530 | GF_FREE(hostname)__gf_free (hostname); | |||
531 | GF_FREE(volume)__gf_free (volume); | |||
532 | return ret; | |||
533 | } | |||
534 | ||||
535 | static int | |||
536 | fetch_pathinfo (xlator_t *this, inode_t *inode, int32_t *op_errno, | |||
537 | char **brickname) | |||
538 | { | |||
539 | int ret = -1; | |||
540 | loc_t loc = {0, }; | |||
541 | dict_t *dict = NULL((void*)0); | |||
542 | ||||
543 | if (!brickname) | |||
544 | goto out; | |||
545 | ||||
546 | if (!op_errno) | |||
547 | goto out; | |||
548 | ||||
549 | uuid_copy (loc.gfid, inode->gfid); | |||
550 | loc.inode = inode_ref (inode); | |||
551 | ||||
552 | ret = syncop_getxattr (FIRST_CHILD(this)(this->children->xlator), &loc, &dict, | |||
553 | GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo"); | |||
554 | if (ret < 0) { | |||
555 | *op_errno = errno(*__errno_location ()); | |||
556 | goto out; | |||
557 | } | |||
558 | ||||
559 | ret = dict_get_str (dict, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo", brickname); | |||
560 | if (ret) | |||
561 | goto out; | |||
562 | ||||
563 | *brickname = gf_strdup(*brickname); | |||
564 | if (*brickname == NULL((void*)0)) { | |||
565 | ret = -1; | |||
566 | goto out; | |||
567 | } | |||
568 | ||||
569 | ret = 0; | |||
570 | out: | |||
571 | if (dict != NULL((void*)0)) { | |||
572 | dict_unref (dict); | |||
573 | } | |||
574 | loc_wipe(&loc); | |||
575 | ||||
576 | return ret; | |||
577 | } | |||
578 | ||||
579 | ||||
580 | int | |||
581 | pl_lockinfo_get_brickname (xlator_t *this, inode_t *inode, int32_t *op_errno) | |||
582 | { | |||
583 | int ret = -1; | |||
584 | posix_locks_private_t *priv = NULL((void*)0); | |||
585 | char *brickname = NULL((void*)0); | |||
586 | char *end = NULL((void*)0); | |||
587 | char *tmp = NULL((void*)0); | |||
588 | ||||
589 | priv = this->private; | |||
590 | ||||
591 | ret = fetch_pathinfo (this, inode, op_errno, &brickname); | |||
592 | if (ret) | |||
593 | goto out; | |||
594 | ||||
595 | end = strrchr (brickname, ':'); | |||
596 | if (!end) { | |||
597 | GF_FREE(brickname)__gf_free (brickname); | |||
598 | ret = -1; | |||
599 | goto out; | |||
600 | } | |||
601 | ||||
602 | tmp = brickname; | |||
603 | brickname = gf_strndup (brickname, (end - brickname)); | |||
604 | if (brickname == NULL((void*)0)) { | |||
605 | ret = -1; | |||
606 | goto out; | |||
607 | } | |||
608 | ||||
609 | priv->brickname = brickname; | |||
610 | ret = 0; | |||
611 | out: | |||
612 | GF_FREE(tmp)__gf_free (tmp); | |||
613 | return ret; | |||
614 | } | |||
615 | ||||
616 | char * | |||
617 | pl_lockinfo_key (xlator_t *this, inode_t *inode, int32_t *op_errno) | |||
618 | { | |||
619 | posix_locks_private_t *priv = NULL((void*)0); | |||
620 | char *key = NULL((void*)0); | |||
621 | int ret = 0; | |||
622 | ||||
623 | priv = this->private; | |||
624 | ||||
625 | if (priv->brickname == NULL((void*)0)) { | |||
626 | ret = pl_lockinfo_get_brickname (this, inode, op_errno); | |||
627 | if (ret < 0) { | |||
628 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("cannot get brickname"); } while (0) ; _gf_log (this->name, "posix.c", __FUNCTION__, 629, GF_LOG_WARNING , "cannot get brickname"); } while (0) | |||
629 | "cannot get brickname")do { do { if (0) printf ("cannot get brickname"); } while (0) ; _gf_log (this->name, "posix.c", __FUNCTION__, 629, GF_LOG_WARNING , "cannot get brickname"); } while (0); | |||
630 | goto out; | |||
631 | } | |||
632 | } | |||
633 | ||||
634 | key = priv->brickname; | |||
635 | out: | |||
636 | return key; | |||
637 | } | |||
638 | ||||
639 | int32_t | |||
640 | pl_fgetxattr_handle_lockinfo (xlator_t *this, fd_t *fd, | |||
641 | dict_t *dict, int32_t *op_errno) | |||
642 | { | |||
643 | pl_inode_t *pl_inode = NULL((void*)0); | |||
644 | char *key = NULL((void*)0), *buf = NULL((void*)0); | |||
645 | int32_t op_ret = 0; | |||
646 | unsigned long fdnum = 0, len = 0; | |||
647 | dict_t *tmp = NULL((void*)0); | |||
648 | ||||
649 | pl_inode = pl_inode_get (this, fd->inode); | |||
650 | ||||
651 | if (!pl_inode) { | |||
652 | gf_log (this->name, GF_LOG_DEBUG, "Could not get inode.")do { do { if (0) printf ("Could not get inode."); } while (0) ; _gf_log (this->name, "posix.c", __FUNCTION__, 652, GF_LOG_DEBUG , "Could not get inode."); } while (0); | |||
653 | *op_errno = EBADFD77; | |||
654 | op_ret = -1; | |||
655 | goto out; | |||
656 | } | |||
657 | ||||
658 | if (!pl_locks_by_fd (pl_inode, fd)) { | |||
659 | op_ret = 0; | |||
660 | goto out; | |||
661 | } | |||
662 | ||||
663 | fdnum = fd_to_fdnum (fd); | |||
664 | ||||
665 | key = pl_lockinfo_key (this, fd->inode, op_errno); | |||
666 | if (key == NULL((void*)0)) { | |||
667 | op_ret = -1; | |||
668 | goto out; | |||
669 | } | |||
670 | ||||
671 | tmp = dict_new (); | |||
672 | if (tmp == NULL((void*)0)) { | |||
673 | op_ret = -1; | |||
674 | *op_errno = ENOMEM12; | |||
675 | goto out; | |||
676 | } | |||
677 | ||||
678 | op_ret = dict_set_uint64 (tmp, key, fdnum); | |||
679 | if (op_ret < 0) { | |||
680 | *op_errno = -op_ret; | |||
681 | op_ret = -1; | |||
682 | gf_log (this->name, GF_LOG_WARNING, "setting lockinfo value "do { do { if (0) printf ("setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 685, GF_LOG_WARNING, "setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0) | |||
683 | "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)",do { do { if (0) printf ("setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 685, GF_LOG_WARNING, "setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0) | |||
684 | fdnum, fd, uuid_utoa (fd->inode->gfid),do { do { if (0) printf ("setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 685, GF_LOG_WARNING, "setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0) | |||
685 | strerror (*op_errno))do { do { if (0) printf ("setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 685, GF_LOG_WARNING, "setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0); | |||
686 | goto out; | |||
687 | } | |||
688 | ||||
689 | len = dict_serialized_length (tmp); | |||
690 | if (len < 0) { | |||
691 | *op_errno = -op_ret; | |||
692 | op_ret = -1; | |||
693 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("dict_serialized_length failed (%s) while handling " "lockinfo for fd (ptr:%p inode-gfid:%s)", strerror (*op_errno ), fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 696, GF_LOG_WARNING , "dict_serialized_length failed (%s) while handling " "lockinfo for fd (ptr:%p inode-gfid:%s)" , strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid) ); } while (0) | |||
694 | "dict_serialized_length failed (%s) while handling "do { do { if (0) printf ("dict_serialized_length failed (%s) while handling " "lockinfo for fd (ptr:%p inode-gfid:%s)", strerror (*op_errno ), fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 696, GF_LOG_WARNING , "dict_serialized_length failed (%s) while handling " "lockinfo for fd (ptr:%p inode-gfid:%s)" , strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid) ); } while (0) | |||
695 | "lockinfo for fd (ptr:%p inode-gfid:%s)",do { do { if (0) printf ("dict_serialized_length failed (%s) while handling " "lockinfo for fd (ptr:%p inode-gfid:%s)", strerror (*op_errno ), fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 696, GF_LOG_WARNING , "dict_serialized_length failed (%s) while handling " "lockinfo for fd (ptr:%p inode-gfid:%s)" , strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid) ); } while (0) | |||
696 | strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid))do { do { if (0) printf ("dict_serialized_length failed (%s) while handling " "lockinfo for fd (ptr:%p inode-gfid:%s)", strerror (*op_errno ), fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 696, GF_LOG_WARNING , "dict_serialized_length failed (%s) while handling " "lockinfo for fd (ptr:%p inode-gfid:%s)" , strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid) ); } while (0); | |||
697 | goto out; | |||
698 | } | |||
699 | ||||
700 | buf = GF_CALLOC (1, len, gf_common_mt_char)__gf_calloc (1, len, gf_common_mt_char); | |||
701 | if (buf == NULL((void*)0)) { | |||
702 | op_ret = -1; | |||
703 | *op_errno = ENOMEM12; | |||
704 | goto out; | |||
705 | } | |||
706 | ||||
707 | op_ret = dict_serialize (tmp, buf); | |||
708 | if (op_ret < 0) { | |||
709 | *op_errno = -op_ret; | |||
710 | op_ret = -1; | |||
711 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("dict_serialize failed (%s) while handling lockinfo " "for fd (ptr: %p inode-gfid:%s)", strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name , "posix.c", __FUNCTION__, 714, GF_LOG_WARNING, "dict_serialize failed (%s) while handling lockinfo " "for fd (ptr: %p inode-gfid:%s)", strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid)); } while (0) | |||
712 | "dict_serialize failed (%s) while handling lockinfo "do { do { if (0) printf ("dict_serialize failed (%s) while handling lockinfo " "for fd (ptr: %p inode-gfid:%s)", strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name , "posix.c", __FUNCTION__, 714, GF_LOG_WARNING, "dict_serialize failed (%s) while handling lockinfo " "for fd (ptr: %p inode-gfid:%s)", strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid)); } while (0) | |||
713 | "for fd (ptr: %p inode-gfid:%s)", strerror (*op_errno),do { do { if (0) printf ("dict_serialize failed (%s) while handling lockinfo " "for fd (ptr: %p inode-gfid:%s)", strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name , "posix.c", __FUNCTION__, 714, GF_LOG_WARNING, "dict_serialize failed (%s) while handling lockinfo " "for fd (ptr: %p inode-gfid:%s)", strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid)); } while (0) | |||
714 | fd, uuid_utoa (fd->inode->gfid))do { do { if (0) printf ("dict_serialize failed (%s) while handling lockinfo " "for fd (ptr: %p inode-gfid:%s)", strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name , "posix.c", __FUNCTION__, 714, GF_LOG_WARNING, "dict_serialize failed (%s) while handling lockinfo " "for fd (ptr: %p inode-gfid:%s)", strerror (*op_errno), fd, uuid_utoa (fd->inode->gfid)); } while (0); | |||
715 | goto out; | |||
716 | } | |||
717 | ||||
718 | op_ret = dict_set_dynptr (dict, GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo", buf, len); | |||
719 | if (op_ret < 0) { | |||
720 | *op_errno = -op_ret; | |||
721 | op_ret = -1; | |||
722 | gf_log (this->name, GF_LOG_WARNING, "setting lockinfo value "do { do { if (0) printf ("setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 725, GF_LOG_WARNING, "setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0) | |||
723 | "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)",do { do { if (0) printf ("setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 725, GF_LOG_WARNING, "setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0) | |||
724 | fdnum, fd, uuid_utoa (fd->inode->gfid),do { do { if (0) printf ("setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 725, GF_LOG_WARNING, "setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0) | |||
725 | strerror (*op_errno))do { do { if (0) printf ("setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 725, GF_LOG_WARNING, "setting lockinfo value " "(%lu) for fd (ptr:%p inode-gfid:%s) failed (%s)" , fdnum, fd, uuid_utoa (fd->inode->gfid), strerror (*op_errno )); } while (0); | |||
726 | goto out; | |||
727 | } | |||
728 | ||||
729 | buf = NULL((void*)0); | |||
730 | out: | |||
731 | if (tmp != NULL((void*)0)) { | |||
732 | dict_unref (tmp); | |||
733 | } | |||
734 | ||||
735 | if (buf != NULL((void*)0)) { | |||
736 | GF_FREE (buf)__gf_free (buf); | |||
737 | } | |||
738 | ||||
739 | return op_ret; | |||
740 | } | |||
741 | ||||
742 | ||||
743 | int32_t | |||
744 | pl_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, | |||
745 | const char *name, dict_t *xdata) | |||
746 | { | |||
747 | int32_t op_ret = 0, op_errno = 0; | |||
748 | dict_t *dict = NULL((void*)0); | |||
749 | ||||
750 | if (!name) { | |||
751 | goto usual; | |||
752 | } | |||
753 | ||||
754 | if (strcmp (name, GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo") == 0) { | |||
755 | dict = dict_new (); | |||
756 | if (dict == NULL((void*)0)) { | |||
757 | op_ret = -1; | |||
758 | op_errno = ENOMEM12; | |||
759 | goto unwind; | |||
760 | } | |||
761 | ||||
762 | op_ret = pl_fgetxattr_handle_lockinfo (this, fd, dict, | |||
763 | &op_errno); | |||
764 | if (op_ret < 0) { | |||
765 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("getting lockinfo on fd (ptr:%p inode-gfid:%s) " "failed (%s)", fd, uuid_utoa (fd->inode->gfid), strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 768, GF_LOG_WARNING, "getting lockinfo on fd (ptr:%p inode-gfid:%s) " "failed (%s)", fd, uuid_utoa (fd->inode->gfid), strerror (op_errno)); } while (0) | |||
766 | "getting lockinfo on fd (ptr:%p inode-gfid:%s) "do { do { if (0) printf ("getting lockinfo on fd (ptr:%p inode-gfid:%s) " "failed (%s)", fd, uuid_utoa (fd->inode->gfid), strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 768, GF_LOG_WARNING, "getting lockinfo on fd (ptr:%p inode-gfid:%s) " "failed (%s)", fd, uuid_utoa (fd->inode->gfid), strerror (op_errno)); } while (0) | |||
767 | "failed (%s)", fd, uuid_utoa (fd->inode->gfid),do { do { if (0) printf ("getting lockinfo on fd (ptr:%p inode-gfid:%s) " "failed (%s)", fd, uuid_utoa (fd->inode->gfid), strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 768, GF_LOG_WARNING, "getting lockinfo on fd (ptr:%p inode-gfid:%s) " "failed (%s)", fd, uuid_utoa (fd->inode->gfid), strerror (op_errno)); } while (0) | |||
768 | strerror (op_errno))do { do { if (0) printf ("getting lockinfo on fd (ptr:%p inode-gfid:%s) " "failed (%s)", fd, uuid_utoa (fd->inode->gfid), strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 768, GF_LOG_WARNING, "getting lockinfo on fd (ptr:%p inode-gfid:%s) " "failed (%s)", fd, uuid_utoa (fd->inode->gfid), strerror (op_errno)); } while (0); | |||
769 | } | |||
770 | ||||
771 | goto unwind; | |||
772 | } else { | |||
773 | goto usual; | |||
774 | } | |||
775 | ||||
776 | unwind: | |||
777 | STACK_UNWIND_STRICT (fgetxattr, frame, op_ret, op_errno, dict, NULL)do { fop_fgetxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 777, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fgetxattr_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, dict, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
778 | if (dict != NULL((void*)0)) { | |||
779 | dict_unref (dict); | |||
780 | } | |||
781 | ||||
782 | return 0; | |||
783 | ||||
784 | usual: | |||
785 | STACK_WIND (frame, default_fgetxattr_cbk, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 786, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fgetxattr_cbk) tmp_cbk = default_fgetxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fgetxattr" ; _new->unwind_to = "default_fgetxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fgetxattr); (this->children-> xlator)->fops->fgetxattr (_new, (this->children-> xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
786 | FIRST_CHILD(this)->fops->fgetxattr, fd, name, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 786, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fgetxattr_cbk) tmp_cbk = default_fgetxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fgetxattr" ; _new->unwind_to = "default_fgetxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fgetxattr); (this->children-> xlator)->fops->fgetxattr (_new, (this->children-> xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
787 | return 0; | |||
788 | } | |||
789 | ||||
790 | int32_t | |||
791 | pl_migrate_locks (call_frame_t *frame, fd_t *newfd, uint64_t oldfd_num, | |||
792 | int32_t *op_errno) | |||
793 | { | |||
794 | pl_inode_t *pl_inode = NULL((void*)0); | |||
795 | uint64_t newfd_num = 0; | |||
796 | posix_lock_t *l = NULL((void*)0); | |||
797 | int32_t op_ret = 0; | |||
798 | ||||
799 | newfd_num = fd_to_fdnum (newfd); | |||
800 | ||||
801 | pl_inode = pl_inode_get (frame->this, newfd->inode); | |||
802 | if (pl_inode == NULL((void*)0)) { | |||
803 | op_ret = -1; | |||
804 | *op_errno = EBADFD77; | |||
805 | goto out; | |||
806 | } | |||
807 | ||||
808 | pthread_mutex_lock (&pl_inode->mutex); | |||
809 | { | |||
810 | list_for_each_entry (l, &pl_inode->ext_list, list)for (l = ((typeof(*l) *)((char *)((&pl_inode->ext_list )->next)-(unsigned long)(&((typeof(*l) *)0)->list)) ); &l->list != (&pl_inode->ext_list); l = ((typeof (*l) *)((char *)(l->list.next)-(unsigned long)(&((typeof (*l) *)0)->list)))) { | |||
811 | if (l->fd_num == oldfd_num) { | |||
812 | l->fd_num = newfd_num; | |||
813 | l->transport = frame->root->trans; | |||
814 | } | |||
815 | } | |||
816 | } | |||
817 | pthread_mutex_unlock (&pl_inode->mutex); | |||
818 | ||||
819 | op_ret = 0; | |||
820 | out: | |||
821 | return op_ret; | |||
822 | } | |||
823 | ||||
824 | int32_t | |||
825 | pl_fsetxattr_handle_lockinfo (call_frame_t *frame, fd_t *fd, char *lockinfo_buf, | |||
826 | int len, int32_t *op_errno) | |||
827 | { | |||
828 | int32_t op_ret = -1; | |||
829 | dict_t *lockinfo = NULL((void*)0); | |||
830 | uint64_t oldfd_num = 0; | |||
831 | char *key = NULL((void*)0); | |||
832 | ||||
833 | lockinfo = dict_new (); | |||
834 | if (lockinfo == NULL((void*)0)) { | |||
835 | op_ret = -1; | |||
836 | *op_errno = ENOMEM12; | |||
837 | goto out; | |||
838 | } | |||
839 | ||||
840 | op_ret = dict_unserialize (lockinfo_buf, len, &lockinfo); | |||
841 | if (op_ret < 0) { | |||
842 | *op_errno = -op_ret; | |||
843 | op_ret = -1; | |||
844 | goto out; | |||
845 | } | |||
846 | ||||
847 | key = pl_lockinfo_key (frame->this, fd->inode, op_errno); | |||
848 | if (key == NULL((void*)0)) { | |||
849 | op_ret = -1; | |||
850 | goto out; | |||
851 | } | |||
852 | ||||
853 | op_ret = dict_get_uint64 (lockinfo, key, &oldfd_num); | |||
854 | ||||
855 | if (oldfd_num == 0) { | |||
856 | op_ret = 0; | |||
857 | goto out; | |||
858 | } | |||
859 | ||||
860 | op_ret = pl_migrate_locks (frame, fd, oldfd_num, op_errno); | |||
861 | if (op_ret < 0) { | |||
862 | gf_log (frame->this->name, GF_LOG_WARNING,do { do { if (0) printf ("migration of locks from oldfd (ptr:%p) to newfd " "(ptr:%p) (inode-gfid:%s)", (void *)oldfd_num, fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (frame->this ->name, "posix.c", __FUNCTION__, 865, GF_LOG_WARNING, "migration of locks from oldfd (ptr:%p) to newfd " "(ptr:%p) (inode-gfid:%s)", (void *)oldfd_num, fd, uuid_utoa (fd->inode->gfid)); } while (0) | |||
863 | "migration of locks from oldfd (ptr:%p) to newfd "do { do { if (0) printf ("migration of locks from oldfd (ptr:%p) to newfd " "(ptr:%p) (inode-gfid:%s)", (void *)oldfd_num, fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (frame->this ->name, "posix.c", __FUNCTION__, 865, GF_LOG_WARNING, "migration of locks from oldfd (ptr:%p) to newfd " "(ptr:%p) (inode-gfid:%s)", (void *)oldfd_num, fd, uuid_utoa (fd->inode->gfid)); } while (0) | |||
864 | "(ptr:%p) (inode-gfid:%s)", (void *)oldfd_num, fd,do { do { if (0) printf ("migration of locks from oldfd (ptr:%p) to newfd " "(ptr:%p) (inode-gfid:%s)", (void *)oldfd_num, fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (frame->this ->name, "posix.c", __FUNCTION__, 865, GF_LOG_WARNING, "migration of locks from oldfd (ptr:%p) to newfd " "(ptr:%p) (inode-gfid:%s)", (void *)oldfd_num, fd, uuid_utoa (fd->inode->gfid)); } while (0) | |||
865 | uuid_utoa (fd->inode->gfid))do { do { if (0) printf ("migration of locks from oldfd (ptr:%p) to newfd " "(ptr:%p) (inode-gfid:%s)", (void *)oldfd_num, fd, uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (frame->this ->name, "posix.c", __FUNCTION__, 865, GF_LOG_WARNING, "migration of locks from oldfd (ptr:%p) to newfd " "(ptr:%p) (inode-gfid:%s)", (void *)oldfd_num, fd, uuid_utoa (fd->inode->gfid)); } while (0); | |||
866 | goto out; | |||
867 | } | |||
868 | ||||
869 | out: | |||
870 | dict_unref (lockinfo); | |||
871 | ||||
872 | return op_ret; | |||
873 | } | |||
874 | ||||
875 | int32_t | |||
876 | pl_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, | |||
877 | int32_t flags, dict_t *xdata) | |||
878 | { | |||
879 | int32_t op_ret = 0, op_errno = 0; | |||
880 | void *lockinfo_buf = NULL((void*)0); | |||
881 | int len = 0; | |||
882 | ||||
883 | op_ret = dict_get_ptr_and_len (dict, GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo", | |||
884 | &lockinfo_buf, &len); | |||
885 | if (lockinfo_buf == NULL((void*)0)) { | |||
886 | goto usual; | |||
887 | } | |||
888 | ||||
889 | op_ret = pl_fsetxattr_handle_lockinfo (frame, fd, lockinfo_buf, len, | |||
890 | &op_errno); | |||
891 | if (op_ret < 0) { | |||
892 | goto unwind; | |||
893 | } | |||
894 | ||||
895 | usual: | |||
896 | STACK_WIND (frame, default_fsetxattr_cbk, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 897, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fsetxattr_cbk) tmp_cbk = default_fsetxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fsetxattr" ; _new->unwind_to = "default_fsetxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fsetxattr); (this->children-> xlator)->fops->fsetxattr (_new, (this->children-> xlator), fd, dict, flags, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
897 | FIRST_CHILD(this)->fops->fsetxattr, fd, dict, flags, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 897, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fsetxattr_cbk) tmp_cbk = default_fsetxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fsetxattr" ; _new->unwind_to = "default_fsetxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fsetxattr); (this->children-> xlator)->fops->fsetxattr (_new, (this->children-> xlator), fd, dict, flags, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
898 | return 0; | |||
899 | ||||
900 | unwind: | |||
901 | STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno, NULL)do { fop_fsetxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 901, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fsetxattr_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
902 | return 0; | |||
903 | } | |||
904 | ||||
905 | int32_t | |||
906 | pl_opendir_cbk (call_frame_t *frame, | |||
907 | void *cookie, | |||
908 | xlator_t *this, | |||
909 | int32_t op_ret, | |||
910 | int32_t op_errno, | |||
911 | fd_t *fd, dict_t *xdata) | |||
912 | { | |||
913 | pl_fdctx_t *fdctx = NULL((void*)0); | |||
914 | ||||
915 | if (op_ret < 0) | |||
916 | goto unwind; | |||
917 | ||||
918 | fdctx = pl_check_n_create_fdctx (this, fd); | |||
919 | if (!fdctx) { | |||
920 | op_errno = ENOMEM12; | |||
921 | op_ret = -1; | |||
922 | goto unwind; | |||
923 | } | |||
924 | ||||
925 | unwind: | |||
926 | STACK_UNWIND_STRICT (opendir,do { fop_opendir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 930, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_opendir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
927 | frame,do { fop_opendir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 930, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_opendir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
928 | op_ret,do { fop_opendir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 930, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_opendir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
929 | op_errno,do { fop_opendir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 930, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_opendir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
930 | fd, xdata)do { fop_opendir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 930, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_opendir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
931 | return 0; | |||
932 | } | |||
933 | ||||
934 | int32_t | |||
935 | pl_opendir (call_frame_t *frame, xlator_t *this, | |||
936 | loc_t *loc, fd_t *fd, dict_t *xdata) | |||
937 | { | |||
938 | STACK_WIND (frame,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 942, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->opendir_cbk) tmp_cbk = pl_opendir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->opendir" ; _new->unwind_to = "pl_opendir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->opendir); (this->children->xlator )->fops->opendir (_new, (this->children->xlator), loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
939 | pl_opendir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 942, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->opendir_cbk) tmp_cbk = pl_opendir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->opendir" ; _new->unwind_to = "pl_opendir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->opendir); (this->children->xlator )->fops->opendir (_new, (this->children->xlator), loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
940 | FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 942, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->opendir_cbk) tmp_cbk = pl_opendir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->opendir" ; _new->unwind_to = "pl_opendir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->opendir); (this->children->xlator )->fops->opendir (_new, (this->children->xlator), loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
941 | FIRST_CHILD(this)->fops->opendir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 942, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->opendir_cbk) tmp_cbk = pl_opendir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->opendir" ; _new->unwind_to = "pl_opendir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->opendir); (this->children->xlator )->fops->opendir (_new, (this->children->xlator), loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
942 | loc, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 942, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->opendir_cbk) tmp_cbk = pl_opendir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->opendir" ; _new->unwind_to = "pl_opendir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->opendir); (this->children->xlator )->fops->opendir (_new, (this->children->xlator), loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
943 | return 0; | |||
944 | ||||
945 | } | |||
946 | ||||
947 | int | |||
948 | pl_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
949 | int32_t op_ret, int32_t op_errno, dict_t *xdata) | |||
950 | { | |||
951 | STACK_UNWIND_STRICT (flush, frame, op_ret, op_errno, xdata)do { fop_flush_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 951, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_flush_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
952 | ||||
953 | return 0; | |||
954 | } | |||
955 | ||||
956 | ||||
957 | int | |||
958 | pl_flush (call_frame_t *frame, xlator_t *this, | |||
959 | fd_t *fd, dict_t *xdata) | |||
960 | { | |||
961 | pl_inode_t *pl_inode = NULL((void*)0); | |||
962 | ||||
963 | pl_inode = pl_inode_get (this, fd->inode); | |||
964 | ||||
965 | if (!pl_inode) { | |||
966 | gf_log (this->name, GF_LOG_DEBUG, "Could not get inode.")do { do { if (0) printf ("Could not get inode."); } while (0) ; _gf_log (this->name, "posix.c", __FUNCTION__, 966, GF_LOG_DEBUG , "Could not get inode."); } while (0); | |||
967 | STACK_UNWIND_STRICT (flush, frame, -1, EBADFD, NULL)do { fop_flush_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 967, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_flush_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 77, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
968 | return 0; | |||
969 | } | |||
970 | ||||
971 | pl_trace_flush (this, frame, fd); | |||
972 | ||||
973 | if (frame->root->lk_owner.len == 0) { | |||
974 | /* Handle special case when protocol/server sets lk-owner to zero. | |||
975 | * This usually happens due to a client disconnection. Hence, free | |||
976 | * all locks opened with this fd. | |||
977 | */ | |||
978 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("Releasing all locks with fd %p", fd ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 979, GF_LOG_TRACE, "Releasing all locks with fd %p", fd); } while (0) | |||
979 | "Releasing all locks with fd %p", fd)do { do { if (0) printf ("Releasing all locks with fd %p", fd ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 979, GF_LOG_TRACE, "Releasing all locks with fd %p", fd); } while (0); | |||
980 | delete_locks_of_fd (this, pl_inode, fd); | |||
981 | goto wind; | |||
982 | ||||
983 | } | |||
984 | pthread_mutex_lock (&pl_inode->mutex); | |||
985 | { | |||
986 | __delete_locks_of_owner (pl_inode, frame->root->trans, | |||
987 | &frame->root->lk_owner); | |||
988 | } | |||
989 | pthread_mutex_unlock (&pl_inode->mutex); | |||
990 | ||||
991 | grant_blocked_locks (this, pl_inode); | |||
992 | ||||
993 | do_blocked_rw (pl_inode); | |||
994 | ||||
995 | wind: | |||
996 | STACK_WIND (frame, pl_flush_cbk, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 997, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->flush_cbk) tmp_cbk = pl_flush_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->flush"; _new ->unwind_to = "pl_flush_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (this->children-> xlator); if (frame->this->ctx->measure_latency) gf_latency_begin (_new, (this->children->xlator)->fops->flush); ( this->children->xlator)->fops->flush (_new, (this ->children->xlator), fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
997 | FIRST_CHILD(this)->fops->flush, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 997, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->flush_cbk) tmp_cbk = pl_flush_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->flush"; _new ->unwind_to = "pl_flush_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (this->children-> xlator); if (frame->this->ctx->measure_latency) gf_latency_begin (_new, (this->children->xlator)->fops->flush); ( this->children->xlator)->fops->flush (_new, (this ->children->xlator), fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
998 | return 0; | |||
999 | } | |||
1000 | ||||
1001 | ||||
1002 | int | |||
1003 | pl_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1004 | int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) | |||
1005 | { | |||
1006 | pl_fdctx_t *fdctx = NULL((void*)0); | |||
1007 | ||||
1008 | if (op_ret < 0) | |||
1009 | goto unwind; | |||
1010 | ||||
1011 | fdctx = pl_check_n_create_fdctx (this, fd); | |||
1012 | if (!fdctx) { | |||
1013 | op_errno = ENOMEM12; | |||
1014 | op_ret = -1; | |||
1015 | goto unwind; | |||
1016 | } | |||
1017 | ||||
1018 | unwind: | |||
1019 | STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd, xdata)do { fop_open_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1019, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_open_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1020 | ||||
1021 | return 0; | |||
1022 | } | |||
1023 | ||||
1024 | ||||
1025 | int | |||
1026 | pl_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, | |||
1027 | fd_t *fd, dict_t *xdata) | |||
1028 | { | |||
1029 | STACK_WIND (frame, pl_open_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1031, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->open_cbk) tmp_cbk = pl_open_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->open"; _new ->unwind_to = "pl_open_cbk"; pthread_spin_init (&_new-> lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (this->children-> xlator); if (frame->this->ctx->measure_latency) gf_latency_begin (_new, (this->children->xlator)->fops->open); (this ->children->xlator)->fops->open (_new, (this-> children->xlator), loc, flags, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1030 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->open,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1031, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->open_cbk) tmp_cbk = pl_open_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->open"; _new ->unwind_to = "pl_open_cbk"; pthread_spin_init (&_new-> lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (this->children-> xlator); if (frame->this->ctx->measure_latency) gf_latency_begin (_new, (this->children->xlator)->fops->open); (this ->children->xlator)->fops->open (_new, (this-> children->xlator), loc, flags, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1031 | loc, flags, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1031, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->open_cbk) tmp_cbk = pl_open_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->open"; _new ->unwind_to = "pl_open_cbk"; pthread_spin_init (&_new-> lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = (this->children-> xlator); if (frame->this->ctx->measure_latency) gf_latency_begin (_new, (this->children->xlator)->fops->open); (this ->children->xlator)->fops->open (_new, (this-> children->xlator), loc, flags, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1032 | ||||
1033 | return 0; | |||
1034 | } | |||
1035 | ||||
1036 | ||||
1037 | int | |||
1038 | pl_create_cbk (call_frame_t *frame, void *cookie, | |||
1039 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||
1040 | fd_t *fd, inode_t *inode, struct iatt *buf, | |||
1041 | struct iatt *preparent, struct iatt *postparent, dict_t *xdata) | |||
1042 | { | |||
1043 | pl_fdctx_t *fdctx = NULL((void*)0); | |||
1044 | ||||
1045 | if (op_ret < 0) | |||
1046 | goto unwind; | |||
1047 | ||||
1048 | fdctx = pl_check_n_create_fdctx (this, fd); | |||
1049 | if (!fdctx) { | |||
1050 | op_errno = ENOMEM12; | |||
1051 | op_ret = -1; | |||
1052 | goto unwind; | |||
1053 | } | |||
1054 | ||||
1055 | unwind: | |||
1056 | STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, fd, inode, buf,do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1057, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, inode, buf, preparent, postparent, xdata); (* __glusterfs_this_location()) = old_THIS; } while (0) | |||
1057 | preparent, postparent, xdata)do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1057, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, inode, buf, preparent, postparent, xdata); (* __glusterfs_this_location()) = old_THIS; } while (0); | |||
1058 | ||||
1059 | return 0; | |||
1060 | } | |||
1061 | ||||
1062 | ||||
1063 | int | |||
1064 | pl_create (call_frame_t *frame, xlator_t *this, | |||
1065 | loc_t *loc, int32_t flags, mode_t mode, mode_t umask, fd_t *fd, | |||
1066 | dict_t *xdata) | |||
1067 | { | |||
1068 | STACK_WIND (frame, pl_create_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1070, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->create_cbk) tmp_cbk = pl_create_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->create" ; _new->unwind_to = "pl_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->create); (this->children->xlator )->fops->create (_new, (this->children->xlator), loc , flags, mode, umask, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1069 | FIRST_CHILD (this), FIRST_CHILD (this)->fops->create,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1070, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->create_cbk) tmp_cbk = pl_create_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->create" ; _new->unwind_to = "pl_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->create); (this->children->xlator )->fops->create (_new, (this->children->xlator), loc , flags, mode, umask, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1070 | loc, flags, mode, umask, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1070, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->create_cbk) tmp_cbk = pl_create_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->create" ; _new->unwind_to = "pl_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->create); (this->children->xlator )->fops->create (_new, (this->children->xlator), loc , flags, mode, umask, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1071 | return 0; | |||
1072 | } | |||
1073 | ||||
1074 | ||||
1075 | int | |||
1076 | pl_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1077 | int32_t op_ret, int32_t op_errno, | |||
1078 | struct iovec *vector, int32_t count, struct iatt *stbuf, | |||
1079 | struct iobref *iobref, dict_t *xdata) | |||
1080 | { | |||
1081 | STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno,do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1082, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, vector, count, stbuf, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1082 | vector, count, stbuf, iobref, xdata)do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1082, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, vector, count, stbuf, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1083 | ||||
1084 | return 0; | |||
1085 | } | |||
1086 | ||||
1087 | int | |||
1088 | pl_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1089 | int32_t op_ret, int32_t op_errno, struct iatt *prebuf, | |||
1090 | struct iatt *postbuf, dict_t *xdata) | |||
1091 | { | |||
1092 | STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf,do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1093, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_writev_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1093 | xdata)do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1093, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_writev_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1094 | ||||
1095 | return 0; | |||
1096 | } | |||
1097 | ||||
1098 | ||||
1099 | void | |||
1100 | do_blocked_rw (pl_inode_t *pl_inode) | |||
1101 | { | |||
1102 | struct list_head wind_list; | |||
1103 | pl_rw_req_t *rw = NULL((void*)0); | |||
1104 | pl_rw_req_t *tmp = NULL((void*)0); | |||
1105 | ||||
1106 | INIT_LIST_HEAD (&wind_list)do { (&wind_list)->next = (&wind_list)->prev = & wind_list; } while (0); | |||
1107 | ||||
1108 | pthread_mutex_lock (&pl_inode->mutex); | |||
1109 | { | |||
1110 | list_for_each_entry_safe (rw, tmp, &pl_inode->rw_list, list)for (rw = ((typeof(*rw) *)((char *)((&pl_inode->rw_list )->next)-(unsigned long)(&((typeof(*rw) *)0)->list) )), tmp = ((typeof(*rw) *)((char *)(rw->list.next)-(unsigned long)(&((typeof(*rw) *)0)->list))); &rw->list != (&pl_inode->rw_list); rw = tmp, tmp = ((typeof(*tmp) * )((char *)(tmp->list.next)-(unsigned long)(&((typeof(* tmp) *)0)->list)))) { | |||
1111 | if (__rw_allowable (pl_inode, &rw->region, | |||
1112 | rw->stub->fop)) { | |||
1113 | list_del_init (&rw->list); | |||
1114 | list_add_tail (&rw->list, &wind_list); | |||
1115 | } | |||
1116 | } | |||
1117 | } | |||
1118 | pthread_mutex_unlock (&pl_inode->mutex); | |||
1119 | ||||
1120 | list_for_each_entry_safe (rw, tmp, &wind_list, list)for (rw = ((typeof(*rw) *)((char *)((&wind_list)->next )-(unsigned long)(&((typeof(*rw) *)0)->list))), tmp = ( (typeof(*rw) *)((char *)(rw->list.next)-(unsigned long)(& ((typeof(*rw) *)0)->list))); &rw->list != (&wind_list ); rw = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->list.next )-(unsigned long)(&((typeof(*tmp) *)0)->list)))) { | |||
1121 | list_del_init (&rw->list); | |||
1122 | call_resume (rw->stub); | |||
| ||||
1123 | GF_FREE (rw)__gf_free (rw); | |||
1124 | } | |||
1125 | ||||
1126 | return; | |||
1127 | } | |||
1128 | ||||
1129 | ||||
1130 | static int | |||
1131 | __rw_allowable (pl_inode_t *pl_inode, posix_lock_t *region, | |||
1132 | glusterfs_fop_t op) | |||
1133 | { | |||
1134 | posix_lock_t *l = NULL((void*)0); | |||
1135 | int ret = 1; | |||
1136 | ||||
1137 | list_for_each_entry (l, &pl_inode->ext_list, list)for (l = ((typeof(*l) *)((char *)((&pl_inode->ext_list )->next)-(unsigned long)(&((typeof(*l) *)0)->list)) ); &l->list != (&pl_inode->ext_list); l = ((typeof (*l) *)((char *)(l->list.next)-(unsigned long)(&((typeof (*l) *)0)->list)))) { | |||
1138 | if (locks_overlap (l, region) && !same_owner (l, region)) { | |||
1139 | if ((op == GF_FOP_READ) && (l->fl_type != F_WRLCK1)) | |||
1140 | continue; | |||
1141 | ret = 0; | |||
1142 | break; | |||
1143 | } | |||
1144 | } | |||
1145 | ||||
1146 | return ret; | |||
1147 | } | |||
1148 | ||||
1149 | ||||
1150 | int | |||
1151 | pl_readv_cont (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, | |||
1152 | off_t offset, uint32_t flags, dict_t *xdata) | |||
1153 | { | |||
1154 | STACK_WIND (frame, pl_readv_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1156, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readv_cbk) tmp_cbk = pl_readv_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->readv"; _new->unwind_to = "pl_readv_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readv); (this->children->xlator )->fops->readv (_new, (this->children->xlator), fd , size, offset, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1155 | FIRST_CHILD (this), FIRST_CHILD (this)->fops->readv,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1156, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readv_cbk) tmp_cbk = pl_readv_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->readv"; _new->unwind_to = "pl_readv_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readv); (this->children->xlator )->fops->readv (_new, (this->children->xlator), fd , size, offset, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1156 | fd, size, offset, flags, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1156, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readv_cbk) tmp_cbk = pl_readv_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->readv"; _new->unwind_to = "pl_readv_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readv); (this->children->xlator )->fops->readv (_new, (this->children->xlator), fd , size, offset, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1157 | ||||
1158 | return 0; | |||
1159 | } | |||
1160 | ||||
1161 | ||||
1162 | int | |||
1163 | pl_readv (call_frame_t *frame, xlator_t *this, | |||
1164 | fd_t *fd, size_t size, off_t offset, uint32_t flags, dict_t *xdata) | |||
1165 | { | |||
1166 | posix_locks_private_t *priv = NULL((void*)0); | |||
1167 | pl_inode_t *pl_inode = NULL((void*)0); | |||
1168 | pl_rw_req_t *rw = NULL((void*)0); | |||
1169 | posix_lock_t region = {.list = {0, }, }; | |||
1170 | int op_ret = 0; | |||
1171 | int op_errno = 0; | |||
1172 | char wind_needed = 1; | |||
1173 | ||||
1174 | ||||
1175 | priv = this->private; | |||
1176 | pl_inode = pl_inode_get (this, fd->inode); | |||
1177 | ||||
1178 | if (priv->mandatory && pl_inode->mandatory) { | |||
1179 | region.fl_start = offset; | |||
1180 | region.fl_end = offset + size - 1; | |||
1181 | region.transport = frame->root->trans; | |||
1182 | region.fd_num = fd_to_fdnum(fd); | |||
1183 | region.client_pid = frame->root->pid; | |||
1184 | region.owner = frame->root->lk_owner; | |||
1185 | ||||
1186 | pthread_mutex_lock (&pl_inode->mutex); | |||
1187 | { | |||
1188 | wind_needed = __rw_allowable (pl_inode, ®ion, | |||
1189 | GF_FOP_READ); | |||
1190 | if (wind_needed) { | |||
1191 | goto unlock; | |||
1192 | } | |||
1193 | ||||
1194 | if (fd->flags & O_NONBLOCK04000) { | |||
1195 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("returning EAGAIN as fd is O_NONBLOCK" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1196, GF_LOG_TRACE, "returning EAGAIN as fd is O_NONBLOCK") ; } while (0) | |||
1196 | "returning EAGAIN as fd is O_NONBLOCK")do { do { if (0) printf ("returning EAGAIN as fd is O_NONBLOCK" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1196, GF_LOG_TRACE, "returning EAGAIN as fd is O_NONBLOCK") ; } while (0); | |||
1197 | op_errno = EAGAIN11; | |||
1198 | op_ret = -1; | |||
1199 | goto unlock; | |||
1200 | } | |||
1201 | ||||
1202 | rw = GF_CALLOC (1, sizeof (*rw),__gf_calloc (1, sizeof (*rw), gf_locks_mt_pl_rw_req_t) | |||
1203 | gf_locks_mt_pl_rw_req_t)__gf_calloc (1, sizeof (*rw), gf_locks_mt_pl_rw_req_t); | |||
1204 | if (!rw) { | |||
1205 | op_errno = ENOMEM12; | |||
1206 | op_ret = -1; | |||
1207 | goto unlock; | |||
1208 | } | |||
1209 | ||||
1210 | rw->stub = fop_readv_stub (frame, pl_readv_cont, | |||
1211 | fd, size, offset, flags, | |||
1212 | xdata); | |||
1213 | if (!rw->stub) { | |||
1214 | op_errno = ENOMEM12; | |||
1215 | op_ret = -1; | |||
1216 | GF_FREE (rw)__gf_free (rw); | |||
1217 | goto unlock; | |||
1218 | } | |||
1219 | ||||
1220 | rw->region = region; | |||
1221 | ||||
1222 | list_add_tail (&rw->list, &pl_inode->rw_list); | |||
1223 | } | |||
1224 | unlock: | |||
1225 | pthread_mutex_unlock (&pl_inode->mutex); | |||
1226 | } | |||
1227 | ||||
1228 | ||||
1229 | if (wind_needed) { | |||
1230 | STACK_WIND (frame, pl_readv_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1232, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readv_cbk) tmp_cbk = pl_readv_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->readv"; _new->unwind_to = "pl_readv_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readv); (this->children->xlator )->fops->readv (_new, (this->children->xlator), fd , size, offset, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1231 | FIRST_CHILD (this), FIRST_CHILD (this)->fops->readv,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1232, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readv_cbk) tmp_cbk = pl_readv_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->readv"; _new->unwind_to = "pl_readv_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readv); (this->children->xlator )->fops->readv (_new, (this->children->xlator), fd , size, offset, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1232 | fd, size, offset, flags, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1232, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readv_cbk) tmp_cbk = pl_readv_cbk; _new ->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->readv"; _new->unwind_to = "pl_readv_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readv); (this->children->xlator )->fops->readv (_new, (this->children->xlator), fd , size, offset, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1233 | } | |||
1234 | ||||
1235 | if (op_ret == -1) | |||
1236 | STACK_UNWIND_STRICT (readv, frame, -1, op_errno,do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1237, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), 0, ((void*)0), ((void*)0), ((void*)0) ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1237 | NULL, 0, NULL, NULL, NULL)do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1237, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), 0, ((void*)0), ((void*)0), ((void*)0) ); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1238 | ||||
1239 | return 0; | |||
1240 | } | |||
1241 | ||||
1242 | ||||
1243 | int | |||
1244 | pl_writev_cont (call_frame_t *frame, xlator_t *this, fd_t *fd, | |||
1245 | struct iovec *vector, int count, off_t offset, | |||
1246 | uint32_t flags, struct iobref *iobref, dict_t *xdata) | |||
1247 | { | |||
1248 | STACK_WIND (frame, pl_writev_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1250, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = pl_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->writev" ; _new->unwind_to = "pl_writev_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1249 | FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1250, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = pl_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->writev" ; _new->unwind_to = "pl_writev_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1250 | fd, vector, count, offset, flags, iobref, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1250, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = pl_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->writev" ; _new->unwind_to = "pl_writev_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1251 | ||||
1252 | return 0; | |||
1253 | } | |||
1254 | ||||
1255 | ||||
1256 | int | |||
1257 | pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, | |||
1258 | struct iovec *vector, int32_t count, off_t offset, | |||
1259 | uint32_t flags, struct iobref *iobref, dict_t *xdata) | |||
1260 | { | |||
1261 | posix_locks_private_t *priv = NULL((void*)0); | |||
1262 | pl_inode_t *pl_inode = NULL((void*)0); | |||
1263 | pl_rw_req_t *rw = NULL((void*)0); | |||
1264 | posix_lock_t region = {.list = {0, }, }; | |||
1265 | int op_ret = 0; | |||
1266 | int op_errno = 0; | |||
1267 | char wind_needed = 1; | |||
1268 | ||||
1269 | priv = this->private; | |||
1270 | pl_inode = pl_inode_get (this, fd->inode); | |||
1271 | ||||
1272 | if (priv->mandatory && pl_inode->mandatory) { | |||
1273 | region.fl_start = offset; | |||
1274 | region.fl_end = offset + iov_length (vector, count) - 1; | |||
1275 | region.transport = frame->root->trans; | |||
1276 | region.fd_num = fd_to_fdnum(fd); | |||
1277 | region.client_pid = frame->root->pid; | |||
1278 | region.owner = frame->root->lk_owner; | |||
1279 | ||||
1280 | pthread_mutex_lock (&pl_inode->mutex); | |||
1281 | { | |||
1282 | wind_needed = __rw_allowable (pl_inode, ®ion, | |||
1283 | GF_FOP_WRITE); | |||
1284 | if (wind_needed) | |||
1285 | goto unlock; | |||
1286 | ||||
1287 | if (fd->flags & O_NONBLOCK04000) { | |||
1288 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("returning EAGAIN because fd is " "O_NONBLOCK" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1290, GF_LOG_TRACE, "returning EAGAIN because fd is " "O_NONBLOCK" ); } while (0) | |||
1289 | "returning EAGAIN because fd is "do { do { if (0) printf ("returning EAGAIN because fd is " "O_NONBLOCK" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1290, GF_LOG_TRACE, "returning EAGAIN because fd is " "O_NONBLOCK" ); } while (0) | |||
1290 | "O_NONBLOCK")do { do { if (0) printf ("returning EAGAIN because fd is " "O_NONBLOCK" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1290, GF_LOG_TRACE, "returning EAGAIN because fd is " "O_NONBLOCK" ); } while (0); | |||
1291 | op_errno = EAGAIN11; | |||
1292 | op_ret = -1; | |||
1293 | goto unlock; | |||
1294 | } | |||
1295 | ||||
1296 | rw = GF_CALLOC (1, sizeof (*rw),__gf_calloc (1, sizeof (*rw), gf_locks_mt_pl_rw_req_t) | |||
1297 | gf_locks_mt_pl_rw_req_t)__gf_calloc (1, sizeof (*rw), gf_locks_mt_pl_rw_req_t); | |||
1298 | if (!rw) { | |||
1299 | op_errno = ENOMEM12; | |||
1300 | op_ret = -1; | |||
1301 | goto unlock; | |||
1302 | } | |||
1303 | ||||
1304 | rw->stub = fop_writev_stub (frame, pl_writev_cont, | |||
1305 | fd, vector, count, offset, | |||
1306 | flags, iobref, xdata); | |||
1307 | if (!rw->stub) { | |||
1308 | op_errno = ENOMEM12; | |||
1309 | op_ret = -1; | |||
1310 | GF_FREE (rw)__gf_free (rw); | |||
1311 | goto unlock; | |||
1312 | } | |||
1313 | ||||
1314 | rw->region = region; | |||
1315 | ||||
1316 | list_add_tail (&rw->list, &pl_inode->rw_list); | |||
1317 | } | |||
1318 | unlock: | |||
1319 | pthread_mutex_unlock (&pl_inode->mutex); | |||
1320 | } | |||
1321 | ||||
1322 | ||||
1323 | if (wind_needed) | |||
1324 | STACK_WIND (frame, pl_writev_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1326, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = pl_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->writev" ; _new->unwind_to = "pl_writev_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1325 | FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1326, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = pl_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->writev" ; _new->unwind_to = "pl_writev_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1326 | fd, vector, count, offset, flags, iobref, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1326, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = pl_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->writev" ; _new->unwind_to = "pl_writev_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1327 | ||||
1328 | if (op_ret == -1) | |||
1329 | STACK_UNWIND_STRICT (writev, frame, -1, op_errno, NULL, NULL,do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1330, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_writev_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1330 | NULL)do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1330, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_writev_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1331 | ||||
1332 | return 0; | |||
1333 | } | |||
1334 | ||||
1335 | static int | |||
1336 | __fd_has_locks (pl_inode_t *pl_inode, fd_t *fd) | |||
1337 | { | |||
1338 | int found = 0; | |||
1339 | posix_lock_t *l = NULL((void*)0); | |||
1340 | ||||
1341 | list_for_each_entry (l, &pl_inode->ext_list, list)for (l = ((typeof(*l) *)((char *)((&pl_inode->ext_list )->next)-(unsigned long)(&((typeof(*l) *)0)->list)) ); &l->list != (&pl_inode->ext_list); l = ((typeof (*l) *)((char *)(l->list.next)-(unsigned long)(&((typeof (*l) *)0)->list)))) { | |||
1342 | if ((l->fd_num == fd_to_fdnum(fd))) { | |||
1343 | found = 1; | |||
1344 | break; | |||
1345 | } | |||
1346 | } | |||
1347 | ||||
1348 | return found; | |||
1349 | } | |||
1350 | ||||
1351 | static posix_lock_t * | |||
1352 | lock_dup (posix_lock_t *lock) | |||
1353 | { | |||
1354 | posix_lock_t *new_lock = NULL((void*)0); | |||
1355 | ||||
1356 | new_lock = new_posix_lock (&lock->user_flock, lock->transport, | |||
1357 | lock->client_pid, &lock->owner, | |||
1358 | (fd_t *)lock->fd_num); | |||
1359 | return new_lock; | |||
1360 | } | |||
1361 | ||||
1362 | static int | |||
1363 | __dup_locks_to_fdctx (pl_inode_t *pl_inode, fd_t *fd, | |||
1364 | pl_fdctx_t *fdctx) | |||
1365 | { | |||
1366 | posix_lock_t *l = NULL((void*)0); | |||
1367 | posix_lock_t *duplock = NULL((void*)0); | |||
1368 | int ret = 0; | |||
1369 | ||||
1370 | list_for_each_entry (l, &pl_inode->ext_list, list)for (l = ((typeof(*l) *)((char *)((&pl_inode->ext_list )->next)-(unsigned long)(&((typeof(*l) *)0)->list)) ); &l->list != (&pl_inode->ext_list); l = ((typeof (*l) *)((char *)(l->list.next)-(unsigned long)(&((typeof (*l) *)0)->list)))) { | |||
1371 | if ((l->fd_num == fd_to_fdnum(fd))) { | |||
1372 | duplock = lock_dup (l); | |||
1373 | if (!duplock) { | |||
1374 | ret = -1; | |||
1375 | break; | |||
1376 | } | |||
1377 | ||||
1378 | list_add_tail (&duplock->list, &fdctx->locks_list); | |||
1379 | } | |||
1380 | } | |||
1381 | ||||
1382 | return ret; | |||
1383 | } | |||
1384 | ||||
1385 | static int | |||
1386 | __copy_locks_to_fdctx (pl_inode_t *pl_inode, fd_t *fd, | |||
1387 | pl_fdctx_t *fdctx) | |||
1388 | { | |||
1389 | int ret = 0; | |||
1390 | ||||
1391 | ret = __dup_locks_to_fdctx (pl_inode, fd, fdctx); | |||
1392 | if (ret) | |||
1393 | goto out; | |||
1394 | ||||
1395 | out: | |||
1396 | return ret; | |||
1397 | ||||
1398 | } | |||
1399 | ||||
1400 | static void | |||
1401 | pl_mark_eol_lock (posix_lock_t *lock) | |||
1402 | { | |||
1403 | lock->user_flock.l_type = GF_LK_EOL; | |||
1404 | return; | |||
1405 | } | |||
1406 | ||||
1407 | static posix_lock_t * | |||
1408 | __get_next_fdctx_lock (pl_fdctx_t *fdctx) | |||
1409 | { | |||
1410 | posix_lock_t *lock = NULL((void*)0); | |||
1411 | ||||
1412 | GF_ASSERT (fdctx)do { if (!(fdctx)) { do { do { if (0) printf ("Assertion failed: " "fdctx"); } while (0); _gf_log_callingfn ("", "posix.c", __FUNCTION__ , 1412, GF_LOG_ERROR, "Assertion failed: " "fdctx"); } while ( 0); } } while (0); | |||
1413 | ||||
1414 | if (list_empty (&fdctx->locks_list)) { | |||
1415 | gf_log (THIS->name, GF_LOG_DEBUG,do { do { if (0) printf ("fdctx lock list empty"); } while (0 ); _gf_log ((*__glusterfs_this_location())->name, "posix.c" , __FUNCTION__, 1416, GF_LOG_DEBUG, "fdctx lock list empty"); } while (0) | |||
1416 | "fdctx lock list empty")do { do { if (0) printf ("fdctx lock list empty"); } while (0 ); _gf_log ((*__glusterfs_this_location())->name, "posix.c" , __FUNCTION__, 1416, GF_LOG_DEBUG, "fdctx lock list empty"); } while (0); | |||
1417 | goto out; | |||
1418 | } | |||
1419 | ||||
1420 | lock = list_entry (fdctx->locks_list.next, typeof (*lock),((typeof (*lock) *)((char *)(fdctx->locks_list.next)-(unsigned long)(&((typeof (*lock) *)0)->list))) | |||
1421 | list)((typeof (*lock) *)((char *)(fdctx->locks_list.next)-(unsigned long)(&((typeof (*lock) *)0)->list))); | |||
1422 | ||||
1423 | GF_ASSERT (lock)do { if (!(lock)) { do { do { if (0) printf ("Assertion failed: " "lock"); } while (0); _gf_log_callingfn ("", "posix.c", __FUNCTION__ , 1423, GF_LOG_ERROR, "Assertion failed: " "lock"); } while ( 0); } } while (0); | |||
1424 | ||||
1425 | list_del_init (&lock->list); | |||
1426 | ||||
1427 | out: | |||
1428 | return lock; | |||
1429 | } | |||
1430 | ||||
1431 | static int | |||
1432 | __set_next_lock_fd (pl_fdctx_t *fdctx, posix_lock_t *reqlock) | |||
1433 | { | |||
1434 | posix_lock_t *lock = NULL((void*)0); | |||
1435 | int ret = 0; | |||
1436 | ||||
1437 | GF_ASSERT (fdctx)do { if (!(fdctx)) { do { do { if (0) printf ("Assertion failed: " "fdctx"); } while (0); _gf_log_callingfn ("", "posix.c", __FUNCTION__ , 1437, GF_LOG_ERROR, "Assertion failed: " "fdctx"); } while ( 0); } } while (0); | |||
1438 | ||||
1439 | lock = __get_next_fdctx_lock (fdctx); | |||
1440 | if (!lock) { | |||
1441 | gf_log (THIS->name, GF_LOG_DEBUG,do { do { if (0) printf ("marking EOL in reqlock"); } while ( 0); _gf_log ((*__glusterfs_this_location())->name, "posix.c" , __FUNCTION__, 1442, GF_LOG_DEBUG, "marking EOL in reqlock") ; } while (0) | |||
1442 | "marking EOL in reqlock")do { do { if (0) printf ("marking EOL in reqlock"); } while ( 0); _gf_log ((*__glusterfs_this_location())->name, "posix.c" , __FUNCTION__, 1442, GF_LOG_DEBUG, "marking EOL in reqlock") ; } while (0); | |||
1443 | pl_mark_eol_lock (reqlock); | |||
1444 | goto out; | |||
1445 | } | |||
1446 | ||||
1447 | reqlock->user_flock = lock->user_flock; | |||
1448 | reqlock->fl_start = lock->fl_start; | |||
1449 | reqlock->fl_type = lock->fl_type; | |||
1450 | reqlock->fl_end = lock->fl_end; | |||
1451 | reqlock->owner = lock->owner; | |||
1452 | ||||
1453 | out: | |||
1454 | if (lock) | |||
1455 | __destroy_lock (lock); | |||
1456 | ||||
1457 | return ret; | |||
1458 | } | |||
1459 | ||||
1460 | static int | |||
1461 | pl_getlk_fd (xlator_t *this, pl_inode_t *pl_inode, | |||
1462 | fd_t *fd, posix_lock_t *reqlock) | |||
1463 | { | |||
1464 | uint64_t tmp = 0; | |||
1465 | pl_fdctx_t *fdctx = NULL((void*)0); | |||
1466 | int ret = 0; | |||
1467 | ||||
1468 | pthread_mutex_lock (&pl_inode->mutex); | |||
1469 | { | |||
1470 | if (!__fd_has_locks (pl_inode, fd)) { | |||
1471 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("fd=%p has no active locks", fd); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1472, GF_LOG_DEBUG , "fd=%p has no active locks", fd); } while (0) | |||
1472 | "fd=%p has no active locks", fd)do { do { if (0) printf ("fd=%p has no active locks", fd); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1472, GF_LOG_DEBUG , "fd=%p has no active locks", fd); } while (0); | |||
1473 | ret = 0; | |||
1474 | goto unlock; | |||
1475 | } | |||
1476 | ||||
1477 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("There are active locks on fd"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1478, GF_LOG_DEBUG , "There are active locks on fd"); } while (0) | |||
1478 | "There are active locks on fd")do { do { if (0) printf ("There are active locks on fd"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1478, GF_LOG_DEBUG , "There are active locks on fd"); } while (0); | |||
1479 | ||||
1480 | ret = fd_ctx_get (fd, this, &tmp); | |||
1481 | fdctx = (pl_fdctx_t *)(long) tmp; | |||
1482 | ||||
1483 | if (list_empty (&fdctx->locks_list)) { | |||
1484 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("no fdctx -> copying all locks on fd" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1485, GF_LOG_TRACE, "no fdctx -> copying all locks on fd" ); } while (0) | |||
1485 | "no fdctx -> copying all locks on fd")do { do { if (0) printf ("no fdctx -> copying all locks on fd" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1485, GF_LOG_TRACE, "no fdctx -> copying all locks on fd" ); } while (0); | |||
1486 | ||||
1487 | ret = __copy_locks_to_fdctx (pl_inode, fd, fdctx); | |||
1488 | if (ret) { | |||
1489 | goto unlock; | |||
1490 | } | |||
1491 | ||||
1492 | ret = __set_next_lock_fd (fdctx, reqlock); | |||
1493 | ||||
1494 | } else { | |||
1495 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("fdctx present -> returning the next lock" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1496, GF_LOG_TRACE, "fdctx present -> returning the next lock" ); } while (0) | |||
1496 | "fdctx present -> returning the next lock")do { do { if (0) printf ("fdctx present -> returning the next lock" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1496, GF_LOG_TRACE, "fdctx present -> returning the next lock" ); } while (0); | |||
1497 | ret = __set_next_lock_fd (fdctx, reqlock); | |||
1498 | if (ret) { | |||
1499 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("could not get next lock of fd"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1500, GF_LOG_DEBUG , "could not get next lock of fd"); } while (0) | |||
1500 | "could not get next lock of fd")do { do { if (0) printf ("could not get next lock of fd"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1500, GF_LOG_DEBUG , "could not get next lock of fd"); } while (0); | |||
1501 | goto unlock; | |||
1502 | } | |||
1503 | } | |||
1504 | } | |||
1505 | ||||
1506 | unlock: | |||
1507 | pthread_mutex_unlock (&pl_inode->mutex); | |||
1508 | return ret; | |||
1509 | ||||
1510 | } | |||
1511 | ||||
1512 | int | |||
1513 | pl_lk (call_frame_t *frame, xlator_t *this, | |||
1514 | fd_t *fd, int32_t cmd, struct gf_flock *flock, dict_t *xdata) | |||
1515 | { | |||
1516 | void *transport = NULL((void*)0); | |||
1517 | pid_t client_pid = 0; | |||
1518 | pl_inode_t *pl_inode = NULL((void*)0); | |||
1519 | int op_ret = 0; | |||
1520 | int op_errno = 0; | |||
1521 | int can_block = 0; | |||
1522 | posix_lock_t *reqlock = NULL((void*)0); | |||
1523 | posix_lock_t *conf = NULL((void*)0); | |||
1524 | int ret = 0; | |||
1525 | ||||
1526 | transport = frame->root->trans; | |||
1527 | client_pid = frame->root->pid; | |||
1528 | ||||
1529 | if ((flock->l_start < 0) || (flock->l_len < 0)) { | |||
1530 | op_ret = -1; | |||
1531 | op_errno = EINVAL22; | |||
1532 | goto unwind; | |||
1533 | } | |||
1534 | ||||
1535 | pl_inode = pl_inode_get (this, fd->inode); | |||
1536 | if (!pl_inode) { | |||
1537 | op_ret = -1; | |||
1538 | op_errno = ENOMEM12; | |||
1539 | goto unwind; | |||
1540 | } | |||
1541 | ||||
1542 | reqlock = new_posix_lock (flock, transport, client_pid, | |||
1543 | &frame->root->lk_owner, fd); | |||
1544 | ||||
1545 | if (!reqlock) { | |||
1546 | op_ret = -1; | |||
1547 | op_errno = ENOMEM12; | |||
1548 | goto unwind; | |||
1549 | } | |||
1550 | ||||
1551 | pl_trace_in (this, frame, fd, NULL((void*)0), cmd, flock, NULL((void*)0)); | |||
1552 | ||||
1553 | switch (cmd) { | |||
1554 | ||||
1555 | case F_RESLK_LCKW: | |||
1556 | can_block = 1; | |||
1557 | ||||
1558 | /* fall through */ | |||
1559 | case F_RESLK_LCK: | |||
1560 | memcpy (&reqlock->user_flock, flock, sizeof (struct gf_flock)); | |||
1561 | reqlock->frame = frame; | |||
1562 | reqlock->this = this; | |||
1563 | ||||
1564 | ret = pl_reserve_setlk (this, pl_inode, reqlock, | |||
1565 | can_block); | |||
1566 | if (ret < 0) { | |||
1567 | if (can_block) | |||
1568 | goto out; | |||
1569 | ||||
1570 | op_ret = -1; | |||
1571 | op_errno = -ret; | |||
1572 | __destroy_lock (reqlock); | |||
1573 | goto unwind; | |||
1574 | } | |||
1575 | /* Finally a getlk and return the call */ | |||
1576 | conf = pl_getlk (pl_inode, reqlock); | |||
1577 | if (conf) | |||
1578 | posix_lock_to_flock (conf, flock); | |||
1579 | break; | |||
1580 | ||||
1581 | case F_RESLK_UNLCK: | |||
1582 | reqlock->frame = frame; | |||
1583 | reqlock->this = this; | |||
1584 | ret = pl_reserve_unlock (this, pl_inode, reqlock); | |||
1585 | if (ret < 0) { | |||
1586 | op_ret = -1; | |||
1587 | op_errno = -ret; | |||
1588 | } | |||
1589 | __destroy_lock (reqlock); | |||
1590 | goto unwind; | |||
1591 | ||||
1592 | break; | |||
1593 | ||||
1594 | case F_GETLK_FD: | |||
1595 | reqlock->frame = frame; | |||
1596 | reqlock->this = this; | |||
1597 | ret = pl_verify_reservelk (this, pl_inode, reqlock, can_block); | |||
1598 | GF_ASSERT (ret >= 0)do { if (!(ret >= 0)) { do { do { if (0) printf ("Assertion failed: " "ret >= 0"); } while (0); _gf_log_callingfn ("", "posix.c" , __FUNCTION__, 1598, GF_LOG_ERROR, "Assertion failed: " "ret >= 0" ); } while (0); } } while (0); | |||
1599 | ||||
1600 | ret = pl_getlk_fd (this, pl_inode, fd, reqlock); | |||
1601 | if (ret < 0) { | |||
1602 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("getting locks on fd failed"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1603, GF_LOG_DEBUG , "getting locks on fd failed"); } while (0) | |||
1603 | "getting locks on fd failed")do { do { if (0) printf ("getting locks on fd failed"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1603, GF_LOG_DEBUG , "getting locks on fd failed"); } while (0); | |||
1604 | op_ret = -1; | |||
1605 | op_errno = ENOLCK37; | |||
1606 | goto unwind; | |||
1607 | } | |||
1608 | ||||
1609 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("Replying with a lock on fd for healing" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1610, GF_LOG_TRACE, "Replying with a lock on fd for healing" ); } while (0) | |||
1610 | "Replying with a lock on fd for healing")do { do { if (0) printf ("Replying with a lock on fd for healing" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1610, GF_LOG_TRACE, "Replying with a lock on fd for healing" ); } while (0); | |||
1611 | ||||
1612 | posix_lock_to_flock (reqlock, flock); | |||
1613 | __destroy_lock (reqlock); | |||
1614 | ||||
1615 | break; | |||
1616 | ||||
1617 | #if F_GETLK12 != F_GETLK6412 | |||
1618 | case F_GETLK6412: | |||
1619 | #endif | |||
1620 | case F_GETLK12: | |||
1621 | conf = pl_getlk (pl_inode, reqlock); | |||
1622 | posix_lock_to_flock (conf, flock); | |||
1623 | __destroy_lock (reqlock); | |||
1624 | ||||
1625 | break; | |||
1626 | ||||
1627 | #if F_SETLKW14 != F_SETLKW6414 | |||
1628 | case F_SETLKW6414: | |||
1629 | #endif | |||
1630 | case F_SETLKW14: | |||
1631 | can_block = 1; | |||
1632 | reqlock->frame = frame; | |||
1633 | reqlock->this = this; | |||
1634 | ||||
1635 | /* fall through */ | |||
1636 | ||||
1637 | #if F_SETLK13 != F_SETLK6413 | |||
1638 | case F_SETLK6413: | |||
1639 | #endif | |||
1640 | case F_SETLK13: | |||
1641 | memcpy (&reqlock->user_flock, flock, sizeof (struct gf_flock)); | |||
1642 | ret = pl_verify_reservelk (this, pl_inode, reqlock, can_block); | |||
1643 | if (ret < 0) { | |||
1644 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("Lock blocked due to conflicting reserve lock" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1645, GF_LOG_TRACE, "Lock blocked due to conflicting reserve lock" ); } while (0) | |||
1645 | "Lock blocked due to conflicting reserve lock")do { do { if (0) printf ("Lock blocked due to conflicting reserve lock" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1645, GF_LOG_TRACE, "Lock blocked due to conflicting reserve lock" ); } while (0); | |||
1646 | goto out; | |||
1647 | } | |||
1648 | ret = pl_setlk (this, pl_inode, reqlock, | |||
1649 | can_block); | |||
1650 | ||||
1651 | if (ret == -1) { | |||
1652 | if ((can_block) && (F_UNLCK2 != flock->l_type)) { | |||
1653 | pl_trace_block (this, frame, fd, NULL((void*)0), cmd, flock, NULL((void*)0)); | |||
1654 | goto out; | |||
1655 | } | |||
1656 | gf_log (this->name, GF_LOG_DEBUG, "returning EAGAIN")do { do { if (0) printf ("returning EAGAIN"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1656, GF_LOG_DEBUG, "returning EAGAIN"); } while (0); | |||
1657 | op_ret = -1; | |||
1658 | op_errno = EAGAIN11; | |||
1659 | __destroy_lock (reqlock); | |||
1660 | ||||
1661 | } else if ((0 == ret) && (F_UNLCK2 == flock->l_type)) { | |||
1662 | /* For NLM's last "unlock on fd" detection */ | |||
1663 | if (pl_locks_by_fd (pl_inode, fd)) | |||
1664 | flock->l_type = F_RDLCK0; | |||
1665 | else | |||
1666 | flock->l_type = F_UNLCK2; | |||
1667 | } | |||
1668 | } | |||
1669 | ||||
1670 | unwind: | |||
1671 | pl_trace_out (this, frame, fd, NULL((void*)0), cmd, flock, op_ret, op_errno, NULL((void*)0)); | |||
1672 | pl_update_refkeeper (this, fd->inode); | |||
1673 | ||||
1674 | ||||
1675 | STACK_UNWIND_STRICT (lk, frame, op_ret, op_errno, flock, xdata)do { fop_lk_cbk_t fn = ((void*)0); call_frame_t *_parent = (( void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 1675, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lk_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, flock, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1676 | out: | |||
1677 | return 0; | |||
1678 | } | |||
1679 | ||||
1680 | ||||
1681 | /* TODO: this function just logs, no action required?? */ | |||
1682 | int | |||
1683 | pl_forget (xlator_t *this, | |||
1684 | inode_t *inode) | |||
1685 | { | |||
1686 | pl_inode_t *pl_inode = NULL((void*)0); | |||
1687 | ||||
1688 | posix_lock_t *ext_tmp = NULL((void*)0); | |||
1689 | posix_lock_t *ext_l = NULL((void*)0); | |||
1690 | struct list_head posixlks_released; | |||
1691 | ||||
1692 | pl_inode_lock_t *ino_tmp = NULL((void*)0); | |||
1693 | pl_inode_lock_t *ino_l = NULL((void*)0); | |||
1694 | struct list_head inodelks_released; | |||
1695 | ||||
1696 | pl_rw_req_t *rw_tmp = NULL((void*)0); | |||
1697 | pl_rw_req_t *rw_req = NULL((void*)0); | |||
1698 | ||||
1699 | pl_entry_lock_t *entry_tmp = NULL((void*)0); | |||
1700 | pl_entry_lock_t *entry_l = NULL((void*)0); | |||
1701 | struct list_head entrylks_released; | |||
1702 | ||||
1703 | pl_dom_list_t *dom = NULL((void*)0); | |||
1704 | pl_dom_list_t *dom_tmp = NULL((void*)0); | |||
1705 | ||||
1706 | INIT_LIST_HEAD (&posixlks_released)do { (&posixlks_released)->next = (&posixlks_released )->prev = &posixlks_released; } while (0); | |||
1707 | INIT_LIST_HEAD (&inodelks_released)do { (&inodelks_released)->next = (&inodelks_released )->prev = &inodelks_released; } while (0); | |||
1708 | INIT_LIST_HEAD (&entrylks_released)do { (&entrylks_released)->next = (&entrylks_released )->prev = &entrylks_released; } while (0); | |||
1709 | ||||
1710 | pl_inode = pl_inode_get (this, inode); | |||
1711 | ||||
1712 | pthread_mutex_lock (&pl_inode->mutex); | |||
1713 | { | |||
1714 | ||||
1715 | if (!list_empty (&pl_inode->rw_list)) { | |||
1716 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Pending R/W requests found, releasing." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1717, GF_LOG_WARNING, "Pending R/W requests found, releasing." ); } while (0) | |||
1717 | "Pending R/W requests found, releasing.")do { do { if (0) printf ("Pending R/W requests found, releasing." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1717, GF_LOG_WARNING, "Pending R/W requests found, releasing." ); } while (0); | |||
1718 | ||||
1719 | list_for_each_entry_safe (rw_req, rw_tmp, &pl_inode->rw_list,for (rw_req = ((typeof(*rw_req) *)((char *)((&pl_inode-> rw_list)->next)-(unsigned long)(&((typeof(*rw_req) *)0 )->list))), rw_tmp = ((typeof(*rw_req) *)((char *)(rw_req-> list.next)-(unsigned long)(&((typeof(*rw_req) *)0)->list ))); &rw_req->list != (&pl_inode->rw_list); rw_req = rw_tmp, rw_tmp = ((typeof(*rw_tmp) *)((char *)(rw_tmp-> list.next)-(unsigned long)(&((typeof(*rw_tmp) *)0)->list )))) | |||
1720 | list)for (rw_req = ((typeof(*rw_req) *)((char *)((&pl_inode-> rw_list)->next)-(unsigned long)(&((typeof(*rw_req) *)0 )->list))), rw_tmp = ((typeof(*rw_req) *)((char *)(rw_req-> list.next)-(unsigned long)(&((typeof(*rw_req) *)0)->list ))); &rw_req->list != (&pl_inode->rw_list); rw_req = rw_tmp, rw_tmp = ((typeof(*rw_tmp) *)((char *)(rw_tmp-> list.next)-(unsigned long)(&((typeof(*rw_tmp) *)0)->list )))) { | |||
1721 | ||||
1722 | list_del (&rw_req->list); | |||
1723 | GF_FREE (rw_req)__gf_free (rw_req); | |||
1724 | } | |||
1725 | } | |||
1726 | ||||
1727 | if (!list_empty (&pl_inode->ext_list)) { | |||
1728 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Pending fcntl locks found, releasing." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1729, GF_LOG_WARNING, "Pending fcntl locks found, releasing." ); } while (0) | |||
1729 | "Pending fcntl locks found, releasing.")do { do { if (0) printf ("Pending fcntl locks found, releasing." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1729, GF_LOG_WARNING, "Pending fcntl locks found, releasing." ); } while (0); | |||
1730 | ||||
1731 | list_for_each_entry_safe (ext_l, ext_tmp, &pl_inode->ext_list,for (ext_l = ((typeof(*ext_l) *)((char *)((&pl_inode-> ext_list)->next)-(unsigned long)(&((typeof(*ext_l) *)0 )->list))), ext_tmp = ((typeof(*ext_l) *)((char *)(ext_l-> list.next)-(unsigned long)(&((typeof(*ext_l) *)0)->list ))); &ext_l->list != (&pl_inode->ext_list); ext_l = ext_tmp, ext_tmp = ((typeof(*ext_tmp) *)((char *)(ext_tmp-> list.next)-(unsigned long)(&((typeof(*ext_tmp) *)0)->list )))) | |||
1732 | list)for (ext_l = ((typeof(*ext_l) *)((char *)((&pl_inode-> ext_list)->next)-(unsigned long)(&((typeof(*ext_l) *)0 )->list))), ext_tmp = ((typeof(*ext_l) *)((char *)(ext_l-> list.next)-(unsigned long)(&((typeof(*ext_l) *)0)->list ))); &ext_l->list != (&pl_inode->ext_list); ext_l = ext_tmp, ext_tmp = ((typeof(*ext_tmp) *)((char *)(ext_tmp-> list.next)-(unsigned long)(&((typeof(*ext_tmp) *)0)->list )))) { | |||
1733 | ||||
1734 | __delete_lock (pl_inode, ext_l); | |||
1735 | if (ext_l->blocked) { | |||
1736 | list_add_tail (&ext_l->list, &posixlks_released); | |||
1737 | continue; | |||
1738 | } | |||
1739 | __destroy_lock (ext_l); | |||
1740 | } | |||
1741 | } | |||
1742 | ||||
1743 | ||||
1744 | list_for_each_entry_safe (dom, dom_tmp, &pl_inode->dom_list, inode_list)for (dom = ((typeof(*dom) *)((char *)((&pl_inode->dom_list )->next)-(unsigned long)(&((typeof(*dom) *)0)->inode_list ))), dom_tmp = ((typeof(*dom) *)((char *)(dom->inode_list. next)-(unsigned long)(&((typeof(*dom) *)0)->inode_list ))); &dom->inode_list != (&pl_inode->dom_list); dom = dom_tmp, dom_tmp = ((typeof(*dom_tmp) *)((char *)(dom_tmp ->inode_list.next)-(unsigned long)(&((typeof(*dom_tmp) *)0)->inode_list)))) { | |||
1745 | ||||
1746 | if (!list_empty (&dom->inodelk_list)) { | |||
1747 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Pending inode locks found, releasing." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1748, GF_LOG_WARNING, "Pending inode locks found, releasing." ); } while (0) | |||
1748 | "Pending inode locks found, releasing.")do { do { if (0) printf ("Pending inode locks found, releasing." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1748, GF_LOG_WARNING, "Pending inode locks found, releasing." ); } while (0); | |||
1749 | ||||
1750 | list_for_each_entry_safe (ino_l, ino_tmp, &dom->inodelk_list, list)for (ino_l = ((typeof(*ino_l) *)((char *)((&dom->inodelk_list )->next)-(unsigned long)(&((typeof(*ino_l) *)0)->list ))), ino_tmp = ((typeof(*ino_l) *)((char *)(ino_l->list.next )-(unsigned long)(&((typeof(*ino_l) *)0)->list))); & ino_l->list != (&dom->inodelk_list); ino_l = ino_tmp , ino_tmp = ((typeof(*ino_tmp) *)((char *)(ino_tmp->list.next )-(unsigned long)(&((typeof(*ino_tmp) *)0)->list)))) { | |||
1751 | __delete_inode_lock (ino_l); | |||
1752 | __pl_inodelk_unref (ino_l); | |||
1753 | } | |||
1754 | ||||
1755 | list_splice_init (&dom->blocked_inodelks, &inodelks_released); | |||
1756 | ||||
1757 | ||||
1758 | } | |||
1759 | if (!list_empty (&dom->entrylk_list)) { | |||
1760 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Pending entry locks found, releasing." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1761, GF_LOG_WARNING, "Pending entry locks found, releasing." ); } while (0) | |||
1761 | "Pending entry locks found, releasing.")do { do { if (0) printf ("Pending entry locks found, releasing." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1761, GF_LOG_WARNING, "Pending entry locks found, releasing." ); } while (0); | |||
1762 | ||||
1763 | list_for_each_entry_safe (entry_l, entry_tmp, &dom->entrylk_list, domain_list)for (entry_l = ((typeof(*entry_l) *)((char *)((&dom->entrylk_list )->next)-(unsigned long)(&((typeof(*entry_l) *)0)-> domain_list))), entry_tmp = ((typeof(*entry_l) *)((char *)(entry_l ->domain_list.next)-(unsigned long)(&((typeof(*entry_l ) *)0)->domain_list))); &entry_l->domain_list != (& dom->entrylk_list); entry_l = entry_tmp, entry_tmp = ((typeof (*entry_tmp) *)((char *)(entry_tmp->domain_list.next)-(unsigned long)(&((typeof(*entry_tmp) *)0)->domain_list)))) { | |||
1764 | list_del_init (&entry_l->domain_list); | |||
1765 | ||||
1766 | GF_FREE ((char *)entry_l->basename)__gf_free ((char *)entry_l->basename); | |||
1767 | GF_FREE (entry_l)__gf_free (entry_l); | |||
1768 | } | |||
1769 | ||||
1770 | list_splice_init (&dom->blocked_entrylks, &entrylks_released); | |||
1771 | } | |||
1772 | ||||
1773 | list_del (&dom->inode_list); | |||
1774 | gf_log ("posix-locks", GF_LOG_TRACE,do { do { if (0) printf (" Cleaning up domain: %s", dom->domain ); } while (0); _gf_log ("posix-locks", "posix.c", __FUNCTION__ , 1775, GF_LOG_TRACE, " Cleaning up domain: %s", dom->domain ); } while (0) | |||
1775 | " Cleaning up domain: %s", dom->domain)do { do { if (0) printf (" Cleaning up domain: %s", dom->domain ); } while (0); _gf_log ("posix-locks", "posix.c", __FUNCTION__ , 1775, GF_LOG_TRACE, " Cleaning up domain: %s", dom->domain ); } while (0); | |||
1776 | GF_FREE ((char *)(dom->domain))__gf_free ((char *)(dom->domain)); | |||
1777 | GF_FREE (dom)__gf_free (dom); | |||
1778 | } | |||
1779 | ||||
1780 | } | |||
1781 | pthread_mutex_unlock (&pl_inode->mutex); | |||
1782 | ||||
1783 | list_for_each_entry_safe (ext_l, ext_tmp, &posixlks_released, list)for (ext_l = ((typeof(*ext_l) *)((char *)((&posixlks_released )->next)-(unsigned long)(&((typeof(*ext_l) *)0)->list ))), ext_tmp = ((typeof(*ext_l) *)((char *)(ext_l->list.next )-(unsigned long)(&((typeof(*ext_l) *)0)->list))); & ext_l->list != (&posixlks_released); ext_l = ext_tmp, ext_tmp = ((typeof(*ext_tmp) *)((char *)(ext_tmp->list.next)-(unsigned long)(&((typeof(*ext_tmp) *)0)->list)))) { | |||
1784 | ||||
1785 | STACK_UNWIND_STRICT (lk, ext_l->frame, -1, 0,do { fop_lk_cbk_t fn = ((void*)0); call_frame_t *_parent = (( void*)0); xlator_t *old_THIS = ((void*)0); if (!ext_l->frame ) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ( "stack", "posix.c", __FUNCTION__, 1786, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lk_cbk_t )ext_l->frame-> ret; _parent = ext_l->frame->parent; pthread_spin_lock ( &ext_l->frame->root->stack_lock); { _parent-> ref_count--; } pthread_spin_unlock (&ext_l->frame-> root->stack_lock); old_THIS = (*__glusterfs_this_location( )); (*__glusterfs_this_location()) = _parent->this; ext_l-> frame->complete = _gf_true; ext_l->frame->unwind_from = __FUNCTION__; if (ext_l->frame->this->ctx->measure_latency ) gf_latency_end (ext_l->frame); fn (_parent, ext_l->frame ->cookie, _parent->this, -1, 0, &ext_l->user_flock , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1786 | &ext_l->user_flock, NULL)do { fop_lk_cbk_t fn = ((void*)0); call_frame_t *_parent = (( void*)0); xlator_t *old_THIS = ((void*)0); if (!ext_l->frame ) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ( "stack", "posix.c", __FUNCTION__, 1786, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lk_cbk_t )ext_l->frame-> ret; _parent = ext_l->frame->parent; pthread_spin_lock ( &ext_l->frame->root->stack_lock); { _parent-> ref_count--; } pthread_spin_unlock (&ext_l->frame-> root->stack_lock); old_THIS = (*__glusterfs_this_location( )); (*__glusterfs_this_location()) = _parent->this; ext_l-> frame->complete = _gf_true; ext_l->frame->unwind_from = __FUNCTION__; if (ext_l->frame->this->ctx->measure_latency ) gf_latency_end (ext_l->frame); fn (_parent, ext_l->frame ->cookie, _parent->this, -1, 0, &ext_l->user_flock , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1787 | __destroy_lock (ext_l); | |||
1788 | } | |||
1789 | ||||
1790 | list_for_each_entry_safe (ino_l, ino_tmp, &inodelks_released, blocked_locks)for (ino_l = ((typeof(*ino_l) *)((char *)((&inodelks_released )->next)-(unsigned long)(&((typeof(*ino_l) *)0)->blocked_locks ))), ino_tmp = ((typeof(*ino_l) *)((char *)(ino_l->blocked_locks .next)-(unsigned long)(&((typeof(*ino_l) *)0)->blocked_locks ))); &ino_l->blocked_locks != (&inodelks_released) ; ino_l = ino_tmp, ino_tmp = ((typeof(*ino_tmp) *)((char *)(ino_tmp ->blocked_locks.next)-(unsigned long)(&((typeof(*ino_tmp ) *)0)->blocked_locks)))) { | |||
1791 | ||||
1792 | STACK_UNWIND_STRICT (inodelk, ino_l->frame, -1, 0, NULL)do { fop_inodelk_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!ino_l-> frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1792, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_inodelk_cbk_t )ino_l->frame ->ret; _parent = ino_l->frame->parent; pthread_spin_lock (&ino_l->frame->root->stack_lock); { _parent-> ref_count--; } pthread_spin_unlock (&ino_l->frame-> root->stack_lock); old_THIS = (*__glusterfs_this_location( )); (*__glusterfs_this_location()) = _parent->this; ino_l-> frame->complete = _gf_true; ino_l->frame->unwind_from = __FUNCTION__; if (ino_l->frame->this->ctx->measure_latency ) gf_latency_end (ino_l->frame); fn (_parent, ino_l->frame ->cookie, _parent->this, -1, 0, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1793 | __pl_inodelk_unref (ino_l); | |||
1794 | } | |||
1795 | ||||
1796 | list_for_each_entry_safe (entry_l, entry_tmp, &entrylks_released, blocked_locks)for (entry_l = ((typeof(*entry_l) *)((char *)((&entrylks_released )->next)-(unsigned long)(&((typeof(*entry_l) *)0)-> blocked_locks))), entry_tmp = ((typeof(*entry_l) *)((char *)( entry_l->blocked_locks.next)-(unsigned long)(&((typeof (*entry_l) *)0)->blocked_locks))); &entry_l->blocked_locks != (&entrylks_released); entry_l = entry_tmp, entry_tmp = ((typeof(*entry_tmp) *)((char *)(entry_tmp->blocked_locks .next)-(unsigned long)(&((typeof(*entry_tmp) *)0)->blocked_locks )))) { | |||
1797 | ||||
1798 | STACK_UNWIND_STRICT (entrylk, entry_l->frame, -1, 0, NULL)do { fop_entrylk_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!entry_l-> frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 1798, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_entrylk_cbk_t )entry_l-> frame->ret; _parent = entry_l->frame->parent; pthread_spin_lock (&entry_l->frame->root->stack_lock); { _parent-> ref_count--; } pthread_spin_unlock (&entry_l->frame-> root->stack_lock); old_THIS = (*__glusterfs_this_location( )); (*__glusterfs_this_location()) = _parent->this; entry_l ->frame->complete = _gf_true; entry_l->frame->unwind_from = __FUNCTION__; if (entry_l->frame->this->ctx->measure_latency ) gf_latency_end (entry_l->frame); fn (_parent, entry_l-> frame->cookie, _parent->this, -1, 0, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1799 | GF_FREE ((char *)entry_l->basename)__gf_free ((char *)entry_l->basename); | |||
1800 | GF_FREE (entry_l)__gf_free (entry_l); | |||
1801 | ||||
1802 | } | |||
1803 | ||||
1804 | GF_FREE (pl_inode)__gf_free (pl_inode); | |||
1805 | ||||
1806 | return 0; | |||
1807 | } | |||
1808 | ||||
1809 | int | |||
1810 | pl_release (xlator_t *this, fd_t *fd) | |||
1811 | { | |||
1812 | pl_inode_t *pl_inode = NULL((void*)0); | |||
1813 | uint64_t tmp_pl_inode = 0; | |||
1814 | int ret = -1; | |||
1815 | uint64_t tmp = 0; | |||
1816 | pl_fdctx_t *fdctx = NULL((void*)0); | |||
1817 | ||||
1818 | if (fd == NULL((void*)0)) { | |||
| ||||
1819 | goto out; | |||
1820 | } | |||
1821 | ||||
1822 | ret = inode_ctx_get (fd->inode, this, &tmp_pl_inode)inode_ctx_get2(fd->inode,this,&tmp_pl_inode,0); | |||
1823 | if (ret != 0) | |||
1824 | goto out; | |||
1825 | ||||
1826 | pl_inode = (pl_inode_t *)(long)tmp_pl_inode; | |||
1827 | ||||
1828 | pl_trace_release (this, fd); | |||
1829 | ||||
1830 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("Releasing all locks with fd %p", fd ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1831, GF_LOG_TRACE, "Releasing all locks with fd %p", fd); } while (0) | |||
1831 | "Releasing all locks with fd %p", fd)do { do { if (0) printf ("Releasing all locks with fd %p", fd ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1831, GF_LOG_TRACE, "Releasing all locks with fd %p", fd); } while (0); | |||
1832 | ||||
1833 | delete_locks_of_fd (this, pl_inode, fd); | |||
1834 | pl_update_refkeeper (this, fd->inode); | |||
1835 | ||||
1836 | ret = fd_ctx_del (fd, this, &tmp); | |||
1837 | if (ret) { | |||
1838 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Could not get fdctx"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1839, GF_LOG_DEBUG , "Could not get fdctx"); } while (0) | |||
1839 | "Could not get fdctx")do { do { if (0) printf ("Could not get fdctx"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1839, GF_LOG_DEBUG , "Could not get fdctx"); } while (0); | |||
1840 | goto out; | |||
1841 | } | |||
1842 | ||||
1843 | fdctx = (pl_fdctx_t *)(long)tmp; | |||
1844 | ||||
1845 | GF_FREE (fdctx)__gf_free (fdctx); | |||
1846 | out: | |||
1847 | return ret; | |||
1848 | } | |||
1849 | ||||
1850 | int | |||
1851 | pl_releasedir (xlator_t *this, fd_t *fd) | |||
1852 | { | |||
1853 | int ret = -1; | |||
1854 | uint64_t tmp = 0; | |||
1855 | pl_fdctx_t *fdctx = NULL((void*)0); | |||
1856 | ||||
1857 | if (fd == NULL((void*)0)) { | |||
1858 | goto out; | |||
1859 | } | |||
1860 | ||||
1861 | ret = fd_ctx_del (fd, this, &tmp); | |||
1862 | if (ret) { | |||
1863 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Could not get fdctx"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1864, GF_LOG_DEBUG , "Could not get fdctx"); } while (0) | |||
1864 | "Could not get fdctx")do { do { if (0) printf ("Could not get fdctx"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 1864, GF_LOG_DEBUG , "Could not get fdctx"); } while (0); | |||
1865 | goto out; | |||
1866 | } | |||
1867 | ||||
1868 | fdctx = (pl_fdctx_t *)(long)tmp; | |||
1869 | ||||
1870 | GF_FREE (fdctx)__gf_free (fdctx); | |||
1871 | out: | |||
1872 | return ret; | |||
1873 | } | |||
1874 | ||||
1875 | int32_t | |||
1876 | __get_posixlk_count (xlator_t *this, pl_inode_t *pl_inode) | |||
1877 | { | |||
1878 | posix_lock_t *lock = NULL((void*)0); | |||
1879 | int32_t count = 0; | |||
1880 | ||||
1881 | list_for_each_entry (lock, &pl_inode->ext_list, list)for (lock = ((typeof(*lock) *)((char *)((&pl_inode->ext_list )->next)-(unsigned long)(&((typeof(*lock) *)0)->list ))); &lock->list != (&pl_inode->ext_list); lock = ((typeof(*lock) *)((char *)(lock->list.next)-(unsigned long )(&((typeof(*lock) *)0)->list)))) { | |||
1882 | ||||
1883 | count++; | |||
1884 | } | |||
1885 | ||||
1886 | return count; | |||
1887 | } | |||
1888 | ||||
1889 | int32_t | |||
1890 | get_posixlk_count (xlator_t *this, inode_t *inode) | |||
1891 | { | |||
1892 | pl_inode_t *pl_inode = NULL((void*)0); | |||
1893 | uint64_t tmp_pl_inode = 0; | |||
1894 | int ret = 0; | |||
1895 | int32_t count = 0; | |||
1896 | ||||
1897 | ret = inode_ctx_get (inode, this, &tmp_pl_inode)inode_ctx_get2(inode,this,&tmp_pl_inode,0); | |||
1898 | if (ret != 0) { | |||
1899 | goto out; | |||
1900 | } | |||
1901 | ||||
1902 | pl_inode = (pl_inode_t *)(long) tmp_pl_inode; | |||
1903 | ||||
1904 | pthread_mutex_lock (&pl_inode->mutex); | |||
1905 | { | |||
1906 | count =__get_posixlk_count (this, pl_inode); | |||
1907 | } | |||
1908 | pthread_mutex_unlock (&pl_inode->mutex); | |||
1909 | ||||
1910 | out: | |||
1911 | return count; | |||
1912 | } | |||
1913 | ||||
1914 | void | |||
1915 | pl_parent_entrylk_xattr_fill (xlator_t *this, inode_t *parent, | |||
1916 | char *basename, dict_t *dict) | |||
1917 | { | |||
1918 | uint32_t entrylk = 0; | |||
1919 | int ret = -1; | |||
1920 | ||||
1921 | if (!parent || !basename || !strlen (basename)) | |||
1922 | goto out; | |||
1923 | entrylk = check_entrylk_on_basename (this, parent, basename); | |||
1924 | out: | |||
1925 | ret = dict_set_uint32 (dict, GLUSTERFS_PARENT_ENTRYLK"glusterfs.parent-entrylk", entrylk); | |||
1926 | if (ret < 0) { | |||
1927 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf (" dict_set failed on key %s", "glusterfs.parent-entrylk" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1928, GF_LOG_DEBUG, " dict_set failed on key %s", "glusterfs.parent-entrylk" ); } while (0) | |||
1928 | " dict_set failed on key %s", GLUSTERFS_PARENT_ENTRYLK)do { do { if (0) printf (" dict_set failed on key %s", "glusterfs.parent-entrylk" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1928, GF_LOG_DEBUG, " dict_set failed on key %s", "glusterfs.parent-entrylk" ); } while (0); | |||
1929 | } | |||
1930 | } | |||
1931 | ||||
1932 | void | |||
1933 | pl_entrylk_xattr_fill (xlator_t *this, inode_t *inode, | |||
1934 | dict_t *dict) | |||
1935 | { | |||
1936 | int32_t count = 0; | |||
1937 | int ret = -1; | |||
1938 | ||||
1939 | count = get_entrylk_count (this, inode); | |||
1940 | ret = dict_set_int32 (dict, GLUSTERFS_ENTRYLK_COUNT"glusterfs.entrylk-count", count); | |||
1941 | if (ret < 0) { | |||
1942 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf (" dict_set failed on key %s", "glusterfs.entrylk-count" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1943, GF_LOG_DEBUG, " dict_set failed on key %s", "glusterfs.entrylk-count" ); } while (0) | |||
1943 | " dict_set failed on key %s", GLUSTERFS_ENTRYLK_COUNT)do { do { if (0) printf (" dict_set failed on key %s", "glusterfs.entrylk-count" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1943, GF_LOG_DEBUG, " dict_set failed on key %s", "glusterfs.entrylk-count" ); } while (0); | |||
1944 | } | |||
1945 | ||||
1946 | } | |||
1947 | ||||
1948 | void | |||
1949 | pl_inodelk_xattr_fill (xlator_t *this, inode_t *inode, | |||
1950 | dict_t *dict) | |||
1951 | { | |||
1952 | int32_t count = 0; | |||
1953 | int ret = -1; | |||
1954 | ||||
1955 | count = get_inodelk_count (this, inode); | |||
1956 | ret = dict_set_int32 (dict, GLUSTERFS_INODELK_COUNT"glusterfs.inodelk-count", count); | |||
1957 | if (ret < 0) { | |||
1958 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf (" dict_set failed on key %s", "glusterfs.inodelk-count" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1959, GF_LOG_DEBUG, " dict_set failed on key %s", "glusterfs.inodelk-count" ); } while (0) | |||
1959 | " dict_set failed on key %s", GLUSTERFS_INODELK_COUNT)do { do { if (0) printf (" dict_set failed on key %s", "glusterfs.inodelk-count" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1959, GF_LOG_DEBUG, " dict_set failed on key %s", "glusterfs.inodelk-count" ); } while (0); | |||
1960 | } | |||
1961 | ||||
1962 | } | |||
1963 | ||||
1964 | void | |||
1965 | pl_posixlk_xattr_fill (xlator_t *this, inode_t *inode, | |||
1966 | dict_t *dict) | |||
1967 | { | |||
1968 | int32_t count = 0; | |||
1969 | int ret = -1; | |||
1970 | ||||
1971 | count = get_posixlk_count (this, inode); | |||
1972 | ret = dict_set_int32 (dict, GLUSTERFS_POSIXLK_COUNT"glusterfs.posixlk-count", count); | |||
1973 | if (ret < 0) { | |||
1974 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf (" dict_set failed on key %s", "glusterfs.posixlk-count" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1975, GF_LOG_DEBUG, " dict_set failed on key %s", "glusterfs.posixlk-count" ); } while (0) | |||
1975 | " dict_set failed on key %s", GLUSTERFS_POSIXLK_COUNT)do { do { if (0) printf (" dict_set failed on key %s", "glusterfs.posixlk-count" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 1975, GF_LOG_DEBUG, " dict_set failed on key %s", "glusterfs.posixlk-count" ); } while (0); | |||
1976 | } | |||
1977 | ||||
1978 | } | |||
1979 | ||||
1980 | int32_t | |||
1981 | pl_lookup_cbk (call_frame_t *frame, | |||
1982 | void *cookie, | |||
1983 | xlator_t *this, | |||
1984 | int32_t op_ret, | |||
1985 | int32_t op_errno, | |||
1986 | inode_t *inode, | |||
1987 | struct iatt *buf, | |||
1988 | dict_t *xdata, | |||
1989 | struct iatt *postparent) | |||
1990 | { | |||
1991 | pl_local_t *local = NULL((void*)0); | |||
1992 | ||||
1993 | GF_VALIDATE_OR_GOTO (this->name, frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn (this->name, "posix.c", __FUNCTION__ , 1993, GF_LOG_ERROR, "invalid argument: " "frame->local") ; } while (0); goto out; } } while (0); | |||
1994 | ||||
1995 | if (op_ret) | |||
1996 | goto out; | |||
1997 | ||||
1998 | local = frame->local; | |||
1999 | ||||
2000 | if (local->parent_entrylk_req) | |||
2001 | pl_parent_entrylk_xattr_fill (this, local->loc.parent, | |||
2002 | (char*)local->loc.name, xdata); | |||
2003 | if (local->entrylk_count_req) | |||
2004 | pl_entrylk_xattr_fill (this, inode, xdata); | |||
2005 | if (local->inodelk_count_req) | |||
2006 | pl_inodelk_xattr_fill (this, inode, xdata); | |||
2007 | if (local->posixlk_count_req) | |||
2008 | pl_posixlk_xattr_fill (this, inode, xdata); | |||
2009 | ||||
2010 | ||||
2011 | out: | |||
2012 | local = frame->local; | |||
2013 | frame->local = NULL((void*)0); | |||
2014 | ||||
2015 | if (local != NULL((void*)0)) { | |||
2016 | loc_wipe (&local->loc); | |||
2017 | mem_put (local); | |||
2018 | } | |||
2019 | ||||
2020 | STACK_UNWIND_STRICT (do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2028, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xdata, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2021 | lookup,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2028, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xdata, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2022 | frame,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2028, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xdata, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2023 | op_ret,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2028, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xdata, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2024 | op_errno,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2028, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xdata, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2025 | inode,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2028, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xdata, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2026 | buf,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2028, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xdata, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2027 | xdata,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2028, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xdata, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2028 | postparent)do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2028, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xdata, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
2029 | return 0; | |||
2030 | } | |||
2031 | ||||
2032 | int32_t | |||
2033 | pl_lookup (call_frame_t *frame, | |||
2034 | xlator_t *this, | |||
2035 | loc_t *loc, | |||
2036 | dict_t *xdata) | |||
2037 | { | |||
2038 | pl_local_t *local = NULL((void*)0); | |||
2039 | int ret = -1; | |||
2040 | ||||
2041 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c" , __FUNCTION__, 2041, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||
2042 | VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c" , __FUNCTION__, 2042, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto out; } } while (0); | |||
2043 | VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c" , __FUNCTION__, 2043, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto out; } } while (0); | |||
2044 | ||||
2045 | local = mem_get0 (this->local_pool); | |||
2046 | GF_VALIDATE_OR_GOTO (this->name, local, out)do { if (!local) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "local"); } while (0); _gf_log_callingfn (this->name, "posix.c", __FUNCTION__, 2046, GF_LOG_ERROR, "invalid argument: " "local"); } while (0); goto out; } } while (0); | |||
2047 | ||||
2048 | if (xdata) { | |||
2049 | if (dict_get (xdata, GLUSTERFS_ENTRYLK_COUNT"glusterfs.entrylk-count")) | |||
2050 | local->entrylk_count_req = 1; | |||
2051 | if (dict_get (xdata, GLUSTERFS_INODELK_COUNT"glusterfs.inodelk-count")) | |||
2052 | local->inodelk_count_req = 1; | |||
2053 | if (dict_get (xdata, GLUSTERFS_POSIXLK_COUNT"glusterfs.posixlk-count")) | |||
2054 | local->posixlk_count_req = 1; | |||
2055 | if (dict_get (xdata, GLUSTERFS_PARENT_ENTRYLK"glusterfs.parent-entrylk")) | |||
2056 | local->parent_entrylk_req = 1; | |||
2057 | } | |||
2058 | ||||
2059 | frame->local = local; | |||
2060 | loc_copy (&local->loc, loc); | |||
2061 | ||||
2062 | STACK_WIND (frame,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 2066, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->lookup_cbk) tmp_cbk = pl_lookup_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"; _new->unwind_to = "pl_lookup_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->lookup); (this->children->xlator )->fops->lookup (_new, (this->children->xlator), loc , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||
2063 | pl_lookup_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 2066, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->lookup_cbk) tmp_cbk = pl_lookup_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"; _new->unwind_to = "pl_lookup_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->lookup); (this->children->xlator )->fops->lookup (_new, (this->children->xlator), loc , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||
2064 | FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 2066, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->lookup_cbk) tmp_cbk = pl_lookup_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"; _new->unwind_to = "pl_lookup_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->lookup); (this->children->xlator )->fops->lookup (_new, (this->children->xlator), loc , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||
2065 | FIRST_CHILD(this)->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 2066, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->lookup_cbk) tmp_cbk = pl_lookup_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"; _new->unwind_to = "pl_lookup_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->lookup); (this->children->xlator )->fops->lookup (_new, (this->children->xlator), loc , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||
2066 | loc, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 2066, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->lookup_cbk) tmp_cbk = pl_lookup_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"; _new->unwind_to = "pl_lookup_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->lookup); (this->children->xlator )->fops->lookup (_new, (this->children->xlator), loc , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); | |||
2067 | ret = 0; | |||
2068 | out: | |||
2069 | if (ret == -1) | |||
2070 | STACK_UNWIND_STRICT (lookup, frame, -1, 0, NULL,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2071, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 0, ((void*)0), ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2071 | NULL, NULL, NULL)do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2071, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root-> stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 0, ((void*)0), ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
2072 | ||||
2073 | return 0; | |||
2074 | } | |||
2075 | int | |||
2076 | pl_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
2077 | int op_ret, int op_errno, gf_dirent_t *entries, dict_t *xdata) | |||
2078 | { | |||
2079 | pl_local_t *local = NULL((void*)0); | |||
2080 | gf_dirent_t *entry = NULL((void*)0); | |||
2081 | ||||
2082 | local = frame->local; | |||
2083 | ||||
2084 | if (op_ret <= 0) | |||
2085 | goto unwind; | |||
2086 | ||||
2087 | 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)))) { | |||
2088 | if (local->entrylk_count_req) | |||
2089 | pl_entrylk_xattr_fill (this, entry->inode, entry->dict); | |||
2090 | if (local->inodelk_count_req) | |||
2091 | pl_inodelk_xattr_fill (this, entry->inode, entry->dict); | |||
2092 | if (local->posixlk_count_req) | |||
2093 | pl_posixlk_xattr_fill (this, entry->inode, entry->dict); | |||
2094 | } | |||
2095 | ||||
2096 | unwind: | |||
2097 | frame->local = NULL((void*)0); | |||
2098 | STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries, xdata)do { fop_readdirp_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2098, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readdirp_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, entries, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
2099 | ||||
2100 | if (local) | |||
2101 | mem_put (local); | |||
2102 | ||||
2103 | return 0; | |||
2104 | } | |||
2105 | ||||
2106 | int | |||
2107 | pl_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, | |||
2108 | off_t offset, dict_t *dict) | |||
2109 | { | |||
2110 | pl_local_t *local = NULL((void*)0); | |||
2111 | ||||
2112 | local = mem_get0 (this->local_pool); | |||
2113 | GF_VALIDATE_OR_GOTO (this->name, local, out)do { if (!local) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "local"); } while (0); _gf_log_callingfn (this->name, "posix.c", __FUNCTION__, 2113, GF_LOG_ERROR, "invalid argument: " "local"); } while (0); goto out; } } while (0); | |||
2114 | ||||
2115 | if (dict) { | |||
2116 | if (dict_get (dict, GLUSTERFS_ENTRYLK_COUNT"glusterfs.entrylk-count")) | |||
2117 | local->entrylk_count_req = 1; | |||
2118 | if (dict_get (dict, GLUSTERFS_INODELK_COUNT"glusterfs.inodelk-count")) | |||
2119 | local->inodelk_count_req = 1; | |||
2120 | if (dict_get (dict, GLUSTERFS_POSIXLK_COUNT"glusterfs.posixlk-count")) | |||
2121 | local->posixlk_count_req = 1; | |||
2122 | } | |||
2123 | ||||
2124 | frame->local = local; | |||
2125 | ||||
2126 | STACK_WIND (frame, pl_readdirp_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 2128, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdirp_cbk) tmp_cbk = pl_readdirp_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdirp" ; _new->unwind_to = "pl_readdirp_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdirp); (this->children->xlator )->fops->readdirp (_new, (this->children->xlator) , fd, size, offset, dict); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
2127 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 2128, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdirp_cbk) tmp_cbk = pl_readdirp_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdirp" ; _new->unwind_to = "pl_readdirp_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdirp); (this->children->xlator )->fops->readdirp (_new, (this->children->xlator) , fd, size, offset, dict); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
2128 | fd, size, offset, dict)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix.c", __FUNCTION__, 2128, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdirp_cbk) tmp_cbk = pl_readdirp_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdirp" ; _new->unwind_to = "pl_readdirp_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdirp); (this->children->xlator )->fops->readdirp (_new, (this->children->xlator) , fd, size, offset, dict); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
2129 | ||||
2130 | return 0; | |||
2131 | out: | |||
2132 | STACK_UNWIND_STRICT (readdirp, frame, -1, ENOMEM, NULL, NULL)do { fop_readdirp_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix.c", __FUNCTION__, 2132, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readdirp_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 12, ((void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
2133 | return 0; | |||
2134 | } | |||
2135 | ||||
2136 | ||||
2137 | void | |||
2138 | pl_dump_lock (char *str, int size, struct gf_flock *flock, | |||
2139 | gf_lkowner_t *owner, void *trans, time_t *granted_time, | |||
2140 | time_t *blkd_time, gf_boolean_t active) | |||
2141 | { | |||
2142 | char *type_str = NULL((void*)0); | |||
2143 | char granted[32] = {0,}; | |||
2144 | char blocked[32] = {0,}; | |||
2145 | ||||
2146 | switch (flock->l_type) { | |||
2147 | case F_RDLCK0: | |||
2148 | type_str = "READ"; | |||
2149 | break; | |||
2150 | case F_WRLCK1: | |||
2151 | type_str = "WRITE"; | |||
2152 | break; | |||
2153 | case F_UNLCK2: | |||
2154 | type_str = "UNLOCK"; | |||
2155 | break; | |||
2156 | default: | |||
2157 | type_str = "UNKNOWN"; | |||
2158 | break; | |||
2159 | } | |||
2160 | ||||
2161 | if (active) { | |||
2162 | if (blkd_time && *blkd_time == 0) { | |||
2163 | snprintf (str, size, RANGE_GRNTD_FMT"type=%s, whence=%hd, start=%llu, len=%llu"", ""pid = %llu, owner=%s, transport=%p, " ", ""granted at %s", | |||
2164 | type_str, flock->l_whence, | |||
2165 | (unsigned long long) flock->l_start, | |||
2166 | (unsigned long long) flock->l_len, | |||
2167 | (unsigned long long) flock->l_pid, | |||
2168 | lkowner_utoa (owner), trans, | |||
2169 | ctime_r (granted_time, granted)); | |||
2170 | } else { | |||
2171 | snprintf (str, size, RANGE_BLKD_GRNTD_FMT"type=%s, whence=%hd, start=%llu, len=%llu"", ""pid = %llu, owner=%s, transport=%p, " ", ""blocked at %s"", ""granted at %s", | |||
2172 | type_str, flock->l_whence, | |||
2173 | (unsigned long long) flock->l_start, | |||
2174 | (unsigned long long) flock->l_len, | |||
2175 | (unsigned long long) flock->l_pid, | |||
2176 | lkowner_utoa (owner), trans, | |||
2177 | ctime_r (blkd_time, blocked), | |||
2178 | ctime_r (granted_time, granted)); | |||
2179 | } | |||
2180 | } | |||
2181 | else { | |||
2182 | snprintf (str, size, RANGE_BLKD_FMT"type=%s, whence=%hd, start=%llu, len=%llu"", ""pid = %llu, owner=%s, transport=%p, " ", ""blocked at %s", | |||
2183 | type_str, flock->l_whence, | |||
2184 | (unsigned long long) flock->l_start, | |||
2185 | (unsigned long long) flock->l_len, | |||
2186 | (unsigned long long) flock->l_pid, | |||
2187 | lkowner_utoa (owner), trans, | |||
2188 | ctime_r (blkd_time, blocked)); | |||
2189 | } | |||
2190 | ||||
2191 | } | |||
2192 | ||||
2193 | void | |||
2194 | __dump_entrylks (pl_inode_t *pl_inode) | |||
2195 | { | |||
2196 | pl_dom_list_t *dom = NULL((void*)0); | |||
2197 | pl_entry_lock_t *lock = NULL((void*)0); | |||
2198 | char blocked[32] = {0,}; | |||
2199 | char granted[32] = {0,}; | |||
2200 | int count = 0; | |||
2201 | char key[GF_DUMP_MAX_BUF_LEN4096] = {0,}; | |||
2202 | ||||
2203 | char tmp[256]; | |||
2204 | ||||
2205 | list_for_each_entry (dom, &pl_inode->dom_list, inode_list)for (dom = ((typeof(*dom) *)((char *)((&pl_inode->dom_list )->next)-(unsigned long)(&((typeof(*dom) *)0)->inode_list ))); &dom->inode_list != (&pl_inode->dom_list); dom = ((typeof(*dom) *)((char *)(dom->inode_list.next)-(unsigned long)(&((typeof(*dom) *)0)->inode_list)))) { | |||
2206 | ||||
2207 | count = 0; | |||
2208 | ||||
2209 | gf_proc_dump_build_key(key,{ _gf_proc_dump_build_key(key, "lock-dump.domain", "domain"); } | |||
2210 | "lock-dump.domain",{ _gf_proc_dump_build_key(key, "lock-dump.domain", "domain"); } | |||
2211 | "domain"){ _gf_proc_dump_build_key(key, "lock-dump.domain", "domain"); }; | |||
2212 | gf_proc_dump_write(key, "%s", dom->domain); | |||
2213 | ||||
2214 | list_for_each_entry (lock, &dom->entrylk_list, domain_list)for (lock = ((typeof(*lock) *)((char *)((&dom->entrylk_list )->next)-(unsigned long)(&((typeof(*lock) *)0)->domain_list ))); &lock->domain_list != (&dom->entrylk_list) ; lock = ((typeof(*lock) *)((char *)(lock->domain_list.next )-(unsigned long)(&((typeof(*lock) *)0)->domain_list)) )) { | |||
2215 | ||||
2216 | gf_proc_dump_build_key(key,{ _gf_proc_dump_build_key(key, "xlator.feature.locks.lock-dump.domain.entrylk" , "entrylk[%d](ACTIVE)", count); } | |||
2217 | "xlator.feature.locks.lock-dump.domain.entrylk",{ _gf_proc_dump_build_key(key, "xlator.feature.locks.lock-dump.domain.entrylk" , "entrylk[%d](ACTIVE)", count); } | |||
2218 | "entrylk[%d](ACTIVE)", count ){ _gf_proc_dump_build_key(key, "xlator.feature.locks.lock-dump.domain.entrylk" , "entrylk[%d](ACTIVE)", count); }; | |||
2219 | if (lock->blkd_time.tv_sec == 0 && lock->blkd_time.tv_usec == 0) { | |||
2220 | snprintf (tmp, 256, ENTRY_GRNTD_FMT"type=%s on basename=%s"", ""pid = %llu, owner=%s, transport=%p, " ", ""granted at %s", | |||
2221 | lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" : | |||
2222 | "ENTRYLK_WRLCK", lock->basename, | |||
2223 | (unsigned long long) lock->client_pid, | |||
2224 | lkowner_utoa (&lock->owner), lock->trans, | |||
2225 | ctime_r (&lock->granted_time.tv_sec, granted)); | |||
2226 | } else { | |||
2227 | snprintf (tmp, 256, ENTRY_BLKD_GRNTD_FMT"type=%s on basename=%s"", ""pid = %llu, owner=%s, transport=%p, " ", ""blocked at %s"", ""granted at %s", | |||
2228 | lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" : | |||
2229 | "ENTRYLK_WRLCK", lock->basename, | |||
2230 | (unsigned long long) lock->client_pid, | |||
2231 | lkowner_utoa (&lock->owner), lock->trans, | |||
2232 | ctime_r (&lock->blkd_time.tv_sec, blocked), | |||
2233 | ctime_r (&lock->granted_time.tv_sec, granted)); | |||
2234 | } | |||
2235 | ||||
2236 | gf_proc_dump_write(key, tmp); | |||
2237 | ||||
2238 | count++; | |||
2239 | } | |||
2240 | ||||
2241 | list_for_each_entry (lock, &dom->blocked_entrylks, blocked_locks)for (lock = ((typeof(*lock) *)((char *)((&dom->blocked_entrylks )->next)-(unsigned long)(&((typeof(*lock) *)0)->blocked_locks ))); &lock->blocked_locks != (&dom->blocked_entrylks ); lock = ((typeof(*lock) *)((char *)(lock->blocked_locks. next)-(unsigned long)(&((typeof(*lock) *)0)->blocked_locks )))) { | |||
2242 | ||||
2243 | gf_proc_dump_build_key(key,{ _gf_proc_dump_build_key(key, "xlator.feature.locks.lock-dump.domain.entrylk" , "entrylk[%d](BLOCKED)", count); } | |||
2244 | "xlator.feature.locks.lock-dump.domain.entrylk",{ _gf_proc_dump_build_key(key, "xlator.feature.locks.lock-dump.domain.entrylk" , "entrylk[%d](BLOCKED)", count); } | |||
2245 | "entrylk[%d](BLOCKED)", count ){ _gf_proc_dump_build_key(key, "xlator.feature.locks.lock-dump.domain.entrylk" , "entrylk[%d](BLOCKED)", count); }; | |||
2246 | snprintf (tmp, 256, ENTRY_BLKD_FMT"type=%s on basename=%s"", ""pid = %llu, owner=%s, transport=%p, " ", ""blocked at %s", | |||
2247 | lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" : | |||
2248 | "ENTRYLK_WRLCK", lock->basename, | |||
2249 | (unsigned long long) lock->client_pid, | |||
2250 | lkowner_utoa (&lock->owner), lock->trans, | |||
2251 | ctime_r (&lock->blkd_time.tv_sec, blocked)); | |||
2252 | ||||
2253 | gf_proc_dump_write(key, tmp); | |||
2254 | ||||
2255 | count++; | |||
2256 | } | |||
2257 | ||||
2258 | } | |||
2259 | ||||
2260 | } | |||
2261 | ||||
2262 | void | |||
2263 | dump_entrylks (pl_inode_t *pl_inode) | |||
2264 | { | |||
2265 | pthread_mutex_lock (&pl_inode->mutex); | |||
2266 | { | |||
2267 | __dump_entrylks (pl_inode); | |||
2268 | } | |||
2269 | pthread_mutex_unlock (&pl_inode->mutex); | |||
2270 | ||||
2271 | } | |||
2272 | ||||
2273 | void | |||
2274 | __dump_inodelks (pl_inode_t *pl_inode) | |||
2275 | { | |||
2276 | pl_dom_list_t *dom = NULL((void*)0); | |||
2277 | pl_inode_lock_t *lock = NULL((void*)0); | |||
2278 | int count = 0; | |||
2279 | char key[GF_DUMP_MAX_BUF_LEN4096]; | |||
2280 | ||||
2281 | char tmp[256]; | |||
2282 | ||||
2283 | list_for_each_entry (dom, &pl_inode->dom_list, inode_list)for (dom = ((typeof(*dom) *)((char *)((&pl_inode->dom_list )->next)-(unsigned long)(&((typeof(*dom) *)0)->inode_list ))); &dom->inode_list != (&pl_inode->dom_list); dom = ((typeof(*dom) *)((char *)(dom->inode_list.next)-(unsigned long)(&((typeof(*dom) *)0)->inode_list)))) { | |||
2284 | ||||
2285 | count = 0; | |||
2286 | ||||
2287 | gf_proc_dump_build_key(key,{ _gf_proc_dump_build_key(key, "lock-dump.domain", "domain"); } | |||
2288 | "lock-dump.domain",{ _gf_proc_dump_build_key(key, "lock-dump.domain", "domain"); } | |||
2289 | "domain"){ _gf_proc_dump_build_key(key, "lock-dump.domain", "domain"); }; | |||
2290 | gf_proc_dump_write(key, "%s", dom->domain); | |||
2291 | ||||
2292 | list_for_each_entry (lock, &dom->inodelk_list, list)for (lock = ((typeof(*lock) *)((char *)((&dom->inodelk_list )->next)-(unsigned long)(&((typeof(*lock) *)0)->list ))); &lock->list != (&dom->inodelk_list); lock = ((typeof(*lock) *)((char *)(lock->list.next)-(unsigned long )(&((typeof(*lock) *)0)->list)))) { | |||
2293 | ||||
2294 | gf_proc_dump_build_key(key,{ _gf_proc_dump_build_key(key, "inodelk", "inodelk[%d](ACTIVE)" ,count); } | |||
2295 | "inodelk",{ _gf_proc_dump_build_key(key, "inodelk", "inodelk[%d](ACTIVE)" ,count); } | |||
2296 | "inodelk[%d](ACTIVE)",count ){ _gf_proc_dump_build_key(key, "inodelk", "inodelk[%d](ACTIVE)" ,count); }; | |||
2297 | ||||
2298 | SET_FLOCK_PID (&lock->user_flock, lock)((&lock->user_flock)->l_pid = lock->client_pid); | |||
2299 | pl_dump_lock (tmp, 256, &lock->user_flock, | |||
2300 | &lock->owner, | |||
2301 | lock->transport, | |||
2302 | &lock->granted_time.tv_sec, | |||
2303 | &lock->blkd_time.tv_sec, | |||
2304 | _gf_true); | |||
2305 | gf_proc_dump_write(key, tmp); | |||
2306 | ||||
2307 | count++; | |||
2308 | } | |||
2309 | ||||
2310 | list_for_each_entry (lock, &dom->blocked_inodelks, blocked_locks)for (lock = ((typeof(*lock) *)((char *)((&dom->blocked_inodelks )->next)-(unsigned long)(&((typeof(*lock) *)0)->blocked_locks ))); &lock->blocked_locks != (&dom->blocked_inodelks ); lock = ((typeof(*lock) *)((char *)(lock->blocked_locks. next)-(unsigned long)(&((typeof(*lock) *)0)->blocked_locks )))) { | |||
2311 | ||||
2312 | gf_proc_dump_build_key(key,{ _gf_proc_dump_build_key(key, "inodelk", "inodelk[%d](BLOCKED)" ,count); } | |||
2313 | "inodelk",{ _gf_proc_dump_build_key(key, "inodelk", "inodelk[%d](BLOCKED)" ,count); } | |||
2314 | "inodelk[%d](BLOCKED)",count ){ _gf_proc_dump_build_key(key, "inodelk", "inodelk[%d](BLOCKED)" ,count); }; | |||
2315 | SET_FLOCK_PID (&lock->user_flock, lock)((&lock->user_flock)->l_pid = lock->client_pid); | |||
2316 | pl_dump_lock (tmp, 256, &lock->user_flock, | |||
2317 | &lock->owner, | |||
2318 | lock->transport, | |||
2319 | 0, &lock->blkd_time.tv_sec, | |||
2320 | _gf_false); | |||
2321 | gf_proc_dump_write(key, tmp); | |||
2322 | ||||
2323 | count++; | |||
2324 | } | |||
2325 | ||||
2326 | } | |||
2327 | ||||
2328 | } | |||
2329 | ||||
2330 | void | |||
2331 | dump_inodelks (pl_inode_t *pl_inode) | |||
2332 | { | |||
2333 | pthread_mutex_lock (&pl_inode->mutex); | |||
2334 | { | |||
2335 | __dump_inodelks (pl_inode); | |||
2336 | } | |||
2337 | pthread_mutex_unlock (&pl_inode->mutex); | |||
2338 | ||||
2339 | } | |||
2340 | ||||
2341 | void | |||
2342 | __dump_posixlks (pl_inode_t *pl_inode) | |||
2343 | { | |||
2344 | posix_lock_t *lock = NULL((void*)0); | |||
2345 | int count = 0; | |||
2346 | char key[GF_DUMP_MAX_BUF_LEN4096]; | |||
2347 | ||||
2348 | char tmp[256]; | |||
2349 | ||||
2350 | list_for_each_entry (lock, &pl_inode->ext_list, list)for (lock = ((typeof(*lock) *)((char *)((&pl_inode->ext_list )->next)-(unsigned long)(&((typeof(*lock) *)0)->list ))); &lock->list != (&pl_inode->ext_list); lock = ((typeof(*lock) *)((char *)(lock->list.next)-(unsigned long )(&((typeof(*lock) *)0)->list)))) { | |||
2351 | ||||
2352 | SET_FLOCK_PID (&lock->user_flock, lock)((&lock->user_flock)->l_pid = lock->client_pid); | |||
2353 | gf_proc_dump_build_key(key,{ _gf_proc_dump_build_key(key, "posixlk", "posixlk[%d](%s)", count , lock->blocked ? "BLOCKED" : "ACTIVE"); } | |||
2354 | "posixlk",{ _gf_proc_dump_build_key(key, "posixlk", "posixlk[%d](%s)", count , lock->blocked ? "BLOCKED" : "ACTIVE"); } | |||
2355 | "posixlk[%d](%s)",{ _gf_proc_dump_build_key(key, "posixlk", "posixlk[%d](%s)", count , lock->blocked ? "BLOCKED" : "ACTIVE"); } | |||
2356 | count,{ _gf_proc_dump_build_key(key, "posixlk", "posixlk[%d](%s)", count , lock->blocked ? "BLOCKED" : "ACTIVE"); } | |||
2357 | lock->blocked ? "BLOCKED" : "ACTIVE"){ _gf_proc_dump_build_key(key, "posixlk", "posixlk[%d](%s)", count , lock->blocked ? "BLOCKED" : "ACTIVE"); }; | |||
2358 | pl_dump_lock (tmp, 256, &lock->user_flock, | |||
2359 | &lock->owner, lock->transport, | |||
2360 | &lock->granted_time.tv_sec, &lock->blkd_time.tv_sec, | |||
2361 | (lock->blocked)? _gf_false: _gf_true); | |||
2362 | gf_proc_dump_write(key, tmp); | |||
2363 | ||||
2364 | count++; | |||
2365 | } | |||
2366 | } | |||
2367 | ||||
2368 | void | |||
2369 | dump_posixlks (pl_inode_t *pl_inode) | |||
2370 | { | |||
2371 | pthread_mutex_lock (&pl_inode->mutex); | |||
2372 | { | |||
2373 | __dump_posixlks (pl_inode); | |||
2374 | } | |||
2375 | pthread_mutex_unlock (&pl_inode->mutex); | |||
2376 | ||||
2377 | } | |||
2378 | ||||
2379 | int32_t | |||
2380 | pl_dump_inode_priv (xlator_t *this, inode_t *inode) | |||
2381 | { | |||
2382 | ||||
2383 | int ret = -1; | |||
2384 | uint64_t tmp_pl_inode = 0; | |||
2385 | pl_inode_t *pl_inode = NULL((void*)0); | |||
2386 | char *pathname = NULL((void*)0); | |||
2387 | gf_boolean_t section_added = _gf_false; | |||
2388 | ||||
2389 | int count = 0; | |||
2390 | ||||
2391 | if (!inode) { | |||
2392 | errno(*__errno_location ()) = EINVAL22; | |||
2393 | goto out; | |||
2394 | } | |||
2395 | ||||
2396 | ret = TRY_LOCK (&inode->lock)pthread_spin_trylock (&inode->lock); | |||
2397 | if (ret) | |||
2398 | goto out; | |||
2399 | { | |||
2400 | ret = __inode_ctx_get (inode, this, &tmp_pl_inode)__inode_ctx_get2(inode,this,&tmp_pl_inode,0); | |||
2401 | if (ret) | |||
2402 | goto unlock; | |||
2403 | } | |||
2404 | unlock: | |||
2405 | UNLOCK (&inode->lock)pthread_spin_unlock (&inode->lock); | |||
2406 | if (ret) | |||
2407 | goto out; | |||
2408 | ||||
2409 | pl_inode = (pl_inode_t *)(long)tmp_pl_inode; | |||
2410 | if (!pl_inode) { | |||
2411 | ret = -1; | |||
2412 | goto out; | |||
2413 | } | |||
2414 | ||||
2415 | gf_proc_dump_add_section("xlator.features.locks.%s.inode", this->name); | |||
2416 | section_added = _gf_true; | |||
2417 | ||||
2418 | /*We are safe to call __inode_path since we have the | |||
2419 | * inode->table->lock */ | |||
2420 | __inode_path (inode, NULL((void*)0), &pathname); | |||
2421 | if (pathname) | |||
2422 | gf_proc_dump_write ("path", "%s", pathname); | |||
2423 | ||||
2424 | gf_proc_dump_write("mandatory", "%d", pl_inode->mandatory); | |||
2425 | ||||
2426 | ret = pthread_mutex_trylock (&pl_inode->mutex); | |||
2427 | if (ret) | |||
2428 | goto out; | |||
2429 | { | |||
2430 | count = __get_entrylk_count (this, pl_inode); | |||
2431 | if (count) { | |||
2432 | gf_proc_dump_write("entrylk-count", "%d", count); | |||
2433 | __dump_entrylks (pl_inode); | |||
2434 | } | |||
2435 | ||||
2436 | count = __get_inodelk_count (this, pl_inode); | |||
2437 | if (count) { | |||
2438 | gf_proc_dump_write("inodelk-count", "%d", count); | |||
2439 | __dump_inodelks (pl_inode); | |||
2440 | } | |||
2441 | ||||
2442 | count = __get_posixlk_count (this, pl_inode); | |||
2443 | if (count) { | |||
2444 | gf_proc_dump_write("posixlk-count", "%d", count); | |||
2445 | __dump_posixlks (pl_inode); | |||
2446 | } | |||
2447 | } | |||
2448 | pthread_mutex_unlock (&pl_inode->mutex); | |||
2449 | ||||
2450 | out: | |||
2451 | GF_FREE (pathname)__gf_free (pathname); | |||
2452 | ||||
2453 | if (ret && inode) { | |||
2454 | if (!section_added) | |||
2455 | gf_proc_dump_add_section ("xlator.features.locks.%s." | |||
2456 | "inode", this->name); | |||
2457 | gf_proc_dump_write ("Unable to print lock state", "(Lock " | |||
2458 | "acquisition failure) %s", | |||
2459 | uuid_utoa (inode->gfid)); | |||
2460 | } | |||
2461 | return ret; | |||
2462 | } | |||
2463 | ||||
2464 | int32_t | |||
2465 | mem_acct_init (xlator_t *this) | |||
2466 | { | |||
2467 | int ret = -1; | |||
2468 | ||||
2469 | if (!this) | |||
2470 | return ret; | |||
2471 | ||||
2472 | ret = xlator_mem_acct_init (this, gf_locks_mt_end + 1); | |||
2473 | ||||
2474 | if (ret != 0) { | |||
2475 | gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"do { do { if (0) printf ("Memory accounting init" "failed"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 2476 , GF_LOG_ERROR, "Memory accounting init" "failed"); } while ( 0) | |||
2476 | "failed")do { do { if (0) printf ("Memory accounting init" "failed"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 2476 , GF_LOG_ERROR, "Memory accounting init" "failed"); } while ( 0); | |||
2477 | return ret; | |||
2478 | } | |||
2479 | ||||
2480 | return ret; | |||
2481 | } | |||
2482 | ||||
2483 | int | |||
2484 | init (xlator_t *this) | |||
2485 | { | |||
2486 | posix_locks_private_t *priv = NULL((void*)0); | |||
2487 | xlator_list_t *trav = NULL((void*)0); | |||
2488 | data_t *mandatory = NULL((void*)0); | |||
2489 | data_t *trace = NULL((void*)0); | |||
2490 | int ret = -1; | |||
2491 | ||||
2492 | if (!this->children || this->children->next) { | |||
2493 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("FATAL: posix-locks should have exactly one child" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 2494, GF_LOG_CRITICAL, "FATAL: posix-locks should have exactly one child" ); } while (0) | |||
2494 | "FATAL: posix-locks should have exactly one child")do { do { if (0) printf ("FATAL: posix-locks should have exactly one child" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 2494, GF_LOG_CRITICAL, "FATAL: posix-locks should have exactly one child" ); } while (0); | |||
2495 | goto out; | |||
2496 | } | |||
2497 | ||||
2498 | if (!this->parents) { | |||
2499 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Volume is dangling. Please check the volume file." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 2500, GF_LOG_WARNING, "Volume is dangling. Please check the volume file." ); } while (0) | |||
2500 | "Volume is dangling. Please check the volume file.")do { do { if (0) printf ("Volume is dangling. Please check the volume file." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 2500, GF_LOG_WARNING, "Volume is dangling. Please check the volume file." ); } while (0); | |||
2501 | } | |||
2502 | ||||
2503 | trav = this->children; | |||
2504 | while (trav->xlator->children) | |||
2505 | trav = trav->xlator->children; | |||
2506 | ||||
2507 | if (strncmp ("storage/", trav->xlator->type, 8)) { | |||
2508 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("'locks' translator is not loaded over a storage " "translator"); } while (0); _gf_log (this->name, "posix.c" , __FUNCTION__, 2510, GF_LOG_CRITICAL, "'locks' translator is not loaded over a storage " "translator"); } while (0) | |||
2509 | "'locks' translator is not loaded over a storage "do { do { if (0) printf ("'locks' translator is not loaded over a storage " "translator"); } while (0); _gf_log (this->name, "posix.c" , __FUNCTION__, 2510, GF_LOG_CRITICAL, "'locks' translator is not loaded over a storage " "translator"); } while (0) | |||
2510 | "translator")do { do { if (0) printf ("'locks' translator is not loaded over a storage " "translator"); } while (0); _gf_log (this->name, "posix.c" , __FUNCTION__, 2510, GF_LOG_CRITICAL, "'locks' translator is not loaded over a storage " "translator"); } while (0); | |||
2511 | goto out;; | |||
2512 | } | |||
2513 | ||||
2514 | priv = GF_CALLOC (1, sizeof (*priv),__gf_calloc (1, sizeof (*priv), gf_locks_mt_posix_locks_private_t ) | |||
2515 | gf_locks_mt_posix_locks_private_t)__gf_calloc (1, sizeof (*priv), gf_locks_mt_posix_locks_private_t ); | |||
2516 | ||||
2517 | mandatory = dict_get (this->options, "mandatory-locks"); | |||
2518 | if (mandatory) | |||
2519 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("mandatory locks not supported in this minor release." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 2520, GF_LOG_WARNING, "mandatory locks not supported in this minor release." ); } while (0) | |||
2520 | "mandatory locks not supported in this minor release.")do { do { if (0) printf ("mandatory locks not supported in this minor release." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 2520, GF_LOG_WARNING, "mandatory locks not supported in this minor release." ); } while (0); | |||
2521 | ||||
2522 | trace = dict_get (this->options, "trace"); | |||
2523 | if (trace) { | |||
2524 | if (gf_string2boolean (trace->data, | |||
2525 | &priv->trace) == -1) { | |||
2526 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("'trace' takes on only boolean values." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 2527, GF_LOG_ERROR, "'trace' takes on only boolean values." ); } while (0) | |||
2527 | "'trace' takes on only boolean values.")do { do { if (0) printf ("'trace' takes on only boolean values." ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 2527, GF_LOG_ERROR, "'trace' takes on only boolean values." ); } while (0); | |||
2528 | goto out; | |||
2529 | } | |||
2530 | } | |||
2531 | ||||
2532 | this->local_pool = mem_pool_new (pl_local_t, 32)mem_pool_new_fn (sizeof(pl_local_t), 32, "pl_local_t"); | |||
2533 | if (!this->local_pool) { | |||
2534 | ret = -1; | |||
2535 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to create local_t's memory pool" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 2536, GF_LOG_ERROR, "failed to create local_t's memory pool" ); } while (0) | |||
2536 | "failed to create local_t's memory pool")do { do { if (0) printf ("failed to create local_t's memory pool" ); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__ , 2536, GF_LOG_ERROR, "failed to create local_t's memory pool" ); } while (0); | |||
2537 | goto out; | |||
2538 | } | |||
2539 | ||||
2540 | this->private = priv; | |||
2541 | ret = 0; | |||
2542 | ||||
2543 | out: | |||
2544 | if (ret) { | |||
2545 | GF_FREE (priv)__gf_free (priv); | |||
2546 | } | |||
2547 | return ret; | |||
2548 | } | |||
2549 | ||||
2550 | ||||
2551 | int | |||
2552 | fini (xlator_t *this) | |||
2553 | { | |||
2554 | posix_locks_private_t *priv = NULL((void*)0); | |||
2555 | ||||
2556 | priv = this->private; | |||
2557 | if (!priv) | |||
2558 | return 0; | |||
2559 | this->private = NULL((void*)0); | |||
2560 | GF_FREE (priv->brickname)__gf_free (priv->brickname); | |||
2561 | GF_FREE (priv)__gf_free (priv); | |||
2562 | ||||
2563 | return 0; | |||
2564 | } | |||
2565 | ||||
2566 | ||||
2567 | int | |||
2568 | pl_inodelk (call_frame_t *frame, xlator_t *this, | |||
2569 | const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *flock, | |||
2570 | dict_t *xdata); | |||
2571 | ||||
2572 | int | |||
2573 | pl_finodelk (call_frame_t *frame, xlator_t *this, | |||
2574 | const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *flock, | |||
2575 | dict_t *xdata); | |||
2576 | ||||
2577 | int | |||
2578 | pl_entrylk (call_frame_t *frame, xlator_t *this, | |||
2579 | const char *volume, loc_t *loc, const char *basename, | |||
2580 | entrylk_cmd cmd, entrylk_type type, dict_t *xdata); | |||
2581 | ||||
2582 | int | |||
2583 | pl_fentrylk (call_frame_t *frame, xlator_t *this, | |||
2584 | const char *volume, fd_t *fd, const char *basename, | |||
2585 | entrylk_cmd cmd, entrylk_type type, dict_t *xdata); | |||
2586 | ||||
2587 | struct xlator_fops fops = { | |||
2588 | .lookup = pl_lookup, | |||
2589 | .create = pl_create, | |||
2590 | .truncate = pl_truncate, | |||
2591 | .ftruncate = pl_ftruncate, | |||
2592 | .open = pl_open, | |||
2593 | .readv = pl_readv, | |||
2594 | .writev = pl_writev, | |||
2595 | .lk = pl_lk, | |||
2596 | .inodelk = pl_inodelk, | |||
2597 | .finodelk = pl_finodelk, | |||
2598 | .entrylk = pl_entrylk, | |||
2599 | .fentrylk = pl_fentrylk, | |||
2600 | .flush = pl_flush, | |||
2601 | .opendir = pl_opendir, | |||
2602 | .readdirp = pl_readdirp, | |||
2603 | .getxattr = pl_getxattr, | |||
2604 | .fgetxattr = pl_fgetxattr, | |||
2605 | .fsetxattr = pl_fsetxattr, | |||
2606 | }; | |||
2607 | ||||
2608 | struct xlator_dumpops dumpops = { | |||
2609 | .inodectx = pl_dump_inode_priv, | |||
2610 | }; | |||
2611 | ||||
2612 | struct xlator_cbks cbks = { | |||
2613 | .forget = pl_forget, | |||
2614 | .release = pl_release, | |||
2615 | .releasedir = pl_releasedir, | |||
2616 | }; | |||
2617 | ||||
2618 | ||||
2619 | struct volume_options options[] = { | |||
2620 | { .key = { "mandatory-locks", "mandatory" }, | |||
2621 | .type = GF_OPTION_TYPE_BOOL | |||
2622 | }, | |||
2623 | { .key = { "trace" }, | |||
2624 | .type = GF_OPTION_TYPE_BOOL | |||
2625 | }, | |||
2626 | { .key = {NULL((void*)0)} }, | |||
2627 | }; |