Lines Matching refs:block
42 static void nlmsvc_insert_block(struct nlm_block *block, unsigned long);
43 static int nlmsvc_remove_block(struct nlm_block *block);
56 nlmsvc_insert_block(struct nlm_block *block, unsigned long when) in nlmsvc_insert_block() argument
60 dprintk("lockd: nlmsvc_insert_block(%p, %ld)\n", block, when); in nlmsvc_insert_block()
61 if (block->b_queued) in nlmsvc_insert_block()
62 nlmsvc_remove_block(block); in nlmsvc_insert_block()
73 block->b_queued = 1; in nlmsvc_insert_block()
74 block->b_when = when; in nlmsvc_insert_block()
75 block->b_next = b; in nlmsvc_insert_block()
76 *bp = block; in nlmsvc_insert_block()
83 nlmsvc_remove_block(struct nlm_block *block) in nlmsvc_remove_block() argument
87 if (!block->b_queued) in nlmsvc_remove_block()
90 if (b == block) { in nlmsvc_remove_block()
91 *bp = block->b_next; in nlmsvc_remove_block()
92 block->b_queued = 0; in nlmsvc_remove_block()
107 struct nlm_block **head, *block; in nlmsvc_lookup_block() local
114 for (head = &nlm_blocked; (block = *head); head = &block->b_next) { in nlmsvc_lookup_block()
115 fl = &block->b_call.a_args.lock.fl; in nlmsvc_lookup_block()
117 block->b_file, fl->fl_pid, in nlmsvc_lookup_block()
120 nlmdbg_cookie2a(&block->b_call.a_args.cookie)); in nlmsvc_lookup_block()
121 if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) { in nlmsvc_lookup_block()
123 *head = block->b_next; in nlmsvc_lookup_block()
124 block->b_queued = 0; in nlmsvc_lookup_block()
126 return block; in nlmsvc_lookup_block()
148 struct nlm_block *block; in nlmsvc_find_block() local
150 for (block = nlm_blocked; block; block = block->b_next) { in nlmsvc_find_block()
152 nlm_blocked, block); in nlmsvc_find_block()
153 if (nlm_cookie_match(&block->b_call.a_args.cookie,cookie) in nlmsvc_find_block()
154 && nlm_cmp_addr(sin, &block->b_host->h_addr)) in nlmsvc_find_block()
158 return block; in nlmsvc_find_block()
175 struct nlm_block *block; in nlmsvc_create_block() local
186 if (!(block = (struct nlm_block *) kmalloc(sizeof(*block), GFP_KERNEL))) in nlmsvc_create_block()
188 memset(block, 0, sizeof(*block)); in nlmsvc_create_block()
189 locks_init_lock(&block->b_call.a_args.lock.fl); in nlmsvc_create_block()
190 locks_init_lock(&block->b_call.a_res.lock.fl); in nlmsvc_create_block()
192 block->b_host = nlmsvc_lookup_host(rqstp); in nlmsvc_create_block()
193 if (block->b_host == NULL) { in nlmsvc_create_block()
197 if (!nlmclnt_setgrantargs(&block->b_call, lock)) in nlmsvc_create_block()
201 block->b_call.a_args.lock.fl.fl_notify = nlmsvc_notify_blocked; in nlmsvc_create_block()
202 block->b_call.a_args.cookie = *cookie; /* see above */ in nlmsvc_create_block()
204 dprintk("lockd: created block %p...\n", block); in nlmsvc_create_block()
207 block->b_daemon = rqstp->rq_server; in nlmsvc_create_block()
208 block->b_file = file; in nlmsvc_create_block()
211 block->b_fnext = file->f_blocks; in nlmsvc_create_block()
212 file->f_blocks = block; in nlmsvc_create_block()
215 call = &block->b_call; in nlmsvc_create_block()
219 return block; in nlmsvc_create_block()
222 kfree(block); in nlmsvc_create_block()
235 nlmsvc_delete_block(struct nlm_block *block, int unlock) in nlmsvc_delete_block() argument
237 struct file_lock *fl = &block->b_call.a_args.lock.fl; in nlmsvc_delete_block()
238 struct nlm_file *file = block->b_file; in nlmsvc_delete_block()
241 dprintk("lockd: deleting block %p...\n", block); in nlmsvc_delete_block()
244 nlmsvc_remove_block(block); in nlmsvc_delete_block()
247 if (unlock && block->b_granted) { in nlmsvc_delete_block()
250 posix_lock_file(&block->b_file->f_file, fl, 0); in nlmsvc_delete_block()
251 block->b_granted = 0; in nlmsvc_delete_block()
259 if (block->b_incall) { in nlmsvc_delete_block()
260 nlmsvc_insert_block(block, NLM_NEVER); in nlmsvc_delete_block()
261 block->b_done = 1; in nlmsvc_delete_block()
267 if (*bp == block) { in nlmsvc_delete_block()
268 *bp = block->b_fnext; in nlmsvc_delete_block()
273 nlm_release_host(block->b_host); in nlmsvc_delete_block()
274 nlmclnt_freegrantargs(&block->b_call); in nlmsvc_delete_block()
275 kfree(block); in nlmsvc_delete_block()
285 struct nlm_block *block, *next; in nlmsvc_traverse_blocks() local
288 for (block = file->f_blocks; block; block = next) { in nlmsvc_traverse_blocks()
289 next = block->b_fnext; in nlmsvc_traverse_blocks()
291 block->b_host->h_inuse = 1; in nlmsvc_traverse_blocks()
293 if (host == NULL || host == block->b_host) in nlmsvc_traverse_blocks()
294 nlmsvc_delete_block(block, 1); in nlmsvc_traverse_blocks()
310 struct nlm_block *block; in nlmsvc_lock() local
323 block = nlmsvc_lookup_block(file, lock, 0); in nlmsvc_lock()
334 if (block) in nlmsvc_lock()
335 nlmsvc_delete_block(block, 0); in nlmsvc_lock()
365 if (block == NULL) { in nlmsvc_lock()
368 if (!(block = nlmsvc_create_block(rqstp, file, lock, cookie))) in nlmsvc_lock()
374 nlmsvc_insert_block(block, NLM_NEVER); in nlmsvc_lock()
376 if (list_empty(&block->b_call.a_args.lock.fl.fl_block)) { in nlmsvc_lock()
380 posix_block_lock(conflock, &block->b_call.a_args.lock.fl); in nlmsvc_lock()
454 struct nlm_block *block; in nlmsvc_cancel_blocked() local
464 if ((block = nlmsvc_lookup_block(file, lock, 1)) != NULL) in nlmsvc_cancel_blocked()
465 nlmsvc_delete_block(block, 1); in nlmsvc_cancel_blocked()
480 struct nlm_block **bp, *block; in nlmsvc_notify_blocked() local
484 for (bp = &nlm_blocked; (block = *bp); bp = &block->b_next) { in nlmsvc_notify_blocked()
485 if (nlm_compare_locks(&block->b_call.a_args.lock.fl, fl)) { in nlmsvc_notify_blocked()
486 nlmsvc_insert_block(block, 0); in nlmsvc_notify_blocked()
487 svc_wake_up(block->b_daemon); in nlmsvc_notify_blocked()
507 nlmsvc_grant_blocked(struct nlm_block *block) in nlmsvc_grant_blocked() argument
509 struct nlm_file *file = block->b_file; in nlmsvc_grant_blocked()
510 struct nlm_lock *lock = &block->b_call.a_args.lock; in nlmsvc_grant_blocked()
514 dprintk("lockd: grant blocked lock %p\n", block); in nlmsvc_grant_blocked()
520 nlmsvc_remove_block(block); in nlmsvc_grant_blocked()
525 if (block->b_granted) { in nlmsvc_grant_blocked()
526 nlm_rebind_host(block->b_call.a_host); in nlmsvc_grant_blocked()
534 nlmsvc_insert_block(block, NLM_NEVER); in nlmsvc_grant_blocked()
547 nlmsvc_insert_block(block, 10 * HZ); in nlmsvc_grant_blocked()
555 block->b_granted = 1; in nlmsvc_grant_blocked()
556 block->b_incall = 1; in nlmsvc_grant_blocked()
559 nlmsvc_insert_block(block, 30 * HZ); in nlmsvc_grant_blocked()
562 nlm_get_host(block->b_call.a_host); in nlmsvc_grant_blocked()
563 if (nlmsvc_async_call(&block->b_call, NLMPROC_GRANTED_MSG, in nlmsvc_grant_blocked()
565 nlm_release_host(block->b_call.a_host); in nlmsvc_grant_blocked()
581 struct nlm_block *block; in nlmsvc_grant_callback() local
589 if (!(block = nlmsvc_find_block(&call->a_args.cookie, peer_addr))) { in nlmsvc_grant_callback()
602 } else if (block->b_done) { in nlmsvc_grant_callback()
609 nlmsvc_insert_block(block, timeout); in nlmsvc_grant_callback()
610 svc_wake_up(block->b_daemon); in nlmsvc_grant_callback()
611 block->b_incall = 0; in nlmsvc_grant_callback()
623 struct nlm_block *block; in nlmsvc_grant_reply() local
629 if (!(block = nlmsvc_find_block(cookie, &rqstp->rq_addr))) in nlmsvc_grant_reply()
631 file = block->b_file; in nlmsvc_grant_reply()
635 if ((block = nlmsvc_find_block(cookie,&rqstp->rq_addr)) != NULL) { in nlmsvc_grant_reply()
638 nlmsvc_insert_block(block, 10 * HZ); in nlmsvc_grant_reply()
639 block = NULL; in nlmsvc_grant_reply()
645 nlmsvc_delete_block(block, 0); in nlmsvc_grant_reply()
647 nlmsvc_delete_block(block, 1); in nlmsvc_grant_reply()
650 if (!block) in nlmsvc_grant_reply()
663 struct nlm_block *block; in nlmsvc_retry_blocked() local
668 while ((block = nlm_blocked)) { in nlmsvc_retry_blocked()
669 if (block->b_when == NLM_NEVER) in nlmsvc_retry_blocked()
671 if (time_after(block->b_when,jiffies)) in nlmsvc_retry_blocked()
674 block, block->b_when, block->b_done); in nlmsvc_retry_blocked()
675 if (block->b_done) in nlmsvc_retry_blocked()
676 nlmsvc_delete_block(block, 0); in nlmsvc_retry_blocked()
678 nlmsvc_grant_blocked(block); in nlmsvc_retry_blocked()
681 if ((block = nlm_blocked) && block->b_when != NLM_NEVER) in nlmsvc_retry_blocked()
682 return (block->b_when - jiffies); in nlmsvc_retry_blocked()