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
131 memcpy(&lock->fh, NFS_FH(file_inode(fl->fl_file)), sizeof(struct nfs_fh)); in nlmclnt_setlockargs()
135 (unsigned int)fl->fl_u.nfs_fl.owner->pid, in nlmclnt_setlockargs()
137 lock->svid = fl->fl_u.nfs_fl.owner->pid; in nlmclnt_setlockargs()
138 lock->fl.fl_start = fl->fl_start; in nlmclnt_setlockargs()
139 lock->fl.fl_end = fl->fl_end; in nlmclnt_setlockargs()
140 lock->fl.fl_type = fl->fl_type; in nlmclnt_setlockargs()
145 WARN_ON_ONCE(req->a_args.lock.fl.fl_ops != NULL); in nlmclnt_release_lockargs()
155 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()
165 if (!fl->fl_u.nfs_fl.owner) { in nlmclnt_proc()
171 nlmclnt_setlockargs(call, fl); in nlmclnt_proc()
174 if (fl->fl_type != F_UNLCK) { in nlmclnt_proc()
176 status = nlmclnt_lock(call, fl); in nlmclnt_proc()
178 status = nlmclnt_unlock(call, fl); in nlmclnt_proc()
180 status = nlmclnt_test(call, fl); in nlmclnt_proc()
183 fl->fl_ops->fl_release_private(fl); in nlmclnt_proc()
184 fl->fl_ops = NULL; in nlmclnt_proc()
202 locks_init_lock(&call->a_args.lock.fl); in nlm_alloc_call()
203 locks_init_lock(&call->a_res.lock.fl); in nlm_alloc_call()
416 nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_test() argument
420 status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_TEST); in nlmclnt_test()
426 fl->fl_type = F_UNLCK; in nlmclnt_test()
432 fl->fl_start = req->a_res.lock.fl.fl_start; in nlmclnt_test()
433 fl->fl_end = req->a_res.lock.fl.fl_end; in nlmclnt_test()
434 fl->fl_type = req->a_res.lock.fl.fl_type; in nlmclnt_test()
435 fl->fl_pid = 0; in nlmclnt_test()
445 static void nlmclnt_locks_copy_lock(struct file_lock *new, struct file_lock *fl) in nlmclnt_locks_copy_lock() argument
447 spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_copy_lock()
448 new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state; in nlmclnt_locks_copy_lock()
449 new->fl_u.nfs_fl.owner = nlm_get_lockowner(fl->fl_u.nfs_fl.owner); in nlmclnt_locks_copy_lock()
450 list_add_tail(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.owner->host->h_granted); in nlmclnt_locks_copy_lock()
451 spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_copy_lock()
454 static void nlmclnt_locks_release_private(struct file_lock *fl) in nlmclnt_locks_release_private() argument
456 spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_release_private()
457 list_del(&fl->fl_u.nfs_fl.list); in nlmclnt_locks_release_private()
458 spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock); in nlmclnt_locks_release_private()
459 nlm_put_lockowner(fl->fl_u.nfs_fl.owner); in nlmclnt_locks_release_private()
467 static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host) in nlmclnt_locks_init_private() argument
469 fl->fl_u.nfs_fl.state = 0; in nlmclnt_locks_init_private()
470 fl->fl_u.nfs_fl.owner = nlm_find_lockowner(host, fl->fl_owner); in nlmclnt_locks_init_private()
471 INIT_LIST_HEAD(&fl->fl_u.nfs_fl.list); in nlmclnt_locks_init_private()
472 fl->fl_ops = &nlmclnt_lock_ops; in nlmclnt_locks_init_private()
475 static int do_vfs_lock(struct file_lock *fl) in do_vfs_lock() argument
478 switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) { in do_vfs_lock()
480 res = posix_lock_file_wait(fl->fl_file, fl); in do_vfs_lock()
483 res = flock_lock_file_wait(fl->fl_file, fl); in do_vfs_lock()
512 nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_lock() argument
514 struct rpc_cred *cred = nfs_file_cred(fl->fl_file); in nlmclnt_lock()
518 unsigned char fl_flags = fl->fl_flags; in nlmclnt_lock()
526 fl->fl_flags |= FL_ACCESS; in nlmclnt_lock()
527 status = do_vfs_lock(fl); in nlmclnt_lock()
528 fl->fl_flags = fl_flags; in nlmclnt_lock()
532 block = nlmclnt_prepare_block(host, fl); in nlmclnt_lock()
541 fl->fl_u.nfs_fl.state = host->h_state; in nlmclnt_lock()
564 if (nlmclnt_cancel(host, req->a_args.block, fl) == 0) in nlmclnt_lock()
571 if (fl->fl_u.nfs_fl.state != host->h_state) { in nlmclnt_lock()
576 fl->fl_flags |= FL_SLEEP; in nlmclnt_lock()
577 if (do_vfs_lock(fl) < 0) in nlmclnt_lock()
580 fl->fl_flags = fl_flags; in nlmclnt_lock()
604 fl_type = fl->fl_type; in nlmclnt_lock()
605 fl->fl_type = F_UNLCK; in nlmclnt_lock()
607 do_vfs_lock(fl); in nlmclnt_lock()
609 fl->fl_type = fl_type; in nlmclnt_lock()
610 fl->fl_flags = fl_flags; in nlmclnt_lock()
619 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()
630 nlmclnt_setlockargs(req, fl); in nlmclnt_reclaim()
633 status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_LOCK); in nlmclnt_reclaim()
638 "(errno %d, status %d)\n", fl->fl_pid, in nlmclnt_reclaim()
660 nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) in nlmclnt_unlock() argument
665 unsigned char fl_flags = fl->fl_flags; in nlmclnt_unlock()
672 fl->fl_flags |= FL_EXISTS; in nlmclnt_unlock()
674 status = do_vfs_lock(fl); in nlmclnt_unlock()
676 fl->fl_flags = fl_flags; in nlmclnt_unlock()
683 status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req, in nlmclnt_unlock()
743 static int nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *fl) in nlmclnt_cancel() argument
756 nlmclnt_setlockargs(req, fl); in nlmclnt_cancel()
760 status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req, in nlmclnt_cancel()