aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/blocklayout/blocklayout.c61
1 files changed, 49 insertions, 12 deletions
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 848660fd58c4..80b0c4a40485 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -1025,10 +1025,55 @@ static const struct rpc_pipe_ops bl_upcall_ops = {
1025 .destroy_msg = bl_pipe_destroy_msg, 1025 .destroy_msg = bl_pipe_destroy_msg,
1026}; 1026};
1027 1027
1028static struct dentry *nfs4blocklayout_register_sb(struct super_block *sb,
1029 struct rpc_pipe *pipe)
1030{
1031 struct dentry *dir, *dentry;
1032
1033 dir = rpc_d_lookup_sb(sb, NFS_PIPE_DIRNAME);
1034 if (dir == NULL)
1035 return ERR_PTR(-ENOENT);
1036 dentry = rpc_mkpipe_dentry(dir, "blocklayout", NULL, pipe);
1037 dput(dir);
1038 return dentry;
1039}
1040
1041static void nfs4blocklayout_unregister_sb(struct super_block *sb,
1042 struct rpc_pipe *pipe)
1043{
1044 if (pipe->dentry)
1045 rpc_unlink(pipe->dentry);
1046}
1047
1048static struct dentry *nfs4blocklayout_register_net(struct net *net,
1049 struct rpc_pipe *pipe)
1050{
1051 struct super_block *pipefs_sb;
1052 struct dentry *dentry;
1053
1054 pipefs_sb = rpc_get_sb_net(net);
1055 if (!pipefs_sb)
1056 return ERR_PTR(-ENOENT);
1057 dentry = nfs4blocklayout_register_sb(pipefs_sb, pipe);
1058 rpc_put_sb_net(net);
1059 return dentry;
1060}
1061
1062static void nfs4blocklayout_unregister_net(struct net *net,
1063 struct rpc_pipe *pipe)
1064{
1065 struct super_block *pipefs_sb;
1066
1067 pipefs_sb = rpc_get_sb_net(net);
1068 if (pipefs_sb) {
1069 nfs4blocklayout_unregister_sb(pipefs_sb, pipe);
1070 rpc_put_sb_net(net);
1071 }
1072}
1073
1028static int __init nfs4blocklayout_init(void) 1074static int __init nfs4blocklayout_init(void)
1029{ 1075{
1030 struct vfsmount *mnt; 1076 struct vfsmount *mnt;
1031 struct path path;
1032 int ret; 1077 int ret;
1033 1078
1034 dprintk("%s: NFSv4 Block Layout Driver Registering...\n", __func__); 1079 dprintk("%s: NFSv4 Block Layout Driver Registering...\n", __func__);
@@ -1044,21 +1089,13 @@ static int __init nfs4blocklayout_init(void)
1044 ret = PTR_ERR(mnt); 1089 ret = PTR_ERR(mnt);
1045 goto out_remove; 1090 goto out_remove;
1046 } 1091 }
1047
1048 ret = vfs_path_lookup(mnt->mnt_root,
1049 mnt,
1050 NFS_PIPE_DIRNAME, 0, &path);
1051 if (ret)
1052 goto out_putrpc;
1053
1054 bl_device_pipe = rpc_mkpipe_data(&bl_upcall_ops, 0); 1092 bl_device_pipe = rpc_mkpipe_data(&bl_upcall_ops, 0);
1055 path_put(&path);
1056 if (IS_ERR(bl_device_pipe)) { 1093 if (IS_ERR(bl_device_pipe)) {
1057 ret = PTR_ERR(bl_device_pipe); 1094 ret = PTR_ERR(bl_device_pipe);
1058 goto out_putrpc; 1095 goto out_putrpc;
1059 } 1096 }
1060 bl_device_pipe->dentry = rpc_mkpipe_dentry(path.dentry, "blocklayout", 1097 bl_device_pipe->dentry = nfs4blocklayout_register_net(&init_net,
1061 NULL, bl_device_pipe); 1098 bl_device_pipe);
1062 if (IS_ERR(bl_device_pipe->dentry)) { 1099 if (IS_ERR(bl_device_pipe->dentry)) {
1063 ret = PTR_ERR(bl_device_pipe->dentry); 1100 ret = PTR_ERR(bl_device_pipe->dentry);
1064 goto out_destroy_pipe; 1101 goto out_destroy_pipe;
@@ -1081,7 +1118,7 @@ static void __exit nfs4blocklayout_exit(void)
1081 __func__); 1118 __func__);
1082 1119
1083 pnfs_unregister_layoutdriver(&blocklayout_type); 1120 pnfs_unregister_layoutdriver(&blocklayout_type);
1084 rpc_unlink(bl_device_pipe->dentry); 1121 nfs4blocklayout_unregister_net(&init_net, bl_device_pipe);
1085 rpc_destroy_pipe_data(bl_device_pipe); 1122 rpc_destroy_pipe_data(bl_device_pipe);
1086 rpc_put_mount(); 1123 rpc_put_mount();
1087} 1124}