blob: 56c9519d900a32ea203112f24b4866227b1bdd33 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/fs/lockd/svcproc.c
3 *
4 * Lockd server procedures. We don't implement the NLM_*_RES
5 * procedures because we don't use the async procedures.
6 *
7 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
8 */
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/types.h>
11#include <linux/time.h>
12#include <linux/slab.h>
Alexey Dobriyan405f5572009-07-11 22:08:37 +040013#include <linux/smp_lock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/lockd/lockd.h>
15#include <linux/lockd/share.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17#define NLMDBG_FACILITY NLMDBG_CLIENT
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#ifdef CONFIG_LOCKD_V4
Al Viro52921e02006-10-19 23:28:46 -070020static __be32
21cast_to_nlm(__be32 status, u32 vers)
Linus Torvalds1da177e2005-04-16 15:20:36 -070022{
23 /* Note: status is assumed to be in network byte order !!! */
24 if (vers != 4){
25 switch (status) {
26 case nlm_granted:
27 case nlm_lck_denied:
28 case nlm_lck_denied_nolocks:
29 case nlm_lck_blocked:
30 case nlm_lck_denied_grace_period:
Marc Eshel5ea0d752006-11-28 16:27:06 -050031 case nlm_drop_reply:
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 break;
33 case nlm4_deadlock:
34 status = nlm_lck_denied;
35 break;
36 default:
37 status = nlm_lck_denied_nolocks;
38 }
39 }
40
41 return (status);
42}
43#define cast_status(status) (cast_to_nlm(status, rqstp->rq_vers))
44#else
45#define cast_status(status) (status)
46#endif
47
48/*
49 * Obtain client and file from arguments
50 */
Al Viro52921e02006-10-19 23:28:46 -070051static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -070052nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
53 struct nlm_host **hostp, struct nlm_file **filp)
54{
55 struct nlm_host *host = NULL;
56 struct nlm_file *file = NULL;
57 struct nlm_lock *lock = &argp->lock;
Al Viro52921e02006-10-19 23:28:46 -070058 __be32 error = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60 /* nfsd callbacks must have been installed for this procedure */
61 if (!nlmsvc_ops)
62 return nlm_lck_denied_nolocks;
63
64 /* Obtain host handle */
Olaf Kirchdb4e4c92006-10-04 02:15:52 -070065 if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
Olaf Kirch977faf32006-10-04 02:15:51 -070066 || (argp->monitor && nsm_monitor(host) < 0))
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 goto no_locks;
68 *hostp = host;
69
70 /* Obtain file pointer. Not used by FREE_ALL call. */
71 if (filp != NULL) {
72 if ((error = nlm_lookup_file(rqstp, &file, &lock->fh)) != 0)
73 goto no_locks;
74 *filp = file;
75
76 /* Set up the missing parts of the file_lock structure */
77 lock->fl.fl_file = file->f_file;
78 lock->fl.fl_owner = (fl_owner_t) host;
79 lock->fl.fl_lmops = &nlmsvc_lock_operations;
80 }
81
82 return 0;
83
84no_locks:
Jeff Laytonb0e92aa2008-07-15 12:35:20 -040085 nlm_release_host(host);
NeilBrownd343fce2006-10-17 00:10:18 -070086 if (error)
87 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 return nlm_lck_denied_nolocks;
89}
90
91/*
92 * NULL: Test for presence of service
93 */
Al Viro7111c662006-10-19 23:28:45 -070094static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -070095nlmsvc_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
96{
97 dprintk("lockd: NULL called\n");
98 return rpc_success;
99}
100
101/*
102 * TEST: Check for conflicting lock
103 */
Al Viro7111c662006-10-19 23:28:45 -0700104static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
106 struct nlm_res *resp)
107{
108 struct nlm_host *host;
109 struct nlm_file *file;
Harvey Harrison317602f2008-07-20 23:41:24 -0700110 __be32 rc = rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
112 dprintk("lockd: TEST called\n");
113 resp->cookie = argp->cookie;
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 /* Obtain client and file */
116 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700117 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119 /* Now check for conflicting locks */
Jeff Layton8f920d52008-07-15 14:06:48 -0400120 resp->status = cast_status(nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie));
Marc Eshel5ea0d752006-11-28 16:27:06 -0500121 if (resp->status == nlm_drop_reply)
Oleg Drokinb7e6b862007-11-26 13:35:11 -0500122 rc = rpc_drop_reply;
123 else
124 dprintk("lockd: TEST status %d vers %d\n",
125 ntohl(resp->status), rqstp->rq_vers);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 nlm_release_host(host);
128 nlm_release_file(file);
Oleg Drokinb7e6b862007-11-26 13:35:11 -0500129 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130}
131
Al Viro7111c662006-10-19 23:28:45 -0700132static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
134 struct nlm_res *resp)
135{
136 struct nlm_host *host;
137 struct nlm_file *file;
Harvey Harrison317602f2008-07-20 23:41:24 -0700138 __be32 rc = rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
140 dprintk("lockd: LOCK called\n");
141
142 resp->cookie = argp->cookie;
143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 /* Obtain client and file */
145 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700146 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
148#if 0
149 /* If supplied state doesn't match current state, we assume it's
150 * an old request that time-warped somehow. Any error return would
151 * do in this case because it's irrelevant anyway.
152 *
153 * NB: We don't retrieve the remote host's state yet.
154 */
155 if (host->h_nsmstate && host->h_nsmstate != argp->state) {
156 resp->status = nlm_lck_denied_nolocks;
157 } else
158#endif
159
160 /* Now try to lock the file */
Jeff Layton6cde4de2008-07-15 14:26:17 -0400161 resp->status = cast_status(nlmsvc_lock(rqstp, file, host, &argp->lock,
J. Bruce Fieldsb2b50282008-02-06 13:59:23 -0500162 argp->block, &argp->cookie,
163 argp->reclaim));
Marc Eshel1a8322b2006-11-28 16:27:06 -0500164 if (resp->status == nlm_drop_reply)
Oleg Drokinb7e6b862007-11-26 13:35:11 -0500165 rc = rpc_drop_reply;
166 else
167 dprintk("lockd: LOCK status %d\n", ntohl(resp->status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 nlm_release_host(host);
170 nlm_release_file(file);
Oleg Drokinb7e6b862007-11-26 13:35:11 -0500171 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172}
173
Al Viro7111c662006-10-19 23:28:45 -0700174static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
176 struct nlm_res *resp)
177{
178 struct nlm_host *host;
179 struct nlm_file *file;
180
181 dprintk("lockd: CANCEL called\n");
182
183 resp->cookie = argp->cookie;
184
185 /* Don't accept requests during grace period */
J. Bruce Fieldsaf558e32007-09-06 12:34:25 -0400186 if (locks_in_grace()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 resp->status = nlm_lck_denied_grace_period;
188 return rpc_success;
189 }
190
191 /* Obtain client and file */
192 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700193 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195 /* Try to cancel request. */
196 resp->status = cast_status(nlmsvc_cancel_blocked(file, &argp->lock));
197
198 dprintk("lockd: CANCEL status %d\n", ntohl(resp->status));
199 nlm_release_host(host);
200 nlm_release_file(file);
201 return rpc_success;
202}
203
204/*
205 * UNLOCK: release a lock
206 */
Al Viro7111c662006-10-19 23:28:45 -0700207static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
209 struct nlm_res *resp)
210{
211 struct nlm_host *host;
212 struct nlm_file *file;
213
214 dprintk("lockd: UNLOCK called\n");
215
216 resp->cookie = argp->cookie;
217
218 /* Don't accept new lock requests during grace period */
J. Bruce Fieldsaf558e32007-09-06 12:34:25 -0400219 if (locks_in_grace()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 resp->status = nlm_lck_denied_grace_period;
221 return rpc_success;
222 }
223
224 /* Obtain client and file */
225 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700226 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
228 /* Now try to remove the lock */
229 resp->status = cast_status(nlmsvc_unlock(file, &argp->lock));
230
231 dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status));
232 nlm_release_host(host);
233 nlm_release_file(file);
234 return rpc_success;
235}
236
237/*
238 * GRANTED: A server calls us to tell that a process' lock request
239 * was granted
240 */
Al Viro7111c662006-10-19 23:28:45 -0700241static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,
243 struct nlm_res *resp)
244{
245 resp->cookie = argp->cookie;
246
247 dprintk("lockd: GRANTED called\n");
Chuck Leverdcff09f2008-10-03 12:50:36 -0400248 resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 dprintk("lockd: GRANTED status %d\n", ntohl(resp->status));
250 return rpc_success;
251}
252
253/*
Trond Myklebustd4716622006-03-20 13:44:45 -0500254 * This is the generic lockd callback for async RPC calls
255 */
256static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
257{
Chuck Leverc041b5f2006-12-05 16:36:03 -0500258 dprintk("lockd: %5u callback returned %d\n", task->tk_pid,
Trond Myklebustd4716622006-03-20 13:44:45 -0500259 -task->tk_status);
260}
261
262static void nlmsvc_callback_release(void *data)
263{
Trond Myklebusta86dc492008-06-11 13:37:09 -0400264 lock_kernel();
Trond Myklebustd4716622006-03-20 13:44:45 -0500265 nlm_release_call(data);
Trond Myklebusta86dc492008-06-11 13:37:09 -0400266 unlock_kernel();
Trond Myklebustd4716622006-03-20 13:44:45 -0500267}
268
269static const struct rpc_call_ops nlmsvc_callback_ops = {
270 .rpc_call_done = nlmsvc_callback_exit,
271 .rpc_release = nlmsvc_callback_release,
272};
273
274/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 * `Async' versions of the above service routines. They aren't really,
276 * because we send the callback before the reply proper. I hope this
277 * doesn't break any clients.
278 */
Al Viro7111c662006-10-19 23:28:45 -0700279static __be32 nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp,
280 __be32 (*func)(struct svc_rqst *, struct nlm_args *, struct nlm_res *))
Trond Myklebustd4716622006-03-20 13:44:45 -0500281{
282 struct nlm_host *host;
283 struct nlm_rqst *call;
Al Viro7111c662006-10-19 23:28:45 -0700284 __be32 stat;
Trond Myklebustd4716622006-03-20 13:44:45 -0500285
Olaf Kirchdb4e4c92006-10-04 02:15:52 -0700286 host = nlmsvc_lookup_host(rqstp,
287 argp->lock.caller,
288 argp->lock.len);
Trond Myklebustd4716622006-03-20 13:44:45 -0500289 if (host == NULL)
290 return rpc_system_err;
291
292 call = nlm_alloc_call(host);
293 if (call == NULL)
294 return rpc_system_err;
295
296 stat = func(rqstp, argp, &call->a_res);
297 if (stat != 0) {
298 nlm_release_call(call);
299 return stat;
300 }
301
302 call->a_flags = RPC_TASK_ASYNC;
303 if (nlm_async_reply(call, proc, &nlmsvc_callback_ops) < 0)
304 return rpc_system_err;
305 return rpc_success;
306}
307
Al Viro7111c662006-10-19 23:28:45 -0700308static __be32 nlmsvc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 void *resp)
310{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 dprintk("lockd: TEST_MSG called\n");
Trond Myklebustd4716622006-03-20 13:44:45 -0500312 return nlmsvc_callback(rqstp, NLMPROC_TEST_RES, argp, nlmsvc_proc_test);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313}
314
Al Viro7111c662006-10-19 23:28:45 -0700315static __be32 nlmsvc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 void *resp)
317{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 dprintk("lockd: LOCK_MSG called\n");
Trond Myklebustd4716622006-03-20 13:44:45 -0500319 return nlmsvc_callback(rqstp, NLMPROC_LOCK_RES, argp, nlmsvc_proc_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320}
321
Al Viro7111c662006-10-19 23:28:45 -0700322static __be32 nlmsvc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 void *resp)
324{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 dprintk("lockd: CANCEL_MSG called\n");
Trond Myklebustd4716622006-03-20 13:44:45 -0500326 return nlmsvc_callback(rqstp, NLMPROC_CANCEL_RES, argp, nlmsvc_proc_cancel);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327}
328
Al Viro7111c662006-10-19 23:28:45 -0700329static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
331 void *resp)
332{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 dprintk("lockd: UNLOCK_MSG called\n");
Trond Myklebustd4716622006-03-20 13:44:45 -0500334 return nlmsvc_callback(rqstp, NLMPROC_UNLOCK_RES, argp, nlmsvc_proc_unlock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335}
336
Al Viro7111c662006-10-19 23:28:45 -0700337static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338nlmsvc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
339 void *resp)
340{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 dprintk("lockd: GRANTED_MSG called\n");
Trond Myklebustd4716622006-03-20 13:44:45 -0500342 return nlmsvc_callback(rqstp, NLMPROC_GRANTED_RES, argp, nlmsvc_proc_granted);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343}
344
345/*
346 * SHARE: create a DOS share or alter existing share.
347 */
Al Viro7111c662006-10-19 23:28:45 -0700348static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349nlmsvc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
350 struct nlm_res *resp)
351{
352 struct nlm_host *host;
353 struct nlm_file *file;
354
355 dprintk("lockd: SHARE called\n");
356
357 resp->cookie = argp->cookie;
358
359 /* Don't accept new lock requests during grace period */
J. Bruce Fieldsaf558e32007-09-06 12:34:25 -0400360 if (locks_in_grace() && !argp->reclaim) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 resp->status = nlm_lck_denied_grace_period;
362 return rpc_success;
363 }
364
365 /* Obtain client and file */
366 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700367 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368
369 /* Now try to create the share */
370 resp->status = cast_status(nlmsvc_share_file(host, file, argp));
371
372 dprintk("lockd: SHARE status %d\n", ntohl(resp->status));
373 nlm_release_host(host);
374 nlm_release_file(file);
375 return rpc_success;
376}
377
378/*
379 * UNSHARE: Release a DOS share.
380 */
Al Viro7111c662006-10-19 23:28:45 -0700381static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382nlmsvc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
383 struct nlm_res *resp)
384{
385 struct nlm_host *host;
386 struct nlm_file *file;
387
388 dprintk("lockd: UNSHARE called\n");
389
390 resp->cookie = argp->cookie;
391
392 /* Don't accept requests during grace period */
J. Bruce Fieldsaf558e32007-09-06 12:34:25 -0400393 if (locks_in_grace()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 resp->status = nlm_lck_denied_grace_period;
395 return rpc_success;
396 }
397
398 /* Obtain client and file */
399 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700400 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
402 /* Now try to unshare the file */
403 resp->status = cast_status(nlmsvc_unshare_file(host, file, argp));
404
405 dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status));
406 nlm_release_host(host);
407 nlm_release_file(file);
408 return rpc_success;
409}
410
411/*
412 * NM_LOCK: Create an unmonitored lock
413 */
Al Viro7111c662006-10-19 23:28:45 -0700414static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415nlmsvc_proc_nm_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
416 struct nlm_res *resp)
417{
418 dprintk("lockd: NM_LOCK called\n");
419
420 argp->monitor = 0; /* just clean the monitor flag */
421 return nlmsvc_proc_lock(rqstp, argp, resp);
422}
423
424/*
425 * FREE_ALL: Release all locks and shares held by client
426 */
Al Viro7111c662006-10-19 23:28:45 -0700427static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428nlmsvc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp,
429 void *resp)
430{
431 struct nlm_host *host;
432
433 /* Obtain client */
434 if (nlmsvc_retrieve_args(rqstp, argp, &host, NULL))
435 return rpc_success;
436
437 nlmsvc_free_host_resources(host);
438 nlm_release_host(host);
439 return rpc_success;
440}
441
442/*
443 * SM_NOTIFY: private callback from statd (not part of official NLM proto)
444 */
Al Viro7111c662006-10-19 23:28:45 -0700445static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
447 void *resp)
448{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 dprintk("lockd: SM_NOTIFY called\n");
Chuck Leverb85e4672008-10-03 12:50:44 -0400450
451 if (!nlm_privileged_requester(rqstp)) {
Chuck Leverad06e4b2007-02-12 00:53:32 -0800452 char buf[RPC_MAX_ADDRBUFLEN];
453 printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",
454 svc_print_addr(rqstp, buf, sizeof(buf)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 return rpc_system_err;
456 }
457
Chuck Lever7fefc9c2008-12-05 19:03:31 -0500458 nlm_host_rebooted(argp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 return rpc_success;
460}
461
462/*
463 * client sent a GRANTED_RES, let's remove the associated block
464 */
Al Viro7111c662006-10-19 23:28:45 -0700465static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466nlmsvc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp,
467 void *resp)
468{
469 if (!nlmsvc_ops)
470 return rpc_success;
471
472 dprintk("lockd: GRANTED_RES called\n");
473
Olaf Kirch39be4502006-10-04 02:16:03 -0700474 nlmsvc_grant_reply(&argp->cookie, argp->status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 return rpc_success;
476}
477
478/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 * NLM Server procedures.
480 */
481
482#define nlmsvc_encode_norep nlmsvc_encode_void
483#define nlmsvc_decode_norep nlmsvc_decode_void
484#define nlmsvc_decode_testres nlmsvc_decode_void
485#define nlmsvc_decode_lockres nlmsvc_decode_void
486#define nlmsvc_decode_unlockres nlmsvc_decode_void
487#define nlmsvc_decode_cancelres nlmsvc_decode_void
488#define nlmsvc_decode_grantedres nlmsvc_decode_void
489
490#define nlmsvc_proc_none nlmsvc_proc_null
491#define nlmsvc_proc_test_res nlmsvc_proc_null
492#define nlmsvc_proc_lock_res nlmsvc_proc_null
493#define nlmsvc_proc_cancel_res nlmsvc_proc_null
494#define nlmsvc_proc_unlock_res nlmsvc_proc_null
495
496struct nlm_void { int dummy; };
497
498#define PROC(name, xargt, xrest, argt, rest, respsize) \
499 { .pc_func = (svc_procfunc) nlmsvc_proc_##name, \
500 .pc_decode = (kxdrproc_t) nlmsvc_decode_##xargt, \
501 .pc_encode = (kxdrproc_t) nlmsvc_encode_##xrest, \
502 .pc_release = NULL, \
503 .pc_argsize = sizeof(struct nlm_##argt), \
504 .pc_ressize = sizeof(struct nlm_##rest), \
505 .pc_xdrressize = respsize, \
506 }
507
508#define Ck (1+XDR_QUADLEN(NLM_MAXCOOKIELEN)) /* cookie */
509#define St 1 /* status */
510#define No (1+1024/4) /* Net Obj */
511#define Rg 2 /* range - offset + size */
512
513struct svc_procedure nlmsvc_procedures[] = {
514 PROC(null, void, void, void, void, 1),
515 PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg),
516 PROC(lock, lockargs, res, args, res, Ck+St),
517 PROC(cancel, cancargs, res, args, res, Ck+St),
518 PROC(unlock, unlockargs, res, args, res, Ck+St),
519 PROC(granted, testargs, res, args, res, Ck+St),
520 PROC(test_msg, testargs, norep, args, void, 1),
521 PROC(lock_msg, lockargs, norep, args, void, 1),
522 PROC(cancel_msg, cancargs, norep, args, void, 1),
523 PROC(unlock_msg, unlockargs, norep, args, void, 1),
524 PROC(granted_msg, testargs, norep, args, void, 1),
525 PROC(test_res, testres, norep, res, void, 1),
526 PROC(lock_res, lockres, norep, res, void, 1),
527 PROC(cancel_res, cancelres, norep, res, void, 1),
528 PROC(unlock_res, unlockres, norep, res, void, 1),
529 PROC(granted_res, res, norep, res, void, 1),
530 /* statd callback */
531 PROC(sm_notify, reboot, void, reboot, void, 1),
532 PROC(none, void, void, void, void, 1),
533 PROC(none, void, void, void, void, 1),
534 PROC(none, void, void, void, void, 1),
535 PROC(share, shareargs, shareres, args, res, Ck+St+1),
536 PROC(unshare, shareargs, shareres, args, res, Ck+St+1),
537 PROC(nm_lock, lockargs, res, args, res, Ck+St),
538 PROC(free_all, notify, void, args, void, 0),
539
540};