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->c.flc_file)), in nlmclnt_setlockargs()
141 (unsigned int)fl->fl_u.nfs_fl.owner->pid, in nlmclnt_setlockargs()
143 lock->svid = fl->fl_u.nfs_fl.owner->pid; in nlmclnt_setlockargs()
144 lock->fl.fl_start = fl->fl_start; in nlmclnt_setlockargs()
145 lock->fl.fl_end = fl->fl_end; in nlmclnt_setlockargs()
146 lock->fl.c.flc_type = fl->c.flc_type; in nlmclnt_setlockargs()
151 WARN_ON_ONCE(req->a_args.lock.fl.fl_ops != NULL); in nlmclnt_release_lockargs()
162 int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl, void *data) in nlmclnt_proc() argument
175 nlmclnt_locks_init_private(fl, host); in nlmclnt_proc()
176 if (!fl->fl_u.nfs_fl.owner) { in nlmclnt_proc()
182 nlmclnt_setlockargs(call, fl); in nlmclnt_proc()
186 if (fl->c.flc_type != F_UNLCK) { in nlmclnt_proc()
188 status = nlmclnt_lock(call, fl); in nlmclnt_proc()
190 status = nlmclnt_unlock(call, fl); in nlmclnt_proc()
192 status = nlmclnt_test(call, fl); in nlmclnt_proc()
195 fl->fl_ops->fl_release_private(fl); in nlmclnt_proc()
196 fl->fl_ops = NULL; in nlmclnt_proc()
214 locks_init_lock(&call->a_args.lock.fl); in nlm_alloc_call()
215 locks_init_lock(&call->a_res.lock.fl); in nlm_alloc_call()
432 nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_test() argument
436 status = nlmclnt_call(nfs_file_cred(fl->c.flc_file), req, in nlmclnt_test()
443 fl->c.flc_type = F_UNLCK; in nlmclnt_test()
449 fl->fl_start = req->a_res.lock.fl.fl_start; in nlmclnt_test()
450 fl->fl_end = req->a_res.lock.fl.fl_end; in nlmclnt_test()
451 fl->c.flc_type = req->a_res.lock.fl.c.flc_type; in nlmclnt_test()
452 fl->c.flc_pid = -req->a_res.lock.fl.c.flc_pid; in nlmclnt_test()
465 static void nlmclnt_locks_copy_lock(struct file_lock *new, struct file_lock *fl) in nlmclnt_locks_copy_lock() argument
467 spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_copy_lock()
468 new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state; in nlmclnt_locks_copy_lock()
469 new->fl_u.nfs_fl.owner = nlmclnt_get_lockowner(fl->fl_u.nfs_fl.owner); in nlmclnt_locks_copy_lock()
470 list_add_tail(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.owner->host->h_granted); in nlmclnt_locks_copy_lock()
471 spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_copy_lock()
474 static void nlmclnt_locks_release_private(struct file_lock *fl) in nlmclnt_locks_release_private() argument
476 spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_release_private()
477 list_del(&fl->fl_u.nfs_fl.list); in nlmclnt_locks_release_private()
478 spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_release_private()
479 nlmclnt_put_lockowner(fl->fl_u.nfs_fl.owner); in nlmclnt_locks_release_private()
487 static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host) in nlmclnt_locks_init_private() argument
489 fl->fl_u.nfs_fl.state = 0; in nlmclnt_locks_init_private()
490 fl->fl_u.nfs_fl.owner = nlmclnt_find_lockowner(host, in nlmclnt_locks_init_private()
491 fl->c.flc_owner); in nlmclnt_locks_init_private()
492 INIT_LIST_HEAD(&fl->fl_u.nfs_fl.list); in nlmclnt_locks_init_private()
493 fl->fl_ops = &nlmclnt_lock_ops; in nlmclnt_locks_init_private()
496 static int do_vfs_lock(struct file_lock *fl) in do_vfs_lock() argument
498 return locks_lock_file_wait(fl->c.flc_file, fl); in do_vfs_lock()
522 nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_lock() argument
524 const struct cred *cred = nfs_file_cred(fl->c.flc_file); in nlmclnt_lock()
528 unsigned char flags = fl->c.flc_flags; in nlmclnt_lock()
537 fl->c.flc_flags |= FL_ACCESS; in nlmclnt_lock()
538 status = do_vfs_lock(fl); in nlmclnt_lock()
539 fl->c.flc_flags = flags; in nlmclnt_lock()
543 nlmclnt_prepare_block(&block, host, fl); in nlmclnt_lock()
559 fl->fl_u.nfs_fl.state = host->h_state; in nlmclnt_lock()
585 if (nlmclnt_cancel(host, req->a_args.block, fl) == 0) in nlmclnt_lock()
592 if (fl->fl_u.nfs_fl.state != host->h_state) { in nlmclnt_lock()
597 fl->c.flc_flags |= FL_SLEEP; in nlmclnt_lock()
598 if (do_vfs_lock(fl) < 0) in nlmclnt_lock()
601 fl->c.flc_flags = flags; in nlmclnt_lock()
628 type = fl->c.flc_type; in nlmclnt_lock()
629 fl->c.flc_type = F_UNLCK; in nlmclnt_lock()
631 do_vfs_lock(fl); in nlmclnt_lock()
633 fl->c.flc_type = type; in nlmclnt_lock()
634 fl->c.flc_flags = flags; in nlmclnt_lock()
643 nlmclnt_reclaim(struct nlm_host *host, struct file_lock *fl, in nlmclnt_reclaim() argument
649 locks_init_lock(&req->a_args.lock.fl); in nlmclnt_reclaim()
650 locks_init_lock(&req->a_res.lock.fl); in nlmclnt_reclaim()
654 nlmclnt_setlockargs(req, fl); in nlmclnt_reclaim()
657 status = nlmclnt_call(nfs_file_cred(fl->c.flc_file), req, in nlmclnt_reclaim()
664 fl->c.flc_pid, in nlmclnt_reclaim()
686 nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_unlock() argument
691 unsigned char flags = fl->c.flc_flags; in nlmclnt_unlock()
698 fl->c.flc_flags |= FL_EXISTS; in nlmclnt_unlock()
700 status = do_vfs_lock(fl); in nlmclnt_unlock()
702 fl->c.flc_flags = flags; in nlmclnt_unlock()
709 status = nlmclnt_async_call(nfs_file_cred(fl->c.flc_file), req, in nlmclnt_unlock()
786 static int nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *fl) in nlmclnt_cancel() argument
799 nlmclnt_setlockargs(req, fl); in nlmclnt_cancel()
803 status = nlmclnt_async_call(nfs_file_cred(fl->c.flc_file), req, in nlmclnt_cancel()