xref: /openbmc/linux/fs/lockd/svc4proc.c (revision 6930bcbfb6ceda63e298c6af6d733ecdf6bd4cde)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * linux/fs/lockd/svc4proc.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 /*
201da177e4SLinus Torvalds  * Obtain client and file from arguments
211da177e4SLinus Torvalds  */
2252921e02SAl Viro static __be32
231da177e4SLinus Torvalds nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
241da177e4SLinus Torvalds 			struct nlm_host **hostp, struct nlm_file **filp)
251da177e4SLinus Torvalds {
261da177e4SLinus Torvalds 	struct nlm_host		*host = NULL;
271da177e4SLinus Torvalds 	struct nlm_file		*file = NULL;
281da177e4SLinus Torvalds 	struct nlm_lock		*lock = &argp->lock;
2952921e02SAl Viro 	__be32			error = 0;
301da177e4SLinus Torvalds 
311da177e4SLinus Torvalds 	/* nfsd callbacks must have been installed for this procedure */
321da177e4SLinus Torvalds 	if (!nlmsvc_ops)
331da177e4SLinus Torvalds 		return nlm_lck_denied_nolocks;
341da177e4SLinus Torvalds 
35*6930bcbfSJeff Layton 	if (lock->lock_start > OFFSET_MAX ||
36*6930bcbfSJeff Layton 	    (lock->lock_len && ((lock->lock_len - 1) > (OFFSET_MAX - lock->lock_start))))
37*6930bcbfSJeff Layton 		return nlm4_fbig;
38*6930bcbfSJeff Layton 
391da177e4SLinus Torvalds 	/* Obtain host handle */
40db4e4c9aSOlaf Kirch 	if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
41977faf39SOlaf Kirch 	 || (argp->monitor && nsm_monitor(host) < 0))
421da177e4SLinus Torvalds 		goto no_locks;
431da177e4SLinus Torvalds 	*hostp = host;
441da177e4SLinus Torvalds 
451da177e4SLinus Torvalds 	/* Obtain file pointer. Not used by FREE_ALL call. */
461da177e4SLinus Torvalds 	if (filp != NULL) {
477f024fcdSJ. Bruce Fields 		int mode = lock_to_openmode(&lock->fl);
487f024fcdSJ. Bruce Fields 
492dc6f19eSJ. Bruce Fields 		error = nlm_lookup_file(rqstp, &file, lock);
502dc6f19eSJ. Bruce Fields 		if (error)
511da177e4SLinus Torvalds 			goto no_locks;
521da177e4SLinus Torvalds 		*filp = file;
531da177e4SLinus Torvalds 
541da177e4SLinus Torvalds 		/* Set up the missing parts of the file_lock structure */
557f024fcdSJ. Bruce Fields 		lock->fl.fl_file  = file->f_file[mode];
56646d73e9SBenjamin Coddington 		lock->fl.fl_pid = current->tgid;
57*6930bcbfSJeff Layton 		lock->fl.fl_start = (loff_t)lock->lock_start;
58*6930bcbfSJeff Layton 		lock->fl.fl_end = lock->lock_len ?
59*6930bcbfSJeff Layton 				   (loff_t)(lock->lock_start + lock->lock_len - 1) :
60*6930bcbfSJeff Layton 				   OFFSET_MAX;
611da177e4SLinus Torvalds 		lock->fl.fl_lmops = &nlmsvc_lock_operations;
6289e0edfbSBenjamin Coddington 		nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid);
6389e0edfbSBenjamin Coddington 		if (!lock->fl.fl_owner) {
6489e0edfbSBenjamin Coddington 			/* lockowner allocation has failed */
6589e0edfbSBenjamin Coddington 			nlmsvc_release_host(host);
6689e0edfbSBenjamin Coddington 			return nlm_lck_denied_nolocks;
6789e0edfbSBenjamin Coddington 		}
681da177e4SLinus Torvalds 	}
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds 	return 0;
711da177e4SLinus Torvalds 
721da177e4SLinus Torvalds no_locks:
7367216b94SChuck Lever 	nlmsvc_release_host(host);
741da177e4SLinus Torvalds  	if (error)
751da177e4SLinus Torvalds 		return error;
761da177e4SLinus Torvalds 	return nlm_lck_denied_nolocks;
771da177e4SLinus Torvalds }
781da177e4SLinus Torvalds 
791da177e4SLinus Torvalds /*
801da177e4SLinus Torvalds  * NULL: Test for presence of service
811da177e4SLinus Torvalds  */
827111c66eSAl Viro static __be32
83a6beb732SChristoph Hellwig nlm4svc_proc_null(struct svc_rqst *rqstp)
841da177e4SLinus Torvalds {
851da177e4SLinus Torvalds 	dprintk("lockd: NULL          called\n");
861da177e4SLinus Torvalds 	return rpc_success;
871da177e4SLinus Torvalds }
881da177e4SLinus Torvalds 
891da177e4SLinus Torvalds /*
901da177e4SLinus Torvalds  * TEST: Check for conflicting lock
911da177e4SLinus Torvalds  */
927111c66eSAl Viro static __be32
93a6beb732SChristoph Hellwig __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
941da177e4SLinus Torvalds {
95a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
961da177e4SLinus Torvalds 	struct nlm_host	*host;
971da177e4SLinus Torvalds 	struct nlm_file	*file;
98184cefbeSBenjamin Coddington 	struct nlm_lockowner *test_owner;
99317602f3SHarvey Harrison 	__be32 rc = rpc_success;
1001da177e4SLinus Torvalds 
1011da177e4SLinus Torvalds 	dprintk("lockd: TEST4        called\n");
1021da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
1031da177e4SLinus Torvalds 
1041da177e4SLinus Torvalds 	/* Obtain client and file */
1051da177e4SLinus Torvalds 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
106d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
1071da177e4SLinus Torvalds 
108184cefbeSBenjamin Coddington 	test_owner = argp->lock.fl.fl_owner;
1091da177e4SLinus Torvalds 	/* Now check for conflicting locks */
1108f920d5eSJeff Layton 	resp->status = nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie);
1115ea0d750SMarc Eshel 	if (resp->status == nlm_drop_reply)
112b7e6b869SOleg Drokin 		rc = rpc_drop_reply;
113b7e6b869SOleg Drokin 	else
1141da177e4SLinus Torvalds 		dprintk("lockd: TEST4        status %d\n", ntohl(resp->status));
115b7e6b869SOleg Drokin 
116184cefbeSBenjamin Coddington 	nlmsvc_put_lockowner(test_owner);
11767216b94SChuck Lever 	nlmsvc_release_host(host);
1181da177e4SLinus Torvalds 	nlm_release_file(file);
119b7e6b869SOleg Drokin 	return rc;
1201da177e4SLinus Torvalds }
1211da177e4SLinus Torvalds 
1227111c66eSAl Viro static __be32
123a6beb732SChristoph Hellwig nlm4svc_proc_test(struct svc_rqst *rqstp)
1241da177e4SLinus Torvalds {
125a6beb732SChristoph Hellwig 	return __nlm4svc_proc_test(rqstp, rqstp->rq_resp);
126a6beb732SChristoph Hellwig }
127a6beb732SChristoph Hellwig 
128a6beb732SChristoph Hellwig static __be32
129a6beb732SChristoph Hellwig __nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_res *resp)
130a6beb732SChristoph Hellwig {
131a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
1321da177e4SLinus Torvalds 	struct nlm_host	*host;
1331da177e4SLinus Torvalds 	struct nlm_file	*file;
134317602f3SHarvey Harrison 	__be32 rc = rpc_success;
1351da177e4SLinus Torvalds 
1361da177e4SLinus Torvalds 	dprintk("lockd: LOCK          called\n");
1371da177e4SLinus Torvalds 
1381da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
1391da177e4SLinus Torvalds 
1401da177e4SLinus Torvalds 	/* Obtain client and file */
1411da177e4SLinus Torvalds 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
142d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
1431da177e4SLinus Torvalds 
1441da177e4SLinus Torvalds #if 0
1451da177e4SLinus Torvalds 	/* If supplied state doesn't match current state, we assume it's
1461da177e4SLinus Torvalds 	 * an old request that time-warped somehow. Any error return would
1471da177e4SLinus Torvalds 	 * do in this case because it's irrelevant anyway.
1481da177e4SLinus Torvalds 	 *
1491da177e4SLinus Torvalds 	 * NB: We don't retrieve the remote host's state yet.
1501da177e4SLinus Torvalds 	 */
1511da177e4SLinus Torvalds 	if (host->h_nsmstate && host->h_nsmstate != argp->state) {
1521da177e4SLinus Torvalds 		resp->status = nlm_lck_denied_nolocks;
1531da177e4SLinus Torvalds 	} else
1541da177e4SLinus Torvalds #endif
1551da177e4SLinus Torvalds 
1561da177e4SLinus Torvalds 	/* Now try to lock the file */
1576cde4de8SJeff Layton 	resp->status = nlmsvc_lock(rqstp, file, host, &argp->lock,
158b2b50289SJ. Bruce Fields 					argp->block, &argp->cookie,
159b2b50289SJ. Bruce Fields 					argp->reclaim);
1601a8322b2SMarc Eshel 	if (resp->status == nlm_drop_reply)
161b7e6b869SOleg Drokin 		rc = rpc_drop_reply;
162b7e6b869SOleg Drokin 	else
1631da177e4SLinus Torvalds 		dprintk("lockd: LOCK         status %d\n", ntohl(resp->status));
164b7e6b869SOleg Drokin 
16589e0edfbSBenjamin Coddington 	nlmsvc_release_lockowner(&argp->lock);
16667216b94SChuck Lever 	nlmsvc_release_host(host);
1671da177e4SLinus Torvalds 	nlm_release_file(file);
168b7e6b869SOleg Drokin 	return rc;
1691da177e4SLinus Torvalds }
1701da177e4SLinus Torvalds 
1717111c66eSAl Viro static __be32
172a6beb732SChristoph Hellwig nlm4svc_proc_lock(struct svc_rqst *rqstp)
1731da177e4SLinus Torvalds {
174a6beb732SChristoph Hellwig 	return __nlm4svc_proc_lock(rqstp, rqstp->rq_resp);
175a6beb732SChristoph Hellwig }
176a6beb732SChristoph Hellwig 
177a6beb732SChristoph Hellwig static __be32
178a6beb732SChristoph Hellwig __nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_res *resp)
179a6beb732SChristoph Hellwig {
180a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
1811da177e4SLinus Torvalds 	struct nlm_host	*host;
1821da177e4SLinus Torvalds 	struct nlm_file	*file;
1831da177e4SLinus Torvalds 
1841da177e4SLinus Torvalds 	dprintk("lockd: CANCEL        called\n");
1851da177e4SLinus Torvalds 
1861da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
1871da177e4SLinus Torvalds 
1881da177e4SLinus Torvalds 	/* Don't accept requests during grace period */
1895ccb0066SStanislav Kinsbursky 	if (locks_in_grace(SVC_NET(rqstp))) {
1901da177e4SLinus Torvalds 		resp->status = nlm_lck_denied_grace_period;
1911da177e4SLinus Torvalds 		return rpc_success;
1921da177e4SLinus Torvalds 	}
1931da177e4SLinus Torvalds 
1941da177e4SLinus Torvalds 	/* Obtain client and file */
1951da177e4SLinus Torvalds 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
196d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
1971da177e4SLinus Torvalds 
1981da177e4SLinus Torvalds 	/* Try to cancel request. */
1995ccb0066SStanislav Kinsbursky 	resp->status = nlmsvc_cancel_blocked(SVC_NET(rqstp), file, &argp->lock);
2001da177e4SLinus Torvalds 
2011da177e4SLinus Torvalds 	dprintk("lockd: CANCEL        status %d\n", ntohl(resp->status));
20289e0edfbSBenjamin Coddington 	nlmsvc_release_lockowner(&argp->lock);
20367216b94SChuck Lever 	nlmsvc_release_host(host);
2041da177e4SLinus Torvalds 	nlm_release_file(file);
2051da177e4SLinus Torvalds 	return rpc_success;
2061da177e4SLinus Torvalds }
2071da177e4SLinus Torvalds 
208a6beb732SChristoph Hellwig static __be32
209a6beb732SChristoph Hellwig nlm4svc_proc_cancel(struct svc_rqst *rqstp)
210a6beb732SChristoph Hellwig {
211a6beb732SChristoph Hellwig 	return __nlm4svc_proc_cancel(rqstp, rqstp->rq_resp);
212a6beb732SChristoph Hellwig }
213a6beb732SChristoph Hellwig 
2141da177e4SLinus Torvalds /*
2151da177e4SLinus Torvalds  * UNLOCK: release a lock
2161da177e4SLinus Torvalds  */
2177111c66eSAl Viro static __be32
218a6beb732SChristoph Hellwig __nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_res *resp)
2191da177e4SLinus Torvalds {
220a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
2211da177e4SLinus Torvalds 	struct nlm_host	*host;
2221da177e4SLinus Torvalds 	struct nlm_file	*file;
2231da177e4SLinus Torvalds 
2241da177e4SLinus Torvalds 	dprintk("lockd: UNLOCK        called\n");
2251da177e4SLinus Torvalds 
2261da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
2271da177e4SLinus Torvalds 
2281da177e4SLinus Torvalds 	/* Don't accept new lock requests during grace period */
2295ccb0066SStanislav Kinsbursky 	if (locks_in_grace(SVC_NET(rqstp))) {
2301da177e4SLinus Torvalds 		resp->status = nlm_lck_denied_grace_period;
2311da177e4SLinus Torvalds 		return rpc_success;
2321da177e4SLinus Torvalds 	}
2331da177e4SLinus Torvalds 
2341da177e4SLinus Torvalds 	/* Obtain client and file */
2351da177e4SLinus Torvalds 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
236d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
2371da177e4SLinus Torvalds 
2381da177e4SLinus Torvalds 	/* Now try to remove the lock */
2395ccb0066SStanislav Kinsbursky 	resp->status = nlmsvc_unlock(SVC_NET(rqstp), file, &argp->lock);
2401da177e4SLinus Torvalds 
2411da177e4SLinus Torvalds 	dprintk("lockd: UNLOCK        status %d\n", ntohl(resp->status));
24289e0edfbSBenjamin Coddington 	nlmsvc_release_lockowner(&argp->lock);
24367216b94SChuck Lever 	nlmsvc_release_host(host);
2441da177e4SLinus Torvalds 	nlm_release_file(file);
2451da177e4SLinus Torvalds 	return rpc_success;
2461da177e4SLinus Torvalds }
2471da177e4SLinus Torvalds 
248a6beb732SChristoph Hellwig static __be32
249a6beb732SChristoph Hellwig nlm4svc_proc_unlock(struct svc_rqst *rqstp)
250a6beb732SChristoph Hellwig {
251a6beb732SChristoph Hellwig 	return __nlm4svc_proc_unlock(rqstp, rqstp->rq_resp);
252a6beb732SChristoph Hellwig }
253a6beb732SChristoph Hellwig 
2541da177e4SLinus Torvalds /*
2551da177e4SLinus Torvalds  * GRANTED: A server calls us to tell that a process' lock request
2561da177e4SLinus Torvalds  * was granted
2571da177e4SLinus Torvalds  */
2587111c66eSAl Viro static __be32
259a6beb732SChristoph Hellwig __nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_res *resp)
2601da177e4SLinus Torvalds {
261a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
262a6beb732SChristoph Hellwig 
2631da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
2641da177e4SLinus Torvalds 
2651da177e4SLinus Torvalds 	dprintk("lockd: GRANTED       called\n");
266dcff09f1SChuck Lever 	resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock);
2671da177e4SLinus Torvalds 	dprintk("lockd: GRANTED       status %d\n", ntohl(resp->status));
2681da177e4SLinus Torvalds 	return rpc_success;
2691da177e4SLinus Torvalds }
2701da177e4SLinus Torvalds 
271a6beb732SChristoph Hellwig static __be32
272a6beb732SChristoph Hellwig nlm4svc_proc_granted(struct svc_rqst *rqstp)
273a6beb732SChristoph Hellwig {
274a6beb732SChristoph Hellwig 	return __nlm4svc_proc_granted(rqstp, rqstp->rq_resp);
275a6beb732SChristoph Hellwig }
276a6beb732SChristoph Hellwig 
2771da177e4SLinus Torvalds /*
278d4716624STrond Myklebust  * This is the generic lockd callback for async RPC calls
279d4716624STrond Myklebust  */
280d4716624STrond Myklebust static void nlm4svc_callback_exit(struct rpc_task *task, void *data)
281d4716624STrond Myklebust {
282d4716624STrond Myklebust }
283d4716624STrond Myklebust 
284d4716624STrond Myklebust static void nlm4svc_callback_release(void *data)
285d4716624STrond Myklebust {
2867db836d4SChuck Lever 	nlmsvc_release_call(data);
287d4716624STrond Myklebust }
288d4716624STrond Myklebust 
289d4716624STrond Myklebust static const struct rpc_call_ops nlm4svc_callback_ops = {
290d4716624STrond Myklebust 	.rpc_call_done = nlm4svc_callback_exit,
291d4716624STrond Myklebust 	.rpc_release = nlm4svc_callback_release,
292d4716624STrond Myklebust };
293d4716624STrond Myklebust 
294d4716624STrond Myklebust /*
2951da177e4SLinus Torvalds  * `Async' versions of the above service routines. They aren't really,
2961da177e4SLinus Torvalds  * because we send the callback before the reply proper. I hope this
2971da177e4SLinus Torvalds  * doesn't break any clients.
2981da177e4SLinus Torvalds  */
299a6beb732SChristoph Hellwig static __be32 nlm4svc_callback(struct svc_rqst *rqstp, u32 proc,
300a6beb732SChristoph Hellwig 		__be32 (*func)(struct svc_rqst *,  struct nlm_res *))
301d4716624STrond Myklebust {
302a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
303d4716624STrond Myklebust 	struct nlm_host	*host;
304d4716624STrond Myklebust 	struct nlm_rqst	*call;
3057111c66eSAl Viro 	__be32 stat;
306d4716624STrond Myklebust 
307db4e4c9aSOlaf Kirch 	host = nlmsvc_lookup_host(rqstp,
308db4e4c9aSOlaf Kirch 				  argp->lock.caller,
309db4e4c9aSOlaf Kirch 				  argp->lock.len);
310d4716624STrond Myklebust 	if (host == NULL)
311d4716624STrond Myklebust 		return rpc_system_err;
312d4716624STrond Myklebust 
313d4716624STrond Myklebust 	call = nlm_alloc_call(host);
314446945abSAl Viro 	nlmsvc_release_host(host);
315d4716624STrond Myklebust 	if (call == NULL)
316d4716624STrond Myklebust 		return rpc_system_err;
317d4716624STrond Myklebust 
318a6beb732SChristoph Hellwig 	stat = func(rqstp, &call->a_res);
319d4716624STrond Myklebust 	if (stat != 0) {
3207db836d4SChuck Lever 		nlmsvc_release_call(call);
321d4716624STrond Myklebust 		return stat;
322d4716624STrond Myklebust 	}
323d4716624STrond Myklebust 
324d4716624STrond Myklebust 	call->a_flags = RPC_TASK_ASYNC;
325d4716624STrond Myklebust 	if (nlm_async_reply(call, proc, &nlm4svc_callback_ops) < 0)
326d4716624STrond Myklebust 		return rpc_system_err;
327d4716624STrond Myklebust 	return rpc_success;
328d4716624STrond Myklebust }
329d4716624STrond Myklebust 
330a6beb732SChristoph Hellwig static __be32 nlm4svc_proc_test_msg(struct svc_rqst *rqstp)
3311da177e4SLinus Torvalds {
3321da177e4SLinus Torvalds 	dprintk("lockd: TEST_MSG      called\n");
333a6beb732SChristoph Hellwig 	return nlm4svc_callback(rqstp, NLMPROC_TEST_RES, __nlm4svc_proc_test);
3341da177e4SLinus Torvalds }
3351da177e4SLinus Torvalds 
336a6beb732SChristoph Hellwig static __be32 nlm4svc_proc_lock_msg(struct svc_rqst *rqstp)
3371da177e4SLinus Torvalds {
3381da177e4SLinus Torvalds 	dprintk("lockd: LOCK_MSG      called\n");
339a6beb732SChristoph Hellwig 	return nlm4svc_callback(rqstp, NLMPROC_LOCK_RES, __nlm4svc_proc_lock);
3401da177e4SLinus Torvalds }
3411da177e4SLinus Torvalds 
342a6beb732SChristoph Hellwig static __be32 nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp)
3431da177e4SLinus Torvalds {
3441da177e4SLinus Torvalds 	dprintk("lockd: CANCEL_MSG    called\n");
345a6beb732SChristoph Hellwig 	return nlm4svc_callback(rqstp, NLMPROC_CANCEL_RES, __nlm4svc_proc_cancel);
3461da177e4SLinus Torvalds }
3471da177e4SLinus Torvalds 
348a6beb732SChristoph Hellwig static __be32 nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp)
3491da177e4SLinus Torvalds {
3501da177e4SLinus Torvalds 	dprintk("lockd: UNLOCK_MSG    called\n");
351a6beb732SChristoph Hellwig 	return nlm4svc_callback(rqstp, NLMPROC_UNLOCK_RES, __nlm4svc_proc_unlock);
3521da177e4SLinus Torvalds }
3531da177e4SLinus Torvalds 
354a6beb732SChristoph Hellwig static __be32 nlm4svc_proc_granted_msg(struct svc_rqst *rqstp)
3551da177e4SLinus Torvalds {
3561da177e4SLinus Torvalds 	dprintk("lockd: GRANTED_MSG   called\n");
357a6beb732SChristoph Hellwig 	return nlm4svc_callback(rqstp, NLMPROC_GRANTED_RES, __nlm4svc_proc_granted);
3581da177e4SLinus Torvalds }
3591da177e4SLinus Torvalds 
3601da177e4SLinus Torvalds /*
3611da177e4SLinus Torvalds  * SHARE: create a DOS share or alter existing share.
3621da177e4SLinus Torvalds  */
3637111c66eSAl Viro static __be32
364a6beb732SChristoph Hellwig nlm4svc_proc_share(struct svc_rqst *rqstp)
3651da177e4SLinus Torvalds {
366a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
367a6beb732SChristoph Hellwig 	struct nlm_res *resp = rqstp->rq_resp;
3681da177e4SLinus Torvalds 	struct nlm_host	*host;
3691da177e4SLinus Torvalds 	struct nlm_file	*file;
3701da177e4SLinus Torvalds 
3711da177e4SLinus Torvalds 	dprintk("lockd: SHARE         called\n");
3721da177e4SLinus Torvalds 
3731da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
3741da177e4SLinus Torvalds 
3751da177e4SLinus Torvalds 	/* Don't accept new lock requests during grace period */
3765ccb0066SStanislav Kinsbursky 	if (locks_in_grace(SVC_NET(rqstp)) && !argp->reclaim) {
3771da177e4SLinus Torvalds 		resp->status = nlm_lck_denied_grace_period;
3781da177e4SLinus Torvalds 		return rpc_success;
3791da177e4SLinus Torvalds 	}
3801da177e4SLinus Torvalds 
3811da177e4SLinus Torvalds 	/* Obtain client and file */
3821da177e4SLinus Torvalds 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
383d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
3841da177e4SLinus Torvalds 
3851da177e4SLinus Torvalds 	/* Now try to create the share */
3861da177e4SLinus Torvalds 	resp->status = nlmsvc_share_file(host, file, argp);
3871da177e4SLinus Torvalds 
3881da177e4SLinus Torvalds 	dprintk("lockd: SHARE         status %d\n", ntohl(resp->status));
38989e0edfbSBenjamin Coddington 	nlmsvc_release_lockowner(&argp->lock);
39067216b94SChuck Lever 	nlmsvc_release_host(host);
3911da177e4SLinus Torvalds 	nlm_release_file(file);
3921da177e4SLinus Torvalds 	return rpc_success;
3931da177e4SLinus Torvalds }
3941da177e4SLinus Torvalds 
3951da177e4SLinus Torvalds /*
3961da177e4SLinus Torvalds  * UNSHARE: Release a DOS share.
3971da177e4SLinus Torvalds  */
3987111c66eSAl Viro static __be32
399a6beb732SChristoph Hellwig nlm4svc_proc_unshare(struct svc_rqst *rqstp)
4001da177e4SLinus Torvalds {
401a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
402a6beb732SChristoph Hellwig 	struct nlm_res *resp = rqstp->rq_resp;
4031da177e4SLinus Torvalds 	struct nlm_host	*host;
4041da177e4SLinus Torvalds 	struct nlm_file	*file;
4051da177e4SLinus Torvalds 
4061da177e4SLinus Torvalds 	dprintk("lockd: UNSHARE       called\n");
4071da177e4SLinus Torvalds 
4081da177e4SLinus Torvalds 	resp->cookie = argp->cookie;
4091da177e4SLinus Torvalds 
4101da177e4SLinus Torvalds 	/* Don't accept requests during grace period */
4115ccb0066SStanislav Kinsbursky 	if (locks_in_grace(SVC_NET(rqstp))) {
4121da177e4SLinus Torvalds 		resp->status = nlm_lck_denied_grace_period;
4131da177e4SLinus Torvalds 		return rpc_success;
4141da177e4SLinus Torvalds 	}
4151da177e4SLinus Torvalds 
4161da177e4SLinus Torvalds 	/* Obtain client and file */
4171da177e4SLinus Torvalds 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
418d343fce1SNeilBrown 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
4191da177e4SLinus Torvalds 
4201da177e4SLinus Torvalds 	/* Now try to lock the file */
4211da177e4SLinus Torvalds 	resp->status = nlmsvc_unshare_file(host, file, argp);
4221da177e4SLinus Torvalds 
4231da177e4SLinus Torvalds 	dprintk("lockd: UNSHARE       status %d\n", ntohl(resp->status));
42489e0edfbSBenjamin Coddington 	nlmsvc_release_lockowner(&argp->lock);
42567216b94SChuck Lever 	nlmsvc_release_host(host);
4261da177e4SLinus Torvalds 	nlm_release_file(file);
4271da177e4SLinus Torvalds 	return rpc_success;
4281da177e4SLinus Torvalds }
4291da177e4SLinus Torvalds 
4301da177e4SLinus Torvalds /*
4311da177e4SLinus Torvalds  * NM_LOCK: Create an unmonitored lock
4321da177e4SLinus Torvalds  */
4337111c66eSAl Viro static __be32
434a6beb732SChristoph Hellwig nlm4svc_proc_nm_lock(struct svc_rqst *rqstp)
4351da177e4SLinus Torvalds {
436a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
437a6beb732SChristoph Hellwig 
4381da177e4SLinus Torvalds 	dprintk("lockd: NM_LOCK       called\n");
4391da177e4SLinus Torvalds 
4401da177e4SLinus Torvalds 	argp->monitor = 0;		/* just clean the monitor flag */
441a6beb732SChristoph Hellwig 	return nlm4svc_proc_lock(rqstp);
4421da177e4SLinus Torvalds }
4431da177e4SLinus Torvalds 
4441da177e4SLinus Torvalds /*
4451da177e4SLinus Torvalds  * FREE_ALL: Release all locks and shares held by client
4461da177e4SLinus Torvalds  */
4477111c66eSAl Viro static __be32
448a6beb732SChristoph Hellwig nlm4svc_proc_free_all(struct svc_rqst *rqstp)
4491da177e4SLinus Torvalds {
450a6beb732SChristoph Hellwig 	struct nlm_args *argp = rqstp->rq_argp;
4511da177e4SLinus Torvalds 	struct nlm_host	*host;
4521da177e4SLinus Torvalds 
4531da177e4SLinus Torvalds 	/* Obtain client */
4541da177e4SLinus Torvalds 	if (nlm4svc_retrieve_args(rqstp, argp, &host, NULL))
4551da177e4SLinus Torvalds 		return rpc_success;
4561da177e4SLinus Torvalds 
4571da177e4SLinus Torvalds 	nlmsvc_free_host_resources(host);
45867216b94SChuck Lever 	nlmsvc_release_host(host);
4591da177e4SLinus Torvalds 	return rpc_success;
4601da177e4SLinus Torvalds }
4611da177e4SLinus Torvalds 
4621da177e4SLinus Torvalds /*
4631da177e4SLinus Torvalds  * SM_NOTIFY: private callback from statd (not part of official NLM proto)
4641da177e4SLinus Torvalds  */
4657111c66eSAl Viro static __be32
466a6beb732SChristoph Hellwig nlm4svc_proc_sm_notify(struct svc_rqst *rqstp)
4671da177e4SLinus Torvalds {
468a6beb732SChristoph Hellwig 	struct nlm_reboot *argp = rqstp->rq_argp;
469a6beb732SChristoph Hellwig 
4701da177e4SLinus Torvalds 	dprintk("lockd: SM_NOTIFY     called\n");
471b85e4676SChuck Lever 
472b85e4676SChuck Lever 	if (!nlm_privileged_requester(rqstp)) {
473ad06e4bdSChuck Lever 		char buf[RPC_MAX_ADDRBUFLEN];
474ad06e4bdSChuck Lever 		printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",
475ad06e4bdSChuck Lever 				svc_print_addr(rqstp, buf, sizeof(buf)));
4761da177e4SLinus Torvalds 		return rpc_system_err;
4771da177e4SLinus Torvalds 	}
4781da177e4SLinus Torvalds 
4790ad95472SAndrey Ryabinin 	nlm_host_rebooted(SVC_NET(rqstp), argp);
4801da177e4SLinus Torvalds 	return rpc_success;
4811da177e4SLinus Torvalds }
4821da177e4SLinus Torvalds 
4831da177e4SLinus Torvalds /*
4841da177e4SLinus Torvalds  * client sent a GRANTED_RES, let's remove the associated block
4851da177e4SLinus Torvalds  */
4867111c66eSAl Viro static __be32
487a6beb732SChristoph Hellwig nlm4svc_proc_granted_res(struct svc_rqst *rqstp)
4881da177e4SLinus Torvalds {
489a6beb732SChristoph Hellwig 	struct nlm_res *argp = rqstp->rq_argp;
490a6beb732SChristoph Hellwig 
4911da177e4SLinus Torvalds         if (!nlmsvc_ops)
4921da177e4SLinus Torvalds                 return rpc_success;
4931da177e4SLinus Torvalds 
4941da177e4SLinus Torvalds         dprintk("lockd: GRANTED_RES   called\n");
4951da177e4SLinus Torvalds 
49639be4502SOlaf Kirch         nlmsvc_grant_reply(&argp->cookie, argp->status);
4971da177e4SLinus Torvalds         return rpc_success;
4981da177e4SLinus Torvalds }
4991da177e4SLinus Torvalds 
50049d99608SChuck Lever static __be32
50149d99608SChuck Lever nlm4svc_proc_unused(struct svc_rqst *rqstp)
50249d99608SChuck Lever {
50349d99608SChuck Lever 	return rpc_proc_unavail;
50449d99608SChuck Lever }
50549d99608SChuck Lever 
5061da177e4SLinus Torvalds 
5071da177e4SLinus Torvalds /*
5081da177e4SLinus Torvalds  * NLM Server procedures.
5091da177e4SLinus Torvalds  */
5101da177e4SLinus Torvalds 
5111da177e4SLinus Torvalds struct nlm_void			{ int dummy; };
5121da177e4SLinus Torvalds 
5131da177e4SLinus Torvalds #define	Ck	(1+XDR_QUADLEN(NLM_MAXCOOKIELEN))	/* cookie */
5141da177e4SLinus Torvalds #define	No	(1+1024/4)				/* netobj */
5151da177e4SLinus Torvalds #define	St	1					/* status */
5161da177e4SLinus Torvalds #define	Rg	4					/* range (offset + length) */
5171da177e4SLinus Torvalds 
51849d99608SChuck Lever const struct svc_procedure nlmsvc_procedures4[24] = {
51949d99608SChuck Lever 	[NLMPROC_NULL] = {
52049d99608SChuck Lever 		.pc_func = nlm4svc_proc_null,
52149d99608SChuck Lever 		.pc_decode = nlm4svc_decode_void,
52249d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
52349d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_void),
52449d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
52549d99608SChuck Lever 		.pc_xdrressize = St,
5262289e87bSChuck Lever 		.pc_name = "NULL",
52749d99608SChuck Lever 	},
52849d99608SChuck Lever 	[NLMPROC_TEST] = {
52949d99608SChuck Lever 		.pc_func = nlm4svc_proc_test,
53049d99608SChuck Lever 		.pc_decode = nlm4svc_decode_testargs,
53149d99608SChuck Lever 		.pc_encode = nlm4svc_encode_testres,
53249d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
53349d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
53449d99608SChuck Lever 		.pc_xdrressize = Ck+St+2+No+Rg,
5352289e87bSChuck Lever 		.pc_name = "TEST",
53649d99608SChuck Lever 	},
53749d99608SChuck Lever 	[NLMPROC_LOCK] = {
53849d99608SChuck Lever 		.pc_func = nlm4svc_proc_lock,
53949d99608SChuck Lever 		.pc_decode = nlm4svc_decode_lockargs,
54049d99608SChuck Lever 		.pc_encode = nlm4svc_encode_res,
54149d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
54249d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
54349d99608SChuck Lever 		.pc_xdrressize = Ck+St,
5442289e87bSChuck Lever 		.pc_name = "LOCK",
54549d99608SChuck Lever 	},
54649d99608SChuck Lever 	[NLMPROC_CANCEL] = {
54749d99608SChuck Lever 		.pc_func = nlm4svc_proc_cancel,
54849d99608SChuck Lever 		.pc_decode = nlm4svc_decode_cancargs,
54949d99608SChuck Lever 		.pc_encode = nlm4svc_encode_res,
55049d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
55149d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
55249d99608SChuck Lever 		.pc_xdrressize = Ck+St,
5532289e87bSChuck Lever 		.pc_name = "CANCEL",
55449d99608SChuck Lever 	},
55549d99608SChuck Lever 	[NLMPROC_UNLOCK] = {
55649d99608SChuck Lever 		.pc_func = nlm4svc_proc_unlock,
55749d99608SChuck Lever 		.pc_decode = nlm4svc_decode_unlockargs,
55849d99608SChuck Lever 		.pc_encode = nlm4svc_encode_res,
55949d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
56049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
56149d99608SChuck Lever 		.pc_xdrressize = Ck+St,
5622289e87bSChuck Lever 		.pc_name = "UNLOCK",
56349d99608SChuck Lever 	},
56449d99608SChuck Lever 	[NLMPROC_GRANTED] = {
56549d99608SChuck Lever 		.pc_func = nlm4svc_proc_granted,
56649d99608SChuck Lever 		.pc_decode = nlm4svc_decode_testargs,
56749d99608SChuck Lever 		.pc_encode = nlm4svc_encode_res,
56849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
56949d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
57049d99608SChuck Lever 		.pc_xdrressize = Ck+St,
5712289e87bSChuck Lever 		.pc_name = "GRANTED",
57249d99608SChuck Lever 	},
57349d99608SChuck Lever 	[NLMPROC_TEST_MSG] = {
57449d99608SChuck Lever 		.pc_func = nlm4svc_proc_test_msg,
57549d99608SChuck Lever 		.pc_decode = nlm4svc_decode_testargs,
57649d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
57749d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
57849d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
57949d99608SChuck Lever 		.pc_xdrressize = St,
5802289e87bSChuck Lever 		.pc_name = "TEST_MSG",
58149d99608SChuck Lever 	},
58249d99608SChuck Lever 	[NLMPROC_LOCK_MSG] = {
58349d99608SChuck Lever 		.pc_func = nlm4svc_proc_lock_msg,
58449d99608SChuck Lever 		.pc_decode = nlm4svc_decode_lockargs,
58549d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
58649d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
58749d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
58849d99608SChuck Lever 		.pc_xdrressize = St,
5892289e87bSChuck Lever 		.pc_name = "LOCK_MSG",
59049d99608SChuck Lever 	},
59149d99608SChuck Lever 	[NLMPROC_CANCEL_MSG] = {
59249d99608SChuck Lever 		.pc_func = nlm4svc_proc_cancel_msg,
59349d99608SChuck Lever 		.pc_decode = nlm4svc_decode_cancargs,
59449d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
59549d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
59649d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
59749d99608SChuck Lever 		.pc_xdrressize = St,
5982289e87bSChuck Lever 		.pc_name = "CANCEL_MSG",
59949d99608SChuck Lever 	},
60049d99608SChuck Lever 	[NLMPROC_UNLOCK_MSG] = {
60149d99608SChuck Lever 		.pc_func = nlm4svc_proc_unlock_msg,
60249d99608SChuck Lever 		.pc_decode = nlm4svc_decode_unlockargs,
60349d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
60449d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
60549d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
60649d99608SChuck Lever 		.pc_xdrressize = St,
6072289e87bSChuck Lever 		.pc_name = "UNLOCK_MSG",
60849d99608SChuck Lever 	},
60949d99608SChuck Lever 	[NLMPROC_GRANTED_MSG] = {
61049d99608SChuck Lever 		.pc_func = nlm4svc_proc_granted_msg,
61149d99608SChuck Lever 		.pc_decode = nlm4svc_decode_testargs,
61249d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
61349d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
61449d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
61549d99608SChuck Lever 		.pc_xdrressize = St,
6162289e87bSChuck Lever 		.pc_name = "GRANTED_MSG",
61749d99608SChuck Lever 	},
61849d99608SChuck Lever 	[NLMPROC_TEST_RES] = {
61949d99608SChuck Lever 		.pc_func = nlm4svc_proc_null,
62049d99608SChuck Lever 		.pc_decode = nlm4svc_decode_void,
62149d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
62249d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_res),
62349d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
62449d99608SChuck Lever 		.pc_xdrressize = St,
6252289e87bSChuck Lever 		.pc_name = "TEST_RES",
62649d99608SChuck Lever 	},
62749d99608SChuck Lever 	[NLMPROC_LOCK_RES] = {
62849d99608SChuck Lever 		.pc_func = nlm4svc_proc_null,
62949d99608SChuck Lever 		.pc_decode = nlm4svc_decode_void,
63049d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
63149d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_res),
63249d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
63349d99608SChuck Lever 		.pc_xdrressize = St,
6342289e87bSChuck Lever 		.pc_name = "LOCK_RES",
63549d99608SChuck Lever 	},
63649d99608SChuck Lever 	[NLMPROC_CANCEL_RES] = {
63749d99608SChuck Lever 		.pc_func = nlm4svc_proc_null,
63849d99608SChuck Lever 		.pc_decode = nlm4svc_decode_void,
63949d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
64049d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_res),
64149d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
64249d99608SChuck Lever 		.pc_xdrressize = St,
6432289e87bSChuck Lever 		.pc_name = "CANCEL_RES",
64449d99608SChuck Lever 	},
64549d99608SChuck Lever 	[NLMPROC_UNLOCK_RES] = {
64649d99608SChuck Lever 		.pc_func = nlm4svc_proc_null,
64749d99608SChuck Lever 		.pc_decode = nlm4svc_decode_void,
64849d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
64949d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_res),
65049d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
65149d99608SChuck Lever 		.pc_xdrressize = St,
6522289e87bSChuck Lever 		.pc_name = "UNLOCK_RES",
65349d99608SChuck Lever 	},
65449d99608SChuck Lever 	[NLMPROC_GRANTED_RES] = {
65549d99608SChuck Lever 		.pc_func = nlm4svc_proc_granted_res,
65649d99608SChuck Lever 		.pc_decode = nlm4svc_decode_res,
65749d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
65849d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_res),
65949d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
66049d99608SChuck Lever 		.pc_xdrressize = St,
6612289e87bSChuck Lever 		.pc_name = "GRANTED_RES",
66249d99608SChuck Lever 	},
66349d99608SChuck Lever 	[NLMPROC_NSM_NOTIFY] = {
66449d99608SChuck Lever 		.pc_func = nlm4svc_proc_sm_notify,
66549d99608SChuck Lever 		.pc_decode = nlm4svc_decode_reboot,
66649d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
66749d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_reboot),
66849d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
66949d99608SChuck Lever 		.pc_xdrressize = St,
6702289e87bSChuck Lever 		.pc_name = "SM_NOTIFY",
67149d99608SChuck Lever 	},
67249d99608SChuck Lever 	[17] = {
67349d99608SChuck Lever 		.pc_func = nlm4svc_proc_unused,
67449d99608SChuck Lever 		.pc_decode = nlm4svc_decode_void,
67549d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
67649d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_void),
67749d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
67849d99608SChuck Lever 		.pc_xdrressize = 0,
6792289e87bSChuck Lever 		.pc_name = "UNUSED",
68049d99608SChuck Lever 	},
68149d99608SChuck Lever 	[18] = {
68249d99608SChuck Lever 		.pc_func = nlm4svc_proc_unused,
68349d99608SChuck Lever 		.pc_decode = nlm4svc_decode_void,
68449d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
68549d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_void),
68649d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
68749d99608SChuck Lever 		.pc_xdrressize = 0,
6882289e87bSChuck Lever 		.pc_name = "UNUSED",
68949d99608SChuck Lever 	},
69049d99608SChuck Lever 	[19] = {
69149d99608SChuck Lever 		.pc_func = nlm4svc_proc_unused,
69249d99608SChuck Lever 		.pc_decode = nlm4svc_decode_void,
69349d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
69449d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_void),
69549d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
69649d99608SChuck Lever 		.pc_xdrressize = 0,
6972289e87bSChuck Lever 		.pc_name = "UNUSED",
69849d99608SChuck Lever 	},
69949d99608SChuck Lever 	[NLMPROC_SHARE] = {
70049d99608SChuck Lever 		.pc_func = nlm4svc_proc_share,
70149d99608SChuck Lever 		.pc_decode = nlm4svc_decode_shareargs,
70249d99608SChuck Lever 		.pc_encode = nlm4svc_encode_shareres,
70349d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
70449d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
70549d99608SChuck Lever 		.pc_xdrressize = Ck+St+1,
7062289e87bSChuck Lever 		.pc_name = "SHARE",
70749d99608SChuck Lever 	},
70849d99608SChuck Lever 	[NLMPROC_UNSHARE] = {
70949d99608SChuck Lever 		.pc_func = nlm4svc_proc_unshare,
71049d99608SChuck Lever 		.pc_decode = nlm4svc_decode_shareargs,
71149d99608SChuck Lever 		.pc_encode = nlm4svc_encode_shareres,
71249d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
71349d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
71449d99608SChuck Lever 		.pc_xdrressize = Ck+St+1,
7152289e87bSChuck Lever 		.pc_name = "UNSHARE",
71649d99608SChuck Lever 	},
71749d99608SChuck Lever 	[NLMPROC_NM_LOCK] = {
71849d99608SChuck Lever 		.pc_func = nlm4svc_proc_nm_lock,
71949d99608SChuck Lever 		.pc_decode = nlm4svc_decode_lockargs,
72049d99608SChuck Lever 		.pc_encode = nlm4svc_encode_res,
72149d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
72249d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_res),
72349d99608SChuck Lever 		.pc_xdrressize = Ck+St,
7242289e87bSChuck Lever 		.pc_name = "NM_LOCK",
72549d99608SChuck Lever 	},
72649d99608SChuck Lever 	[NLMPROC_FREE_ALL] = {
72749d99608SChuck Lever 		.pc_func = nlm4svc_proc_free_all,
72849d99608SChuck Lever 		.pc_decode = nlm4svc_decode_notify,
72949d99608SChuck Lever 		.pc_encode = nlm4svc_encode_void,
73049d99608SChuck Lever 		.pc_argsize = sizeof(struct nlm_args),
73149d99608SChuck Lever 		.pc_ressize = sizeof(struct nlm_void),
73249d99608SChuck Lever 		.pc_xdrressize = St,
7332289e87bSChuck Lever 		.pc_name = "FREE_ALL",
73449d99608SChuck Lever 	},
7351da177e4SLinus Torvalds };
736