linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / net / sunrpc / clnt.c
index 3e19d32..d784797 100644 (file)
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/utsname.h>
-#include <linux/workqueue.h>
 
 #include <linux/sunrpc/clnt.h>
+#include <linux/workqueue.h>
 #include <linux/sunrpc/rpc_pipe_fs.h>
-#include <linux/sunrpc/metrics.h>
+
+#include <linux/nfs.h>
 
 
 #define RPC_SLACK_SPACE                (1024)  /* total overkill */
@@ -70,15 +71,8 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
        static uint32_t clntid;
        int error;
 
-       clnt->cl_vfsmnt = ERR_PTR(-ENOENT);
-       clnt->cl_dentry = ERR_PTR(-ENOENT);
        if (dir_name == NULL)
                return 0;
-
-       clnt->cl_vfsmnt = rpc_get_mount();
-       if (IS_ERR(clnt->cl_vfsmnt))
-               return PTR_ERR(clnt->cl_vfsmnt);
-
        for (;;) {
                snprintf(clnt->cl_pathname, sizeof(clnt->cl_pathname),
                                "%s/clnt%x", dir_name,
@@ -91,7 +85,6 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
                if (error != -EEXIST) {
                        printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n",
                                        clnt->cl_pathname, error);
-                       rpc_put_mount();
                        return error;
                }
        }
@@ -125,9 +118,10 @@ rpc_new_client(struct rpc_xprt *xprt, char *servname,
                goto out_err;
 
        err = -ENOMEM;
-       clnt = kzalloc(sizeof(*clnt), GFP_KERNEL);
+       clnt = kmalloc(sizeof(*clnt), GFP_KERNEL);
        if (!clnt)
                goto out_err;
+       memset(clnt, 0, sizeof(*clnt));
        atomic_set(&clnt->cl_users, 0);
        atomic_set(&clnt->cl_count, 1);
        clnt->cl_parent = clnt;
@@ -153,7 +147,6 @@ rpc_new_client(struct rpc_xprt *xprt, char *servname,
        clnt->cl_vers     = version->number;
        clnt->cl_prot     = xprt->prot;
        clnt->cl_stats    = program->stats;
-       clnt->cl_metrics  = rpc_alloc_iostats(clnt);
        rpc_init_wait_queue(&clnt->cl_pmap_default.pm_bindwait, "bindwait");
 
        if (!clnt->cl_port)
@@ -182,10 +175,7 @@ rpc_new_client(struct rpc_xprt *xprt, char *servname,
        return clnt;
 
 out_no_auth:
-       if (!IS_ERR(clnt->cl_dentry)) {
-               rpc_rmdir(clnt->cl_dentry);
-               rpc_put_mount();
-       }
+       rpc_rmdir(clnt->cl_pathname);
 out_no_path:
        if (clnt->cl_server != clnt->cl_inline_name)
                kfree(clnt->cl_server);
@@ -250,13 +240,11 @@ rpc_clone_client(struct rpc_clnt *clnt)
        new->cl_autobind = 0;
        new->cl_oneshot = 0;
        new->cl_dead = 0;
-       if (!IS_ERR(new->cl_dentry))
-               dget(new->cl_dentry);
        rpc_init_rtt(&new->cl_rtt_default, clnt->cl_xprt->timeout.to_initval);
        if (new->cl_auth)
                atomic_inc(&new->cl_auth->au_count);
        new->cl_pmap            = &new->cl_pmap_default;
-       new->cl_metrics         = rpc_alloc_iostats(clnt);
+       rpc_init_wait_queue(&new->cl_pmap_default.pm_bindwait, "bindwait");
        return new;
 out_no_clnt:
        printk(KERN_INFO "RPC: out of memory in %s\n", __FUNCTION__);
@@ -314,15 +302,11 @@ rpc_destroy_client(struct rpc_clnt *clnt)
                clnt->cl_auth = NULL;
        }
        if (clnt->cl_parent != clnt) {
-               if (!IS_ERR(clnt->cl_dentry))
-                       dput(clnt->cl_dentry);
                rpc_destroy_client(clnt->cl_parent);
                goto out_free;
        }
-       if (!IS_ERR(clnt->cl_dentry)) {
-               rpc_rmdir(clnt->cl_dentry);
-               rpc_put_mount();
-       }
+       if (clnt->cl_pathname[0])
+               rpc_rmdir(clnt->cl_pathname);
        if (clnt->cl_xprt) {
                xprt_destroy(clnt->cl_xprt);
                clnt->cl_xprt = NULL;
@@ -330,8 +314,6 @@ rpc_destroy_client(struct rpc_clnt *clnt)
        if (clnt->cl_server != clnt->cl_inline_name)
                kfree(clnt->cl_server);
 out_free:
-       rpc_free_iostats(clnt->cl_metrics);
-       clnt->cl_metrics = NULL;
        kfree(clnt);
        return 0;
 }
@@ -491,16 +473,15 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
        int             status;
 
        /* If this client is slain all further I/O fails */
-       status = -EIO;
        if (clnt->cl_dead) 
-               goto out_release;
+               return -EIO;
 
        flags |= RPC_TASK_ASYNC;
 
        /* Create/initialize a new RPC task */
        status = -ENOMEM;
        if (!(task = rpc_new_task(clnt, flags, tk_ops, data)))
-               goto out_release;
+               goto out;
 
        /* Mask signals on GSS_AUTH upcalls */
        rpc_task_sigmask(task, &oldset);                
@@ -515,10 +496,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
                rpc_release_task(task);
 
        rpc_restore_sigmask(&oldset);           
-       return status;
-out_release:
-       if (tk_ops->rpc_release != NULL)
-               tk_ops->rpc_release(data);
+out:
        return status;
 }
 
@@ -918,43 +896,26 @@ call_transmit(struct rpc_task *task)
        task->tk_status = xprt_prepare_transmit(task);
        if (task->tk_status != 0)
                return;
-       task->tk_action = call_transmit_status;
        /* Encode here so that rpcsec_gss can use correct sequence number. */
        if (rpc_task_need_encode(task)) {
-               BUG_ON(task->tk_rqstp->rq_bytes_sent != 0);
+               task->tk_rqstp->rq_bytes_sent = 0;
                call_encode(task);
                /* Did the encode result in an error condition? */
                if (task->tk_status != 0)
-                       return;
+                       goto out_nosend;
        }
+       task->tk_action = call_transmit_status;
        xprt_transmit(task);
        if (task->tk_status < 0)
                return;
-       /*
-        * On success, ensure that we call xprt_end_transmit() before sleeping
-        * in order to allow access to the socket to other RPC requests.
-        */
-       call_transmit_status(task);
-       if (task->tk_msg.rpc_proc->p_decode != NULL)
-               return;
-       task->tk_action = rpc_exit_task;
-       rpc_wake_up_task(task);
-}
-
-/*
- * 5a. Handle cleanup after a transmission
- */
-static void
-call_transmit_status(struct rpc_task *task)
-{
-       task->tk_action = call_status;
-       /*
-        * Special case: if we've been waiting on the socket's write_space()
-        * callback, then don't call xprt_end_transmit().
-        */
-       if (task->tk_status == -EAGAIN)
-               return;
-       xprt_end_transmit(task);
+       if (!task->tk_msg.rpc_proc->p_decode) {
+               task->tk_action = rpc_exit_task;
+               rpc_wake_up_task(task);
+       }
+       return;
+out_nosend:
+       /* release socket write lock before attempting to handle error */
+       xprt_abort_transmit(task);
        rpc_task_force_reencode(task);
 }
 
@@ -1006,7 +967,18 @@ call_status(struct rpc_task *task)
 }
 
 /*
- * 6a. Handle RPC timeout
+ * 6a. Handle transmission errors.
+ */
+static void
+call_transmit_status(struct rpc_task *task)
+{
+       if (task->tk_status != -EAGAIN)
+               rpc_task_force_reencode(task);
+       call_status(task);
+}
+
+/*
+ * 6b. Handle RPC timeout
  *     We do not release the request slot, so we keep using the
  *     same XID for all retransmits.
  */
@@ -1021,8 +993,6 @@ call_timeout(struct rpc_task *task)
        }
 
        dprintk("RPC: %4d call_timeout (major)\n", task->tk_pid);
-       task->tk_timeouts++;
-
        if (RPC_IS_SOFT(task)) {
                printk(KERN_NOTICE "%s: server %s not responding, timed out\n",
                                clnt->cl_protname, clnt->cl_server);
@@ -1075,11 +1045,6 @@ call_decode(struct rpc_task *task)
                return;
        }
 
-       /*
-        * Ensure that we see all writes made by xprt_complete_rqst()
-        * before it changed req->rq_received.
-        */
-       smp_rmb();
        req->rq_rcv_buf.len = req->rq_private_buf.len;
 
        /* Check that the softirq receive buffer is valid */
@@ -1181,17 +1146,6 @@ call_verify(struct rpc_task *task)
        u32     *p = iov->iov_base, n;
        int error = -EACCES;
 
-       if ((task->tk_rqstp->rq_rcv_buf.len & 3) != 0) {
-               /* RFC-1014 says that the representation of XDR data must be a
-                * multiple of four bytes
-                * - if it isn't pointer subtraction in the NFS client may give
-                *   undefined results
-                */
-               printk(KERN_WARNING
-                      "call_verify: XDR representation not a multiple of"
-                      " 4 bytes: 0x%x\n", task->tk_rqstp->rq_rcv_buf.len);
-               goto out_eio;
-       }
        if ((len -= 3) < 0)
                goto out_overflow;
        p += 1; /* skip XID */
@@ -1240,8 +1194,8 @@ call_verify(struct rpc_task *task)
                        task->tk_action = call_bind;
                        goto out_retry;
                case RPC_AUTH_TOOWEAK:
-                       printk(KERN_NOTICE "call_verify: server %s requires stronger "
-                              "authentication.\n", task->tk_client->cl_server);
+                       printk(KERN_NOTICE "call_verify: server requires stronger "
+                              "authentication.\n");
                        break;
                default:
                        printk(KERN_WARNING "call_verify: unknown auth error: %x\n", n);