aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/clnt.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/clnt.c')
-rw-r--r--net/sunrpc/clnt.c53
1 files changed, 36 insertions, 17 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 5a8f01d726e9..63bf591310e0 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -67,26 +67,42 @@ static u32 * call_verify(struct rpc_task *task);
67static int 67static int
68rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) 68rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
69{ 69{
70 static uint32_t clntid; 70 static unsigned int clntid;
71 char name[128];
71 int error; 72 int error;
72 73
73 if (dir_name == NULL) 74 if (dir_name == NULL)
74 return 0; 75 return 0;
75 for (;;) { 76
76 snprintf(clnt->cl_pathname, sizeof(clnt->cl_pathname), 77 retry_parent:
77 "%s/clnt%x", dir_name, 78 clnt->__cl_parent_dentry = rpc_mkdir(NULL, dir_name, NULL);
78 (unsigned int)clntid++); 79 if (IS_ERR(clnt->__cl_parent_dentry)) {
79 clnt->cl_pathname[sizeof(clnt->cl_pathname) - 1] = '\0'; 80 error = PTR_ERR(clnt->__cl_parent_dentry);
80 clnt->cl_dentry = rpc_mkdir(clnt->cl_pathname, clnt); 81 if (error == -EEXIST)
81 if (!IS_ERR(clnt->cl_dentry)) 82 goto retry_parent; /* XXX(hch): WTF? */
82 return 0; 83
84 printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n",
85 dir_name, error);
86 return error;
87 }
88
89
90 retry_child:
91 snprintf(name, sizeof(name), "clnt%x", clntid++);
92 name[sizeof(name) - 1] = '\0';
93
94 clnt->cl_dentry = rpc_mkdir(clnt->__cl_parent_dentry, name, clnt);
95 if (IS_ERR(clnt->cl_dentry)) {
83 error = PTR_ERR(clnt->cl_dentry); 96 error = PTR_ERR(clnt->cl_dentry);
84 if (error != -EEXIST) { 97 if (error == -EEXIST)
85 printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n", 98 goto retry_child;
86 clnt->cl_pathname, error); 99 printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n",
87 return error; 100 name, error);
88 } 101 rpc_rmdir(clnt->__cl_parent_dentry);
102 return error;
89 } 103 }
104
105 return 0;
90} 106}
91 107
92/* 108/*
@@ -174,7 +190,8 @@ rpc_new_client(struct rpc_xprt *xprt, char *servname,
174 return clnt; 190 return clnt;
175 191
176out_no_auth: 192out_no_auth:
177 rpc_rmdir(clnt->cl_pathname); 193 rpc_rmdir(clnt->cl_dentry);
194 rpc_rmdir(clnt->__cl_parent_dentry);
178out_no_path: 195out_no_path:
179 if (clnt->cl_server != clnt->cl_inline_name) 196 if (clnt->cl_server != clnt->cl_inline_name)
180 kfree(clnt->cl_server); 197 kfree(clnt->cl_server);
@@ -302,8 +319,10 @@ rpc_destroy_client(struct rpc_clnt *clnt)
302 rpc_destroy_client(clnt->cl_parent); 319 rpc_destroy_client(clnt->cl_parent);
303 goto out_free; 320 goto out_free;
304 } 321 }
305 if (clnt->cl_pathname[0]) 322 if (clnt->cl_dentry)
306 rpc_rmdir(clnt->cl_pathname); 323 rpc_rmdir(clnt->cl_dentry);
324 if (clnt->__cl_parent_dentry)
325 rpc_rmdir(clnt->__cl_parent_dentry);
307 if (clnt->cl_xprt) { 326 if (clnt->cl_xprt) {
308 xprt_destroy(clnt->cl_xprt); 327 xprt_destroy(clnt->cl_xprt);
309 clnt->cl_xprt = NULL; 328 clnt->cl_xprt = NULL;