aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4callback.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd/nfs4callback.c')
-rw-r--r--fs/nfsd/nfs4callback.c89
1 files changed, 27 insertions, 62 deletions
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 31d6633c7fe4..9d536a8cb379 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -39,6 +39,7 @@
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <linux/kthread.h>
42#include <linux/sunrpc/xdr.h> 43#include <linux/sunrpc/xdr.h>
43#include <linux/sunrpc/svc.h> 44#include <linux/sunrpc/svc.h>
44#include <linux/sunrpc/clnt.h> 45#include <linux/sunrpc/clnt.h>
@@ -343,26 +344,28 @@ static struct rpc_version * nfs_cb_version[] = {
343 &nfs_cb_version4, 344 &nfs_cb_version4,
344}; 345};
345 346
346/* 347/* Reference counting, callback cleanup, etc., all look racy as heck.
347 * Use the SETCLIENTID credential 348 * And why is cb_set an atomic? */
348 */ 349
349static struct rpc_cred * 350static int do_probe_callback(void *data)
350nfsd4_lookupcred(struct nfs4_client *clp, int taskflags)
351{ 351{
352 struct auth_cred acred; 352 struct nfs4_client *clp = data;
353 struct rpc_clnt *clnt = clp->cl_callback.cb_client; 353 struct nfs4_callback *cb = &clp->cl_callback;
354 struct rpc_cred *ret; 354 struct rpc_message msg = {
355 355 .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL],
356 get_group_info(clp->cl_cred.cr_group_info); 356 .rpc_argp = clp,
357 acred.uid = clp->cl_cred.cr_uid; 357 };
358 acred.gid = clp->cl_cred.cr_gid; 358 int status;
359 acred.group_info = clp->cl_cred.cr_group_info; 359
360 360 status = rpc_call_sync(cb->cb_client, &msg, RPC_TASK_SOFT);
361 dprintk("NFSD: looking up %s cred\n", 361
362 clnt->cl_auth->au_ops->au_name); 362 if (status) {
363 ret = rpcauth_lookup_credcache(clnt->cl_auth, &acred, taskflags); 363 rpc_shutdown_client(cb->cb_client);
364 put_group_info(clp->cl_cred.cr_group_info); 364 cb->cb_client = NULL;
365 return ret; 365 } else
366 atomic_set(&cb->cb_set, 1);
367 put_nfs4_client(clp);
368 return 0;
366} 369}
367 370
368/* 371/*
@@ -390,11 +393,7 @@ nfsd4_probe_callback(struct nfs4_client *clp)
390 .authflavor = RPC_AUTH_UNIX, /* XXX: need AUTH_GSS... */ 393 .authflavor = RPC_AUTH_UNIX, /* XXX: need AUTH_GSS... */
391 .flags = (RPC_CLNT_CREATE_NOPING), 394 .flags = (RPC_CLNT_CREATE_NOPING),
392 }; 395 };
393 struct rpc_message msg = { 396 struct task_struct *t;
394 .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL],
395 .rpc_argp = clp,
396 };
397 int status;
398 397
399 if (atomic_read(&cb->cb_set)) 398 if (atomic_read(&cb->cb_set))
400 return; 399 return;
@@ -426,16 +425,11 @@ nfsd4_probe_callback(struct nfs4_client *clp)
426 /* the task holds a reference to the nfs4_client struct */ 425 /* the task holds a reference to the nfs4_client struct */
427 atomic_inc(&clp->cl_count); 426 atomic_inc(&clp->cl_count);
428 427
429 msg.rpc_cred = nfsd4_lookupcred(clp,0); 428 t = kthread_run(do_probe_callback, clp, "nfs4_cb_probe");
430 if (IS_ERR(msg.rpc_cred))
431 goto out_release_clp;
432 status = rpc_call_async(cb->cb_client, &msg, RPC_TASK_ASYNC, &nfs4_cb_null_ops, NULL);
433 put_rpccred(msg.rpc_cred);
434 429
435 if (status != 0) { 430 if (IS_ERR(t))
436 dprintk("NFSD: asynchronous NFSPROC4_CB_NULL failed!\n");
437 goto out_release_clp; 431 goto out_release_clp;
438 } 432
439 return; 433 return;
440 434
441out_release_clp: 435out_release_clp:
@@ -447,30 +441,6 @@ out_err:
447 (int)clp->cl_name.len, clp->cl_name.data); 441 (int)clp->cl_name.len, clp->cl_name.data);
448} 442}
449 443
450static void
451nfs4_cb_null(struct rpc_task *task, void *dummy)
452{
453 struct nfs4_client *clp = (struct nfs4_client *)task->tk_msg.rpc_argp;
454 struct nfs4_callback *cb = &clp->cl_callback;
455 __be32 addr = htonl(cb->cb_addr);
456
457 dprintk("NFSD: nfs4_cb_null task->tk_status %d\n", task->tk_status);
458
459 if (task->tk_status < 0) {
460 dprintk("NFSD: callback establishment to client %.*s failed\n",
461 (int)clp->cl_name.len, clp->cl_name.data);
462 goto out;
463 }
464 atomic_set(&cb->cb_set, 1);
465 dprintk("NFSD: callback set to client %u.%u.%u.%u\n", NIPQUAD(addr));
466out:
467 put_nfs4_client(clp);
468}
469
470static const struct rpc_call_ops nfs4_cb_null_ops = {
471 .rpc_call_done = nfs4_cb_null,
472};
473
474/* 444/*
475 * called with dp->dl_count inc'ed. 445 * called with dp->dl_count inc'ed.
476 * nfs4_lock_state() may or may not have been called. 446 * nfs4_lock_state() may or may not have been called.
@@ -491,10 +461,6 @@ nfsd4_cb_recall(struct nfs4_delegation *dp)
491 if ((!atomic_read(&clp->cl_callback.cb_set)) || !clnt) 461 if ((!atomic_read(&clp->cl_callback.cb_set)) || !clnt)
492 return; 462 return;
493 463
494 msg.rpc_cred = nfsd4_lookupcred(clp, 0);
495 if (IS_ERR(msg.rpc_cred))
496 goto out;
497
498 cbr->cbr_trunc = 0; /* XXX need to implement truncate optimization */ 464 cbr->cbr_trunc = 0; /* XXX need to implement truncate optimization */
499 cbr->cbr_dp = dp; 465 cbr->cbr_dp = dp;
500 466
@@ -515,13 +481,12 @@ nfsd4_cb_recall(struct nfs4_delegation *dp)
515 status = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT); 481 status = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT);
516 } 482 }
517out_put_cred: 483out_put_cred:
518 put_rpccred(msg.rpc_cred);
519out:
520 if (status == -EIO) 484 if (status == -EIO)
521 atomic_set(&clp->cl_callback.cb_set, 0); 485 atomic_set(&clp->cl_callback.cb_set, 0);
522 /* Success or failure, now we're either waiting for lease expiration 486 /* Success or failure, now we're either waiting for lease expiration
523 * or deleg_return. */ 487 * or deleg_return. */
524 dprintk("NFSD: nfs4_cb_recall: dp %p dl_flock %p dl_count %d\n",dp, dp->dl_flock, atomic_read(&dp->dl_count)); 488 dprintk("NFSD: nfs4_cb_recall: dp %p dl_flock %p dl_count %d\n",dp, dp->dl_flock, atomic_read(&dp->dl_count));
489 put_nfs4_client(clp);
525 nfs4_put_delegation(dp); 490 nfs4_put_delegation(dp);
526 return; 491 return;
527} 492}