netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stanislav Kinsbursky <skinsbursky@parallels.com>
To: Trond.Myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org, xemul@parallels.com, neilb@suse.de,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	jbottomley@parallels.com, bfields@fieldses.org,
	davem@davemloft.net, devel@openvz.org
Subject: [PATCH 5/6] NFS: handle NFS idmap pipe PipeFS dentries by network namespace aware routines
Date: Mon, 28 Nov 2011 17:34:02 +0300	[thread overview]
Message-ID: <20111128133402.4251.18289.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20111128132805.4251.15252.stgit@localhost6.localdomain6>

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>

---
 fs/nfs/idmap.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index 60698a1..0680f63 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -350,6 +350,56 @@ static const struct rpc_pipe_ops idmap_upcall_ops = {
 	.destroy_msg	= idmap_pipe_destroy_msg,
 };
 
+static void __nfs_idmap_unregister(struct rpc_pipe *pipe)
+{
+	if (pipe->dentry)
+		rpc_unlink(pipe->dentry);
+}
+
+static int __nfs_idmap_register(struct dentry *dir,
+				     struct idmap *idmap,
+				     struct rpc_pipe *pipe)
+{
+	struct dentry *dentry;
+
+	dentry = rpc_mkpipe_dentry(dir, "idmap", idmap, pipe);
+	if (IS_ERR(dentry))
+		return PTR_ERR(dentry);
+	pipe->dentry = dentry;
+	return 0;
+}
+
+static void nfs_idmap_unregister(struct nfs_client *clp,
+				      struct rpc_pipe *pipe)
+{
+	struct net *net = clp->net;
+	struct super_block *pipefs_sb;
+
+	pipefs_sb = rpc_get_sb_net(net);
+	if (pipefs_sb) {
+		__nfs_idmap_unregister(pipe);
+		rpc_put_sb_net(net);
+	}
+}
+
+static int nfs_idmap_register(struct nfs_client *clp,
+				   struct idmap *idmap,
+				   struct rpc_pipe *pipe)
+{
+	struct net *net = clp->net;
+	struct super_block *pipefs_sb;
+	int err = 0;
+
+	pipefs_sb = rpc_get_sb_net(net);
+	if (pipefs_sb) {
+		if (clp->cl_rpcclient->cl_dentry)
+			err = __nfs_idmap_register(clp->cl_rpcclient->cl_dentry,
+						   idmap, pipe);
+		rpc_put_sb_net(net);
+	}
+	return err;
+}
+
 int
 nfs_idmap_new(struct nfs_client *clp)
 {
@@ -369,12 +419,8 @@ nfs_idmap_new(struct nfs_client *clp)
 		kfree(idmap);
 		return error;
 	}
-
-	if (clp->cl_rpcclient->cl_dentry)
-		pipe->dentry = rpc_mkpipe_dentry(clp->cl_rpcclient->cl_dentry,
-				"idmap", idmap, pipe);
-	if (IS_ERR(pipe->dentry)) {
-		error = PTR_ERR(pipe->dentry);
+	error = nfs_idmap_register(clp, idmap, pipe);
+	if (error) {
 		rpc_destroy_pipe_data(pipe);
 		kfree(idmap);
 		return error;
@@ -397,8 +443,7 @@ nfs_idmap_delete(struct nfs_client *clp)
 
 	if (!idmap)
 		return;
-	if (idmap->idmap_pipe->dentry)
-		rpc_unlink(idmap->idmap_pipe->dentry);
+	nfs_idmap_unregister(clp, idmap->idmap_pipe);
 	rpc_destroy_pipe_data(idmap->idmap_pipe);
 	clp->cl_idmap = NULL;
 	kfree(idmap);

  parent reply	other threads:[~2011-11-28 14:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-28 14:33 [PATCH 0/6] NFS: create clients and IDMAP pipes per network namespace Stanislav Kinsbursky
2011-11-28 14:33 ` [PATCH 1/6] SUNRPC: fix pipe->ops cleanup on pipe dentry unlink Stanislav Kinsbursky
2011-11-28 14:33 ` [PATCH 2/6] NFS: make NFS client allocated per network namespace context Stanislav Kinsbursky
2011-11-28 14:33 ` [PATCH 3/6] NFS: pass NFS client owner network namespace to RPC client creation routine Stanislav Kinsbursky
2011-11-28 14:33 ` [PATCH 4/6] NFS: create callback transports in parent transport network namespace Stanislav Kinsbursky
2011-11-28 14:34 ` Stanislav Kinsbursky [this message]
2011-11-28 14:34 ` [PATCH 6/6] NFS: idmap PipeFS notifier introduced Stanislav Kinsbursky
2011-12-30 22:54   ` Trond Myklebust
2012-01-10 10:27     ` Stanislav Kinsbursky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111128133402.4251.18289.stgit@localhost6.localdomain6 \
    --to=skinsbursky@parallels.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=davem@davemloft.net \
    --cc=devel@openvz.org \
    --cc=jbottomley@parallels.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=xemul@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).