aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/svc4proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/lockd/svc4proc.c')
-rw-r--r--fs/lockd/svc4proc.c85
1 files changed, 36 insertions, 49 deletions
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index a2dd9ccb9b32..0ce5c81ff507 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -24,22 +24,22 @@
24/* 24/*
25 * Obtain client and file from arguments 25 * Obtain client and file from arguments
26 */ 26 */
27static u32 27static __be32
28nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, 28nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
29 struct nlm_host **hostp, struct nlm_file **filp) 29 struct nlm_host **hostp, struct nlm_file **filp)
30{ 30{
31 struct nlm_host *host = NULL; 31 struct nlm_host *host = NULL;
32 struct nlm_file *file = NULL; 32 struct nlm_file *file = NULL;
33 struct nlm_lock *lock = &argp->lock; 33 struct nlm_lock *lock = &argp->lock;
34 u32 error = 0; 34 __be32 error = 0;
35 35
36 /* nfsd callbacks must have been installed for this procedure */ 36 /* nfsd callbacks must have been installed for this procedure */
37 if (!nlmsvc_ops) 37 if (!nlmsvc_ops)
38 return nlm_lck_denied_nolocks; 38 return nlm_lck_denied_nolocks;
39 39
40 /* Obtain host handle */ 40 /* Obtain host handle */
41 if (!(host = nlmsvc_lookup_host(rqstp)) 41 if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
42 || (argp->monitor && !host->h_monitored && nsm_monitor(host) < 0)) 42 || (argp->monitor && nsm_monitor(host) < 0))
43 goto no_locks; 43 goto no_locks;
44 *hostp = host; 44 *hostp = host;
45 45
@@ -68,7 +68,7 @@ no_locks:
68/* 68/*
69 * NULL: Test for presence of service 69 * NULL: Test for presence of service
70 */ 70 */
71static int 71static __be32
72nlm4svc_proc_null(struct svc_rqst *rqstp, void *argp, void *resp) 72nlm4svc_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
73{ 73{
74 dprintk("lockd: NULL called\n"); 74 dprintk("lockd: NULL called\n");
@@ -78,7 +78,7 @@ nlm4svc_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
78/* 78/*
79 * TEST: Check for conflicting lock 79 * TEST: Check for conflicting lock
80 */ 80 */
81static int 81static __be32
82nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp, 82nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
83 struct nlm_res *resp) 83 struct nlm_res *resp)
84{ 84{
@@ -96,7 +96,7 @@ nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
96 96
97 /* Obtain client and file */ 97 /* Obtain client and file */
98 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 98 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
99 return rpc_success; 99 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
100 100
101 /* Now check for conflicting locks */ 101 /* Now check for conflicting locks */
102 resp->status = nlmsvc_testlock(file, &argp->lock, &resp->lock); 102 resp->status = nlmsvc_testlock(file, &argp->lock, &resp->lock);
@@ -107,7 +107,7 @@ nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
107 return rpc_success; 107 return rpc_success;
108} 108}
109 109
110static int 110static __be32
111nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp, 111nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
112 struct nlm_res *resp) 112 struct nlm_res *resp)
113{ 113{
@@ -126,7 +126,7 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
126 126
127 /* Obtain client and file */ 127 /* Obtain client and file */
128 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 128 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
129 return rpc_success; 129 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
130 130
131#if 0 131#if 0
132 /* If supplied state doesn't match current state, we assume it's 132 /* If supplied state doesn't match current state, we assume it's
@@ -150,7 +150,7 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
150 return rpc_success; 150 return rpc_success;
151} 151}
152 152
153static int 153static __be32
154nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp, 154nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
155 struct nlm_res *resp) 155 struct nlm_res *resp)
156{ 156{
@@ -169,7 +169,7 @@ nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
169 169
170 /* Obtain client and file */ 170 /* Obtain client and file */
171 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 171 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
172 return rpc_success; 172 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
173 173
174 /* Try to cancel request. */ 174 /* Try to cancel request. */
175 resp->status = nlmsvc_cancel_blocked(file, &argp->lock); 175 resp->status = nlmsvc_cancel_blocked(file, &argp->lock);
@@ -183,7 +183,7 @@ nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp,
183/* 183/*
184 * UNLOCK: release a lock 184 * UNLOCK: release a lock
185 */ 185 */
186static int 186static __be32
187nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp, 187nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
188 struct nlm_res *resp) 188 struct nlm_res *resp)
189{ 189{
@@ -202,7 +202,7 @@ nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
202 202
203 /* Obtain client and file */ 203 /* Obtain client and file */
204 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 204 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
205 return rpc_success; 205 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
206 206
207 /* Now try to remove the lock */ 207 /* Now try to remove the lock */
208 resp->status = nlmsvc_unlock(file, &argp->lock); 208 resp->status = nlmsvc_unlock(file, &argp->lock);
@@ -217,7 +217,7 @@ nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp,
217 * GRANTED: A server calls us to tell that a process' lock request 217 * GRANTED: A server calls us to tell that a process' lock request
218 * was granted 218 * was granted
219 */ 219 */
220static int 220static __be32
221nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp, 221nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,
222 struct nlm_res *resp) 222 struct nlm_res *resp)
223{ 223{
@@ -253,14 +253,16 @@ static const struct rpc_call_ops nlm4svc_callback_ops = {
253 * because we send the callback before the reply proper. I hope this 253 * because we send the callback before the reply proper. I hope this
254 * doesn't break any clients. 254 * doesn't break any clients.
255 */ 255 */
256static int nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp, 256static __be32 nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp,
257 int (*func)(struct svc_rqst *, struct nlm_args *, struct nlm_res *)) 257 __be32 (*func)(struct svc_rqst *, struct nlm_args *, struct nlm_res *))
258{ 258{
259 struct nlm_host *host; 259 struct nlm_host *host;
260 struct nlm_rqst *call; 260 struct nlm_rqst *call;
261 int stat; 261 __be32 stat;
262 262
263 host = nlmsvc_lookup_host(rqstp); 263 host = nlmsvc_lookup_host(rqstp,
264 argp->lock.caller,
265 argp->lock.len);
264 if (host == NULL) 266 if (host == NULL)
265 return rpc_system_err; 267 return rpc_system_err;
266 268
@@ -280,35 +282,35 @@ static int nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *a
280 return rpc_success; 282 return rpc_success;
281} 283}
282 284
283static int nlm4svc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 285static __be32 nlm4svc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
284 void *resp) 286 void *resp)
285{ 287{
286 dprintk("lockd: TEST_MSG called\n"); 288 dprintk("lockd: TEST_MSG called\n");
287 return nlm4svc_callback(rqstp, NLMPROC_TEST_RES, argp, nlm4svc_proc_test); 289 return nlm4svc_callback(rqstp, NLMPROC_TEST_RES, argp, nlm4svc_proc_test);
288} 290}
289 291
290static int nlm4svc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 292static __be32 nlm4svc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
291 void *resp) 293 void *resp)
292{ 294{
293 dprintk("lockd: LOCK_MSG called\n"); 295 dprintk("lockd: LOCK_MSG called\n");
294 return nlm4svc_callback(rqstp, NLMPROC_LOCK_RES, argp, nlm4svc_proc_lock); 296 return nlm4svc_callback(rqstp, NLMPROC_LOCK_RES, argp, nlm4svc_proc_lock);
295} 297}
296 298
297static int nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 299static __be32 nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
298 void *resp) 300 void *resp)
299{ 301{
300 dprintk("lockd: CANCEL_MSG called\n"); 302 dprintk("lockd: CANCEL_MSG called\n");
301 return nlm4svc_callback(rqstp, NLMPROC_CANCEL_RES, argp, nlm4svc_proc_cancel); 303 return nlm4svc_callback(rqstp, NLMPROC_CANCEL_RES, argp, nlm4svc_proc_cancel);
302} 304}
303 305
304static int nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 306static __be32 nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
305 void *resp) 307 void *resp)
306{ 308{
307 dprintk("lockd: UNLOCK_MSG called\n"); 309 dprintk("lockd: UNLOCK_MSG called\n");
308 return nlm4svc_callback(rqstp, NLMPROC_UNLOCK_RES, argp, nlm4svc_proc_unlock); 310 return nlm4svc_callback(rqstp, NLMPROC_UNLOCK_RES, argp, nlm4svc_proc_unlock);
309} 311}
310 312
311static int nlm4svc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 313static __be32 nlm4svc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
312 void *resp) 314 void *resp)
313{ 315{
314 dprintk("lockd: GRANTED_MSG called\n"); 316 dprintk("lockd: GRANTED_MSG called\n");
@@ -318,7 +320,7 @@ static int nlm4svc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *arg
318/* 320/*
319 * SHARE: create a DOS share or alter existing share. 321 * SHARE: create a DOS share or alter existing share.
320 */ 322 */
321static int 323static __be32
322nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp, 324nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
323 struct nlm_res *resp) 325 struct nlm_res *resp)
324{ 326{
@@ -337,7 +339,7 @@ nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
337 339
338 /* Obtain client and file */ 340 /* Obtain client and file */
339 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 341 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
340 return rpc_success; 342 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
341 343
342 /* Now try to create the share */ 344 /* Now try to create the share */
343 resp->status = nlmsvc_share_file(host, file, argp); 345 resp->status = nlmsvc_share_file(host, file, argp);
@@ -351,7 +353,7 @@ nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp,
351/* 353/*
352 * UNSHARE: Release a DOS share. 354 * UNSHARE: Release a DOS share.
353 */ 355 */
354static int 356static __be32
355nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp, 357nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
356 struct nlm_res *resp) 358 struct nlm_res *resp)
357{ 359{
@@ -370,7 +372,7 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
370 372
371 /* Obtain client and file */ 373 /* Obtain client and file */
372 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 374 if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
373 return rpc_success; 375 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
374 376
375 /* Now try to lock the file */ 377 /* Now try to lock the file */
376 resp->status = nlmsvc_unshare_file(host, file, argp); 378 resp->status = nlmsvc_unshare_file(host, file, argp);
@@ -384,7 +386,7 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp,
384/* 386/*
385 * NM_LOCK: Create an unmonitored lock 387 * NM_LOCK: Create an unmonitored lock
386 */ 388 */
387static int 389static __be32
388nlm4svc_proc_nm_lock(struct svc_rqst *rqstp, struct nlm_args *argp, 390nlm4svc_proc_nm_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
389 struct nlm_res *resp) 391 struct nlm_res *resp)
390{ 392{
@@ -397,7 +399,7 @@ nlm4svc_proc_nm_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
397/* 399/*
398 * FREE_ALL: Release all locks and shares held by client 400 * FREE_ALL: Release all locks and shares held by client
399 */ 401 */
400static int 402static __be32
401nlm4svc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp, 403nlm4svc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp,
402 void *resp) 404 void *resp)
403{ 405{
@@ -415,15 +417,11 @@ nlm4svc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp,
415/* 417/*
416 * SM_NOTIFY: private callback from statd (not part of official NLM proto) 418 * SM_NOTIFY: private callback from statd (not part of official NLM proto)
417 */ 419 */
418static int 420static __be32
419nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, 421nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
420 void *resp) 422 void *resp)
421{ 423{
422 struct sockaddr_in saddr = rqstp->rq_addr; 424 struct sockaddr_in saddr = rqstp->rq_addr;
423 int vers = argp->vers;
424 int prot = argp->proto >> 1;
425
426 struct nlm_host *host;
427 425
428 dprintk("lockd: SM_NOTIFY called\n"); 426 dprintk("lockd: SM_NOTIFY called\n");
429 if (saddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK) 427 if (saddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK)
@@ -438,28 +436,17 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,
438 /* Obtain the host pointer for this NFS server and try to 436 /* Obtain the host pointer for this NFS server and try to
439 * reclaim all locks we hold on this server. 437 * reclaim all locks we hold on this server.
440 */ 438 */
439 memset(&saddr, 0, sizeof(saddr));
441 saddr.sin_addr.s_addr = argp->addr; 440 saddr.sin_addr.s_addr = argp->addr;
441 nlm_host_rebooted(&saddr, argp->mon, argp->len, argp->state);
442 442
443 if ((argp->proto & 1)==0) {
444 if ((host = nlmclnt_lookup_host(&saddr, prot, vers)) != NULL) {
445 nlmclnt_recovery(host, argp->state);
446 nlm_release_host(host);
447 }
448 } else {
449 /* If we run on an NFS server, delete all locks held by the client */
450
451 if ((host = nlm_lookup_host(1, &saddr, prot, vers)) != NULL) {
452 nlmsvc_free_host_resources(host);
453 nlm_release_host(host);
454 }
455 }
456 return rpc_success; 443 return rpc_success;
457} 444}
458 445
459/* 446/*
460 * client sent a GRANTED_RES, let's remove the associated block 447 * client sent a GRANTED_RES, let's remove the associated block
461 */ 448 */
462static int 449static __be32
463nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp, 450nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp,
464 void *resp) 451 void *resp)
465{ 452{
@@ -468,7 +455,7 @@ nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp,
468 455
469 dprintk("lockd: GRANTED_RES called\n"); 456 dprintk("lockd: GRANTED_RES called\n");
470 457
471 nlmsvc_grant_reply(rqstp, &argp->cookie, argp->status); 458 nlmsvc_grant_reply(&argp->cookie, argp->status);
472 return rpc_success; 459 return rpc_success;
473} 460}
474 461