Commit 4929d1d33fdbe8385cdd49ccd23563e9ff247ff8

Authored by Stanislav Kinsbursky
Committed by Trond Myklebust
1 parent 7bb782c6ac

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>

Showing 1 changed file with 53 additions and 8 deletions Side-by-side Diff

... ... @@ -431,6 +431,56 @@
431 431 .destroy_msg = idmap_pipe_destroy_msg,
432 432 };
433 433  
  434 +static void __nfs_idmap_unregister(struct rpc_pipe *pipe)
  435 +{
  436 + if (pipe->dentry)
  437 + rpc_unlink(pipe->dentry);
  438 +}
  439 +
  440 +static 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 +
  453 +static 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 +
  466 +static 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 +
434 484 int
435 485 nfs_idmap_new(struct nfs_client *clp)
436 486 {
... ... @@ -450,12 +500,8 @@
450 500 kfree(idmap);
451 501 return error;
452 502 }
453   -
454   - if (clp->cl_rpcclient->cl_dentry)
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);
  503 + error = nfs_idmap_register(clp, idmap, pipe);
  504 + if (error) {
459 505 rpc_destroy_pipe_data(pipe);
460 506 kfree(idmap);
461 507 return error;
... ... @@ -478,8 +524,7 @@
478 524  
479 525 if (!idmap)
480 526 return;
481   - if (idmap->idmap_pipe->dentry)
482   - rpc_unlink(idmap->idmap_pipe->dentry);
  527 + nfs_idmap_unregister(clp, idmap->idmap_pipe);
483 528 rpc_destroy_pipe_data(idmap->idmap_pipe);
484 529 clp->cl_idmap = NULL;
485 530 kfree(idmap);