SUNRPC: hold current network namespace while pipefs superblock is active
authorStanislav Kinsbursky <skinsbursky@parallels.com>
Mon, 26 Dec 2011 12:39:04 +0000 (15:39 +0300)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 31 Jan 2012 23:20:23 +0000 (18:20 -0500)
We want to be sure that network namespace is still alive while we have pipefs
mounted.
This will be required later, when RPC pipefs will be mounting only from
user-space context.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/rpc_pipe.c

index e32e6b8c006d641d3b3b0772f64645ad2d75515e..f628b0f48a87c04f6cf384356148e6d9f5029c35 100644 (file)
@@ -27,6 +27,9 @@
 #include <linux/workqueue.h>
 #include <linux/sunrpc/rpc_pipe_fs.h>
 #include <linux/sunrpc/cache.h>
+#include <linux/nsproxy.h>
+
+#include "netns.h"
 
 static struct vfsmount *rpc_mnt __read_mostly;
 static int rpc_mount_count;
@@ -1011,6 +1014,7 @@ rpc_fill_super(struct super_block *sb, void *data, int silent)
        }
        if (rpc_populate(root, files, RPCAUTH_lockd, RPCAUTH_RootEOF, NULL))
                return -ENOMEM;
+       sb->s_fs_info = get_net(net);
        return 0;
 }
 
@@ -1021,11 +1025,19 @@ rpc_mount(struct file_system_type *fs_type,
        return mount_ns(fs_type, flags, current->nsproxy->net_ns, rpc_fill_super);
 }
 
+void rpc_kill_sb(struct super_block *sb)
+{
+       struct net *net = sb->s_fs_info;
+
+       put_net(net);
+       kill_litter_super(sb);
+}
+
 static struct file_system_type rpc_pipe_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "rpc_pipefs",
        .mount          = rpc_mount,
-       .kill_sb        = kill_litter_super,
+       .kill_sb        = rpc_kill_sb,
 };
 
 static void