Lines Matching refs:block
44 static void nlmsvc_release_block(struct nlm_block *block);
45 static void nlmsvc_insert_block(struct nlm_block *block, unsigned long);
46 static void nlmsvc_remove_block(struct nlm_block *block);
91 nlmsvc_insert_block_locked(struct nlm_block *block, unsigned long when) in nlmsvc_insert_block_locked() argument
96 dprintk("lockd: nlmsvc_insert_block(%p, %ld)\n", block, when); in nlmsvc_insert_block_locked()
97 if (list_empty(&block->b_list)) { in nlmsvc_insert_block_locked()
98 kref_get(&block->b_count); in nlmsvc_insert_block_locked()
100 list_del_init(&block->b_list); in nlmsvc_insert_block_locked()
117 list_add_tail(&block->b_list, pos); in nlmsvc_insert_block_locked()
118 block->b_when = when; in nlmsvc_insert_block_locked()
121 static void nlmsvc_insert_block(struct nlm_block *block, unsigned long when) in nlmsvc_insert_block() argument
124 nlmsvc_insert_block_locked(block, when); in nlmsvc_insert_block()
132 nlmsvc_remove_block(struct nlm_block *block) in nlmsvc_remove_block() argument
134 if (!list_empty(&block->b_list)) { in nlmsvc_remove_block()
136 list_del_init(&block->b_list); in nlmsvc_remove_block()
138 nlmsvc_release_block(block); in nlmsvc_remove_block()
148 struct nlm_block *block; in nlmsvc_lookup_block() local
155 list_for_each_entry(block, &nlm_blocked, b_list) { in nlmsvc_lookup_block()
156 fl = &block->b_call->a_args.lock.fl; in nlmsvc_lookup_block()
158 block->b_file, fl->fl_pid, in nlmsvc_lookup_block()
161 nlmdbg_cookie2a(&block->b_call->a_args.cookie)); in nlmsvc_lookup_block()
162 if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) { in nlmsvc_lookup_block()
163 kref_get(&block->b_count); in nlmsvc_lookup_block()
164 return block; in nlmsvc_lookup_block()
186 struct nlm_block *block; in nlmsvc_find_block() local
188 list_for_each_entry(block, &nlm_blocked, b_list) { in nlmsvc_find_block()
189 if (nlm_cookie_match(&block->b_call->a_args.cookie,cookie)) in nlmsvc_find_block()
196 dprintk("nlmsvc_find_block(%s): block=%p\n", nlmdbg_cookie2a(cookie), block); in nlmsvc_find_block()
197 kref_get(&block->b_count); in nlmsvc_find_block()
198 return block; in nlmsvc_find_block()
221 struct nlm_block *block; in nlmsvc_create_block() local
229 block = kzalloc(sizeof(*block), GFP_KERNEL); in nlmsvc_create_block()
230 if (block == NULL) in nlmsvc_create_block()
232 kref_init(&block->b_count); in nlmsvc_create_block()
233 INIT_LIST_HEAD(&block->b_list); in nlmsvc_create_block()
234 INIT_LIST_HEAD(&block->b_flist); in nlmsvc_create_block()
244 dprintk("lockd: created block %p...\n", block); in nlmsvc_create_block()
247 block->b_daemon = rqstp->rq_server; in nlmsvc_create_block()
248 block->b_host = host; in nlmsvc_create_block()
249 block->b_file = file; in nlmsvc_create_block()
253 list_add(&block->b_flist, &file->f_blocks); in nlmsvc_create_block()
256 block->b_call = call; in nlmsvc_create_block()
258 call->a_block = block; in nlmsvc_create_block()
260 return block; in nlmsvc_create_block()
263 kfree(block); in nlmsvc_create_block()
274 static int nlmsvc_unlink_block(struct nlm_block *block) in nlmsvc_unlink_block() argument
277 dprintk("lockd: unlinking block %p...\n", block); in nlmsvc_unlink_block()
280 status = locks_delete_block(&block->b_call->a_args.lock.fl); in nlmsvc_unlink_block()
281 nlmsvc_remove_block(block); in nlmsvc_unlink_block()
287 struct nlm_block *block = container_of(kref, struct nlm_block, b_count); in nlmsvc_free_block() local
288 struct nlm_file *file = block->b_file; in nlmsvc_free_block()
290 dprintk("lockd: freeing block %p...\n", block); in nlmsvc_free_block()
293 list_del_init(&block->b_flist); in nlmsvc_free_block()
296 nlmsvc_freegrantargs(block->b_call); in nlmsvc_free_block()
297 nlmsvc_release_call(block->b_call); in nlmsvc_free_block()
298 nlm_release_file(block->b_file); in nlmsvc_free_block()
299 kfree(block); in nlmsvc_free_block()
302 static void nlmsvc_release_block(struct nlm_block *block) in nlmsvc_release_block() argument
304 if (block != NULL) in nlmsvc_release_block()
305 kref_put_mutex(&block->b_count, nlmsvc_free_block, &block->b_file->f_mutex); in nlmsvc_release_block()
316 struct nlm_block *block, *next; in nlmsvc_traverse_blocks() local
320 list_for_each_entry_safe(block, next, &file->f_blocks, b_flist) { in nlmsvc_traverse_blocks()
321 if (!match(block->b_host, host)) in nlmsvc_traverse_blocks()
325 if (list_empty(&block->b_list)) in nlmsvc_traverse_blocks()
327 kref_get(&block->b_count); in nlmsvc_traverse_blocks()
329 nlmsvc_unlink_block(block); in nlmsvc_traverse_blocks()
330 nlmsvc_release_block(block); in nlmsvc_traverse_blocks()
443 nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block) in nlmsvc_defer_lock_rqst() argument
447 block->b_flags |= B_QUEUED; in nlmsvc_defer_lock_rqst()
449 nlmsvc_insert_block(block, NLM_TIMEOUT); in nlmsvc_defer_lock_rqst()
451 block->b_cache_req = &rqstp->rq_chandle; in nlmsvc_defer_lock_rqst()
453 block->b_deferred_req = in nlmsvc_defer_lock_rqst()
454 rqstp->rq_chandle.defer(block->b_cache_req); in nlmsvc_defer_lock_rqst()
455 if (block->b_deferred_req != NULL) in nlmsvc_defer_lock_rqst()
459 block, block->b_flags, ntohl(status)); in nlmsvc_defer_lock_rqst()
473 struct nlm_block *block = NULL; in nlmsvc_lock() local
497 block = nlmsvc_lookup_block(file, lock); in nlmsvc_lock()
498 if (block == NULL) { in nlmsvc_lock()
499 block = nlmsvc_create_block(rqstp, host, file, lock, cookie); in nlmsvc_lock()
501 if (block == NULL) in nlmsvc_lock()
503 lock = &block->b_call->a_args.lock; in nlmsvc_lock()
507 if (block->b_flags & B_QUEUED) { in nlmsvc_lock()
509 block, block->b_flags); in nlmsvc_lock()
510 if (block->b_granted) { in nlmsvc_lock()
511 nlmsvc_unlink_block(block); in nlmsvc_lock()
515 if (block->b_flags & B_TIMED_OUT) { in nlmsvc_lock()
516 nlmsvc_unlink_block(block); in nlmsvc_lock()
559 ret = nlmsvc_defer_lock_rqst(rqstp, block); in nlmsvc_lock()
572 nlmsvc_insert_block(block, NLM_NEVER); in nlmsvc_lock()
575 nlmsvc_release_block(block); in nlmsvc_lock()
688 struct nlm_block *block; in nlmsvc_cancel_blocked() local
703 block = nlmsvc_lookup_block(file, lock); in nlmsvc_cancel_blocked()
705 if (block != NULL) { in nlmsvc_cancel_blocked()
707 vfs_cancel_lock(block->b_file->f_file[mode], in nlmsvc_cancel_blocked()
708 &block->b_call->a_args.lock.fl); in nlmsvc_cancel_blocked()
709 status = nlmsvc_unlink_block(block); in nlmsvc_cancel_blocked()
710 nlmsvc_release_block(block); in nlmsvc_cancel_blocked()
725 nlmsvc_update_deferred_block(struct nlm_block *block, int result) in nlmsvc_update_deferred_block() argument
727 block->b_flags |= B_GOT_CALLBACK; in nlmsvc_update_deferred_block()
729 block->b_granted = 1; in nlmsvc_update_deferred_block()
731 block->b_flags |= B_TIMED_OUT; in nlmsvc_update_deferred_block()
736 struct nlm_block *block; in nlmsvc_grant_deferred() local
740 list_for_each_entry(block, &nlm_blocked, b_list) { in nlmsvc_grant_deferred()
741 if (nlm_compare_locks(&block->b_call->a_args.lock.fl, fl)) { in nlmsvc_grant_deferred()
743 block, block->b_flags); in nlmsvc_grant_deferred()
744 if (block->b_flags & B_QUEUED) { in nlmsvc_grant_deferred()
745 if (block->b_flags & B_TIMED_OUT) { in nlmsvc_grant_deferred()
749 nlmsvc_update_deferred_block(block, result); in nlmsvc_grant_deferred()
751 block->b_granted = 1; in nlmsvc_grant_deferred()
753 nlmsvc_insert_block_locked(block, 0); in nlmsvc_grant_deferred()
754 svc_wake_up(block->b_daemon); in nlmsvc_grant_deferred()
775 struct nlm_block *block; in nlmsvc_notify_blocked() local
779 list_for_each_entry(block, &nlm_blocked, b_list) { in nlmsvc_notify_blocked()
780 if (nlm_compare_locks(&block->b_call->a_args.lock.fl, fl)) { in nlmsvc_notify_blocked()
781 nlmsvc_insert_block_locked(block, 0); in nlmsvc_notify_blocked()
783 svc_wake_up(block->b_daemon); in nlmsvc_notify_blocked()
820 nlmsvc_grant_blocked(struct nlm_block *block) in nlmsvc_grant_blocked() argument
822 struct nlm_file *file = block->b_file; in nlmsvc_grant_blocked()
823 struct nlm_lock *lock = &block->b_call->a_args.lock; in nlmsvc_grant_blocked()
828 dprintk("lockd: grant blocked lock %p\n", block); in nlmsvc_grant_blocked()
830 kref_get(&block->b_count); in nlmsvc_grant_blocked()
833 nlmsvc_unlink_block(block); in nlmsvc_grant_blocked()
838 if (block->b_granted) { in nlmsvc_grant_blocked()
839 nlm_rebind_host(block->b_host); in nlmsvc_grant_blocked()
861 nlmsvc_insert_block(block, NLM_NEVER); in nlmsvc_grant_blocked()
862 nlmsvc_release_block(block); in nlmsvc_grant_blocked()
867 nlmsvc_insert_block(block, 10 * HZ); in nlmsvc_grant_blocked()
868 nlmsvc_release_block(block); in nlmsvc_grant_blocked()
875 block->b_granted = 1; in nlmsvc_grant_blocked()
880 nlmsvc_insert_block(block, NLM_NEVER); in nlmsvc_grant_blocked()
885 error = nlm_async_call(block->b_call, NLMPROC_GRANTED_MSG, in nlmsvc_grant_blocked()
890 nlmsvc_insert_block(block, 10 * HZ); in nlmsvc_grant_blocked()
904 struct nlm_block *block = call->a_block; in nlmsvc_grant_callback() local
918 if (list_empty(&block->b_list)) in nlmsvc_grant_callback()
931 nlmsvc_insert_block_locked(block, timeout); in nlmsvc_grant_callback()
932 svc_wake_up(block->b_daemon); in nlmsvc_grant_callback()
959 struct nlm_block *block; in nlmsvc_grant_reply() local
963 if (!(block = nlmsvc_find_block(cookie))) in nlmsvc_grant_reply()
968 nlmsvc_insert_block(block, 10 * HZ); in nlmsvc_grant_reply()
974 nlmsvc_unlink_block(block); in nlmsvc_grant_reply()
976 nlmsvc_release_block(block); in nlmsvc_grant_reply()
984 retry_deferred_block(struct nlm_block *block) in retry_deferred_block() argument
986 if (!(block->b_flags & B_GOT_CALLBACK)) in retry_deferred_block()
987 block->b_flags |= B_TIMED_OUT; in retry_deferred_block()
988 nlmsvc_insert_block(block, NLM_TIMEOUT); in retry_deferred_block()
989 dprintk("revisit block %p flags %d\n", block, block->b_flags); in retry_deferred_block()
990 if (block->b_deferred_req) { in retry_deferred_block()
991 block->b_deferred_req->revisit(block->b_deferred_req, 0); in retry_deferred_block()
992 block->b_deferred_req = NULL; in retry_deferred_block()
1005 struct nlm_block *block; in nlmsvc_retry_blocked() local
1009 block = list_entry(nlm_blocked.next, struct nlm_block, b_list); in nlmsvc_retry_blocked()
1011 if (block->b_when == NLM_NEVER) in nlmsvc_retry_blocked()
1013 if (time_after(block->b_when, jiffies)) { in nlmsvc_retry_blocked()
1014 timeout = block->b_when - jiffies; in nlmsvc_retry_blocked()
1020 block, block->b_when); in nlmsvc_retry_blocked()
1021 if (block->b_flags & B_QUEUED) { in nlmsvc_retry_blocked()
1023 block, block->b_granted, block->b_flags); in nlmsvc_retry_blocked()
1024 retry_deferred_block(block); in nlmsvc_retry_blocked()
1026 nlmsvc_grant_blocked(block); in nlmsvc_retry_blocked()