File: | libglusterfs/src/fd-lk.c |
Location: | line 460, column 9 |
Description: | Null pointer passed as an argument to a 'nonnull' parameter |
1 | /* | ||
2 | Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> | ||
3 | This file is part of GlusterFS. | ||
4 | |||
5 | This file is licensed to you under your choice of the GNU Lesser | ||
6 | General Public License, version 3 or any later version (LGPLv3 or | ||
7 | later), or the GNU General Public License, version 2 (GPLv2), in all | ||
8 | cases as published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include "fd-lk.h" | ||
12 | #include "common-utils.h" | ||
13 | |||
14 | |||
15 | int32_t | ||
16 | _fd_lk_delete_lock (fd_lk_ctx_node_t *lock) | ||
17 | { | ||
18 | int32_t ret = -1; | ||
19 | |||
20 | GF_VALIDATE_OR_GOTO ("fd-lk", lock, out)do { if (!lock) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "lock"); } while (0); _gf_log_callingfn ("fd-lk", "fd-lk.c", __FUNCTION__, 20, GF_LOG_ERROR, "invalid argument: " "lock"); } while (0); goto out; } } while (0); | ||
21 | |||
22 | list_del_init (&lock->next); | ||
23 | |||
24 | ret = 0; | ||
25 | out: | ||
26 | return ret; | ||
27 | } | ||
28 | |||
29 | int32_t | ||
30 | _fd_lk_destroy_lock (fd_lk_ctx_node_t *lock) | ||
31 | { | ||
32 | int32_t ret = -1; | ||
33 | |||
34 | GF_VALIDATE_OR_GOTO ("fd-lk", lock, out)do { if (!lock) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "lock"); } while (0); _gf_log_callingfn ("fd-lk", "fd-lk.c", __FUNCTION__, 34, GF_LOG_ERROR, "invalid argument: " "lock"); } while (0); goto out; } } while (0); | ||
35 | |||
36 | GF_FREE (lock)__gf_free (lock); | ||
37 | |||
38 | ret = 0; | ||
39 | out: | ||
40 | return ret; | ||
41 | } | ||
42 | |||
43 | int | ||
44 | _fd_lk_destroy_lock_list (fd_lk_ctx_t *lk_ctx) | ||
45 | { | ||
46 | int ret = -1; | ||
47 | fd_lk_ctx_node_t *lk = NULL((void*)0); | ||
48 | fd_lk_ctx_node_t *tmp = NULL((void*)0); | ||
49 | |||
50 | GF_VALIDATE_OR_GOTO ("fd-lk", lk_ctx, out)do { if (!lk_ctx) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "lk_ctx"); } while (0); _gf_log_callingfn ("fd-lk", "fd-lk.c", __FUNCTION__, 50, GF_LOG_ERROR, "invalid argument: " "lk_ctx"); } while (0); goto out; } } while (0); | ||
51 | |||
52 | list_for_each_entry_safe (lk, tmp, &lk_ctx->lk_list, next)for (lk = ((typeof(*lk) *)((char *)((&lk_ctx->lk_list) ->next)-(unsigned long)(&((typeof(*lk) *)0)->next)) ), tmp = ((typeof(*lk) *)((char *)(lk->next.next)-(unsigned long)(&((typeof(*lk) *)0)->next))); &lk->next != (&lk_ctx->lk_list); lk = tmp, tmp = ((typeof(*tmp) *) ((char *)(tmp->next.next)-(unsigned long)(&((typeof(*tmp ) *)0)->next)))) { | ||
53 | _fd_lk_delete_lock (lk); | ||
54 | _fd_lk_destroy_lock (lk); | ||
55 | } | ||
56 | ret = 0; | ||
57 | out: | ||
58 | return ret; | ||
59 | } | ||
60 | |||
61 | int | ||
62 | fd_lk_ctx_unref (fd_lk_ctx_t *lk_ctx) | ||
63 | { | ||
64 | int ref = -1; | ||
65 | |||
66 | GF_VALIDATE_OR_GOTO ("fd-lk", lk_ctx, err)do { if (!lk_ctx) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "lk_ctx"); } while (0); _gf_log_callingfn ("fd-lk", "fd-lk.c", __FUNCTION__, 66, GF_LOG_ERROR, "invalid argument: " "lk_ctx"); } while (0); goto err; } } while (0); | ||
67 | |||
68 | LOCK (&lk_ctx->lock)pthread_spin_lock (&lk_ctx->lock); | ||
69 | { | ||
70 | ref = --lk_ctx->ref; | ||
71 | if (ref < 0) | ||
72 | GF_ASSERT (!ref)do { if (!(!ref)) { do { do { if (0) printf ("Assertion failed: " "!ref"); } while (0); _gf_log_callingfn ("", "fd-lk.c", __FUNCTION__ , 72, GF_LOG_ERROR, "Assertion failed: " "!ref"); } while (0) ; } } while (0); | ||
73 | if (ref == 0) | ||
74 | _fd_lk_destroy_lock_list (lk_ctx); | ||
75 | } | ||
76 | UNLOCK (&lk_ctx->lock)pthread_spin_unlock (&lk_ctx->lock); | ||
77 | |||
78 | if (ref == 0) { | ||
79 | LOCK_DESTROY (&lk_ctx->lock)pthread_spin_destroy (&lk_ctx->lock); | ||
80 | GF_FREE (lk_ctx)__gf_free (lk_ctx); | ||
81 | } | ||
82 | |||
83 | return 0; | ||
84 | err: | ||
85 | return -1; | ||
86 | } | ||
87 | |||
88 | fd_lk_ctx_t * | ||
89 | _fd_lk_ctx_ref (fd_lk_ctx_t *lk_ctx) | ||
90 | { | ||
91 | if (!lk_ctx) { | ||
92 | gf_log_callingfn ("fd", GF_LOG_WARNING,do { do { if (0) printf ("invalid argument"); } while (0); _gf_log_callingfn ("fd", "fd-lk.c", __FUNCTION__, 93, GF_LOG_WARNING, "invalid argument" ); } while (0) | ||
93 | "invalid argument")do { do { if (0) printf ("invalid argument"); } while (0); _gf_log_callingfn ("fd", "fd-lk.c", __FUNCTION__, 93, GF_LOG_WARNING, "invalid argument" ); } while (0); | ||
94 | return NULL((void*)0); | ||
95 | } | ||
96 | |||
97 | ++lk_ctx->ref; | ||
98 | |||
99 | return lk_ctx; | ||
100 | } | ||
101 | |||
102 | fd_lk_ctx_t * | ||
103 | fd_lk_ctx_ref (fd_lk_ctx_t *lk_ctx) | ||
104 | { | ||
105 | fd_lk_ctx_t *new_lk_ctx = NULL((void*)0); | ||
106 | |||
107 | if (!lk_ctx) { | ||
108 | gf_log_callingfn ("fd", GF_LOG_WARNING,do { do { if (0) printf ("invalid argument"); } while (0); _gf_log_callingfn ("fd", "fd-lk.c", __FUNCTION__, 109, GF_LOG_WARNING, "invalid argument" ); } while (0) | ||
109 | "invalid argument")do { do { if (0) printf ("invalid argument"); } while (0); _gf_log_callingfn ("fd", "fd-lk.c", __FUNCTION__, 109, GF_LOG_WARNING, "invalid argument" ); } while (0); | ||
110 | return NULL((void*)0); | ||
111 | } | ||
112 | |||
113 | LOCK (&lk_ctx->lock)pthread_spin_lock (&lk_ctx->lock); | ||
114 | { | ||
115 | new_lk_ctx = _fd_lk_ctx_ref (lk_ctx); | ||
116 | } | ||
117 | UNLOCK (&lk_ctx->lock)pthread_spin_unlock (&lk_ctx->lock); | ||
118 | |||
119 | return new_lk_ctx; | ||
120 | } | ||
121 | |||
122 | fd_lk_ctx_t * | ||
123 | fd_lk_ctx_try_ref (fd_lk_ctx_t *lk_ctx) | ||
124 | { | ||
125 | int ret = -1; | ||
126 | fd_lk_ctx_t *new_lk_ctx = NULL((void*)0); | ||
127 | |||
128 | if (!lk_ctx) { | ||
129 | goto out; | ||
130 | } | ||
131 | |||
132 | ret = TRY_LOCK (&lk_ctx->lock)pthread_spin_trylock (&lk_ctx->lock); | ||
133 | if (ret) | ||
134 | goto out; | ||
135 | |||
136 | new_lk_ctx = _fd_lk_ctx_ref (lk_ctx); | ||
137 | UNLOCK (&lk_ctx->lock)pthread_spin_unlock (&lk_ctx->lock); | ||
138 | |||
139 | out: | ||
140 | return new_lk_ctx; | ||
141 | } | ||
142 | |||
143 | fd_lk_ctx_t * | ||
144 | fd_lk_ctx_create () | ||
145 | { | ||
146 | fd_lk_ctx_t *fd_lk_ctx = NULL((void*)0); | ||
147 | |||
148 | fd_lk_ctx = GF_CALLOC (1, sizeof (fd_lk_ctx_t),__gf_calloc (1, sizeof (fd_lk_ctx_t), gf_common_mt_fd_lk_ctx_t ) | ||
149 | gf_common_mt_fd_lk_ctx_t)__gf_calloc (1, sizeof (fd_lk_ctx_t), gf_common_mt_fd_lk_ctx_t ); | ||
150 | if (!fd_lk_ctx) | ||
151 | goto out; | ||
152 | |||
153 | INIT_LIST_HEAD (&fd_lk_ctx->lk_list)do { (&fd_lk_ctx->lk_list)->next = (&fd_lk_ctx-> lk_list)->prev = &fd_lk_ctx->lk_list; } while (0); | ||
154 | |||
155 | LOCK_INIT (&fd_lk_ctx->lock)pthread_spin_init (&fd_lk_ctx->lock, 0); | ||
156 | |||
157 | fd_lk_ctx = fd_lk_ctx_ref (fd_lk_ctx); | ||
158 | out: | ||
159 | return fd_lk_ctx; | ||
160 | } | ||
161 | |||
162 | int | ||
163 | _fd_lk_insert_lock (fd_lk_ctx_t *lk_ctx, | ||
164 | fd_lk_ctx_node_t *lock) | ||
165 | { | ||
166 | list_add_tail (&lock->next, &lk_ctx->lk_list); | ||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | static off_t | ||
171 | _fd_lk_get_lock_len (off_t start, off_t end) | ||
172 | { | ||
173 | if (end == LLONG_MAX9223372036854775807LL) | ||
174 | return 0; | ||
175 | else | ||
176 | return (end - start + 1); | ||
177 | } | ||
178 | |||
179 | fd_lk_ctx_node_t * | ||
180 | fd_lk_ctx_node_new (int32_t cmd, struct gf_flock *flock) | ||
181 | { | ||
182 | fd_lk_ctx_node_t *new_lock = NULL((void*)0); | ||
183 | |||
184 | /* TODO: get from mem-pool */ | ||
185 | new_lock = GF_CALLOC (1, sizeof (fd_lk_ctx_node_t),__gf_calloc (1, sizeof (fd_lk_ctx_node_t), gf_common_mt_fd_lk_ctx_node_t ) | ||
186 | gf_common_mt_fd_lk_ctx_node_t)__gf_calloc (1, sizeof (fd_lk_ctx_node_t), gf_common_mt_fd_lk_ctx_node_t ); | ||
187 | if (!new_lock) | ||
188 | goto out; | ||
189 | |||
190 | new_lock->cmd = cmd; | ||
191 | |||
192 | if (flock) { | ||
193 | new_lock->fl_type = flock->l_type; | ||
194 | new_lock->fl_start = flock->l_start; | ||
195 | |||
196 | if (flock->l_len == 0) | ||
197 | new_lock->fl_end = LLONG_MAX9223372036854775807LL; | ||
198 | else | ||
199 | new_lock->fl_end = flock->l_start + flock->l_len - 1; | ||
200 | |||
201 | memcpy (&new_lock->user_flock, flock, | ||
202 | sizeof (struct gf_flock)); | ||
203 | } | ||
204 | |||
205 | INIT_LIST_HEAD (&new_lock->next)do { (&new_lock->next)->next = (&new_lock->next )->prev = &new_lock->next; } while (0); | ||
206 | out: | ||
207 | return new_lock; | ||
208 | } | ||
209 | |||
210 | int32_t | ||
211 | _fd_lk_delete_unlck_locks (fd_lk_ctx_t *lk_ctx) | ||
212 | { | ||
213 | int32_t ret = -1; | ||
214 | fd_lk_ctx_node_t *tmp = NULL((void*)0); | ||
215 | fd_lk_ctx_node_t *lk = NULL((void*)0); | ||
216 | |||
217 | GF_VALIDATE_OR_GOTO ("fd-lk", lk_ctx, out)do { if (!lk_ctx) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "lk_ctx"); } while (0); _gf_log_callingfn ("fd-lk", "fd-lk.c", __FUNCTION__, 217, GF_LOG_ERROR, "invalid argument: " "lk_ctx"); } while (0); goto out; } } while (0); | ||
218 | |||
219 | list_for_each_entry_safe (lk, tmp, &lk_ctx->lk_list, next)for (lk = ((typeof(*lk) *)((char *)((&lk_ctx->lk_list) ->next)-(unsigned long)(&((typeof(*lk) *)0)->next)) ), tmp = ((typeof(*lk) *)((char *)(lk->next.next)-(unsigned long)(&((typeof(*lk) *)0)->next))); &lk->next != (&lk_ctx->lk_list); lk = tmp, tmp = ((typeof(*tmp) *) ((char *)(tmp->next.next)-(unsigned long)(&((typeof(*tmp ) *)0)->next)))) { | ||
220 | if (lk->fl_type == F_UNLCK2) { | ||
221 | _fd_lk_delete_lock (lk); | ||
222 | _fd_lk_destroy_lock (lk); | ||
223 | } | ||
224 | } | ||
225 | out: | ||
226 | return ret; | ||
227 | } | ||
228 | |||
229 | int | ||
230 | fd_lk_overlap (fd_lk_ctx_node_t *l1, | ||
231 | fd_lk_ctx_node_t *l2) | ||
232 | { | ||
233 | if (l1->fl_end >= l2->fl_start && | ||
234 | l2->fl_end >= l1->fl_start) | ||
235 | return 1; | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | fd_lk_ctx_node_t * | ||
241 | _fd_lk_add_locks (fd_lk_ctx_node_t *l1, | ||
242 | fd_lk_ctx_node_t *l2) | ||
243 | { | ||
244 | fd_lk_ctx_node_t *sum = NULL((void*)0); | ||
245 | |||
246 | sum = fd_lk_ctx_node_new (0, NULL((void*)0)); | ||
247 | if (!sum) | ||
248 | goto out; | ||
249 | |||
250 | sum->fl_start = min (l1->fl_start, l2->fl_start)((l1->fl_start)<(l2->fl_start)?(l1->fl_start):(l2 ->fl_start)); | ||
251 | sum->fl_end = max (l1->fl_end, l2->fl_end)((l1->fl_end)>(l2->fl_end)?(l1->fl_end):(l2->fl_end )); | ||
252 | |||
253 | sum->user_flock.l_start = sum->fl_start; | ||
254 | sum->user_flock.l_len = _fd_lk_get_lock_len (sum->fl_start, | ||
255 | sum->fl_end); | ||
256 | out: | ||
257 | return sum; | ||
258 | } | ||
259 | |||
260 | /* Subtract two locks */ | ||
261 | struct _values { | ||
262 | fd_lk_ctx_node_t *locks[3]; | ||
263 | }; | ||
264 | |||
265 | int32_t | ||
266 | _fd_lk_sub_locks (struct _values *v, | ||
267 | fd_lk_ctx_node_t *big, | ||
268 | fd_lk_ctx_node_t *small) | ||
269 | { | ||
270 | int32_t ret = -1; | ||
271 | |||
272 | if ((big->fl_start == small->fl_start) && | ||
273 | (big->fl_end == small->fl_end)) { | ||
274 | /* both edges coincide with big */ | ||
275 | v->locks[0] = fd_lk_ctx_node_new (small->cmd, NULL((void*)0)); | ||
276 | if (!v->locks[0]) | ||
277 | goto out; | ||
278 | |||
279 | memcpy (v->locks[0], big, sizeof (fd_lk_ctx_node_t)); | ||
280 | |||
281 | v->locks[0]->fl_type = small->fl_type; | ||
282 | v->locks[0]->user_flock.l_type = small->fl_type; | ||
283 | } else if ((small->fl_start > big->fl_start) && | ||
284 | (small->fl_end < big->fl_end)) { | ||
285 | /* small lock is completely inside big lock, | ||
286 | break it down into 3 different locks. */ | ||
287 | v->locks[0] = fd_lk_ctx_node_new (big->cmd, NULL((void*)0)); | ||
288 | if (!v->locks[0]) | ||
289 | goto out; | ||
290 | |||
291 | v->locks[1] = fd_lk_ctx_node_new (small->cmd, NULL((void*)0)); | ||
292 | if (!v->locks[1]) | ||
293 | goto out; | ||
294 | |||
295 | v->locks[2] = fd_lk_ctx_node_new (big->cmd, NULL((void*)0)); | ||
296 | if (!v->locks[2]) | ||
297 | goto out; | ||
298 | |||
299 | memcpy (v->locks[0], big, sizeof (fd_lk_ctx_node_t)); | ||
300 | v->locks[0]->fl_end = small->fl_start - 1; | ||
301 | v->locks[0]->user_flock.l_len = | ||
302 | _fd_lk_get_lock_len (v->locks[0]->fl_start, | ||
303 | v->locks[0]->fl_end); | ||
304 | |||
305 | memcpy (v->locks[1], small, sizeof (fd_lk_ctx_node_t)); | ||
306 | |||
307 | memcpy (v->locks[2], big, sizeof (fd_lk_ctx_node_t)); | ||
308 | v->locks[2]->fl_start = small->fl_end + 1; | ||
309 | v->locks[2]->user_flock.l_len = | ||
310 | _fd_lk_get_lock_len (v->locks[2]->fl_start, | ||
311 | v->locks[2]->fl_end); | ||
312 | } else if (small->fl_start == big->fl_start) { | ||
313 | /* One of the ends co-incide, break the | ||
314 | locks into two seperate parts */ | ||
315 | v->locks[0] = fd_lk_ctx_node_new (small->cmd, NULL((void*)0)); | ||
316 | if (!v->locks[0]) | ||
317 | goto out; | ||
318 | |||
319 | v->locks[1] = fd_lk_ctx_node_new (big->cmd, NULL((void*)0)); | ||
320 | if (!v->locks[1]) | ||
321 | goto out; | ||
322 | |||
323 | memcpy (v->locks[0], small, sizeof (fd_lk_ctx_node_t)); | ||
324 | |||
325 | memcpy (v->locks[1], big, sizeof (fd_lk_ctx_node_t)); | ||
326 | v->locks[1]->fl_start = small->fl_end + 1; | ||
327 | v->locks[1]->user_flock.l_start = small->fl_end + 1; | ||
328 | } else if (small->fl_end == big->fl_end) { | ||
329 | /* One of the ends co-incide, break the | ||
330 | locks into two seperate parts */ | ||
331 | v->locks[0] = fd_lk_ctx_node_new (small->cmd, NULL((void*)0)); | ||
332 | if (!v->locks[0]) | ||
333 | goto out; | ||
334 | |||
335 | v->locks[1] = fd_lk_ctx_node_new (big->cmd, NULL((void*)0)); | ||
336 | if (!v->locks[1]) | ||
337 | goto out; | ||
338 | |||
339 | memcpy (v->locks[0], big, sizeof (fd_lk_ctx_node_t)); | ||
340 | v->locks[0]->fl_end = small->fl_start - 1; | ||
341 | v->locks[0]->user_flock.l_len = | ||
342 | _fd_lk_get_lock_len (v->locks[0]->fl_start, | ||
343 | v->locks[0]->fl_end); | ||
344 | |||
345 | memcpy (v->locks[1], small, sizeof (fd_lk_ctx_node_t)); | ||
346 | } else { | ||
347 | /* We should never come to this case */ | ||
348 | GF_ASSERT (!"Invalid case")do { if (!(!"Invalid case")) { do { do { if (0) printf ("Assertion failed: " "!\"Invalid case\""); } while (0); _gf_log_callingfn ("", "fd-lk.c" , __FUNCTION__, 348, GF_LOG_ERROR, "Assertion failed: " "!\"Invalid case\"" ); } while (0); } } while (0); | ||
349 | } | ||
350 | ret = 0; | ||
351 | out: | ||
352 | return ret; | ||
353 | } | ||
354 | |||
355 | static void | ||
356 | _fd_lk_insert_and_merge (fd_lk_ctx_t *lk_ctx, | ||
357 | fd_lk_ctx_node_t *lock) | ||
358 | { | ||
359 | int32_t ret = -1; | ||
360 | int32_t i = 0; | ||
361 | fd_lk_ctx_node_t *entry = NULL((void*)0); | ||
362 | fd_lk_ctx_node_t *t = NULL((void*)0); | ||
363 | fd_lk_ctx_node_t *sum = NULL((void*)0); | ||
364 | struct _values v = {.locks = {0, 0, 0 }}; | ||
365 | |||
366 | list_for_each_entry_safe (entry, t, &lk_ctx->lk_list, next)for (entry = ((typeof(*entry) *)((char *)((&lk_ctx->lk_list )->next)-(unsigned long)(&((typeof(*entry) *)0)->next ))), t = ((typeof(*entry) *)((char *)(entry->next.next)-(unsigned long)(&((typeof(*entry) *)0)->next))); &entry-> next != (&lk_ctx->lk_list); entry = t, t = ((typeof(*t ) *)((char *)(t->next.next)-(unsigned long)(&((typeof( *t) *)0)->next)))) { | ||
367 | if (!fd_lk_overlap (entry, lock)) | ||
368 | continue; | ||
369 | |||
370 | if (entry->fl_type == lock->fl_type) { | ||
371 | sum = _fd_lk_add_locks (entry, lock); | ||
372 | if (!sum) | ||
373 | return; | ||
374 | sum->fl_type = entry->fl_type; | ||
375 | sum->user_flock.l_type = entry->fl_type; | ||
376 | _fd_lk_delete_lock (entry); | ||
377 | _fd_lk_destroy_lock (entry); | ||
378 | _fd_lk_destroy_lock (lock); | ||
379 | _fd_lk_insert_and_merge (lk_ctx, sum); | ||
380 | return; | ||
381 | } else { | ||
382 | sum = _fd_lk_add_locks (entry, lock); | ||
383 | sum->fl_type = lock->fl_type; | ||
384 | sum->user_flock.l_type = lock->fl_type; | ||
385 | ret = _fd_lk_sub_locks (&v, sum, lock); | ||
386 | if (ret) | ||
387 | return; | ||
388 | _fd_lk_delete_lock (entry); | ||
389 | _fd_lk_destroy_lock (entry); | ||
390 | |||
391 | _fd_lk_delete_lock (lock); | ||
392 | _fd_lk_destroy_lock (lock); | ||
393 | |||
394 | _fd_lk_destroy_lock (sum); | ||
395 | |||
396 | for (i = 0; i < 3; i++) { | ||
397 | if (!v.locks[i]) | ||
398 | continue; | ||
399 | |||
400 | INIT_LIST_HEAD (&v.locks[i]->next)do { (&v.locks[i]->next)->next = (&v.locks[i]-> next)->prev = &v.locks[i]->next; } while (0); | ||
401 | _fd_lk_insert_and_merge (lk_ctx, v.locks[i]); | ||
402 | } | ||
403 | _fd_lk_delete_unlck_locks (lk_ctx); | ||
404 | return; | ||
405 | } | ||
406 | } | ||
407 | |||
408 | /* no conflicts, so just insert */ | ||
409 | if (lock->fl_type != F_UNLCK2) { | ||
410 | _fd_lk_insert_lock (lk_ctx, lock); | ||
411 | } else { | ||
412 | _fd_lk_destroy_lock (lock); | ||
413 | } | ||
414 | } | ||
415 | |||
416 | static void | ||
417 | print_lock_list (fd_lk_ctx_t *lk_ctx) | ||
418 | { | ||
419 | fd_lk_ctx_node_t *lk = NULL((void*)0); | ||
420 | |||
421 | gf_log ("fd-lk", GF_LOG_DEBUG, "lock list:")do { do { if (0) printf ("lock list:"); } while (0); _gf_log ( "fd-lk", "fd-lk.c", __FUNCTION__, 421, GF_LOG_DEBUG, "lock list:" ); } while (0); | ||
422 | |||
423 | list_for_each_entry (lk, &lk_ctx->lk_list, next)for (lk = ((typeof(*lk) *)((char *)((&lk_ctx->lk_list) ->next)-(unsigned long)(&((typeof(*lk) *)0)->next)) ); &lk->next != (&lk_ctx->lk_list); lk = ((typeof (*lk) *)((char *)(lk->next.next)-(unsigned long)(&((typeof (*lk) *)0)->next)))) | ||
424 | gf_log ("fd-lk", GF_LOG_DEBUG, "owner = %s, "do { do { if (0) printf ("owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); _gf_log ("fd-lk", "fd-lk.c", __FUNCTION__, 433 , GF_LOG_DEBUG, "owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0) | ||
425 | "cmd = %s fl_type = %s, fs_start = %"PRId64", "do { do { if (0) printf ("owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); _gf_log ("fd-lk", "fd-lk.c", __FUNCTION__, 433 , GF_LOG_DEBUG, "owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0) | ||
426 | "fs_end = %"PRId64", user_flock: l_type = %s, "do { do { if (0) printf ("owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); _gf_log ("fd-lk", "fd-lk.c", __FUNCTION__, 433 , GF_LOG_DEBUG, "owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0) | ||
427 | "l_start = %"PRId64", l_len = %"PRId64", ",do { do { if (0) printf ("owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); _gf_log ("fd-lk", "fd-lk.c", __FUNCTION__, 433 , GF_LOG_DEBUG, "owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0) | ||
428 | lkowner_utoa (&lk->user_flock.l_owner),do { do { if (0) printf ("owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); _gf_log ("fd-lk", "fd-lk.c", __FUNCTION__, 433 , GF_LOG_DEBUG, "owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0) | ||
429 | get_lk_cmd (lk->cmd), get_lk_type (lk->fl_type),do { do { if (0) printf ("owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); _gf_log ("fd-lk", "fd-lk.c", __FUNCTION__, 433 , GF_LOG_DEBUG, "owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0) | ||
430 | lk->fl_start, lk->fl_end,do { do { if (0) printf ("owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); _gf_log ("fd-lk", "fd-lk.c", __FUNCTION__, 433 , GF_LOG_DEBUG, "owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0) | ||
431 | get_lk_type (lk->user_flock.l_type),do { do { if (0) printf ("owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); _gf_log ("fd-lk", "fd-lk.c", __FUNCTION__, 433 , GF_LOG_DEBUG, "owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0) | ||
432 | lk->user_flock.l_start,do { do { if (0) printf ("owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); _gf_log ("fd-lk", "fd-lk.c", __FUNCTION__, 433 , GF_LOG_DEBUG, "owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0) | ||
433 | lk->user_flock.l_len)do { do { if (0) printf ("owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); _gf_log ("fd-lk", "fd-lk.c", __FUNCTION__, 433 , GF_LOG_DEBUG, "owner = %s, " "cmd = %s fl_type = %s, fs_start = %" "ll" "d"", " "fs_end = %""ll" "d"", user_flock: l_type = %s, " "l_start = %""ll" "d"", l_len = %""ll" "d"", ", lkowner_utoa (&lk->user_flock.l_owner), lk->cmd == 14 ? "F_SETLKW" : (lk->cmd == 13 ? "F_SETLK" : "F_GETLK"), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK" ), lk->fl_start, lk->fl_end, lk->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock.l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start, lk->user_flock.l_len ); } while (0); | ||
434 | } | ||
435 | |||
436 | int | ||
437 | fd_lk_insert_and_merge (fd_t *fd, int32_t cmd, | ||
438 | struct gf_flock *flock) | ||
439 | { | ||
440 | int32_t ret = -1; | ||
441 | fd_lk_ctx_t *lk_ctx = NULL((void*)0); | ||
442 | fd_lk_ctx_node_t *lk = NULL((void*)0); | ||
443 | |||
444 | GF_VALIDATE_OR_GOTO ("fd-lk", fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn ("fd-lk", "fd-lk.c", __FUNCTION__, 444, GF_LOG_ERROR, "invalid argument: " "fd"); } while (0); goto out; } } while (0); | ||
445 | GF_VALIDATE_OR_GOTO ("fd-lk", flock, out)do { if (!flock) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "flock"); } while (0); _gf_log_callingfn ("fd-lk", "fd-lk.c", __FUNCTION__, 445, GF_LOG_ERROR, "invalid argument: " "flock"); } while (0); goto out; } } while (0); | ||
446 | |||
447 | lk_ctx = fd_lk_ctx_ref (fd->lk_ctx); | ||
448 | lk = fd_lk_ctx_node_new (cmd, flock); | ||
449 | |||
450 | gf_log ("fd-lk", GF_LOG_DEBUG,do { do { if (0) printf ("new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0); _gf_log ("fd-lk", "fd-lk.c" , __FUNCTION__, 458, GF_LOG_DEBUG, "new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0) | ||
451 | "new lock requrest: owner = %s, fl_type = %s, "do { do { if (0) printf ("new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0); _gf_log ("fd-lk", "fd-lk.c" , __FUNCTION__, 458, GF_LOG_DEBUG, "new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0) | ||
452 | "fs_start = %"PRId64", fs_end = %"PRId64", "do { do { if (0) printf ("new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0); _gf_log ("fd-lk", "fd-lk.c" , __FUNCTION__, 458, GF_LOG_DEBUG, "new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0) | ||
453 | "user_flock: l_type = %s, l_start = %"PRId64", "do { do { if (0) printf ("new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0); _gf_log ("fd-lk", "fd-lk.c" , __FUNCTION__, 458, GF_LOG_DEBUG, "new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0) | ||
454 | "l_len = %"PRId64, lkowner_utoa (&flock->l_owner),do { do { if (0) printf ("new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0); _gf_log ("fd-lk", "fd-lk.c" , __FUNCTION__, 458, GF_LOG_DEBUG, "new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0) | ||
455 | get_lk_type (lk->fl_type), lk->fl_start,do { do { if (0) printf ("new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0); _gf_log ("fd-lk", "fd-lk.c" , __FUNCTION__, 458, GF_LOG_DEBUG, "new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0) | ||
456 | lk->fl_end, get_lk_type (lk->user_flock.l_type),do { do { if (0) printf ("new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0); _gf_log ("fd-lk", "fd-lk.c" , __FUNCTION__, 458, GF_LOG_DEBUG, "new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0) | ||
457 | lk->user_flock.l_start,do { do { if (0) printf ("new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0); _gf_log ("fd-lk", "fd-lk.c" , __FUNCTION__, 458, GF_LOG_DEBUG, "new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0) | ||
458 | lk->user_flock.l_len)do { do { if (0) printf ("new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0); _gf_log ("fd-lk", "fd-lk.c" , __FUNCTION__, 458, GF_LOG_DEBUG, "new lock requrest: owner = %s, fl_type = %s, " "fs_start = %""ll" "d"", fs_end = %""ll" "d"", " "user_flock: l_type = %s, l_start = %" "ll" "d"", " "l_len = %""ll" "d", lkowner_utoa (&flock-> l_owner), lk->fl_type == 2 ? "F_UNLCK" : (lk->fl_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->fl_start, lk->fl_end, lk ->user_flock.l_type == 2 ? "F_UNLCK" : (lk->user_flock. l_type == 0 ? "F_RDLCK" : "F_WRLCK"), lk->user_flock.l_start , lk->user_flock.l_len); } while (0); | ||
459 | |||
460 | LOCK (&lk_ctx->lock)pthread_spin_lock (&lk_ctx->lock); | ||
Within the expansion of the macro 'LOCK':
| |||
461 | { | ||
462 | _fd_lk_insert_and_merge (lk_ctx, lk); | ||
463 | print_lock_list (lk_ctx); | ||
464 | } | ||
465 | UNLOCK (&lk_ctx->lock)pthread_spin_unlock (&lk_ctx->lock); | ||
466 | |||
467 | fd_lk_ctx_unref (lk_ctx); | ||
468 | |||
469 | ret = 0; | ||
470 | out: | ||
471 | return ret; | ||
472 | } | ||
473 | |||
474 | |||
475 | gf_boolean_t | ||
476 | fd_lk_ctx_empty (fd_lk_ctx_t *lk_ctx) | ||
477 | { | ||
478 | gf_boolean_t verdict = _gf_true; | ||
479 | |||
480 | if (!lk_ctx) | ||
481 | return _gf_true; | ||
482 | |||
483 | LOCK (&lk_ctx->lock)pthread_spin_lock (&lk_ctx->lock); | ||
484 | { | ||
485 | verdict = list_empty (&lk_ctx->lk_list); | ||
486 | } | ||
487 | UNLOCK (&lk_ctx->lock)pthread_spin_unlock (&lk_ctx->lock); | ||
488 | |||
489 | return verdict; | ||
490 | } |