Lines Matching refs:fl
34 static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host);
129 static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_setlockargs() argument
136 memcpy(&lock->fh, NFS_FH(file_inode(fl->fl_file)), sizeof(struct nfs_fh)); in nlmclnt_setlockargs()
140 (unsigned int)fl->fl_u.nfs_fl.owner->pid, in nlmclnt_setlockargs()
142 lock->svid = fl->fl_u.nfs_fl.owner->pid; in nlmclnt_setlockargs()
143 lock->fl.fl_start = fl->fl_start; in nlmclnt_setlockargs()
144 lock->fl.fl_end = fl->fl_end; in nlmclnt_setlockargs()
145 lock->fl.fl_type = fl->fl_type; in nlmclnt_setlockargs()
150 WARN_ON_ONCE(req->a_args.lock.fl.fl_ops != NULL); in nlmclnt_release_lockargs()
161 int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl, void *data) in nlmclnt_proc() argument
174 nlmclnt_locks_init_private(fl, host); in nlmclnt_proc()
175 if (!fl->fl_u.nfs_fl.owner) { in nlmclnt_proc()
181 nlmclnt_setlockargs(call, fl); in nlmclnt_proc()
185 if (fl->fl_type != F_UNLCK) { in nlmclnt_proc()
187 status = nlmclnt_lock(call, fl); in nlmclnt_proc()
189 status = nlmclnt_unlock(call, fl); in nlmclnt_proc()
191 status = nlmclnt_test(call, fl); in nlmclnt_proc()
194 fl->fl_ops->fl_release_private(fl); in nlmclnt_proc()
195 fl->fl_ops = NULL; in nlmclnt_proc()
213 locks_init_lock(&call->a_args.lock.fl); in nlm_alloc_call()
214 locks_init_lock(&call->a_res.lock.fl); in nlm_alloc_call()
431 nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_test() argument
435 status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_TEST); in nlmclnt_test()
441 fl->fl_type = F_UNLCK; in nlmclnt_test()
447 fl->fl_start = req->a_res.lock.fl.fl_start; in nlmclnt_test()
448 fl->fl_end = req->a_res.lock.fl.fl_end; in nlmclnt_test()
449 fl->fl_type = req->a_res.lock.fl.fl_type; in nlmclnt_test()
450 fl->fl_pid = -req->a_res.lock.fl.fl_pid; in nlmclnt_test()
463 static void nlmclnt_locks_copy_lock(struct file_lock *new, struct file_lock *fl) in nlmclnt_locks_copy_lock() argument
465 spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_copy_lock()
466 new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state; in nlmclnt_locks_copy_lock()
467 new->fl_u.nfs_fl.owner = nlmclnt_get_lockowner(fl->fl_u.nfs_fl.owner); in nlmclnt_locks_copy_lock()
468 list_add_tail(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.owner->host->h_granted); in nlmclnt_locks_copy_lock()
469 spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_copy_lock()
472 static void nlmclnt_locks_release_private(struct file_lock *fl) in nlmclnt_locks_release_private() argument
474 spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_release_private()
475 list_del(&fl->fl_u.nfs_fl.list); in nlmclnt_locks_release_private()
476 spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_release_private()
477 nlmclnt_put_lockowner(fl->fl_u.nfs_fl.owner); in nlmclnt_locks_release_private()
485 static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host) in nlmclnt_locks_init_private() argument
487 fl->fl_u.nfs_fl.state = 0; in nlmclnt_locks_init_private()
488 fl->fl_u.nfs_fl.owner = nlmclnt_find_lockowner(host, fl->fl_owner); in nlmclnt_locks_init_private()
489 INIT_LIST_HEAD(&fl->fl_u.nfs_fl.list); in nlmclnt_locks_init_private()
490 fl->fl_ops = &nlmclnt_lock_ops; in nlmclnt_locks_init_private()
493 static int do_vfs_lock(struct file_lock *fl) in do_vfs_lock() argument
495 return locks_lock_file_wait(fl->fl_file, fl); in do_vfs_lock()
519 nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_lock() argument
521 const struct cred *cred = nfs_file_cred(fl->fl_file); in nlmclnt_lock()
525 unsigned char fl_flags = fl->fl_flags; in nlmclnt_lock()
534 fl->fl_flags |= FL_ACCESS; in nlmclnt_lock()
535 status = do_vfs_lock(fl); in nlmclnt_lock()
536 fl->fl_flags = fl_flags; in nlmclnt_lock()
540 nlmclnt_prepare_block(&block, host, fl); in nlmclnt_lock()
556 fl->fl_u.nfs_fl.state = host->h_state; in nlmclnt_lock()
582 if (nlmclnt_cancel(host, req->a_args.block, fl) == 0) in nlmclnt_lock()
589 if (fl->fl_u.nfs_fl.state != host->h_state) { in nlmclnt_lock()
594 fl->fl_flags |= FL_SLEEP; in nlmclnt_lock()
595 if (do_vfs_lock(fl) < 0) in nlmclnt_lock()
598 fl->fl_flags = fl_flags; in nlmclnt_lock()
625 fl_type = fl->fl_type; in nlmclnt_lock()
626 fl->fl_type = F_UNLCK; in nlmclnt_lock()
628 do_vfs_lock(fl); in nlmclnt_lock()
630 fl->fl_type = fl_type; in nlmclnt_lock()
631 fl->fl_flags = fl_flags; in nlmclnt_lock()
640 nlmclnt_reclaim(struct nlm_host *host, struct file_lock *fl, in nlmclnt_reclaim() argument
646 locks_init_lock(&req->a_args.lock.fl); in nlmclnt_reclaim()
647 locks_init_lock(&req->a_res.lock.fl); in nlmclnt_reclaim()
651 nlmclnt_setlockargs(req, fl); in nlmclnt_reclaim()
654 status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_LOCK); in nlmclnt_reclaim()
659 "(errno %d, status %d)\n", fl->fl_pid, in nlmclnt_reclaim()
681 nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_unlock() argument
686 unsigned char fl_flags = fl->fl_flags; in nlmclnt_unlock()
693 fl->fl_flags |= FL_EXISTS; in nlmclnt_unlock()
695 status = do_vfs_lock(fl); in nlmclnt_unlock()
697 fl->fl_flags = fl_flags; in nlmclnt_unlock()
704 status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req, in nlmclnt_unlock()
781 static int nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *fl) in nlmclnt_cancel() argument
794 nlmclnt_setlockargs(req, fl); in nlmclnt_cancel()
798 status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req, in nlmclnt_cancel()