xref: /openbmc/linux/fs/lockd/svcproc.c (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * linux/fs/lockd/svcproc.c
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Lockd server procedures. We don't implement the NLM_*_RES
61da177e4SLinus Torvalds  * procedures because we don't use the async procedures.
71da177e4SLinus Torvalds  *
81da177e4SLinus Torvalds  * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
91da177e4SLinus Torvalds  */
101da177e4SLinus Torvalds 
111da177e4SLinus Torvalds #include <linux/types.h>
121da177e4SLinus Torvalds #include <linux/time.h>
131da177e4SLinus Torvalds #include <linux/lockd/lockd.h>
141da177e4SLinus Torvalds #include <linux/lockd/share.h>
155ccb0066SStanislav Kinsbursky #include <linux/sunrpc/svc_xprt.h>
161da177e4SLinus Torvalds 
171da177e4SLinus Torvalds #define NLMDBG_FACILITY		NLMDBG_CLIENT
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds #ifdef CONFIG_LOCKD_V4
2052921e02SAl Viro static __be32
cast_to_nlm(__be32 status,u32 vers)2152921e02SAl Viro cast_to_nlm(__be32 status, u32 vers)
221da177e4SLinus Torvalds {
231da177e4SLinus Torvalds 	/* Note: status is assumed to be in network byte order !!! */
241da177e4SLinus Torvalds 	if (vers != 4){
251da177e4SLinus Torvalds 		switch (status) {
261da177e4SLinus Torvalds 		case nlm_granted:
271da177e4SLinus Torvalds 		case nlm_lck_denied:
281da177e4SLinus Torvalds 		case nlm_lck_denied_nolocks:
291da177e4SLinus Torvalds 		case nlm_lck_blocked:
301da177e4SLinus Torvalds 		case nlm_lck_denied_grace_period:
315ea0d750SMarc Eshel 		case nlm_drop_reply:
321da177e4SLinus Torvalds 			break;
331da177e4SLinus Torvalds 		case nlm4_deadlock:
341da177e4SLinus Torvalds 			status = nlm_lck_denied;
351da177e4SLinus Torvalds 			break;
361da177e4SLinus Torvalds 		default:
371da177e4SLinus Torvalds 			status = nlm_lck_denied_nolocks;
381da177e4SLinus Torvalds 		}
391da177e4SLinus Torvalds 	}
401da177e4SLinus Torvalds 
411da177e4SLinus Torvalds 	return (status);
421da177e4SLinus Torvalds }
431da177e4SLinus Torvalds #define	cast_status(status) (cast_to_nlm(status, rqstp->rq_vers))
441da177e4SLinus Torvalds #else
451da177e4SLinus Torvalds #define cast_status(status) (status)
461da177e4SLinus Torvalds #endif
471da177e4SLinus Torvalds 
481da177e4SLinus Torvalds /*
491da177e4SLinus Torvalds  * Obtain client and file from arguments
501da177e4SLinus Torvalds  */
5152921e02SAl Viro static __be32
nlmsvc_retrieve_args(struct svc_rqst * rqstp,struct nlm_args * argp,struct nlm_host ** hostp,struct nlm_file ** filp)521da177e4SLinus Torvalds nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
531da177e4SLinus Torvalds 			struct nlm_host **hostp, struct nlm_file **filp)
541da177e4SLinus Torvalds {
551da177e4SLinus Torvalds 	struct nlm_host		*host = NULL;
561da177e4SLinus Torvalds 	struct nlm_file		*file = NULL;
571da177e4SLinus Torvalds 	struct nlm_lock		*lock = &argp->lock;
587f024fcdSJ. Bruce Fields 	int			mode;
5952921e02SAl Viro 	__be32			error = 0;
601da177e4SLinus Torvalds 
611da177e4SLinus Torvalds 	/* nfsd callbacks must have been installed for this procedure */
621da177e4SLinus Torvalds 	if (!nlmsvc_ops)
631da177e4SLinus Torvalds 		return nlm_lck_denied_nolocks;
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds 	/* Obtain host handle */
66db4e4c9aSOlaf Kirch 	if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
67977faf39SOlaf Kirch 	 || (argp->monitor && nsm_monitor(host) < 0))
681da177e4SLinus Torvalds 		goto no_locks;
691da177e4SLinus Torvalds 	*hostp = host;
701da177e4SLinus Torvalds 
711da177e4SLinus Torvalds 	/* Obtain file pointer. Not used by FREE_ALL call. */
721da177e4SLinus Torvalds 	if (filp != NULL) {
732dc6f19eSJ. Bruce Fields 		error = cast_status(nlm_lookup_file(rqstp, &file, lock));
74cd0b16c1STrond Myklebust 		if (error != 0)
751da177e4SLinus Torvalds 			goto no_locks;
761da177e4SLinus Torvalds 		*filp = file;
771da177e4SLinus Torvalds 
781da177e4SLinus Torvalds 		/* Set up the missing parts of the file_lock structure */
797f024fcdSJ. Bruce Fields 		mode = lock_to_openmode(&lock->fl);
80*75c7940dSJeff Layton 		lock->fl.fl_flags = FL_POSIX;
817f024fcdSJ. Bruce Fields 		lock->fl.fl_file  = file->f_file[mode];
82646d73e9SBenjamin Coddington 		lock->fl.fl_pid = current->tgid;
831da177e4SLinus Torvalds 		lock->fl.fl_lmops = &nlmsvc_lock_operations;
8489e0edfbSBenjamin Coddington 		nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid);
8589e0edfbSBenjamin Coddington 		if (!lock->fl.fl_owner) {
8689e0edfbSBenjamin Coddington 			/* lockowner allocation has failed */
8789e0edfbSBenjamin Coddington 			nlmsvc_release_host(host);
8889e0edfbSBenjamin Coddington 			return nlm_lck_denied_nolocks;
8989e0edfbSBenjamin Coddington 		}
901da177e4SLinus Torvalds 	}
911da177e4SLinus Torvalds 
921da177e4SLinus Torvalds 	return 0;
931da177e4SLinus Torvalds 
941da177e4SLinus Torvalds no_locks:
9567216b94SChuck Lever 	nlmsvc_release_host(host);
96d343fce1SNeilBrown 	if (error)
97d343fce1SNeilBrown 		return error;
981da177e4SLinus Torvalds 	return nlm_lck_denied_nolocks;
991da177e4SLinus Torvalds }
1001da177e4SLinus Torvalds 
1011da177e4SLinus Torvalds /*
1021da177e4SLinus Torvalds  * NULL: Test for presence of service
1031da177e4SLinus Torvalds  */
1047111c66eSAl Viro static __be32
nlmsvc_proc_null(struct svc_rqst * rqstp)105a6beb732SChristoph Hellwig nlmsvc_proc_null(struct svc_rqst *rqstp)
1061da177e4SLinus Torvalds {
1071da177e4SLinus Torvalds 	dprintk("lockd: NULL          called\n");
1081da177e4SLinus Torvalds 	return rpc_success;
1091da177e4SLinus Torvalds }
1101da177e4SLinus Torvalds 
1111da177e4SLinus Torvalds /*
1121da177e4SLinus Torvalds  * TEST: Check for conflicting lock
1131da177e4SLinus Torvalds  */
1147111c66eSAl Viro static __be32
__nlmsvc_proc_test(struct svc_rqst * rqstp,struct nlm_res * resp)115a6beb732SChristoph Hellwig __nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
1161da177e4SLinus Torvalds {
117a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
1181da177e4SLinus Torvalds 	struct nlm_host	*host;
1191da177e4SLinus Torvalds 	struct nlm_file	*file;
120184cefbeSBenjamin Coddington 	struct nlm_lockowner *test_owner;
121317602f3SHarvey Harrison 	__be32 rc = rpc_success;
1221da177e4SLinus Torvalds 
1231da177e4SLinus Torvalds 	dprintk("lockd: TEST          called\n");
1241da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
1251da177e4SLinus Torvalds 
1261da177e4SLinus Torvalds 	/* Obtain client and file */
1271da177e4SLinus Torvalds 	if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
128d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
1291da177e4SLinus Torvalds 
130184cefbeSBenjamin Coddington 	test_owner = argp->lock.fl.fl_owner;
131184cefbeSBenjamin Coddington 
1321da177e4SLinus Torvalds 	/* Now check for conflicting locks */
1338f920d5eSJeff Layton 	resp->status = cast_status(nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie));
1345ea0d750SMarc Eshel 	if (resp->status == nlm_drop_reply)
135b7e6b869SOleg Drokin 		rc = rpc_drop_reply;
136b7e6b869SOleg Drokin 	else
1371da177e4SLinus Torvalds 		dprintk("lockd: TEST          status %d vers %d\n",
1381da177e4SLinus Torvalds 			ntohl(resp->status), rqstp->rq_vers);
139b7e6b869SOleg Drokin 
140184cefbeSBenjamin Coddington 	nlmsvc_put_lockowner(test_owner);
14167216b94SChuck Lever 	nlmsvc_release_host(host);
1421da177e4SLinus Torvalds 	nlm_release_file(file);
143b7e6b869SOleg Drokin 	return rc;
1441da177e4SLinus Torvalds }
1451da177e4SLinus Torvalds 
1467111c66eSAl Viro static __be32
nlmsvc_proc_test(struct svc_rqst * rqstp)147a6beb732SChristoph Hellwig nlmsvc_proc_test(struct svc_rqst *rqstp)
1481da177e4SLinus Torvalds {
149a6beb732SChristoph Hellwig 	return __nlmsvc_proc_test(rqstp, rqstp->rq_resp);
150a6beb732SChristoph Hellwig }
151a6beb732SChristoph Hellwig 
152a6beb732SChristoph Hellwig static __be32
__nlmsvc_proc_lock(struct svc_rqst * rqstp,struct nlm_res * resp)153a6beb732SChristoph Hellwig __nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_res *resp)
154a6beb732SChristoph Hellwig {
155a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
1561da177e4SLinus Torvalds 	struct nlm_host	*host;
1571da177e4SLinus Torvalds 	struct nlm_file	*file;
158317602f3SHarvey Harrison 	__be32 rc = rpc_success;
1591da177e4SLinus Torvalds 
1601da177e4SLinus Torvalds 	dprintk("lockd: LOCK          called\n");
1611da177e4SLinus Torvalds 
1621da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
1631da177e4SLinus Torvalds 
1641da177e4SLinus Torvalds 	/* Obtain client and file */
1651da177e4SLinus Torvalds 	if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
166d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
1671da177e4SLinus Torvalds 
1681da177e4SLinus Torvalds #if 0
1691da177e4SLinus Torvalds 	/* If supplied state doesn't match current state, we assume it's
1701da177e4SLinus Torvalds 	 * an old request that time-warped somehow. Any error return would
1711da177e4SLinus Torvalds 	 * do in this case because it's irrelevant anyway.
1721da177e4SLinus Torvalds 	 *
1731da177e4SLinus Torvalds 	 * NB: We don't retrieve the remote host's state yet.
1741da177e4SLinus Torvalds 	 */
1751da177e4SLinus Torvalds 	if (host->h_nsmstate && host->h_nsmstate != argp->state) {
1761da177e4SLinus Torvalds 		resp->status = nlm_lck_denied_nolocks;
1771da177e4SLinus Torvalds 	} else
1781da177e4SLinus Torvalds #endif
1791da177e4SLinus Torvalds 
1801da177e4SLinus Torvalds 	/* Now try to lock the file */
1816cde4de8SJeff Layton 	resp->status = cast_status(nlmsvc_lock(rqstp, file, host, &argp->lock,
182b2b50289SJ. Bruce Fields 					       argp->block, &argp->cookie,
183b2b50289SJ. Bruce Fields 					       argp->reclaim));
1841a8322b2SMarc Eshel 	if (resp->status == nlm_drop_reply)
185b7e6b869SOleg Drokin 		rc = rpc_drop_reply;
186b7e6b869SOleg Drokin 	else
1871da177e4SLinus Torvalds 		dprintk("lockd: LOCK         status %d\n", ntohl(resp->status));
188b7e6b869SOleg Drokin 
18989e0edfbSBenjamin Coddington 	nlmsvc_release_lockowner(&argp->lock);
19067216b94SChuck Lever 	nlmsvc_release_host(host);
1911da177e4SLinus Torvalds 	nlm_release_file(file);
192b7e6b869SOleg Drokin 	return rc;
1931da177e4SLinus Torvalds }
1941da177e4SLinus Torvalds 
1957111c66eSAl Viro static __be32
nlmsvc_proc_lock(struct svc_rqst * rqstp)196a6beb732SChristoph Hellwig nlmsvc_proc_lock(struct svc_rqst *rqstp)
1971da177e4SLinus Torvalds {
198a6beb732SChristoph Hellwig 	return __nlmsvc_proc_lock(rqstp, rqstp->rq_resp);
199a6beb732SChristoph Hellwig }
200a6beb732SChristoph Hellwig 
201a6beb732SChristoph Hellwig static __be32
__nlmsvc_proc_cancel(struct svc_rqst * rqstp,struct nlm_res * resp)202a6beb732SChristoph Hellwig __nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_res *resp)
203a6beb732SChristoph Hellwig {
204a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
2051da177e4SLinus Torvalds 	struct nlm_host	*host;
2061da177e4SLinus Torvalds 	struct nlm_file	*file;
2075ccb0066SStanislav Kinsbursky 	struct net *net = SVC_NET(rqstp);
2081da177e4SLinus Torvalds 
2091da177e4SLinus Torvalds 	dprintk("lockd: CANCEL        called\n");
2101da177e4SLinus Torvalds 
2111da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
2121da177e4SLinus Torvalds 
2131da177e4SLinus Torvalds 	/* Don't accept requests during grace period */
2145ccb0066SStanislav Kinsbursky 	if (locks_in_grace(net)) {
2151da177e4SLinus Torvalds 		resp->status = nlm_lck_denied_grace_period;
2161da177e4SLinus Torvalds 		return rpc_success;
2171da177e4SLinus Torvalds 	}
2181da177e4SLinus Torvalds 
2191da177e4SLinus Torvalds 	/* Obtain client and file */
2201da177e4SLinus Torvalds 	if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
221d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
2221da177e4SLinus Torvalds 
2231da177e4SLinus Torvalds 	/* Try to cancel request. */
2245ccb0066SStanislav Kinsbursky 	resp->status = cast_status(nlmsvc_cancel_blocked(net, file, &argp->lock));
2251da177e4SLinus Torvalds 
2261da177e4SLinus Torvalds 	dprintk("lockd: CANCEL        status %d\n", ntohl(resp->status));
22789e0edfbSBenjamin Coddington 	nlmsvc_release_lockowner(&argp->lock);
22867216b94SChuck Lever 	nlmsvc_release_host(host);
2291da177e4SLinus Torvalds 	nlm_release_file(file);
2301da177e4SLinus Torvalds 	return rpc_success;
2311da177e4SLinus Torvalds }
2321da177e4SLinus Torvalds 
233a6beb732SChristoph Hellwig static __be32
nlmsvc_proc_cancel(struct svc_rqst * rqstp)234a6beb732SChristoph Hellwig nlmsvc_proc_cancel(struct svc_rqst *rqstp)
235a6beb732SChristoph Hellwig {
236a6beb732SChristoph Hellwig 	return __nlmsvc_proc_cancel(rqstp, rqstp->rq_resp);
237a6beb732SChristoph Hellwig }
238a6beb732SChristoph Hellwig 
2391da177e4SLinus Torvalds /*
2401da177e4SLinus Torvalds  * UNLOCK: release a lock
2411da177e4SLinus Torvalds  */
2427111c66eSAl Viro static __be32
__nlmsvc_proc_unlock(struct svc_rqst * rqstp,struct nlm_res * resp)243a6beb732SChristoph Hellwig __nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_res *resp)
2441da177e4SLinus Torvalds {
245a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
2461da177e4SLinus Torvalds 	struct nlm_host	*host;
2471da177e4SLinus Torvalds 	struct nlm_file	*file;
2485ccb0066SStanislav Kinsbursky 	struct net *net = SVC_NET(rqstp);
2491da177e4SLinus Torvalds 
2501da177e4SLinus Torvalds 	dprintk("lockd: UNLOCK        called\n");
2511da177e4SLinus Torvalds 
2521da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
2531da177e4SLinus Torvalds 
2541da177e4SLinus Torvalds 	/* Don't accept new lock requests during grace period */
2555ccb0066SStanislav Kinsbursky 	if (locks_in_grace(net)) {
2561da177e4SLinus Torvalds 		resp->status = nlm_lck_denied_grace_period;
2571da177e4SLinus Torvalds 		return rpc_success;
2581da177e4SLinus Torvalds 	}
2591da177e4SLinus Torvalds 
2601da177e4SLinus Torvalds 	/* Obtain client and file */
2611da177e4SLinus Torvalds 	if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
262d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
2631da177e4SLinus Torvalds 
2641da177e4SLinus Torvalds 	/* Now try to remove the lock */
2655ccb0066SStanislav Kinsbursky 	resp->status = cast_status(nlmsvc_unlock(net, file, &argp->lock));
2661da177e4SLinus Torvalds 
2671da177e4SLinus Torvalds 	dprintk("lockd: UNLOCK        status %d\n", ntohl(resp->status));
26889e0edfbSBenjamin Coddington 	nlmsvc_release_lockowner(&argp->lock);
26967216b94SChuck Lever 	nlmsvc_release_host(host);
2701da177e4SLinus Torvalds 	nlm_release_file(file);
2711da177e4SLinus Torvalds 	return rpc_success;
2721da177e4SLinus Torvalds }
2731da177e4SLinus Torvalds 
274a6beb732SChristoph Hellwig static __be32
nlmsvc_proc_unlock(struct svc_rqst * rqstp)275a6beb732SChristoph Hellwig nlmsvc_proc_unlock(struct svc_rqst *rqstp)
276a6beb732SChristoph Hellwig {
277a6beb732SChristoph Hellwig 	return __nlmsvc_proc_unlock(rqstp, rqstp->rq_resp);
278a6beb732SChristoph Hellwig }
279a6beb732SChristoph Hellwig 
2801da177e4SLinus Torvalds /*
2811da177e4SLinus Torvalds  * GRANTED: A server calls us to tell that a process' lock request
2821da177e4SLinus Torvalds  * was granted
2831da177e4SLinus Torvalds  */
2847111c66eSAl Viro static __be32
__nlmsvc_proc_granted(struct svc_rqst * rqstp,struct nlm_res * resp)285a6beb732SChristoph Hellwig __nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_res *resp)
2861da177e4SLinus Torvalds {
287a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
288a6beb732SChristoph Hellwig 
2891da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
2901da177e4SLinus Torvalds 
2911da177e4SLinus Torvalds 	dprintk("lockd: GRANTED       called\n");
292dcff09f1SChuck Lever 	resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock);
2931da177e4SLinus Torvalds 	dprintk("lockd: GRANTED       status %d\n", ntohl(resp->status));
2941da177e4SLinus Torvalds 	return rpc_success;
2951da177e4SLinus Torvalds }
2961da177e4SLinus Torvalds 
297a6beb732SChristoph Hellwig static __be32
nlmsvc_proc_granted(struct svc_rqst * rqstp)298a6beb732SChristoph Hellwig nlmsvc_proc_granted(struct svc_rqst *rqstp)
299a6beb732SChristoph Hellwig {
300a6beb732SChristoph Hellwig 	return __nlmsvc_proc_granted(rqstp, rqstp->rq_resp);
301a6beb732SChristoph Hellwig }
302a6beb732SChristoph Hellwig 
3031da177e4SLinus Torvalds /*
304d4716624STrond Myklebust  * This is the generic lockd callback for async RPC calls
305d4716624STrond Myklebust  */
nlmsvc_callback_exit(struct rpc_task * task,void * data)306d4716624STrond Myklebust static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
307d4716624STrond Myklebust {
308d4716624STrond Myklebust }
309d4716624STrond Myklebust 
nlmsvc_release_call(struct nlm_rqst * call)3107db836d4SChuck Lever void nlmsvc_release_call(struct nlm_rqst *call)
3117db836d4SChuck Lever {
312fbca30c5SElena Reshetova 	if (!refcount_dec_and_test(&call->a_count))
3137db836d4SChuck Lever 		return;
31467216b94SChuck Lever 	nlmsvc_release_host(call->a_host);
3157db836d4SChuck Lever 	kfree(call);
3167db836d4SChuck Lever }
3177db836d4SChuck Lever 
nlmsvc_callback_release(void * data)318d4716624STrond Myklebust static void nlmsvc_callback_release(void *data)
319d4716624STrond Myklebust {
3207db836d4SChuck Lever 	nlmsvc_release_call(data);
321d4716624STrond Myklebust }
322d4716624STrond Myklebust 
323d4716624STrond Myklebust static const struct rpc_call_ops nlmsvc_callback_ops = {
324d4716624STrond Myklebust 	.rpc_call_done = nlmsvc_callback_exit,
325d4716624STrond Myklebust 	.rpc_release = nlmsvc_callback_release,
326d4716624STrond Myklebust };
327d4716624STrond Myklebust 
328d4716624STrond Myklebust /*
3291da177e4SLinus Torvalds  * `Async' versions of the above service routines. They aren't really,
3301da177e4SLinus Torvalds  * because we send the callback before the reply proper. I hope this
3311da177e4SLinus Torvalds  * doesn't break any clients.
3321da177e4SLinus Torvalds  */
nlmsvc_callback(struct svc_rqst * rqstp,u32 proc,__be32 (* func)(struct svc_rqst *,struct nlm_res *))333a6beb732SChristoph Hellwig static __be32 nlmsvc_callback(struct svc_rqst *rqstp, u32 proc,
334a6beb732SChristoph Hellwig 		__be32 (*func)(struct svc_rqst *, struct nlm_res *))
335d4716624STrond Myklebust {
336a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
337d4716624STrond Myklebust 	struct nlm_host	*host;
338d4716624STrond Myklebust 	struct nlm_rqst	*call;
3397111c66eSAl Viro 	__be32 stat;
340d4716624STrond Myklebust 
341db4e4c9aSOlaf Kirch 	host = nlmsvc_lookup_host(rqstp,
342db4e4c9aSOlaf Kirch 				  argp->lock.caller,
343db4e4c9aSOlaf Kirch 				  argp->lock.len);
344d4716624STrond Myklebust 	if (host == NULL)
345d4716624STrond Myklebust 		return rpc_system_err;
346d4716624STrond Myklebust 
347d4716624STrond Myklebust 	call = nlm_alloc_call(host);
348446945abSAl Viro 	nlmsvc_release_host(host);
349d4716624STrond Myklebust 	if (call == NULL)
350d4716624STrond Myklebust 		return rpc_system_err;
351d4716624STrond Myklebust 
352a6beb732SChristoph Hellwig 	stat = func(rqstp, &call->a_res);
353d4716624STrond Myklebust 	if (stat != 0) {
3547db836d4SChuck Lever 		nlmsvc_release_call(call);
355d4716624STrond Myklebust 		return stat;
356d4716624STrond Myklebust 	}
357d4716624STrond Myklebust 
358d4716624STrond Myklebust 	call->a_flags = RPC_TASK_ASYNC;
359d4716624STrond Myklebust 	if (nlm_async_reply(call, proc, &nlmsvc_callback_ops) < 0)
360d4716624STrond Myklebust 		return rpc_system_err;
361d4716624STrond Myklebust 	return rpc_success;
362d4716624STrond Myklebust }
363d4716624STrond Myklebust 
nlmsvc_proc_test_msg(struct svc_rqst * rqstp)364a6beb732SChristoph Hellwig static __be32 nlmsvc_proc_test_msg(struct svc_rqst *rqstp)
3651da177e4SLinus Torvalds {
3661da177e4SLinus Torvalds 	dprintk("lockd: TEST_MSG      called\n");
367a6beb732SChristoph Hellwig 	return nlmsvc_callback(rqstp, NLMPROC_TEST_RES, __nlmsvc_proc_test);
3681da177e4SLinus Torvalds }
3691da177e4SLinus Torvalds 
nlmsvc_proc_lock_msg(struct svc_rqst * rqstp)370a6beb732SChristoph Hellwig static __be32 nlmsvc_proc_lock_msg(struct svc_rqst *rqstp)
3711da177e4SLinus Torvalds {
3721da177e4SLinus Torvalds 	dprintk("lockd: LOCK_MSG      called\n");
373a6beb732SChristoph Hellwig 	return nlmsvc_callback(rqstp, NLMPROC_LOCK_RES, __nlmsvc_proc_lock);
3741da177e4SLinus Torvalds }
3751da177e4SLinus Torvalds 
nlmsvc_proc_cancel_msg(struct svc_rqst * rqstp)376a6beb732SChristoph Hellwig static __be32 nlmsvc_proc_cancel_msg(struct svc_rqst *rqstp)
3771da177e4SLinus Torvalds {
3781da177e4SLinus Torvalds 	dprintk("lockd: CANCEL_MSG    called\n");
379a6beb732SChristoph Hellwig 	return nlmsvc_callback(rqstp, NLMPROC_CANCEL_RES, __nlmsvc_proc_cancel);
3801da177e4SLinus Torvalds }
3811da177e4SLinus Torvalds 
3827111c66eSAl Viro static __be32
nlmsvc_proc_unlock_msg(struct svc_rqst * rqstp)383a6beb732SChristoph Hellwig nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp)
3841da177e4SLinus Torvalds {
3851da177e4SLinus Torvalds 	dprintk("lockd: UNLOCK_MSG    called\n");
386a6beb732SChristoph Hellwig 	return nlmsvc_callback(rqstp, NLMPROC_UNLOCK_RES, __nlmsvc_proc_unlock);
3871da177e4SLinus Torvalds }
3881da177e4SLinus Torvalds 
3897111c66eSAl Viro static __be32
nlmsvc_proc_granted_msg(struct svc_rqst * rqstp)390a6beb732SChristoph Hellwig nlmsvc_proc_granted_msg(struct svc_rqst *rqstp)
3911da177e4SLinus Torvalds {
3921da177e4SLinus Torvalds 	dprintk("lockd: GRANTED_MSG   called\n");
393a6beb732SChristoph Hellwig 	return nlmsvc_callback(rqstp, NLMPROC_GRANTED_RES, __nlmsvc_proc_granted);
3941da177e4SLinus Torvalds }
3951da177e4SLinus Torvalds 
3961da177e4SLinus Torvalds /*
3971da177e4SLinus Torvalds  * SHARE: create a DOS share or alter existing share.
3981da177e4SLinus Torvalds  */
3997111c66eSAl Viro static __be32
nlmsvc_proc_share(struct svc_rqst * rqstp)400a6beb732SChristoph Hellwig nlmsvc_proc_share(struct svc_rqst *rqstp)
4011da177e4SLinus Torvalds {
402a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
403a6beb732SChristoph Hellwig 	struct nlm_res *resp = rqstp->rq_resp;
4041da177e4SLinus Torvalds 	struct nlm_host	*host;
4051da177e4SLinus Torvalds 	struct nlm_file	*file;
4061da177e4SLinus Torvalds 
4071da177e4SLinus Torvalds 	dprintk("lockd: SHARE         called\n");
4081da177e4SLinus Torvalds 
4091da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
4101da177e4SLinus Torvalds 
4111da177e4SLinus Torvalds 	/* Don't accept new lock requests during grace period */
4125ccb0066SStanislav Kinsbursky 	if (locks_in_grace(SVC_NET(rqstp)) && !argp->reclaim) {
4131da177e4SLinus Torvalds 		resp->status = nlm_lck_denied_grace_period;
4141da177e4SLinus Torvalds 		return rpc_success;
4151da177e4SLinus Torvalds 	}
4161da177e4SLinus Torvalds 
4171da177e4SLinus Torvalds 	/* Obtain client and file */
4181da177e4SLinus Torvalds 	if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
419d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
4201da177e4SLinus Torvalds 
4211da177e4SLinus Torvalds 	/* Now try to create the share */
4221da177e4SLinus Torvalds 	resp->status = cast_status(nlmsvc_share_file(host, file, argp));
4231da177e4SLinus Torvalds 
4241da177e4SLinus Torvalds 	dprintk("lockd: SHARE         status %d\n", ntohl(resp->status));
42589e0edfbSBenjamin Coddington 	nlmsvc_release_lockowner(&argp->lock);
42667216b94SChuck Lever 	nlmsvc_release_host(host);
4271da177e4SLinus Torvalds 	nlm_release_file(file);
4281da177e4SLinus Torvalds 	return rpc_success;
4291da177e4SLinus Torvalds }
4301da177e4SLinus Torvalds 
4311da177e4SLinus Torvalds /*
4321da177e4SLinus Torvalds  * UNSHARE: Release a DOS share.
4331da177e4SLinus Torvalds  */
4347111c66eSAl Viro static __be32
nlmsvc_proc_unshare(struct svc_rqst * rqstp)435a6beb732SChristoph Hellwig nlmsvc_proc_unshare(struct svc_rqst *rqstp)
4361da177e4SLinus Torvalds {
437a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
438a6beb732SChristoph Hellwig 	struct nlm_res *resp = rqstp->rq_resp;
4391da177e4SLinus Torvalds 	struct nlm_host	*host;
4401da177e4SLinus Torvalds 	struct nlm_file	*file;
4411da177e4SLinus Torvalds 
4421da177e4SLinus Torvalds 	dprintk("lockd: UNSHARE       called\n");
4431da177e4SLinus Torvalds 
4441da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
4451da177e4SLinus Torvalds 
4461da177e4SLinus Torvalds 	/* Don't accept requests during grace period */
4475ccb0066SStanislav Kinsbursky 	if (locks_in_grace(SVC_NET(rqstp))) {
4481da177e4SLinus Torvalds 		resp->status = nlm_lck_denied_grace_period;
4491da177e4SLinus Torvalds 		return rpc_success;
4501da177e4SLinus Torvalds 	}
4511da177e4SLinus Torvalds 
4521da177e4SLinus Torvalds 	/* Obtain client and file */
4531da177e4SLinus Torvalds 	if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
454d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
4551da177e4SLinus Torvalds 
4561da177e4SLinus Torvalds 	/* Now try to unshare the file */
4571da177e4SLinus Torvalds 	resp->status = cast_status(nlmsvc_unshare_file(host, file, argp));
4581da177e4SLinus Torvalds 
4591da177e4SLinus Torvalds 	dprintk("lockd: UNSHARE       status %d\n", ntohl(resp->status));
46089e0edfbSBenjamin Coddington 	nlmsvc_release_lockowner(&argp->lock);
46167216b94SChuck Lever 	nlmsvc_release_host(host);
4621da177e4SLinus Torvalds 	nlm_release_file(file);
4631da177e4SLinus Torvalds 	return rpc_success;
4641da177e4SLinus Torvalds }
4651da177e4SLinus Torvalds 
4661da177e4SLinus Torvalds /*
4671da177e4SLinus Torvalds  * NM_LOCK: Create an unmonitored lock
4681da177e4SLinus Torvalds  */
4697111c66eSAl Viro static __be32
nlmsvc_proc_nm_lock(struct svc_rqst * rqstp)470a6beb732SChristoph Hellwig nlmsvc_proc_nm_lock(struct svc_rqst *rqstp)
4711da177e4SLinus Torvalds {
472a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
473a6beb732SChristoph Hellwig 
4741da177e4SLinus Torvalds 	dprintk("lockd: NM_LOCK       called\n");
4751da177e4SLinus Torvalds 
4761da177e4SLinus Torvalds 	argp->monitor = 0;		/* just clean the monitor flag */
477a6beb732SChristoph Hellwig 	return nlmsvc_proc_lock(rqstp);
4781da177e4SLinus Torvalds }
4791da177e4SLinus Torvalds 
4801da177e4SLinus Torvalds /*
4811da177e4SLinus Torvalds  * FREE_ALL: Release all locks and shares held by client
4821da177e4SLinus Torvalds  */
4837111c66eSAl Viro static __be32
nlmsvc_proc_free_all(struct svc_rqst * rqstp)484a6beb732SChristoph Hellwig nlmsvc_proc_free_all(struct svc_rqst *rqstp)
4851da177e4SLinus Torvalds {
486a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
4871da177e4SLinus Torvalds 	struct nlm_host	*host;
4881da177e4SLinus Torvalds 
4891da177e4SLinus Torvalds 	/* Obtain client */
4901da177e4SLinus Torvalds 	if (nlmsvc_retrieve_args(rqstp, argp, &host, NULL))
4911da177e4SLinus Torvalds 		return rpc_success;
4921da177e4SLinus Torvalds 
4931da177e4SLinus Torvalds 	nlmsvc_free_host_resources(host);
49467216b94SChuck Lever 	nlmsvc_release_host(host);
4951da177e4SLinus Torvalds 	return rpc_success;
4961da177e4SLinus Torvalds }
4971da177e4SLinus Torvalds 
4981da177e4SLinus Torvalds /*
4991da177e4SLinus Torvalds  * SM_NOTIFY: private callback from statd (not part of official NLM proto)
5001da177e4SLinus Torvalds  */
5017111c66eSAl Viro static __be32
nlmsvc_proc_sm_notify(struct svc_rqst * rqstp)502a6beb732SChristoph Hellwig nlmsvc_proc_sm_notify(struct svc_rqst *rqstp)
5031da177e4SLinus Torvalds {
504a6beb732SChristoph Hellwig 	struct nlm_reboot *argp = rqstp->rq_argp;
505a6beb732SChristoph Hellwig 
5061da177e4SLinus Torvalds 	dprintk("lockd: SM_NOTIFY     called\n");
507b85e4676SChuck Lever 
508b85e4676SChuck Lever 	if (!nlm_privileged_requester(rqstp)) {
509ad06e4bdSChuck Lever 		char buf[RPC_MAX_ADDRBUFLEN];
510ad06e4bdSChuck Lever 		printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",
511ad06e4bdSChuck Lever 				svc_print_addr(rqstp, buf, sizeof(buf)));
5121da177e4SLinus Torvalds 		return rpc_system_err;
5131da177e4SLinus Torvalds 	}
5141da177e4SLinus Torvalds 
5150ad95472SAndrey Ryabinin 	nlm_host_rebooted(SVC_NET(rqstp), argp);
5161da177e4SLinus Torvalds 	return rpc_success;
5171da177e4SLinus Torvalds }
5181da177e4SLinus Torvalds 
5191da177e4SLinus Torvalds /*
5201da177e4SLinus Torvalds  * client sent a GRANTED_RES, let's remove the associated block
5211da177e4SLinus Torvalds  */
5227111c66eSAl Viro static __be32
nlmsvc_proc_granted_res(struct svc_rqst * rqstp)523a6beb732SChristoph Hellwig nlmsvc_proc_granted_res(struct svc_rqst *rqstp)
5241da177e4SLinus Torvalds {
525a6beb732SChristoph Hellwig 	struct nlm_res *argp = rqstp->rq_argp;
526a6beb732SChristoph Hellwig 
5271da177e4SLinus Torvalds 	if (!nlmsvc_ops)
5281da177e4SLinus Torvalds 		return rpc_success;
5291da177e4SLinus Torvalds 
5301da177e4SLinus Torvalds 	dprintk("lockd: GRANTED_RES   called\n");
5311da177e4SLinus Torvalds 
53239be4502SOlaf Kirch 	nlmsvc_grant_reply(&argp->cookie, argp->status);
5331da177e4SLinus Torvalds 	return rpc_success;
5341da177e4SLinus Torvalds }
5351da177e4SLinus Torvalds 
53649d99608SChuck Lever static __be32
nlmsvc_proc_unused(struct svc_rqst * rqstp)53749d99608SChuck Lever nlmsvc_proc_unused(struct svc_rqst *rqstp)
53849d99608SChuck Lever {
53949d99608SChuck Lever 	return rpc_proc_unavail;
54049d99608SChuck Lever }
54149d99608SChuck Lever 
5421da177e4SLinus Torvalds /*
5431da177e4SLinus Torvalds  * NLM Server procedures.
5441da177e4SLinus Torvalds  */
5451da177e4SLinus Torvalds 
5461da177e4SLinus Torvalds struct nlm_void			{ int dummy; };
5471da177e4SLinus Torvalds 
5481da177e4SLinus Torvalds #define	Ck	(1+XDR_QUADLEN(NLM_MAXCOOKIELEN))	/* cookie */
5491da177e4SLinus Torvalds #define	St	1				/* status */
5501da177e4SLinus Torvalds #define	No	(1+1024/4)			/* Net Obj */
5511da177e4SLinus Torvalds #define	Rg	2				/* range - offset + size */
5521da177e4SLinus Torvalds 
55349d99608SChuck Lever const struct svc_procedure nlmsvc_procedures[24] = {
55449d99608SChuck Lever 	[NLMPROC_NULL] = {
55549d99608SChuck Lever 		.pc_func = nlmsvc_proc_null,
55649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_void,
55749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
55849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_void),
559103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_void),
56049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
56149d99608SChuck Lever 		.pc_xdrressize = St,
5622289e87bSChuck Lever 		.pc_name = "NULL",
56349d99608SChuck Lever 	},
56449d99608SChuck Lever 	[NLMPROC_TEST] = {
56549d99608SChuck Lever 		.pc_func = nlmsvc_proc_test,
56649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_testargs,
56749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_testres,
56849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
569103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
57049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
57149d99608SChuck Lever 		.pc_xdrressize = Ck+St+2+No+Rg,
5722289e87bSChuck Lever 		.pc_name = "TEST",
57349d99608SChuck Lever 	},
57449d99608SChuck Lever 	[NLMPROC_LOCK] = {
57549d99608SChuck Lever 		.pc_func = nlmsvc_proc_lock,
57649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_lockargs,
57749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_res,
57849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
579103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
58049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
58149d99608SChuck Lever 		.pc_xdrressize = Ck+St,
5822289e87bSChuck Lever 		.pc_name = "LOCK",
58349d99608SChuck Lever 	},
58449d99608SChuck Lever 	[NLMPROC_CANCEL] = {
58549d99608SChuck Lever 		.pc_func = nlmsvc_proc_cancel,
58649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_cancargs,
58749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_res,
58849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
589103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
59049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
59149d99608SChuck Lever 		.pc_xdrressize = Ck+St,
5922289e87bSChuck Lever 		.pc_name = "CANCEL",
59349d99608SChuck Lever 	},
59449d99608SChuck Lever 	[NLMPROC_UNLOCK] = {
59549d99608SChuck Lever 		.pc_func = nlmsvc_proc_unlock,
59649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_unlockargs,
59749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_res,
59849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
599103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
60049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
60149d99608SChuck Lever 		.pc_xdrressize = Ck+St,
6022289e87bSChuck Lever 		.pc_name = "UNLOCK",
60349d99608SChuck Lever 	},
60449d99608SChuck Lever 	[NLMPROC_GRANTED] = {
60549d99608SChuck Lever 		.pc_func = nlmsvc_proc_granted,
60649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_testargs,
60749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_res,
60849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
609103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
61049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
61149d99608SChuck Lever 		.pc_xdrressize = Ck+St,
6122289e87bSChuck Lever 		.pc_name = "GRANTED",
61349d99608SChuck Lever 	},
61449d99608SChuck Lever 	[NLMPROC_TEST_MSG] = {
61549d99608SChuck Lever 		.pc_func = nlmsvc_proc_test_msg,
61649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_testargs,
61749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
61849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
619103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
62049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
62149d99608SChuck Lever 		.pc_xdrressize = St,
6222289e87bSChuck Lever 		.pc_name = "TEST_MSG",
62349d99608SChuck Lever 	},
62449d99608SChuck Lever 	[NLMPROC_LOCK_MSG] = {
62549d99608SChuck Lever 		.pc_func = nlmsvc_proc_lock_msg,
62649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_lockargs,
62749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
62849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
629103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
63049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
63149d99608SChuck Lever 		.pc_xdrressize = St,
6322289e87bSChuck Lever 		.pc_name = "LOCK_MSG",
63349d99608SChuck Lever 	},
63449d99608SChuck Lever 	[NLMPROC_CANCEL_MSG] = {
63549d99608SChuck Lever 		.pc_func = nlmsvc_proc_cancel_msg,
63649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_cancargs,
63749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
63849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
639103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
64049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
64149d99608SChuck Lever 		.pc_xdrressize = St,
6422289e87bSChuck Lever 		.pc_name = "CANCEL_MSG",
64349d99608SChuck Lever 	},
64449d99608SChuck Lever 	[NLMPROC_UNLOCK_MSG] = {
64549d99608SChuck Lever 		.pc_func = nlmsvc_proc_unlock_msg,
64649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_unlockargs,
64749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
64849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
649103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
65049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
65149d99608SChuck Lever 		.pc_xdrressize = St,
6522289e87bSChuck Lever 		.pc_name = "UNLOCK_MSG",
65349d99608SChuck Lever 	},
65449d99608SChuck Lever 	[NLMPROC_GRANTED_MSG] = {
65549d99608SChuck Lever 		.pc_func = nlmsvc_proc_granted_msg,
65649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_testargs,
65749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
65849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
659103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
66049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
66149d99608SChuck Lever 		.pc_xdrressize = St,
6622289e87bSChuck Lever 		.pc_name = "GRANTED_MSG",
66349d99608SChuck Lever 	},
66449d99608SChuck Lever 	[NLMPROC_TEST_RES] = {
66549d99608SChuck Lever 		.pc_func = nlmsvc_proc_null,
66649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_void,
66749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
66849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_res),
669103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_res),
67049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
67149d99608SChuck Lever 		.pc_xdrressize = St,
6722289e87bSChuck Lever 		.pc_name = "TEST_RES",
67349d99608SChuck Lever 	},
67449d99608SChuck Lever 	[NLMPROC_LOCK_RES] = {
67549d99608SChuck Lever 		.pc_func = nlmsvc_proc_null,
67649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_void,
67749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
67849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_res),
679103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_res),
68049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
68149d99608SChuck Lever 		.pc_xdrressize = St,
6822289e87bSChuck Lever 		.pc_name = "LOCK_RES",
68349d99608SChuck Lever 	},
68449d99608SChuck Lever 	[NLMPROC_CANCEL_RES] = {
68549d99608SChuck Lever 		.pc_func = nlmsvc_proc_null,
68649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_void,
68749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
68849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_res),
689103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_res),
69049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
69149d99608SChuck Lever 		.pc_xdrressize = St,
6922289e87bSChuck Lever 		.pc_name = "CANCEL_RES",
69349d99608SChuck Lever 	},
69449d99608SChuck Lever 	[NLMPROC_UNLOCK_RES] = {
69549d99608SChuck Lever 		.pc_func = nlmsvc_proc_null,
69649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_void,
69749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
69849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_res),
699103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_res),
70049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
70149d99608SChuck Lever 		.pc_xdrressize = St,
7022289e87bSChuck Lever 		.pc_name = "UNLOCK_RES",
70349d99608SChuck Lever 	},
70449d99608SChuck Lever 	[NLMPROC_GRANTED_RES] = {
70549d99608SChuck Lever 		.pc_func = nlmsvc_proc_granted_res,
70649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_res,
70749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
70849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_res),
709103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_res),
71049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
71149d99608SChuck Lever 		.pc_xdrressize = St,
7122289e87bSChuck Lever 		.pc_name = "GRANTED_RES",
71349d99608SChuck Lever 	},
71449d99608SChuck Lever 	[NLMPROC_NSM_NOTIFY] = {
71549d99608SChuck Lever 		.pc_func = nlmsvc_proc_sm_notify,
71649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_reboot,
71749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
71849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_reboot),
719103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_reboot),
72049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
72149d99608SChuck Lever 		.pc_xdrressize = St,
7222289e87bSChuck Lever 		.pc_name = "SM_NOTIFY",
72349d99608SChuck Lever 	},
72449d99608SChuck Lever 	[17] = {
72549d99608SChuck Lever 		.pc_func = nlmsvc_proc_unused,
72649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_void,
72749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
72849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_void),
729103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_void),
73049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
73149d99608SChuck Lever 		.pc_xdrressize = St,
7322289e87bSChuck Lever 		.pc_name = "UNUSED",
73349d99608SChuck Lever 	},
73449d99608SChuck Lever 	[18] = {
73549d99608SChuck Lever 		.pc_func = nlmsvc_proc_unused,
73649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_void,
73749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
73849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_void),
739103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_void),
74049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
74149d99608SChuck Lever 		.pc_xdrressize = St,
7422289e87bSChuck Lever 		.pc_name = "UNUSED",
74349d99608SChuck Lever 	},
74449d99608SChuck Lever 	[19] = {
74549d99608SChuck Lever 		.pc_func = nlmsvc_proc_unused,
74649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_void,
74749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
74849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_void),
749103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_void),
75049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
75149d99608SChuck Lever 		.pc_xdrressize = St,
7522289e87bSChuck Lever 		.pc_name = "UNUSED",
75349d99608SChuck Lever 	},
75449d99608SChuck Lever 	[NLMPROC_SHARE] = {
75549d99608SChuck Lever 		.pc_func = nlmsvc_proc_share,
75649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_shareargs,
75749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_shareres,
75849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
759103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
76049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
76149d99608SChuck Lever 		.pc_xdrressize = Ck+St+1,
7622289e87bSChuck Lever 		.pc_name = "SHARE",
76349d99608SChuck Lever 	},
76449d99608SChuck Lever 	[NLMPROC_UNSHARE] = {
76549d99608SChuck Lever 		.pc_func = nlmsvc_proc_unshare,
76649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_shareargs,
76749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_shareres,
76849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
769103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
77049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
77149d99608SChuck Lever 		.pc_xdrressize = Ck+St+1,
7722289e87bSChuck Lever 		.pc_name = "UNSHARE",
77349d99608SChuck Lever 	},
77449d99608SChuck Lever 	[NLMPROC_NM_LOCK] = {
77549d99608SChuck Lever 		.pc_func = nlmsvc_proc_nm_lock,
77649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_lockargs,
77749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_res,
77849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
779103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
78049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
78149d99608SChuck Lever 		.pc_xdrressize = Ck+St,
7822289e87bSChuck Lever 		.pc_name = "NM_LOCK",
78349d99608SChuck Lever 	},
78449d99608SChuck Lever 	[NLMPROC_FREE_ALL] = {
78549d99608SChuck Lever 		.pc_func = nlmsvc_proc_free_all,
78649d99608SChuck Lever 		.pc_decode = nlmsvc_decode_notify,
78749d99608SChuck Lever 		.pc_encode = nlmsvc_encode_void,
78849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
789103cc1faSChuck Lever 		.pc_argzero = sizeof(struct nlm_args),
79049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
79149d99608SChuck Lever 		.pc_xdrressize = 0,
7922289e87bSChuck Lever 		.pc_name = "FREE_ALL",
79349d99608SChuck Lever 	},
7941da177e4SLinus Torvalds };
795