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
135 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()
150 struct nlm_block *block; in nlmsvc_lookup_block() local
158 list_for_each_entry(block, &nlm_blocked, b_list) { in nlmsvc_lookup_block()
159 fl = &block->b_call->a_args.lock.fl; in nlmsvc_lookup_block()
161 block->b_file, fl->fl_pid, in nlmsvc_lookup_block()
164 nlmdbg_cookie2a(&block->b_call->a_args.cookie)); in nlmsvc_lookup_block()
165 if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) { in nlmsvc_lookup_block()
166 kref_get(&block->b_count); in nlmsvc_lookup_block()
168 return block; in nlmsvc_lookup_block()
191 struct nlm_block *block; in nlmsvc_find_block() local
194 list_for_each_entry(block, &nlm_blocked, b_list) { in nlmsvc_find_block()
195 if (nlm_cookie_match(&block->b_call->a_args.cookie,cookie)) in nlmsvc_find_block()
203 dprintk("nlmsvc_find_block(%s): block=%p\n", nlmdbg_cookie2a(cookie), block); in nlmsvc_find_block()
204 kref_get(&block->b_count); in nlmsvc_find_block()
206 return block; in nlmsvc_find_block()
229 struct nlm_block *block; in nlmsvc_create_block() local
237 block = kzalloc(sizeof(*block), GFP_KERNEL); in nlmsvc_create_block()
238 if (block == NULL) in nlmsvc_create_block()
240 kref_init(&block->b_count); in nlmsvc_create_block()
241 INIT_LIST_HEAD(&block->b_list); in nlmsvc_create_block()
242 INIT_LIST_HEAD(&block->b_flist); in nlmsvc_create_block()
252 dprintk("lockd: created block %p...\n", block); in nlmsvc_create_block()
255 block->b_daemon = rqstp->rq_server; in nlmsvc_create_block()
256 block->b_host = host; in nlmsvc_create_block()
257 block->b_file = file; in nlmsvc_create_block()
261 list_add(&block->b_flist, &file->f_blocks); in nlmsvc_create_block()
264 block->b_call = call; in nlmsvc_create_block()
266 call->a_block = block; in nlmsvc_create_block()
268 return block; in nlmsvc_create_block()
271 kfree(block); in nlmsvc_create_block()
282 static int nlmsvc_unlink_block(struct nlm_block *block) in nlmsvc_unlink_block() argument
285 dprintk("lockd: unlinking block %p...\n", block); in nlmsvc_unlink_block()
288 status = locks_delete_block(&block->b_call->a_args.lock.fl); in nlmsvc_unlink_block()
289 nlmsvc_remove_block(block); in nlmsvc_unlink_block()
295 struct nlm_block *block = container_of(kref, struct nlm_block, b_count); in nlmsvc_free_block() local
296 struct nlm_file *file = block->b_file; in nlmsvc_free_block()
298 dprintk("lockd: freeing block %p...\n", block); in nlmsvc_free_block()
301 list_del_init(&block->b_flist); in nlmsvc_free_block()
304 nlmsvc_freegrantargs(block->b_call); in nlmsvc_free_block()
305 nlmsvc_release_call(block->b_call); in nlmsvc_free_block()
306 nlm_release_file(block->b_file); in nlmsvc_free_block()
307 kfree(block); in nlmsvc_free_block()
310 static void nlmsvc_release_block(struct nlm_block *block) in nlmsvc_release_block() argument
312 if (block != NULL) in nlmsvc_release_block()
313 kref_put_mutex(&block->b_count, nlmsvc_free_block, &block->b_file->f_mutex); in nlmsvc_release_block()
324 struct nlm_block *block, *next; in nlmsvc_traverse_blocks() local
329 list_for_each_entry_safe(block, next, &file->f_blocks, b_flist) { in nlmsvc_traverse_blocks()
330 if (!match(block->b_host, host)) in nlmsvc_traverse_blocks()
334 if (list_empty(&block->b_list)) in nlmsvc_traverse_blocks()
336 kref_get(&block->b_count); in nlmsvc_traverse_blocks()
339 nlmsvc_unlink_block(block); in nlmsvc_traverse_blocks()
340 nlmsvc_release_block(block); in nlmsvc_traverse_blocks()
454 nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block) in nlmsvc_defer_lock_rqst() argument
458 block->b_flags |= B_QUEUED; in nlmsvc_defer_lock_rqst()
460 nlmsvc_insert_block(block, NLM_TIMEOUT); in nlmsvc_defer_lock_rqst()
462 block->b_cache_req = &rqstp->rq_chandle; in nlmsvc_defer_lock_rqst()
464 block->b_deferred_req = in nlmsvc_defer_lock_rqst()
465 rqstp->rq_chandle.defer(block->b_cache_req); in nlmsvc_defer_lock_rqst()
466 if (block->b_deferred_req != NULL) in nlmsvc_defer_lock_rqst()
470 block, block->b_flags, ntohl(status)); in nlmsvc_defer_lock_rqst()
487 struct nlm_block *block = NULL; in nlmsvc_lock() local
510 block = nlmsvc_lookup_block(file, lock); in nlmsvc_lock()
511 if (block == NULL) { in nlmsvc_lock()
512 block = nlmsvc_create_block(rqstp, host, file, lock, cookie); in nlmsvc_lock()
514 if (block == NULL) in nlmsvc_lock()
516 lock = &block->b_call->a_args.lock; in nlmsvc_lock()
520 if (block->b_flags & B_QUEUED) { in nlmsvc_lock()
522 block, block->b_flags); in nlmsvc_lock()
523 if (block->b_granted) { in nlmsvc_lock()
524 nlmsvc_unlink_block(block); in nlmsvc_lock()
528 if (block->b_flags & B_TIMED_OUT) { in nlmsvc_lock()
529 nlmsvc_unlink_block(block); in nlmsvc_lock()
572 ret = nlmsvc_defer_lock_rqst(rqstp, block); in nlmsvc_lock()
585 nlmsvc_insert_block(block, NLM_NEVER); in nlmsvc_lock()
588 nlmsvc_release_block(block); in nlmsvc_lock()
695 struct nlm_block *block; in nlmsvc_cancel_blocked() local
710 block = nlmsvc_lookup_block(file, lock); in nlmsvc_cancel_blocked()
712 if (block != NULL) { in nlmsvc_cancel_blocked()
713 struct file_lock *fl = &block->b_call->a_args.lock.fl; in nlmsvc_cancel_blocked()
716 vfs_cancel_lock(block->b_file->f_file[mode], fl); in nlmsvc_cancel_blocked()
717 status = nlmsvc_unlink_block(block); in nlmsvc_cancel_blocked()
718 nlmsvc_release_block(block); in nlmsvc_cancel_blocked()
733 nlmsvc_update_deferred_block(struct nlm_block *block, int result) in nlmsvc_update_deferred_block() argument
735 block->b_flags |= B_GOT_CALLBACK; in nlmsvc_update_deferred_block()
737 block->b_granted = 1; in nlmsvc_update_deferred_block()
739 block->b_flags |= B_TIMED_OUT; in nlmsvc_update_deferred_block()
744 struct nlm_block *block; in nlmsvc_grant_deferred() local
748 list_for_each_entry(block, &nlm_blocked, b_list) { in nlmsvc_grant_deferred()
749 if (nlm_compare_locks(&block->b_call->a_args.lock.fl, fl)) { in nlmsvc_grant_deferred()
751 block, block->b_flags); in nlmsvc_grant_deferred()
752 if (block->b_flags & B_QUEUED) { in nlmsvc_grant_deferred()
753 if (block->b_flags & B_TIMED_OUT) { in nlmsvc_grant_deferred()
757 nlmsvc_update_deferred_block(block, result); in nlmsvc_grant_deferred()
759 block->b_granted = 1; in nlmsvc_grant_deferred()
761 nlmsvc_insert_block_locked(block, 0); in nlmsvc_grant_deferred()
762 svc_wake_up(block->b_daemon); in nlmsvc_grant_deferred()
783 struct nlm_block *block; in nlmsvc_notify_blocked() local
787 list_for_each_entry(block, &nlm_blocked, b_list) { in nlmsvc_notify_blocked()
788 if (nlm_compare_locks(&block->b_call->a_args.lock.fl, fl)) { in nlmsvc_notify_blocked()
789 nlmsvc_insert_block_locked(block, 0); in nlmsvc_notify_blocked()
791 svc_wake_up(block->b_daemon); in nlmsvc_notify_blocked()
828 nlmsvc_grant_blocked(struct nlm_block *block) in nlmsvc_grant_blocked() argument
830 struct nlm_file *file = block->b_file; in nlmsvc_grant_blocked()
831 struct nlm_lock *lock = &block->b_call->a_args.lock; in nlmsvc_grant_blocked()
836 dprintk("lockd: grant blocked lock %p\n", block); in nlmsvc_grant_blocked()
838 kref_get(&block->b_count); in nlmsvc_grant_blocked()
841 nlmsvc_unlink_block(block); in nlmsvc_grant_blocked()
846 if (block->b_granted) { in nlmsvc_grant_blocked()
847 nlm_rebind_host(block->b_host); in nlmsvc_grant_blocked()
869 nlmsvc_insert_block(block, NLM_NEVER); in nlmsvc_grant_blocked()
870 nlmsvc_release_block(block); in nlmsvc_grant_blocked()
875 nlmsvc_insert_block(block, 10 * HZ); in nlmsvc_grant_blocked()
876 nlmsvc_release_block(block); in nlmsvc_grant_blocked()
883 block->b_granted = 1; in nlmsvc_grant_blocked()
888 nlmsvc_insert_block(block, NLM_NEVER); in nlmsvc_grant_blocked()
893 error = nlm_async_call(block->b_call, NLMPROC_GRANTED_MSG, in nlmsvc_grant_blocked()
898 nlmsvc_insert_block(block, 10 * HZ); in nlmsvc_grant_blocked()
912 struct nlm_block *block = call->a_block; in nlmsvc_grant_callback() local
926 if (list_empty(&block->b_list)) in nlmsvc_grant_callback()
939 nlmsvc_insert_block_locked(block, timeout); in nlmsvc_grant_callback()
940 svc_wake_up(block->b_daemon); in nlmsvc_grant_callback()
967 struct nlm_block *block; in nlmsvc_grant_reply() local
973 if (!(block = nlmsvc_find_block(cookie))) in nlmsvc_grant_reply()
979 nlmsvc_insert_block(block, 10 * HZ); in nlmsvc_grant_reply()
983 nlmsvc_unlink_block(block); in nlmsvc_grant_reply()
984 fl = &block->b_call->a_args.lock.fl; in nlmsvc_grant_reply()
995 nlmsvc_unlink_block(block); in nlmsvc_grant_reply()
997 nlmsvc_release_block(block); in nlmsvc_grant_reply()
1005 retry_deferred_block(struct nlm_block *block) in retry_deferred_block() argument
1007 if (!(block->b_flags & B_GOT_CALLBACK)) in retry_deferred_block()
1008 block->b_flags |= B_TIMED_OUT; in retry_deferred_block()
1009 nlmsvc_insert_block(block, NLM_TIMEOUT); in retry_deferred_block()
1010 dprintk("revisit block %p flags %d\n", block, block->b_flags); in retry_deferred_block()
1011 if (block->b_deferred_req) { in retry_deferred_block()
1012 block->b_deferred_req->revisit(block->b_deferred_req, 0); in retry_deferred_block()
1013 block->b_deferred_req = NULL; in retry_deferred_block()
1026 struct nlm_block *block; in nlmsvc_retry_blocked() local
1030 block = list_entry(nlm_blocked.next, struct nlm_block, b_list); in nlmsvc_retry_blocked()
1032 if (block->b_when == NLM_NEVER) in nlmsvc_retry_blocked()
1034 if (time_after(block->b_when, jiffies)) { in nlmsvc_retry_blocked()
1035 timeout = block->b_when - jiffies; in nlmsvc_retry_blocked()
1041 block, block->b_when); in nlmsvc_retry_blocked()
1042 if (block->b_flags & B_QUEUED) { in nlmsvc_retry_blocked()
1044 block, block->b_granted, block->b_flags); in nlmsvc_retry_blocked()
1045 retry_deferred_block(block); in nlmsvc_retry_blocked()
1047 nlmsvc_grant_blocked(block); in nlmsvc_retry_blocked()