File: | xlators/features/locks/src/inodelk.c |
Location: | line 451, column 9 |
Description: | The left operand of '-' is a garbage 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 | #ifndef _CONFIG_H | ||
11 | #define _CONFIG_H | ||
12 | #include "config.h" | ||
13 | #endif | ||
14 | |||
15 | #include "glusterfs.h" | ||
16 | #include "compat.h" | ||
17 | #include "xlator.h" | ||
18 | #include "inode.h" | ||
19 | #include "logging.h" | ||
20 | #include "common-utils.h" | ||
21 | #include "list.h" | ||
22 | |||
23 | #include "locks.h" | ||
24 | #include "common.h" | ||
25 | |||
26 | inline void | ||
27 | __delete_inode_lock (pl_inode_lock_t *lock) | ||
28 | { | ||
29 | list_del (&lock->list); | ||
30 | } | ||
31 | |||
32 | static inline void | ||
33 | __pl_inodelk_ref (pl_inode_lock_t *lock) | ||
34 | { | ||
35 | lock->ref++; | ||
36 | } | ||
37 | |||
38 | inline void | ||
39 | __pl_inodelk_unref (pl_inode_lock_t *lock) | ||
40 | { | ||
41 | lock->ref--; | ||
42 | if (!lock->ref) | ||
43 | GF_FREE (lock)__gf_free (lock); | ||
44 | } | ||
45 | |||
46 | /* Check if 2 inodelks are conflicting on type. Only 2 shared locks don't conflict */ | ||
47 | static inline int | ||
48 | inodelk_type_conflict (pl_inode_lock_t *l1, pl_inode_lock_t *l2) | ||
49 | { | ||
50 | if (l2->fl_type == F_WRLCK1 || l1->fl_type == F_WRLCK1) | ||
51 | return 1; | ||
52 | |||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | void | ||
57 | pl_print_inodelk (char *str, int size, int cmd, struct gf_flock *flock, const char *domain) | ||
58 | { | ||
59 | char *cmd_str = NULL((void*)0); | ||
60 | char *type_str = NULL((void*)0); | ||
61 | |||
62 | switch (cmd) { | ||
63 | #if F_GETLK12 != F_GETLK6412 | ||
64 | case F_GETLK6412: | ||
65 | #endif | ||
66 | case F_GETLK12: | ||
67 | cmd_str = "GETLK"; | ||
68 | break; | ||
69 | |||
70 | #if F_SETLK13 != F_SETLK6413 | ||
71 | case F_SETLK6413: | ||
72 | #endif | ||
73 | case F_SETLK13: | ||
74 | cmd_str = "SETLK"; | ||
75 | break; | ||
76 | |||
77 | #if F_SETLKW14 != F_SETLKW6414 | ||
78 | case F_SETLKW6414: | ||
79 | #endif | ||
80 | case F_SETLKW14: | ||
81 | cmd_str = "SETLKW"; | ||
82 | break; | ||
83 | |||
84 | default: | ||
85 | cmd_str = "UNKNOWN"; | ||
86 | break; | ||
87 | } | ||
88 | |||
89 | switch (flock->l_type) { | ||
90 | case F_RDLCK0: | ||
91 | type_str = "READ"; | ||
92 | break; | ||
93 | case F_WRLCK1: | ||
94 | type_str = "WRITE"; | ||
95 | break; | ||
96 | case F_UNLCK2: | ||
97 | type_str = "UNLOCK"; | ||
98 | break; | ||
99 | default: | ||
100 | type_str = "UNKNOWN"; | ||
101 | break; | ||
102 | } | ||
103 | |||
104 | snprintf (str, size, "lock=INODELK, cmd=%s, type=%s, " | ||
105 | "domain: %s, start=%llu, len=%llu, pid=%llu", | ||
106 | cmd_str, type_str, domain, | ||
107 | (unsigned long long) flock->l_start, | ||
108 | (unsigned long long) flock->l_len, | ||
109 | (unsigned long long) flock->l_pid); | ||
110 | } | ||
111 | |||
112 | /* Determine if the two inodelks overlap reach other's lock regions */ | ||
113 | static int | ||
114 | inodelk_overlap (pl_inode_lock_t *l1, pl_inode_lock_t *l2) | ||
115 | { | ||
116 | return ((l1->fl_end >= l2->fl_start) && | ||
117 | (l2->fl_end >= l1->fl_start)); | ||
118 | } | ||
119 | |||
120 | /* Returns true if the 2 inodelks have the same owner */ | ||
121 | static inline int | ||
122 | same_inodelk_owner (pl_inode_lock_t *l1, pl_inode_lock_t *l2) | ||
123 | { | ||
124 | return (is_same_lkowner (&l1->owner, &l2->owner) && | ||
125 | (l1->transport == l2->transport)); | ||
126 | } | ||
127 | |||
128 | /* Returns true if the 2 inodelks conflict with each other */ | ||
129 | static int | ||
130 | inodelk_conflict (pl_inode_lock_t *l1, pl_inode_lock_t *l2) | ||
131 | { | ||
132 | return (inodelk_overlap (l1, l2) && | ||
133 | inodelk_type_conflict (l1, l2)); | ||
134 | } | ||
135 | |||
136 | /* Determine if lock is grantable or not */ | ||
137 | static pl_inode_lock_t * | ||
138 | __inodelk_grantable (pl_dom_list_t *dom, pl_inode_lock_t *lock) | ||
139 | { | ||
140 | pl_inode_lock_t *l = NULL((void*)0); | ||
141 | pl_inode_lock_t *ret = NULL((void*)0); | ||
142 | if (list_empty (&dom->inodelk_list)) | ||
143 | goto out; | ||
144 | list_for_each_entry (l, &dom->inodelk_list, list)for (l = ((typeof(*l) *)((char *)((&dom->inodelk_list) ->next)-(unsigned long)(&((typeof(*l) *)0)->list))) ; &l->list != (&dom->inodelk_list); l = ((typeof (*l) *)((char *)(l->list.next)-(unsigned long)(&((typeof (*l) *)0)->list)))){ | ||
145 | if (inodelk_conflict (lock, l) && | ||
146 | !same_inodelk_owner (lock, l)) { | ||
147 | ret = l; | ||
148 | goto out; | ||
149 | } | ||
150 | } | ||
151 | out: | ||
152 | return ret; | ||
153 | } | ||
154 | |||
155 | static pl_inode_lock_t * | ||
156 | __blocked_lock_conflict (pl_dom_list_t *dom, pl_inode_lock_t *lock) | ||
157 | { | ||
158 | pl_inode_lock_t *l = NULL((void*)0); | ||
159 | pl_inode_lock_t *ret = NULL((void*)0); | ||
160 | |||
161 | if (list_empty (&dom->blocked_inodelks)) | ||
162 | return NULL((void*)0); | ||
163 | |||
164 | list_for_each_entry (l, &dom->blocked_inodelks, blocked_locks)for (l = ((typeof(*l) *)((char *)((&dom->blocked_inodelks )->next)-(unsigned long)(&((typeof(*l) *)0)->blocked_locks ))); &l->blocked_locks != (&dom->blocked_inodelks ); l = ((typeof(*l) *)((char *)(l->blocked_locks.next)-(unsigned long)(&((typeof(*l) *)0)->blocked_locks)))) { | ||
165 | if (inodelk_conflict (lock, l)) { | ||
166 | ret = l; | ||
167 | goto out; | ||
168 | } | ||
169 | } | ||
170 | |||
171 | out: | ||
172 | return ret; | ||
173 | } | ||
174 | |||
175 | static int | ||
176 | __owner_has_lock (pl_dom_list_t *dom, pl_inode_lock_t *newlock) | ||
177 | { | ||
178 | pl_inode_lock_t *lock = NULL((void*)0); | ||
179 | |||
180 | 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)))) { | ||
181 | if (same_inodelk_owner (lock, newlock)) | ||
182 | return 1; | ||
183 | } | ||
184 | |||
185 | 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 )))) { | ||
186 | if (same_inodelk_owner (lock, newlock)) | ||
187 | return 1; | ||
188 | } | ||
189 | |||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | |||
194 | /* Determines if lock can be granted and adds the lock. If the lock | ||
195 | * is blocking, adds it to the blocked_inodelks list of the domain. | ||
196 | */ | ||
197 | static int | ||
198 | __lock_inodelk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock, | ||
199 | int can_block, pl_dom_list_t *dom) | ||
200 | { | ||
201 | pl_inode_lock_t *conf = NULL((void*)0); | ||
202 | int ret = -EINVAL22; | ||
203 | |||
204 | conf = __inodelk_grantable (dom, lock); | ||
205 | if (conf){ | ||
206 | ret = -EAGAIN11; | ||
207 | if (can_block == 0) | ||
208 | goto out; | ||
209 | |||
210 | gettimeofday (&lock->blkd_time, NULL((void*)0)); | ||
211 | list_add_tail (&lock->blocked_locks, &dom->blocked_inodelks); | ||
212 | |||
213 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("%s (pid=%d) lk-owner:%s %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 219, GF_LOG_TRACE , "%s (pid=%d) lk-owner:%s %""ll" "d"" - %""ll" "d"" => Blocked" , lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid , lkowner_utoa (&lock->owner), lock->user_flock.l_start , lock->user_flock.l_len); } while (0) | ||
214 | "%s (pid=%d) lk-owner:%s %"PRId64" - %"PRId64" => Blocked",do { do { if (0) printf ("%s (pid=%d) lk-owner:%s %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 219, GF_LOG_TRACE , "%s (pid=%d) lk-owner:%s %""ll" "d"" - %""ll" "d"" => Blocked" , lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid , lkowner_utoa (&lock->owner), lock->user_flock.l_start , lock->user_flock.l_len); } while (0) | ||
215 | lock->fl_type == F_UNLCK ? "Unlock" : "Lock",do { do { if (0) printf ("%s (pid=%d) lk-owner:%s %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 219, GF_LOG_TRACE , "%s (pid=%d) lk-owner:%s %""ll" "d"" - %""ll" "d"" => Blocked" , lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid , lkowner_utoa (&lock->owner), lock->user_flock.l_start , lock->user_flock.l_len); } while (0) | ||
216 | lock->client_pid,do { do { if (0) printf ("%s (pid=%d) lk-owner:%s %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 219, GF_LOG_TRACE , "%s (pid=%d) lk-owner:%s %""ll" "d"" - %""ll" "d"" => Blocked" , lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid , lkowner_utoa (&lock->owner), lock->user_flock.l_start , lock->user_flock.l_len); } while (0) | ||
217 | lkowner_utoa (&lock->owner),do { do { if (0) printf ("%s (pid=%d) lk-owner:%s %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 219, GF_LOG_TRACE , "%s (pid=%d) lk-owner:%s %""ll" "d"" - %""ll" "d"" => Blocked" , lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid , lkowner_utoa (&lock->owner), lock->user_flock.l_start , lock->user_flock.l_len); } while (0) | ||
218 | lock->user_flock.l_start,do { do { if (0) printf ("%s (pid=%d) lk-owner:%s %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 219, GF_LOG_TRACE , "%s (pid=%d) lk-owner:%s %""ll" "d"" - %""ll" "d"" => Blocked" , lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid , lkowner_utoa (&lock->owner), lock->user_flock.l_start , lock->user_flock.l_len); } while (0) | ||
219 | lock->user_flock.l_len)do { do { if (0) printf ("%s (pid=%d) lk-owner:%s %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 219, GF_LOG_TRACE , "%s (pid=%d) lk-owner:%s %""ll" "d"" - %""ll" "d"" => Blocked" , lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid , lkowner_utoa (&lock->owner), lock->user_flock.l_start , lock->user_flock.l_len); } while (0); | ||
220 | |||
221 | |||
222 | goto out; | ||
223 | } | ||
224 | |||
225 | if (__blocked_lock_conflict (dom, lock) && !(__owner_has_lock (dom, lock))) { | ||
226 | ret = -EAGAIN11; | ||
227 | if (can_block == 0) | ||
228 | goto out; | ||
229 | |||
230 | gettimeofday (&lock->blkd_time, NULL((void*)0)); | ||
231 | list_add_tail (&lock->blocked_locks, &dom->blocked_inodelks); | ||
232 | |||
233 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("Lock is grantable, but blocking to prevent starvation" ); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 234, GF_LOG_TRACE, "Lock is grantable, but blocking to prevent starvation" ); } while (0) | ||
234 | "Lock is grantable, but blocking to prevent starvation")do { do { if (0) printf ("Lock is grantable, but blocking to prevent starvation" ); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 234, GF_LOG_TRACE, "Lock is grantable, but blocking to prevent starvation" ); } while (0); | ||
235 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 241, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
236 | "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => Blocked",do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 241, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
237 | lock->fl_type == F_UNLCK ? "Unlock" : "Lock",do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 241, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
238 | lock->client_pid,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 241, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
239 | lkowner_utoa (&lock->owner),do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 241, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
240 | lock->user_flock.l_start,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 241, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
241 | lock->user_flock.l_len)do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 241, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Blocked", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0); | ||
242 | |||
243 | |||
244 | goto out; | ||
245 | } | ||
246 | __pl_inodelk_ref (lock); | ||
247 | gettimeofday (&lock->granted_time, NULL((void*)0)); | ||
248 | list_add (&lock->list, &dom->inodelk_list); | ||
249 | |||
250 | ret = 0; | ||
251 | |||
252 | out: | ||
253 | return ret; | ||
254 | } | ||
255 | |||
256 | /* Return true if the two inodelks have exactly same lock boundaries */ | ||
257 | static int | ||
258 | inodelks_equal (pl_inode_lock_t *l1, pl_inode_lock_t *l2) | ||
259 | { | ||
260 | if ((l1->fl_start == l2->fl_start) && | ||
261 | (l1->fl_end == l2->fl_end)) | ||
262 | return 1; | ||
263 | |||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | |||
268 | static pl_inode_lock_t * | ||
269 | find_matching_inodelk (pl_inode_lock_t *lock, pl_dom_list_t *dom) | ||
270 | { | ||
271 | pl_inode_lock_t *l = NULL((void*)0); | ||
272 | list_for_each_entry (l, &dom->inodelk_list, list)for (l = ((typeof(*l) *)((char *)((&dom->inodelk_list) ->next)-(unsigned long)(&((typeof(*l) *)0)->list))) ; &l->list != (&dom->inodelk_list); l = ((typeof (*l) *)((char *)(l->list.next)-(unsigned long)(&((typeof (*l) *)0)->list)))) { | ||
273 | if (inodelks_equal (l, lock) && | ||
274 | same_inodelk_owner (l, lock)) | ||
275 | return l; | ||
276 | } | ||
277 | return NULL((void*)0); | ||
278 | } | ||
279 | |||
280 | /* Set F_UNLCK removes a lock which has the exact same lock boundaries | ||
281 | * as the UNLCK lock specifies. If such a lock is not found, returns invalid | ||
282 | */ | ||
283 | static pl_inode_lock_t * | ||
284 | __inode_unlock_lock (xlator_t *this, pl_inode_lock_t *lock, pl_dom_list_t *dom) | ||
285 | { | ||
286 | |||
287 | pl_inode_lock_t *conf = NULL((void*)0); | ||
288 | |||
289 | conf = find_matching_inodelk (lock, dom); | ||
290 | if (!conf) { | ||
291 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf (" Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), lock ->transport); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 295, GF_LOG_ERROR, " Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), lock ->transport); } while (0) | ||
292 | " Matching lock not found for unlock %llu-%llu, by %s "do { do { if (0) printf (" Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), lock ->transport); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 295, GF_LOG_ERROR, " Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), lock ->transport); } while (0) | ||
293 | "on %p", (unsigned long long)lock->fl_start,do { do { if (0) printf (" Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), lock ->transport); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 295, GF_LOG_ERROR, " Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), lock ->transport); } while (0) | ||
294 | (unsigned long long)lock->fl_end,do { do { if (0) printf (" Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), lock ->transport); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 295, GF_LOG_ERROR, " Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), lock ->transport); } while (0) | ||
295 | lkowner_utoa (&lock->owner), lock->transport)do { do { if (0) printf (" Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), lock ->transport); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 295, GF_LOG_ERROR, " Matching lock not found for unlock %llu-%llu, by %s " "on %p", (unsigned long long)lock->fl_start, (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner), lock ->transport); } while (0); | ||
296 | goto out; | ||
297 | } | ||
298 | __delete_inode_lock (conf); | ||
299 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf (" Matching lock found for unlock %llu-%llu, by %s on %p" , (unsigned long long)lock->fl_start, (unsigned long long) lock->fl_end, lkowner_utoa (&lock->owner), lock-> transport); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 303, GF_LOG_DEBUG, " Matching lock found for unlock %llu-%llu, by %s on %p" , (unsigned long long)lock->fl_start, (unsigned long long) lock->fl_end, lkowner_utoa (&lock->owner), lock-> transport); } while (0) | ||
300 | " Matching lock found for unlock %llu-%llu, by %s on %p",do { do { if (0) printf (" Matching lock found for unlock %llu-%llu, by %s on %p" , (unsigned long long)lock->fl_start, (unsigned long long) lock->fl_end, lkowner_utoa (&lock->owner), lock-> transport); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 303, GF_LOG_DEBUG, " Matching lock found for unlock %llu-%llu, by %s on %p" , (unsigned long long)lock->fl_start, (unsigned long long) lock->fl_end, lkowner_utoa (&lock->owner), lock-> transport); } while (0) | ||
301 | (unsigned long long)lock->fl_start,do { do { if (0) printf (" Matching lock found for unlock %llu-%llu, by %s on %p" , (unsigned long long)lock->fl_start, (unsigned long long) lock->fl_end, lkowner_utoa (&lock->owner), lock-> transport); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 303, GF_LOG_DEBUG, " Matching lock found for unlock %llu-%llu, by %s on %p" , (unsigned long long)lock->fl_start, (unsigned long long) lock->fl_end, lkowner_utoa (&lock->owner), lock-> transport); } while (0) | ||
302 | (unsigned long long)lock->fl_end, lkowner_utoa (&lock->owner),do { do { if (0) printf (" Matching lock found for unlock %llu-%llu, by %s on %p" , (unsigned long long)lock->fl_start, (unsigned long long) lock->fl_end, lkowner_utoa (&lock->owner), lock-> transport); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 303, GF_LOG_DEBUG, " Matching lock found for unlock %llu-%llu, by %s on %p" , (unsigned long long)lock->fl_start, (unsigned long long) lock->fl_end, lkowner_utoa (&lock->owner), lock-> transport); } while (0) | ||
303 | lock->transport)do { do { if (0) printf (" Matching lock found for unlock %llu-%llu, by %s on %p" , (unsigned long long)lock->fl_start, (unsigned long long) lock->fl_end, lkowner_utoa (&lock->owner), lock-> transport); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 303, GF_LOG_DEBUG, " Matching lock found for unlock %llu-%llu, by %s on %p" , (unsigned long long)lock->fl_start, (unsigned long long) lock->fl_end, lkowner_utoa (&lock->owner), lock-> transport); } while (0); | ||
304 | |||
305 | out: | ||
306 | return conf; | ||
307 | } | ||
308 | static void | ||
309 | __grant_blocked_inode_locks (xlator_t *this, pl_inode_t *pl_inode, | ||
310 | struct list_head *granted, pl_dom_list_t *dom) | ||
311 | { | ||
312 | int bl_ret = 0; | ||
313 | pl_inode_lock_t *bl = NULL((void*)0); | ||
314 | pl_inode_lock_t *tmp = NULL((void*)0); | ||
315 | |||
316 | struct list_head blocked_list; | ||
317 | |||
318 | INIT_LIST_HEAD (&blocked_list)do { (&blocked_list)->next = (&blocked_list)->prev = &blocked_list; } while (0); | ||
319 | list_splice_init (&dom->blocked_inodelks, &blocked_list); | ||
320 | |||
321 | list_for_each_entry_safe (bl, tmp, &blocked_list, blocked_locks)for (bl = ((typeof(*bl) *)((char *)((&blocked_list)->next )-(unsigned long)(&((typeof(*bl) *)0)->blocked_locks)) ), tmp = ((typeof(*bl) *)((char *)(bl->blocked_locks.next) -(unsigned long)(&((typeof(*bl) *)0)->blocked_locks))) ; &bl->blocked_locks != (&blocked_list); bl = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->blocked_locks.next) -(unsigned long)(&((typeof(*tmp) *)0)->blocked_locks)) )) { | ||
322 | |||
323 | list_del_init (&bl->blocked_locks); | ||
324 | |||
325 | bl_ret = __lock_inodelk (this, pl_inode, bl, 1, dom); | ||
326 | |||
327 | if (bl_ret == 0) { | ||
328 | list_add (&bl->blocked_locks, granted); | ||
329 | } | ||
330 | } | ||
331 | return; | ||
332 | } | ||
333 | |||
334 | /* Grant all inodelks blocked on a lock */ | ||
335 | void | ||
336 | grant_blocked_inode_locks (xlator_t *this, pl_inode_t *pl_inode, pl_dom_list_t *dom) | ||
337 | { | ||
338 | struct list_head granted; | ||
339 | pl_inode_lock_t *lock; | ||
340 | pl_inode_lock_t *tmp; | ||
341 | |||
342 | INIT_LIST_HEAD (&granted)do { (&granted)->next = (&granted)->prev = & granted; } while (0); | ||
343 | |||
344 | pthread_mutex_lock (&pl_inode->mutex); | ||
345 | { | ||
346 | __grant_blocked_inode_locks (this, pl_inode, &granted, dom); | ||
347 | } | ||
348 | pthread_mutex_unlock (&pl_inode->mutex); | ||
349 | |||
350 | list_for_each_entry_safe (lock, tmp, &granted, blocked_locks)for (lock = ((typeof(*lock) *)((char *)((&granted)->next )-(unsigned long)(&((typeof(*lock) *)0)->blocked_locks ))), tmp = ((typeof(*lock) *)((char *)(lock->blocked_locks .next)-(unsigned long)(&((typeof(*lock) *)0)->blocked_locks ))); &lock->blocked_locks != (&granted); lock = tmp , tmp = ((typeof(*tmp) *)((char *)(tmp->blocked_locks.next )-(unsigned long)(&((typeof(*tmp) *)0)->blocked_locks) ))) { | ||
351 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 357, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
352 | "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => Granted",do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 357, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
353 | lock->fl_type == F_UNLCK ? "Unlock" : "Lock",do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 357, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
354 | lock->client_pid,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 357, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
355 | lkowner_utoa (&lock->owner),do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 357, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
356 | lock->user_flock.l_start,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 357, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
357 | lock->user_flock.l_len)do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 357, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => Granted", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0); | ||
358 | |||
359 | pl_trace_out (this, lock->frame, NULL((void*)0), NULL((void*)0), F_SETLKW14, | ||
360 | &lock->user_flock, 0, 0, lock->volume); | ||
361 | |||
362 | STACK_UNWIND_STRICT (inodelk, lock->frame, 0, 0, NULL)do { fop_inodelk_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!lock-> frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "inodelk.c", __FUNCTION__, 362, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_inodelk_cbk_t )lock->frame ->ret; _parent = lock->frame->parent; pthread_spin_lock (&lock->frame->root->stack_lock); { _parent-> ref_count--; } pthread_spin_unlock (&lock->frame->root ->stack_lock); old_THIS = (*__glusterfs_this_location()); ( *__glusterfs_this_location()) = _parent->this; lock->frame ->complete = _gf_true; lock->frame->unwind_from = __FUNCTION__ ; if (lock->frame->this->ctx->measure_latency) gf_latency_end (lock->frame); fn (_parent, lock->frame->cookie, _parent ->this, 0, 0, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | ||
363 | } | ||
364 | |||
365 | pthread_mutex_lock (&pl_inode->mutex); | ||
366 | { | ||
367 | list_for_each_entry_safe (lock, tmp, &granted, blocked_locks)for (lock = ((typeof(*lock) *)((char *)((&granted)->next )-(unsigned long)(&((typeof(*lock) *)0)->blocked_locks ))), tmp = ((typeof(*lock) *)((char *)(lock->blocked_locks .next)-(unsigned long)(&((typeof(*lock) *)0)->blocked_locks ))); &lock->blocked_locks != (&granted); lock = tmp , tmp = ((typeof(*tmp) *)((char *)(tmp->blocked_locks.next )-(unsigned long)(&((typeof(*tmp) *)0)->blocked_locks) ))) { | ||
368 | list_del_init (&lock->blocked_locks); | ||
369 | __pl_inodelk_unref (lock); | ||
370 | } | ||
371 | } | ||
372 | pthread_mutex_unlock (&pl_inode->mutex); | ||
373 | } | ||
374 | |||
375 | /* Release all inodelks from this transport */ | ||
376 | static int | ||
377 | release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom, | ||
378 | inode_t *inode, void *trans) | ||
379 | { | ||
380 | pl_inode_lock_t *tmp = NULL((void*)0); | ||
381 | pl_inode_lock_t *l = NULL((void*)0); | ||
382 | |||
383 | pl_inode_t * pinode = NULL((void*)0); | ||
384 | |||
385 | struct list_head released; | ||
386 | |||
387 | char *path = NULL((void*)0); | ||
388 | char *file = NULL((void*)0); | ||
389 | |||
390 | INIT_LIST_HEAD (&released)do { (&released)->next = (&released)->prev = & released; } while (0); | ||
391 | |||
392 | pinode = pl_inode_get (this, inode); | ||
393 | |||
394 | pthread_mutex_lock (&pinode->mutex); | ||
395 | { | ||
396 | |||
397 | list_for_each_entry_safe (l, tmp, &dom->blocked_inodelks, blocked_locks)for (l = ((typeof(*l) *)((char *)((&dom->blocked_inodelks )->next)-(unsigned long)(&((typeof(*l) *)0)->blocked_locks ))), tmp = ((typeof(*l) *)((char *)(l->blocked_locks.next) -(unsigned long)(&((typeof(*l) *)0)->blocked_locks))); &l->blocked_locks != (&dom->blocked_inodelks); l = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->blocked_locks .next)-(unsigned long)(&((typeof(*tmp) *)0)->blocked_locks )))) { | ||
398 | if (l->transport != trans) | ||
399 | continue; | ||
400 | |||
401 | list_del_init (&l->blocked_locks); | ||
402 | |||
403 | inode_path (inode, NULL((void*)0), &path); | ||
404 | if (path) | ||
405 | file = path; | ||
406 | else | ||
407 | file = uuid_utoa (inode->gfid); | ||
408 | |||
409 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("releasing blocking lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 413, GF_LOG_DEBUG, "releasing blocking lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0) | ||
410 | "releasing blocking lock on %s held by "do { do { if (0) printf ("releasing blocking lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 413, GF_LOG_DEBUG, "releasing blocking lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0) | ||
411 | "{transport=%p, pid=%"PRId64" lk-owner=%s}",do { do { if (0) printf ("releasing blocking lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 413, GF_LOG_DEBUG, "releasing blocking lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0) | ||
412 | file, trans, (uint64_t) l->client_pid,do { do { if (0) printf ("releasing blocking lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 413, GF_LOG_DEBUG, "releasing blocking lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0) | ||
413 | lkowner_utoa (&l->owner))do { do { if (0) printf ("releasing blocking lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 413, GF_LOG_DEBUG, "releasing blocking lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); | ||
414 | |||
415 | list_add (&l->blocked_locks, &released); | ||
416 | if (path) { | ||
417 | GF_FREE (path)__gf_free (path); | ||
418 | path = NULL((void*)0); | ||
419 | } | ||
420 | } | ||
421 | |||
422 | list_for_each_entry_safe (l, tmp, &dom->inodelk_list, list)for (l = ((typeof(*l) *)((char *)((&dom->inodelk_list) ->next)-(unsigned long)(&((typeof(*l) *)0)->list))) , tmp = ((typeof(*l) *)((char *)(l->list.next)-(unsigned long )(&((typeof(*l) *)0)->list))); &l->list != (& dom->inodelk_list); l = tmp, tmp = ((typeof(*tmp) *)((char *)(tmp->list.next)-(unsigned long)(&((typeof(*tmp) *) 0)->list)))) { | ||
423 | if (l->transport != trans) | ||
424 | continue; | ||
425 | |||
426 | inode_path (inode, NULL((void*)0), &path); | ||
427 | if (path) | ||
428 | file = path; | ||
429 | else | ||
430 | file = uuid_utoa (inode->gfid); | ||
431 | |||
432 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("releasing granted lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 436, GF_LOG_DEBUG, "releasing granted lock on %s held by " "{transport=%p, pid=%" "ll" "d"" lk-owner=%s}", file, trans, (uint64_t) l->client_pid , lkowner_utoa (&l->owner)); } while (0) | ||
433 | "releasing granted lock on %s held by "do { do { if (0) printf ("releasing granted lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 436, GF_LOG_DEBUG, "releasing granted lock on %s held by " "{transport=%p, pid=%" "ll" "d"" lk-owner=%s}", file, trans, (uint64_t) l->client_pid , lkowner_utoa (&l->owner)); } while (0) | ||
434 | "{transport=%p, pid=%"PRId64" lk-owner=%s}",do { do { if (0) printf ("releasing granted lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 436, GF_LOG_DEBUG, "releasing granted lock on %s held by " "{transport=%p, pid=%" "ll" "d"" lk-owner=%s}", file, trans, (uint64_t) l->client_pid , lkowner_utoa (&l->owner)); } while (0) | ||
435 | file, trans, (uint64_t) l->client_pid,do { do { if (0) printf ("releasing granted lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 436, GF_LOG_DEBUG, "releasing granted lock on %s held by " "{transport=%p, pid=%" "ll" "d"" lk-owner=%s}", file, trans, (uint64_t) l->client_pid , lkowner_utoa (&l->owner)); } while (0) | ||
436 | lkowner_utoa (&l->owner))do { do { if (0) printf ("releasing granted lock on %s held by " "{transport=%p, pid=%""ll" "d"" lk-owner=%s}", file, trans, ( uint64_t) l->client_pid, lkowner_utoa (&l->owner)); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 436, GF_LOG_DEBUG, "releasing granted lock on %s held by " "{transport=%p, pid=%" "ll" "d"" lk-owner=%s}", file, trans, (uint64_t) l->client_pid , lkowner_utoa (&l->owner)); } while (0); | ||
437 | |||
438 | if (path) { | ||
439 | GF_FREE (path)__gf_free (path); | ||
440 | path = NULL((void*)0); | ||
441 | } | ||
442 | |||
443 | __delete_inode_lock (l); | ||
444 | __pl_inodelk_unref (l); | ||
445 | } | ||
446 | } | ||
447 | GF_FREE (path)__gf_free (path); | ||
448 | |||
449 | pthread_mutex_unlock (&pinode->mutex); | ||
450 | |||
451 | list_for_each_entry_safe (l, tmp, &released, blocked_locks)for (l = ((typeof(*l) *)((char *)((&released)->next)-( unsigned long)(&((typeof(*l) *)0)->blocked_locks))), tmp = ((typeof(*l) *)((char *)(l->blocked_locks.next)-(unsigned long)(&((typeof(*l) *)0)->blocked_locks))); &l-> blocked_locks != (&released); l = tmp, tmp = ((typeof(*tmp ) *)((char *)(tmp->blocked_locks.next)-(unsigned long)(& ((typeof(*tmp) *)0)->blocked_locks)))) { | ||
Within the expansion of the macro 'list_for_each_entry_safe':
| |||
452 | list_del_init (&l->blocked_locks); | ||
453 | |||
454 | STACK_UNWIND_STRICT (inodelk, l->frame, -1, EAGAIN, NULL)do { fop_inodelk_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", "inodelk.c", __FUNCTION__, 454, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_inodelk_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, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | ||
455 | //No need to take lock as the locks are only in one list | ||
456 | __pl_inodelk_unref (l); | ||
457 | } | ||
458 | |||
459 | grant_blocked_inode_locks (this, pinode, dom); | ||
460 | return 0; | ||
461 | } | ||
462 | |||
463 | |||
464 | static int | ||
465 | pl_inode_setlk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock, | ||
466 | int can_block, pl_dom_list_t *dom) | ||
467 | { | ||
468 | int ret = -EINVAL22; | ||
469 | pl_inode_lock_t *retlock = NULL((void*)0); | ||
470 | gf_boolean_t unref = _gf_true; | ||
471 | |||
472 | pthread_mutex_lock (&pl_inode->mutex); | ||
473 | { | ||
474 | if (lock->fl_type != F_UNLCK2) { | ||
475 | ret = __lock_inodelk (this, pl_inode, lock, can_block, dom); | ||
476 | if (ret == 0) { | ||
477 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0); _gf_log ( this->name, "inodelk.c", __FUNCTION__, 483, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0) | ||
478 | "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => OK",do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0); _gf_log ( this->name, "inodelk.c", __FUNCTION__, 483, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0) | ||
479 | lock->fl_type == F_UNLCK ? "Unlock" : "Lock",do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0); _gf_log ( this->name, "inodelk.c", __FUNCTION__, 483, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0) | ||
480 | lock->client_pid,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0); _gf_log ( this->name, "inodelk.c", __FUNCTION__, 483, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0) | ||
481 | lkowner_utoa (&lock->owner),do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0); _gf_log ( this->name, "inodelk.c", __FUNCTION__, 483, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0) | ||
482 | lock->fl_start,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0); _gf_log ( this->name, "inodelk.c", __FUNCTION__, 483, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0) | ||
483 | lock->fl_end)do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0); _gf_log ( this->name, "inodelk.c", __FUNCTION__, 483, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %" "ll" "d"" - %""ll" "d"" => OK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->fl_start, lock->fl_end); } while (0); | ||
484 | } else if (ret == -EAGAIN11) { | ||
485 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 491, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
486 | "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => NOK",do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 491, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
487 | lock->fl_type == F_UNLCK ? "Unlock" : "Lock",do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 491, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
488 | lock->client_pid,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 491, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
489 | lkowner_utoa (&lock->owner),do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 491, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
490 | lock->user_flock.l_start,do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 491, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0) | ||
491 | lock->user_flock.l_len)do { do { if (0) printf ("%s (pid=%d) (lk-owner=%s) %""ll" "d" " - %""ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock", lock->client_pid, lkowner_utoa (&lock->owner ), lock->user_flock.l_start, lock->user_flock.l_len); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 491, GF_LOG_TRACE, "%s (pid=%d) (lk-owner=%s) %""ll" "d"" - %" "ll" "d"" => NOK", lock->fl_type == 2 ? "Unlock" : "Lock" , lock->client_pid, lkowner_utoa (&lock->owner), lock ->user_flock.l_start, lock->user_flock.l_len); } while ( 0); | ||
492 | if (can_block) | ||
493 | unref = _gf_false; | ||
494 | } | ||
495 | } else { | ||
496 | retlock = __inode_unlock_lock (this, lock, dom); | ||
497 | if (!retlock) { | ||
498 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Bad Unlock issued on Inode lock"); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 499, GF_LOG_DEBUG, "Bad Unlock issued on Inode lock"); } while (0) | ||
499 | "Bad Unlock issued on Inode lock")do { do { if (0) printf ("Bad Unlock issued on Inode lock"); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__ , 499, GF_LOG_DEBUG, "Bad Unlock issued on Inode lock"); } while (0); | ||
500 | ret = -EINVAL22; | ||
501 | goto out; | ||
502 | } | ||
503 | __pl_inodelk_unref (retlock); | ||
504 | |||
505 | ret = 0; | ||
506 | } | ||
507 | } | ||
508 | out: | ||
509 | if (unref) | ||
510 | __pl_inodelk_unref (lock); | ||
511 | pthread_mutex_unlock (&pl_inode->mutex); | ||
512 | grant_blocked_inode_locks (this, pl_inode, dom); | ||
513 | return ret; | ||
514 | } | ||
515 | |||
516 | /* Create a new inode_lock_t */ | ||
517 | pl_inode_lock_t * | ||
518 | new_inode_lock (struct gf_flock *flock, void *transport, pid_t client_pid, | ||
519 | gf_lkowner_t *owner, const char *volume) | ||
520 | |||
521 | { | ||
522 | pl_inode_lock_t *lock = NULL((void*)0); | ||
523 | |||
524 | lock = GF_CALLOC (1, sizeof (*lock),__gf_calloc (1, sizeof (*lock), gf_locks_mt_pl_inode_lock_t) | ||
525 | gf_locks_mt_pl_inode_lock_t)__gf_calloc (1, sizeof (*lock), gf_locks_mt_pl_inode_lock_t); | ||
526 | if (!lock) { | ||
527 | return NULL((void*)0); | ||
528 | } | ||
529 | |||
530 | lock->fl_start = flock->l_start; | ||
531 | lock->fl_type = flock->l_type; | ||
532 | |||
533 | if (flock->l_len == 0) | ||
534 | lock->fl_end = LLONG_MAX9223372036854775807LL; | ||
535 | else | ||
536 | lock->fl_end = flock->l_start + flock->l_len - 1; | ||
537 | |||
538 | lock->transport = transport; | ||
539 | lock->client_pid = client_pid; | ||
540 | lock->volume = volume; | ||
541 | lock->owner = *owner; | ||
542 | |||
543 | INIT_LIST_HEAD (&lock->list)do { (&lock->list)->next = (&lock->list)-> prev = &lock->list; } while (0); | ||
544 | INIT_LIST_HEAD (&lock->blocked_locks)do { (&lock->blocked_locks)->next = (&lock-> blocked_locks)->prev = &lock->blocked_locks; } while (0); | ||
545 | __pl_inodelk_ref (lock); | ||
546 | |||
547 | return lock; | ||
548 | } | ||
549 | |||
550 | /* Common inodelk code called from pl_inodelk and pl_finodelk */ | ||
551 | int | ||
552 | pl_common_inodelk (call_frame_t *frame, xlator_t *this, | ||
553 | const char *volume, inode_t *inode, int32_t cmd, | ||
554 | struct gf_flock *flock, loc_t *loc, fd_t *fd) | ||
555 | { | ||
556 | int32_t op_ret = -1; | ||
557 | int32_t op_errno = 0; | ||
558 | int ret = -1; | ||
559 | int can_block = 0; | ||
560 | pid_t client_pid = -1; | ||
561 | void * transport = NULL((void*)0); | ||
562 | pl_inode_t * pinode = NULL((void*)0); | ||
563 | pl_inode_lock_t * reqlock = NULL((void*)0); | ||
564 | pl_dom_list_t * dom = NULL((void*)0); | ||
565 | |||
566 | 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!)"), "inodelk.c" , __FUNCTION__, 566, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | ||
567 | VALIDATE_OR_GOTO (inode, unwind)do { if (!inode) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "inodelk.c" , __FUNCTION__, 567, GF_LOG_WARNING, "invalid argument: " "inode" ); } while (0); goto unwind; } } while (0); | ||
568 | VALIDATE_OR_GOTO (flock, unwind)do { if (!flock) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "flock"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "inodelk.c" , __FUNCTION__, 568, GF_LOG_WARNING, "invalid argument: " "flock" ); } while (0); goto unwind; } } while (0); | ||
569 | |||
570 | if ((flock->l_start < 0) || (flock->l_len < 0)) { | ||
571 | op_errno = EINVAL22; | ||
572 | goto unwind; | ||
573 | } | ||
574 | |||
575 | pl_trace_in (this, frame, fd, loc, cmd, flock, volume); | ||
576 | |||
577 | transport = frame->root->trans; | ||
578 | client_pid = frame->root->pid; | ||
579 | |||
580 | pinode = pl_inode_get (this, inode); | ||
581 | if (!pinode) { | ||
582 | op_errno = ENOMEM12; | ||
583 | goto unwind; | ||
584 | } | ||
585 | |||
586 | dom = get_domain (pinode, volume); | ||
587 | if (!dom) { | ||
588 | op_errno = ENOMEM12; | ||
589 | goto unwind; | ||
590 | } | ||
591 | |||
592 | if (frame->root->lk_owner.len == 0) { | ||
593 | /* | ||
594 | special case: this means release all locks | ||
595 | from this transport | ||
596 | */ | ||
597 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("Releasing all locks from transport %p" , transport); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 598, GF_LOG_TRACE, "Releasing all locks from transport %p" , transport); } while (0) | ||
598 | "Releasing all locks from transport %p", transport)do { do { if (0) printf ("Releasing all locks from transport %p" , transport); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 598, GF_LOG_TRACE, "Releasing all locks from transport %p" , transport); } while (0); | ||
599 | |||
600 | release_inode_locks_of_transport (this, dom, inode, transport); | ||
601 | |||
602 | op_ret = 0; | ||
603 | goto unwind; | ||
604 | } | ||
605 | |||
606 | reqlock = new_inode_lock (flock, transport, client_pid, | ||
607 | &frame->root->lk_owner, volume); | ||
608 | |||
609 | if (!reqlock) { | ||
610 | op_ret = -1; | ||
611 | op_errno = ENOMEM12; | ||
612 | goto unwind; | ||
613 | } | ||
614 | |||
615 | reqlock->frame = frame; | ||
616 | reqlock->this = this; | ||
617 | |||
618 | switch (cmd) { | ||
619 | case F_SETLKW14: | ||
620 | can_block = 1; | ||
621 | reqlock->frame = frame; | ||
622 | reqlock->this = this; | ||
623 | |||
624 | /* fall through */ | ||
625 | |||
626 | case F_SETLK13: | ||
627 | memcpy (&reqlock->user_flock, flock, sizeof (struct gf_flock)); | ||
628 | ret = pl_inode_setlk (this, pinode, reqlock, | ||
629 | can_block, dom); | ||
630 | |||
631 | if (ret < 0) { | ||
632 | if ((can_block) && (F_UNLCK2 != flock->l_type)) { | ||
633 | pl_trace_block (this, frame, fd, loc, | ||
634 | cmd, flock, volume); | ||
635 | goto out; | ||
636 | } | ||
637 | gf_log (this->name, GF_LOG_TRACE, "returning EAGAIN")do { do { if (0) printf ("returning EAGAIN"); } while (0); _gf_log (this->name, "inodelk.c", __FUNCTION__, 637, GF_LOG_TRACE , "returning EAGAIN"); } while (0); | ||
638 | op_errno = -ret; | ||
639 | goto unwind; | ||
640 | } | ||
641 | break; | ||
642 | |||
643 | default: | ||
644 | op_errno = ENOTSUP95; | ||
645 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Lock command F_GETLK not supported for [f]inodelk " "(cmd=%d)", cmd); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 648, GF_LOG_DEBUG, "Lock command F_GETLK not supported for [f]inodelk " "(cmd=%d)", cmd); } while (0) | ||
646 | "Lock command F_GETLK not supported for [f]inodelk "do { do { if (0) printf ("Lock command F_GETLK not supported for [f]inodelk " "(cmd=%d)", cmd); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 648, GF_LOG_DEBUG, "Lock command F_GETLK not supported for [f]inodelk " "(cmd=%d)", cmd); } while (0) | ||
647 | "(cmd=%d)",do { do { if (0) printf ("Lock command F_GETLK not supported for [f]inodelk " "(cmd=%d)", cmd); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 648, GF_LOG_DEBUG, "Lock command F_GETLK not supported for [f]inodelk " "(cmd=%d)", cmd); } while (0) | ||
648 | cmd)do { do { if (0) printf ("Lock command F_GETLK not supported for [f]inodelk " "(cmd=%d)", cmd); } while (0); _gf_log (this->name, "inodelk.c" , __FUNCTION__, 648, GF_LOG_DEBUG, "Lock command F_GETLK not supported for [f]inodelk " "(cmd=%d)", cmd); } while (0); | ||
649 | goto unwind; | ||
650 | } | ||
651 | |||
652 | op_ret = 0; | ||
653 | |||
654 | unwind: | ||
655 | if ((inode != NULL((void*)0)) && (flock !=NULL((void*)0))) { | ||
656 | pl_update_refkeeper (this, inode); | ||
657 | pl_trace_out (this, frame, fd, loc, cmd, flock, op_ret, op_errno, volume); | ||
658 | } | ||
659 | |||
660 | STACK_UNWIND_STRICT (inodelk, frame, op_ret, op_errno, NULL)do { fop_inodelk_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" , "inodelk.c", __FUNCTION__, 660, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_inodelk_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); | ||
661 | out: | ||
662 | return 0; | ||
663 | } | ||
664 | |||
665 | int | ||
666 | pl_inodelk (call_frame_t *frame, xlator_t *this, | ||
667 | const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *flock) | ||
668 | { | ||
669 | |||
670 | pl_common_inodelk (frame, this, volume, loc->inode, cmd, flock, loc, NULL((void*)0)); | ||
671 | |||
672 | return 0; | ||
673 | } | ||
674 | |||
675 | int | ||
676 | pl_finodelk (call_frame_t *frame, xlator_t *this, | ||
677 | const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *flock) | ||
678 | { | ||
679 | |||
680 | pl_common_inodelk (frame, this, volume, fd->inode, cmd, flock, NULL((void*)0), fd); | ||
681 | |||
682 | return 0; | ||
683 | |||
684 | } | ||
685 | |||
686 | |||
687 | int32_t | ||
688 | __get_inodelk_count (xlator_t *this, pl_inode_t *pl_inode) | ||
689 | { | ||
690 | int32_t count = 0; | ||
691 | pl_inode_lock_t *lock = NULL((void*)0); | ||
692 | pl_dom_list_t *dom = NULL((void*)0); | ||
693 | |||
694 | 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)))) { | ||
695 | 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)))) { | ||
696 | count++; | ||
697 | } | ||
698 | 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 )))) { | ||
699 | count++; | ||
700 | } | ||
701 | |||
702 | } | ||
703 | |||
704 | return count; | ||
705 | } | ||
706 | |||
707 | int32_t | ||
708 | get_inodelk_count (xlator_t *this, inode_t *inode) | ||
709 | { | ||
710 | pl_inode_t *pl_inode = NULL((void*)0); | ||
711 | uint64_t tmp_pl_inode = 0; | ||
712 | int ret = 0; | ||
713 | int32_t count = 0; | ||
714 | |||
715 | ret = inode_ctx_get (inode, this, &tmp_pl_inode)inode_ctx_get2(inode,this,&tmp_pl_inode,0); | ||
716 | if (ret != 0) { | ||
717 | goto out; | ||
718 | } | ||
719 | |||
720 | pl_inode = (pl_inode_t *)(long) tmp_pl_inode; | ||
721 | |||
722 | pthread_mutex_lock (&pl_inode->mutex); | ||
723 | { | ||
724 | count = __get_inodelk_count (this, pl_inode); | ||
725 | } | ||
726 | pthread_mutex_unlock (&pl_inode->mutex); | ||
727 | |||
728 | out: | ||
729 | return count; | ||
730 | } |