Lines Matching refs:lock

46 static int nlmsvc_setgrantargs(struct nlm_rqst *call, struct nlm_lock *lock);
146 nlmsvc_lookup_block(struct nlm_file *file, struct nlm_lock *lock) in nlmsvc_lookup_block() argument
152 file, lock->fl.c.flc_pid, in nlmsvc_lookup_block()
153 (long long)lock->fl.fl_start, in nlmsvc_lookup_block()
154 (long long)lock->fl.fl_end, in nlmsvc_lookup_block()
155 lock->fl.c.flc_type); in nlmsvc_lookup_block()
158 fl = &block->b_call->a_args.lock.fl; in nlmsvc_lookup_block()
164 if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) { in nlmsvc_lookup_block()
225 struct nlm_file *file, struct nlm_lock *lock, in nlmsvc_create_block() argument
243 if (!nlmsvc_setgrantargs(call, lock)) in nlmsvc_create_block()
247 call->a_args.lock.fl.c.flc_flags |= FL_SLEEP; in nlmsvc_create_block()
248 call->a_args.lock.fl.fl_lmops = &nlmsvc_lock_operations; in nlmsvc_create_block()
287 status = locks_delete_block(&block->b_call->a_args.lock.fl); in nlmsvc_unlink_block()
403 nlmsvc_release_lockowner(struct nlm_lock *lock) in nlmsvc_release_lockowner() argument
405 if (lock->fl.c.flc_owner) in nlmsvc_release_lockowner()
406 nlmsvc_put_lockowner(lock->fl.c.flc_owner); in nlmsvc_release_lockowner()
419 static int nlmsvc_setgrantargs(struct nlm_rqst *call, struct nlm_lock *lock) in nlmsvc_setgrantargs() argument
421 locks_copy_lock(&call->a_args.lock.fl, &lock->fl); in nlmsvc_setgrantargs()
422 memcpy(&call->a_args.lock.fh, &lock->fh, sizeof(call->a_args.lock.fh)); in nlmsvc_setgrantargs()
423 call->a_args.lock.caller = utsname()->nodename; in nlmsvc_setgrantargs()
424 call->a_args.lock.oh.len = lock->oh.len; in nlmsvc_setgrantargs()
427 call->a_args.lock.oh.data = call->a_owner; in nlmsvc_setgrantargs()
428 call->a_args.lock.svid = ((struct nlm_lockowner *) lock->fl.c.flc_owner)->pid; in nlmsvc_setgrantargs()
430 if (lock->oh.len > NLMCLNT_OHSIZE) { in nlmsvc_setgrantargs()
431 void *data = kmalloc(lock->oh.len, GFP_KERNEL); in nlmsvc_setgrantargs()
434 call->a_args.lock.oh.data = (u8 *) data; in nlmsvc_setgrantargs()
437 memcpy(call->a_args.lock.oh.data, lock->oh.data, lock->oh.len); in nlmsvc_setgrantargs()
443 if (call->a_args.lock.oh.data != call->a_owner) in nlmsvc_freegrantargs()
444 kfree(call->a_args.lock.oh.data); in nlmsvc_freegrantargs()
446 locks_release_private(&call->a_args.lock.fl); in nlmsvc_freegrantargs()
480 struct nlm_host *host, struct nlm_lock *lock, int wait, in nlmsvc_lock() argument
492 lock->fl.c.flc_type, in nlmsvc_lock()
493 lock->fl.c.flc_pid, in nlmsvc_lock()
494 (long long)lock->fl.fl_start, in nlmsvc_lock()
495 (long long)lock->fl.fl_end, in nlmsvc_lock()
508 block = nlmsvc_lookup_block(file, lock); in nlmsvc_lock()
510 block = nlmsvc_create_block(rqstp, host, file, lock, cookie); in nlmsvc_lock()
514 lock = &block->b_call->a_args.lock; in nlmsvc_lock()
516 lock->fl.c.flc_flags &= ~FL_SLEEP; in nlmsvc_lock()
564 lock->fl.c.flc_flags &= ~FL_SLEEP; in nlmsvc_lock()
565 mode = lock_to_openmode(&lock->fl); in nlmsvc_lock()
566 error = vfs_lock_file(file->f_file[mode], F_SETLK, &lock->fl, NULL); in nlmsvc_lock()
567 lock->fl.c.flc_flags &= ~FL_SLEEP; in nlmsvc_lock()
610 struct nlm_host *host, struct nlm_lock *lock, in nlmsvc_testlock() argument
620 lock->fl.c.flc_type, in nlmsvc_testlock()
621 (long long)lock->fl.fl_start, in nlmsvc_testlock()
622 (long long)lock->fl.fl_end); in nlmsvc_testlock()
629 mode = lock_to_openmode(&lock->fl); in nlmsvc_testlock()
630 error = vfs_test_lock(file->f_file[mode], &lock->fl); in nlmsvc_testlock()
640 if (lock->fl.c.flc_type == F_UNLCK) { in nlmsvc_testlock()
646 lock->fl.c.flc_type, (long long)lock->fl.fl_start, in nlmsvc_testlock()
647 (long long)lock->fl.fl_end); in nlmsvc_testlock()
651 conflock->svid = lock->fl.c.flc_pid; in nlmsvc_testlock()
652 conflock->fl.c.flc_type = lock->fl.c.flc_type; in nlmsvc_testlock()
653 conflock->fl.fl_start = lock->fl.fl_start; in nlmsvc_testlock()
654 conflock->fl.fl_end = lock->fl.fl_end; in nlmsvc_testlock()
655 locks_release_private(&lock->fl); in nlmsvc_testlock()
670 nlmsvc_unlock(struct net *net, struct nlm_file *file, struct nlm_lock *lock) in nlmsvc_unlock() argument
677 lock->fl.c.flc_pid, in nlmsvc_unlock()
678 (long long)lock->fl.fl_start, in nlmsvc_unlock()
679 (long long)lock->fl.fl_end); in nlmsvc_unlock()
682 nlmsvc_cancel_blocked(net, file, lock); in nlmsvc_unlock()
684 lock->fl.c.flc_type = F_UNLCK; in nlmsvc_unlock()
685 lock->fl.c.flc_file = file->f_file[O_RDONLY]; in nlmsvc_unlock()
686 if (lock->fl.c.flc_file) in nlmsvc_unlock()
687 error = vfs_lock_file(lock->fl.c.flc_file, F_SETLK, in nlmsvc_unlock()
688 &lock->fl, NULL); in nlmsvc_unlock()
689 lock->fl.c.flc_file = file->f_file[O_WRONLY]; in nlmsvc_unlock()
690 if (lock->fl.c.flc_file) in nlmsvc_unlock()
691 error |= vfs_lock_file(lock->fl.c.flc_file, F_SETLK, in nlmsvc_unlock()
692 &lock->fl, NULL); in nlmsvc_unlock()
705 nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *lock) in nlmsvc_cancel_blocked() argument
714 lock->fl.c.flc_pid, in nlmsvc_cancel_blocked()
715 (long long)lock->fl.fl_start, in nlmsvc_cancel_blocked()
716 (long long)lock->fl.fl_end); in nlmsvc_cancel_blocked()
722 block = nlmsvc_lookup_block(file, lock); in nlmsvc_cancel_blocked()
725 struct file_lock *fl = &block->b_call->a_args.lock.fl; in nlmsvc_cancel_blocked()
761 if (nlm_compare_locks(&block->b_call->a_args.lock.fl, fl)) { in nlmsvc_grant_deferred()
800 if (nlm_compare_locks(&block->b_call->a_args.lock.fl, fl)) { in nlmsvc_notify_blocked()
843 struct nlm_lock *lock = &block->b_call->a_args.lock; in nlmsvc_grant_blocked() local
867 lock->fl.c.flc_flags |= FL_SLEEP; in nlmsvc_grant_blocked()
868 fl_start = lock->fl.fl_start; in nlmsvc_grant_blocked()
869 fl_end = lock->fl.fl_end; in nlmsvc_grant_blocked()
870 mode = lock_to_openmode(&lock->fl); in nlmsvc_grant_blocked()
871 error = vfs_lock_file(file->f_file[mode], F_SETLK, &lock->fl, NULL); in nlmsvc_grant_blocked()
872 lock->fl.c.flc_flags &= ~FL_SLEEP; in nlmsvc_grant_blocked()
873 lock->fl.fl_start = fl_start; in nlmsvc_grant_blocked()
874 lock->fl.fl_end = fl_end; in nlmsvc_grant_blocked()
996 fl = &block->b_call->a_args.lock.fl; in nlmsvc_grant_reply()