Lines Matching +full:lock +full:- +full:status
1 // SPDX-License-Identifier: GPL-2.0
21 cast_to_nlm(__be32 status, u32 vers) in cast_to_nlm() argument
23 /* Note: status is assumed to be in network byte order !!! */ in cast_to_nlm()
25 switch (status) { in cast_to_nlm()
34 status = nlm_lck_denied; in cast_to_nlm()
37 status = nlm_lck_denied_nolocks; in cast_to_nlm()
41 return (status); in cast_to_nlm()
43 #define cast_status(status) (cast_to_nlm(status, rqstp->rq_vers)) argument
45 #define cast_status(status) (status) argument
57 struct nlm_lock *lock = &argp->lock; in nlmsvc_retrieve_args() local
66 if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len)) in nlmsvc_retrieve_args()
67 || (argp->monitor && nsm_monitor(host) < 0)) in nlmsvc_retrieve_args()
73 error = cast_status(nlm_lookup_file(rqstp, &file, lock)); in nlmsvc_retrieve_args()
79 mode = lock_to_openmode(&lock->fl); in nlmsvc_retrieve_args()
80 lock->fl.c.flc_flags = FL_POSIX; in nlmsvc_retrieve_args()
81 lock->fl.c.flc_file = file->f_file[mode]; in nlmsvc_retrieve_args()
82 lock->fl.c.flc_pid = current->tgid; in nlmsvc_retrieve_args()
83 lock->fl.fl_lmops = &nlmsvc_lock_operations; in nlmsvc_retrieve_args()
84 nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid); in nlmsvc_retrieve_args()
85 if (!lock->fl.c.flc_owner) { in nlmsvc_retrieve_args()
112 * TEST: Check for conflicting lock
117 struct nlm_args *argp = rqstp->rq_argp; in __nlmsvc_proc_test()
124 resp->cookie = argp->cookie; in __nlmsvc_proc_test()
127 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) in __nlmsvc_proc_test()
128 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; in __nlmsvc_proc_test()
130 test_owner = argp->lock.fl.c.flc_owner; in __nlmsvc_proc_test()
133 resp->status = cast_status(nlmsvc_testlock(rqstp, file, host, in __nlmsvc_proc_test()
134 &argp->lock, &resp->lock)); in __nlmsvc_proc_test()
135 if (resp->status == nlm_drop_reply) in __nlmsvc_proc_test()
138 dprintk("lockd: TEST status %d vers %d\n", in __nlmsvc_proc_test()
139 ntohl(resp->status), rqstp->rq_vers); in __nlmsvc_proc_test()
150 return __nlmsvc_proc_test(rqstp, rqstp->rq_resp); in nlmsvc_proc_test()
156 struct nlm_args *argp = rqstp->rq_argp; in __nlmsvc_proc_lock()
161 dprintk("lockd: LOCK called\n"); in __nlmsvc_proc_lock()
163 resp->cookie = argp->cookie; in __nlmsvc_proc_lock()
166 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) in __nlmsvc_proc_lock()
167 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; in __nlmsvc_proc_lock()
169 /* Now try to lock the file */ in __nlmsvc_proc_lock()
170 resp->status = cast_status(nlmsvc_lock(rqstp, file, host, &argp->lock, in __nlmsvc_proc_lock()
171 argp->block, &argp->cookie, in __nlmsvc_proc_lock()
172 argp->reclaim)); in __nlmsvc_proc_lock()
173 if (resp->status == nlm_drop_reply) in __nlmsvc_proc_lock()
176 dprintk("lockd: LOCK status %d\n", ntohl(resp->status)); in __nlmsvc_proc_lock()
178 nlmsvc_release_lockowner(&argp->lock); in __nlmsvc_proc_lock()
187 return __nlmsvc_proc_lock(rqstp, rqstp->rq_resp); in nlmsvc_proc_lock()
193 struct nlm_args *argp = rqstp->rq_argp; in __nlmsvc_proc_cancel()
200 resp->cookie = argp->cookie; in __nlmsvc_proc_cancel()
204 resp->status = nlm_lck_denied_grace_period; in __nlmsvc_proc_cancel()
209 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) in __nlmsvc_proc_cancel()
210 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; in __nlmsvc_proc_cancel()
213 resp->status = cast_status(nlmsvc_cancel_blocked(net, file, &argp->lock)); in __nlmsvc_proc_cancel()
215 dprintk("lockd: CANCEL status %d\n", ntohl(resp->status)); in __nlmsvc_proc_cancel()
216 nlmsvc_release_lockowner(&argp->lock); in __nlmsvc_proc_cancel()
225 return __nlmsvc_proc_cancel(rqstp, rqstp->rq_resp); in nlmsvc_proc_cancel()
229 * UNLOCK: release a lock
234 struct nlm_args *argp = rqstp->rq_argp; in __nlmsvc_proc_unlock()
241 resp->cookie = argp->cookie; in __nlmsvc_proc_unlock()
243 /* Don't accept new lock requests during grace period */ in __nlmsvc_proc_unlock()
245 resp->status = nlm_lck_denied_grace_period; in __nlmsvc_proc_unlock()
250 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) in __nlmsvc_proc_unlock()
251 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; in __nlmsvc_proc_unlock()
253 /* Now try to remove the lock */ in __nlmsvc_proc_unlock()
254 resp->status = cast_status(nlmsvc_unlock(net, file, &argp->lock)); in __nlmsvc_proc_unlock()
256 dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status)); in __nlmsvc_proc_unlock()
257 nlmsvc_release_lockowner(&argp->lock); in __nlmsvc_proc_unlock()
266 return __nlmsvc_proc_unlock(rqstp, rqstp->rq_resp); in nlmsvc_proc_unlock()
270 * GRANTED: A server calls us to tell that a process' lock request
276 struct nlm_args *argp = rqstp->rq_argp; in __nlmsvc_proc_granted()
278 resp->cookie = argp->cookie; in __nlmsvc_proc_granted()
281 resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock); in __nlmsvc_proc_granted()
282 dprintk("lockd: GRANTED status %d\n", ntohl(resp->status)); in __nlmsvc_proc_granted()
289 return __nlmsvc_proc_granted(rqstp, rqstp->rq_resp); in nlmsvc_proc_granted()
301 if (!refcount_dec_and_test(&call->a_count)) in nlmsvc_release_call()
303 nlmsvc_release_host(call->a_host); in nlmsvc_release_call()
325 struct nlm_args *argp = rqstp->rq_argp; in nlmsvc_callback()
331 argp->lock.caller, in nlmsvc_callback()
332 argp->lock.len); in nlmsvc_callback()
341 stat = func(rqstp, &call->a_res); in nlmsvc_callback()
347 call->a_flags = RPC_TASK_ASYNC; in nlmsvc_callback()
391 struct nlm_args *argp = rqstp->rq_argp; in nlmsvc_proc_share()
392 struct nlm_res *resp = rqstp->rq_resp; in nlmsvc_proc_share()
398 resp->cookie = argp->cookie; in nlmsvc_proc_share()
400 /* Don't accept new lock requests during grace period */ in nlmsvc_proc_share()
401 if (locks_in_grace(SVC_NET(rqstp)) && !argp->reclaim) { in nlmsvc_proc_share()
402 resp->status = nlm_lck_denied_grace_period; in nlmsvc_proc_share()
407 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) in nlmsvc_proc_share()
408 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; in nlmsvc_proc_share()
411 resp->status = cast_status(nlmsvc_share_file(host, file, argp)); in nlmsvc_proc_share()
413 dprintk("lockd: SHARE status %d\n", ntohl(resp->status)); in nlmsvc_proc_share()
414 nlmsvc_release_lockowner(&argp->lock); in nlmsvc_proc_share()
426 struct nlm_args *argp = rqstp->rq_argp; in nlmsvc_proc_unshare()
427 struct nlm_res *resp = rqstp->rq_resp; in nlmsvc_proc_unshare()
433 resp->cookie = argp->cookie; in nlmsvc_proc_unshare()
437 resp->status = nlm_lck_denied_grace_period; in nlmsvc_proc_unshare()
442 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) in nlmsvc_proc_unshare()
443 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; in nlmsvc_proc_unshare()
446 resp->status = cast_status(nlmsvc_unshare_file(host, file, argp)); in nlmsvc_proc_unshare()
448 dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status)); in nlmsvc_proc_unshare()
449 nlmsvc_release_lockowner(&argp->lock); in nlmsvc_proc_unshare()
456 * NM_LOCK: Create an unmonitored lock
461 struct nlm_args *argp = rqstp->rq_argp; in nlmsvc_proc_nm_lock()
465 argp->monitor = 0; /* just clean the monitor flag */ in nlmsvc_proc_nm_lock()
475 struct nlm_args *argp = rqstp->rq_argp; in nlmsvc_proc_free_all()
493 struct nlm_reboot *argp = rqstp->rq_argp; in nlmsvc_proc_sm_notify()
514 struct nlm_res *argp = rqstp->rq_argp; in nlmsvc_proc_granted_res()
521 nlmsvc_grant_reply(&argp->cookie, argp->status); in nlmsvc_proc_granted_res()
538 #define St 1 /* status */
540 #define Rg 2 /* range - offset + size */
571 .pc_name = "LOCK",