Lines Matching refs:fl

30 static void	nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host);
124 static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_setlockargs() argument
130 memcpy(&lock->fh, NFS_FH(fl->fl_file->f_path.dentry->d_inode), sizeof(struct nfs_fh)); in nlmclnt_setlockargs()
134 (unsigned int)fl->fl_u.nfs_fl.owner->pid, in nlmclnt_setlockargs()
136 lock->svid = fl->fl_u.nfs_fl.owner->pid; in nlmclnt_setlockargs()
137 lock->fl.fl_start = fl->fl_start; in nlmclnt_setlockargs()
138 lock->fl.fl_end = fl->fl_end; in nlmclnt_setlockargs()
139 lock->fl.fl_type = fl->fl_type; in nlmclnt_setlockargs()
144 BUG_ON(req->a_args.lock.fl.fl_ops != NULL); in nlmclnt_release_lockargs()
154 int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl) in nlmclnt_proc() argument
164 nlmclnt_locks_init_private(fl, host); in nlmclnt_proc()
166 nlmclnt_setlockargs(call, fl); in nlmclnt_proc()
169 if (fl->fl_type != F_UNLCK) { in nlmclnt_proc()
171 status = nlmclnt_lock(call, fl); in nlmclnt_proc()
173 status = nlmclnt_unlock(call, fl); in nlmclnt_proc()
175 status = nlmclnt_test(call, fl); in nlmclnt_proc()
178 fl->fl_ops->fl_release_private(fl); in nlmclnt_proc()
179 fl->fl_ops = NULL; in nlmclnt_proc()
200 locks_init_lock(&call->a_args.lock.fl); in nlm_alloc_call()
201 locks_init_lock(&call->a_res.lock.fl); in nlm_alloc_call()
414 nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_test() argument
418 status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_TEST); in nlmclnt_test()
424 fl->fl_type = F_UNLCK; in nlmclnt_test()
430 fl->fl_start = req->a_res.lock.fl.fl_start; in nlmclnt_test()
431 fl->fl_end = req->a_res.lock.fl.fl_end; in nlmclnt_test()
432 fl->fl_type = req->a_res.lock.fl.fl_type; in nlmclnt_test()
433 fl->fl_pid = 0; in nlmclnt_test()
443 static void nlmclnt_locks_copy_lock(struct file_lock *new, struct file_lock *fl) in nlmclnt_locks_copy_lock() argument
445 spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_copy_lock()
446 new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state; in nlmclnt_locks_copy_lock()
447 new->fl_u.nfs_fl.owner = nlm_get_lockowner(fl->fl_u.nfs_fl.owner); in nlmclnt_locks_copy_lock()
448 list_add_tail(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.owner->host->h_granted); in nlmclnt_locks_copy_lock()
449 spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_copy_lock()
452 static void nlmclnt_locks_release_private(struct file_lock *fl) in nlmclnt_locks_release_private() argument
454 spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_release_private()
455 list_del(&fl->fl_u.nfs_fl.list); in nlmclnt_locks_release_private()
456 spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_release_private()
457 nlm_put_lockowner(fl->fl_u.nfs_fl.owner); in nlmclnt_locks_release_private()
465 static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host) in nlmclnt_locks_init_private() argument
467 BUG_ON(fl->fl_ops != NULL); in nlmclnt_locks_init_private()
468 fl->fl_u.nfs_fl.state = 0; in nlmclnt_locks_init_private()
469 fl->fl_u.nfs_fl.owner = nlm_find_lockowner(host, fl->fl_owner); in nlmclnt_locks_init_private()
470 INIT_LIST_HEAD(&fl->fl_u.nfs_fl.list); in nlmclnt_locks_init_private()
471 fl->fl_ops = &nlmclnt_lock_ops; in nlmclnt_locks_init_private()
474 static int do_vfs_lock(struct file_lock *fl) in do_vfs_lock() argument
477 switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) { in do_vfs_lock()
479 res = posix_lock_file_wait(fl->fl_file, fl); in do_vfs_lock()
482 res = flock_lock_file_wait(fl->fl_file, fl); in do_vfs_lock()
511 nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_lock() argument
513 struct rpc_cred *cred = nfs_file_cred(fl->fl_file); in nlmclnt_lock()
517 unsigned char fl_flags = fl->fl_flags; in nlmclnt_lock()
525 fl->fl_flags |= FL_ACCESS; in nlmclnt_lock()
526 status = do_vfs_lock(fl); in nlmclnt_lock()
527 fl->fl_flags = fl_flags; in nlmclnt_lock()
531 block = nlmclnt_prepare_block(host, fl); in nlmclnt_lock()
540 fl->fl_u.nfs_fl.state = host->h_state; in nlmclnt_lock()
563 if (nlmclnt_cancel(host, req->a_args.block, fl) == 0) in nlmclnt_lock()
570 if (fl->fl_u.nfs_fl.state != host->h_state) { in nlmclnt_lock()
575 fl->fl_flags |= FL_SLEEP; in nlmclnt_lock()
576 if (do_vfs_lock(fl) < 0) in nlmclnt_lock()
579 fl->fl_flags = fl_flags; in nlmclnt_lock()
603 fl_type = fl->fl_type; in nlmclnt_lock()
604 fl->fl_type = F_UNLCK; in nlmclnt_lock()
606 do_vfs_lock(fl); in nlmclnt_lock()
608 fl->fl_type = fl_type; in nlmclnt_lock()
609 fl->fl_flags = fl_flags; in nlmclnt_lock()
618 nlmclnt_reclaim(struct nlm_host *host, struct file_lock *fl) in nlmclnt_reclaim() argument
625 locks_init_lock(&req->a_args.lock.fl); in nlmclnt_reclaim()
626 locks_init_lock(&req->a_res.lock.fl); in nlmclnt_reclaim()
631 nlmclnt_setlockargs(req, fl); in nlmclnt_reclaim()
634 status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_LOCK); in nlmclnt_reclaim()
639 "(errno %d, status %d)\n", fl->fl_pid, in nlmclnt_reclaim()
661 nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_unlock() argument
666 unsigned char fl_flags = fl->fl_flags; in nlmclnt_unlock()
673 fl->fl_flags |= FL_EXISTS; in nlmclnt_unlock()
675 status = do_vfs_lock(fl); in nlmclnt_unlock()
677 fl->fl_flags = fl_flags; in nlmclnt_unlock()
684 status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req, in nlmclnt_unlock()
737 static int nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *fl) in nlmclnt_cancel() argument
750 nlmclnt_setlockargs(req, fl); in nlmclnt_cancel()
754 status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req, in nlmclnt_cancel()