]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - net/sunrpc/clnt.c
[PATCH] RPC,NFS: new rpc_pipefs patch
[mv-sheeva.git] / net / sunrpc / clnt.c
index 0d1b010a4a01194a2026f3d05c6e48f3872e8a4a..63bf591310e0ecac8ad172d3358afb4a709f8098 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  linux/net/sunrpc/rpcclnt.c
+ *  linux/net/sunrpc/clnt.c
  *
  *  This file contains the high-level RPC interface.
  *  It is modeled as a finite state machine to support both synchronous
@@ -67,26 +67,42 @@ static u32 *        call_verify(struct rpc_task *task);
 static int
 rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
 {
-       static uint32_t clntid;
+       static unsigned int clntid;
+       char name[128];
        int error;
 
        if (dir_name == NULL)
                return 0;
-       for (;;) {
-               snprintf(clnt->cl_pathname, sizeof(clnt->cl_pathname),
-                               "%s/clnt%x", dir_name,
-                               (unsigned int)clntid++);
-               clnt->cl_pathname[sizeof(clnt->cl_pathname) - 1] = '\0';
-               clnt->cl_dentry = rpc_mkdir(clnt->cl_pathname, clnt);
-               if (!IS_ERR(clnt->cl_dentry))
-                       return 0;
+
+ retry_parent:
+       clnt->__cl_parent_dentry = rpc_mkdir(NULL, dir_name, NULL);
+       if (IS_ERR(clnt->__cl_parent_dentry)) {
+               error = PTR_ERR(clnt->__cl_parent_dentry);
+               if (error == -EEXIST)
+                       goto retry_parent; /* XXX(hch): WTF? */
+       
+               printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n",
+                               dir_name, error);
+               return error;
+       }
+
+
+ retry_child:
+       snprintf(name, sizeof(name), "clnt%x", clntid++);
+       name[sizeof(name) - 1] = '\0';
+
+       clnt->cl_dentry = rpc_mkdir(clnt->__cl_parent_dentry, name, clnt);
+       if (IS_ERR(clnt->cl_dentry)) {
                error = PTR_ERR(clnt->cl_dentry);
-               if (error != -EEXIST) {
-                       printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n",
-                                       clnt->cl_pathname, error);
-                       return error;
-               }
+               if (error == -EEXIST)
+                       goto retry_child;
+               printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n",
+                               name, error);
+               rpc_rmdir(clnt->__cl_parent_dentry);
+               return error;
        }
+
+       return 0;
 }
 
 /*
@@ -174,7 +190,8 @@ rpc_new_client(struct rpc_xprt *xprt, char *servname,
        return clnt;
 
 out_no_auth:
-       rpc_rmdir(clnt->cl_pathname);
+       rpc_rmdir(clnt->cl_dentry);
+       rpc_rmdir(clnt->__cl_parent_dentry);
 out_no_path:
        if (clnt->cl_server != clnt->cl_inline_name)
                kfree(clnt->cl_server);
@@ -302,8 +319,10 @@ rpc_destroy_client(struct rpc_clnt *clnt)
                rpc_destroy_client(clnt->cl_parent);
                goto out_free;
        }
-       if (clnt->cl_pathname[0])
-               rpc_rmdir(clnt->cl_pathname);
+       if (clnt->cl_dentry)
+               rpc_rmdir(clnt->cl_dentry);
+       if (clnt->__cl_parent_dentry)
+               rpc_rmdir(clnt->__cl_parent_dentry);
        if (clnt->cl_xprt) {
                xprt_destroy(clnt->cl_xprt);
                clnt->cl_xprt = NULL;
@@ -517,14 +536,8 @@ void
 rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize)
 {
        struct rpc_xprt *xprt = clnt->cl_xprt;
-
-       xprt->sndsize = 0;
-       if (sndsize)
-               xprt->sndsize = sndsize + RPC_SLACK_SPACE;
-       xprt->rcvsize = 0;
-       if (rcvsize)
-               xprt->rcvsize = rcvsize + RPC_SLACK_SPACE;
-       xprt->ops->set_buffer_size(xprt);
+       if (xprt->ops->set_buffer_size)
+               xprt->ops->set_buffer_size(xprt, sndsize, rcvsize);
 }
 
 /*
@@ -740,7 +753,7 @@ call_bind(struct rpc_task *task)
        task->tk_action = call_connect;
        if (!clnt->cl_port) {
                task->tk_action = call_bind_status;
-               task->tk_timeout = RPC_CONNECT_TIMEOUT;
+               task->tk_timeout = task->tk_xprt->bind_timeout;
                rpc_getport(task, clnt);
        }
 }
@@ -1075,13 +1088,12 @@ static u32 *
 call_header(struct rpc_task *task)
 {
        struct rpc_clnt *clnt = task->tk_client;
-       struct rpc_xprt *xprt = clnt->cl_xprt;
        struct rpc_rqst *req = task->tk_rqstp;
        u32             *p = req->rq_svec[0].iov_base;
 
        /* FIXME: check buffer size? */
-       if (xprt->stream)
-               *p++ = 0;               /* fill in later */
+
+       p = xprt_skip_transport_header(task->tk_xprt, p);
        *p++ = req->rq_xid;             /* XID */
        *p++ = htonl(RPC_CALL);         /* CALL */
        *p++ = htonl(RPC_VERSION);      /* RPC version */