aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-01-10 07:13:11 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-01-31 18:20:27 -0500
commit4929d1d33fdbe8385cdd49ccd23563e9ff247ff8 (patch)
tree6fde948b75129c0152f0cc07ed7e07efa1c9b11c
parent7bb782c6ac75898604eb547ed37b05c49b1edf21 (diff)
NFS: handle NFS idmap pipe PipeFS dentries by network namespace aware routines
This patch makes NFS idmap pipes dentries allocated and destroyed in network namespace context by PipeFS network namespace aware routines. Network namespace context is obtained from nfs_client structure. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/idmap.c61
1 files changed, 53 insertions, 8 deletions
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index 588d7da5b17..769274ed51c 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -431,6 +431,56 @@ static const struct rpc_pipe_ops idmap_upcall_ops = {
431 .destroy_msg = idmap_pipe_destroy_msg, 431 .destroy_msg = idmap_pipe_destroy_msg,
432}; 432};
433 433
434static void __nfs_idmap_unregister(struct rpc_pipe *pipe)
435{
436 if (pipe->dentry)
437 rpc_unlink(pipe->dentry);
438}
439
440static int __nfs_idmap_register(struct dentry *dir,
441 struct idmap *idmap,
442 struct rpc_pipe *pipe)
443{
444 struct dentry *dentry;
445
446 dentry = rpc_mkpipe_dentry(dir, "idmap", idmap, pipe);
447 if (IS_ERR(dentry))
448 return PTR_ERR(dentry);
449 pipe->dentry = dentry;
450 return 0;
451}
452
453static void nfs_idmap_unregister(struct nfs_client *clp,
454 struct rpc_pipe *pipe)
455{
456 struct net *net = clp->net;
457 struct super_block *pipefs_sb;
458
459 pipefs_sb = rpc_get_sb_net(net);
460 if (pipefs_sb) {
461 __nfs_idmap_unregister(pipe);
462 rpc_put_sb_net(net);
463 }
464}
465
466static int nfs_idmap_register(struct nfs_client *clp,
467 struct idmap *idmap,
468 struct rpc_pipe *pipe)
469{
470 struct net *net = clp->net;
471 struct super_block *pipefs_sb;
472 int err = 0;
473
474 pipefs_sb = rpc_get_sb_net(net);
475 if (pipefs_sb) {
476 if (clp->cl_rpcclient->cl_dentry)
477 err = __nfs_idmap_register(clp->cl_rpcclient->cl_dentry,
478 idmap, pipe);
479 rpc_put_sb_net(net);
480 }
481 return err;
482}
483
434int 484int
435nfs_idmap_new(struct nfs_client *clp) 485nfs_idmap_new(struct nfs_client *clp)
436{ 486{
@@ -450,12 +500,8 @@ nfs_idmap_new(struct nfs_client *clp)
450 kfree(idmap); 500 kfree(idmap);
451 return error; 501 return error;
452 } 502 }
453 503 error = nfs_idmap_register(clp, idmap, pipe);
454 if (clp->cl_rpcclient->cl_dentry) 504 if (error) {
455 pipe->dentry = rpc_mkpipe_dentry(clp->cl_rpcclient->cl_dentry,
456 "idmap", idmap, pipe);
457 if (IS_ERR(pipe->dentry)) {
458 error = PTR_ERR(pipe->dentry);
459 rpc_destroy_pipe_data(pipe); 505 rpc_destroy_pipe_data(pipe);
460 kfree(idmap); 506 kfree(idmap);
461 return error; 507 return error;
@@ -478,8 +524,7 @@ nfs_idmap_delete(struct nfs_client *clp)
478 524
479 if (!idmap) 525 if (!idmap)
480 return; 526 return;
481 if (idmap->idmap_pipe->dentry) 527 nfs_idmap_unregister(clp, idmap->idmap_pipe);
482 rpc_unlink(idmap->idmap_pipe->dentry);
483 rpc_destroy_pipe_data(idmap->idmap_pipe); 528 rpc_destroy_pipe_data(idmap->idmap_pipe);
484 clp->cl_idmap = NULL; 529 clp->cl_idmap = NULL;
485 kfree(idmap); 530 kfree(idmap);