The patch titled

     v9fs: fix handling of malformed 9P messages

has been added to the -mm tree.  Its filename is

     v9fs-fix-handling-of-malformed-9p-messages.patch

Patches currently in -mm which might be from [EMAIL PROTECTED] are

v9fs-documentation-makefiles-configuration.patch
v9fs-documentation-makefiles-configuration-add-fd-based-transport-to-makefile-docs.patch
v9fs-vfs-file-dentry-and-directory-operations.patch
v9fs-vfs-inode-operations.patch
v9fs-vfs-superblock-operations-and-glue.patch
v9fs-vfs-superblock-operations-and-glue-add-fd-based-transport-to-mount-options.patch
v9fs-9p-protocol-implementation.patch
v9fs-transport-modules.patch
v9fs-transport-modules-add-fd-based-transport-module.patch
v9fs-debug-and-support-routines.patch
v9fs-change-error-magic-numbers-to-defined-constants.patch
v9fs-clean-up-vfs_inode-and-setattr-functions.patch
v9fs-fix-support-for-special-files-devices-named-pipes-etc.patch
v9fs-readlink-extended-mode-check.patch
v9fs-fix-handling-of-malformed-9p-messages.patch
v9fs-fix-a-problem-with-named-pipe-transport.patch
v9fs-use-standard-kernel-byteswapping.patch
v9fs-adjust-follow_link-and-put_link-to.patch
v9fs-fix-plan9port-example-in-v9fs.patch
v9fs-remove-sparse-bitwise-warnings.patch



From: Eric Van Hensbergen <[EMAIL PROTECTED]>

This patch attempts to do a better job of cleaning up after detecting errors
on the transport.  This should also improve error reporting on broken
connections to servers.

Signed-off-by: Latchesar Ionkov <[EMAIL PROTECTED]>
Signed-off-by: Eric Van Hensbergen <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 fs/9p/error.h      |    1 +
 fs/9p/mux.c        |   53 ++++++++++++++++++++++++++++++++++-------------------
 fs/9p/mux.h        |    1 +
 fs/9p/trans_sock.c |   12 ++++++++++--
 4 files changed, 46 insertions(+), 21 deletions(-)

diff -puN fs/9p/error.h~v9fs-fix-handling-of-malformed-9p-messages fs/9p/error.h
--- devel/fs/9p/error.h~v9fs-fix-handling-of-malformed-9p-messages      
2005-08-29 22:22:30.000000000 -0700
+++ devel-akpm/fs/9p/error.h    2005-08-29 22:22:30.000000000 -0700
@@ -47,6 +47,7 @@ static struct errormap errmap[] = {
        {"Operation not permitted", EPERM},
        {"wstat prohibited", EPERM},
        {"No such file or directory", ENOENT},
+       {"directory entry not found", ENOENT},
        {"file not found", ENOENT},
        {"Interrupted system call", EINTR},
        {"Input/output error", EIO},
diff -puN fs/9p/mux.c~v9fs-fix-handling-of-malformed-9p-messages fs/9p/mux.c
--- devel/fs/9p/mux.c~v9fs-fix-handling-of-malformed-9p-messages        
2005-08-29 22:22:30.000000000 -0700
+++ devel-akpm/fs/9p/mux.c      2005-08-29 22:22:30.000000000 -0700
@@ -162,18 +162,21 @@ static int v9fs_recv(struct v9fs_session
        dprintk(DEBUG_MUX, "waiting for response: %d\n", req->tcall->tag);
        ret = wait_event_interruptible(v9ses->read_wait,
                       ((v9ses->transport->status != Connected) ||
-                       (req->rcall != 0) || dprintcond(v9ses, req)));
+                       (req->rcall != 0) || (req->err < 0) ||
+                       dprintcond(v9ses, req)));
 
        dprintk(DEBUG_MUX, "got it: rcall %p\n", req->rcall);
+
+       spin_lock(&v9ses->muxlock);
+       list_del(&req->next);
+       spin_unlock(&v9ses->muxlock);
+
+       if (req->err < 0)
+               return req->err;
+
        if (v9ses->transport->status == Disconnected)
                return -ECONNRESET;
 
-       if (ret == 0) {
-               spin_lock(&v9ses->muxlock);
-               list_del(&req->next);
-               spin_unlock(&v9ses->muxlock);
-       }
-
        return ret;
 }
 
@@ -245,6 +248,9 @@ v9fs_mux_rpc(struct v9fs_session_info *v
        if (!v9ses)
                return -EINVAL;
 
+       if (!v9ses->transport || v9ses->transport->status != Connected)
+               return -EIO;
+
        if (rcall)
                *rcall = NULL;
 
@@ -257,6 +263,7 @@ v9fs_mux_rpc(struct v9fs_session_info *v
        tcall->tag = tid;
 
        req.tcall = tcall;
+       req.err = 0;
        req.rcall = NULL;
 
        ret = v9fs_send(v9ses, &req);
@@ -351,16 +358,21 @@ static int v9fs_recvproc(void *data)
                }
 
                err = read_message(v9ses, rcall, v9ses->maxdata + V9FS_IOHDRSZ);
-               if (err < 0) {
-                       kfree(rcall);
-                       break;
-               }
                spin_lock(&v9ses->muxlock);
-               list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) {
-                       if (rreq->tcall->tag == rcall->tag) {
-                               req = rreq;
-                               req->rcall = rcall;
-                               break;
+               if (err < 0) {
+                       list_for_each_entry_safe(rreq, rptr, 
&v9ses->mux_fcalls, next) {
+                               rreq->err = err;
+                       }
+                       if(err != -ERESTARTSYS)
+                               eprintk(KERN_ERR,
+                                       "Transport error while reading message 
%d\n", err);
+               } else {
+                       list_for_each_entry_safe(rreq, rptr, 
&v9ses->mux_fcalls, next) {
+                               if (rreq->tcall->tag == rcall->tag) {
+                                       req = rreq;
+                                       req->rcall = rcall;
+                                       break;
+                               }
                        }
                }
 
@@ -379,9 +391,10 @@ static int v9fs_recvproc(void *data)
                spin_unlock(&v9ses->muxlock);
 
                if (!req) {
-                       dprintk(DEBUG_ERROR,
-                               "unexpected response: id %d tag %d\n",
-                               rcall->id, rcall->tag);
+                       if (err >= 0)
+                               dprintk(DEBUG_ERROR,
+                                       "unexpected response: id %d tag %d\n",
+                                       rcall->id, rcall->tag);
 
                        kfree(rcall);
                }
@@ -390,6 +403,8 @@ static int v9fs_recvproc(void *data)
                set_current_state(TASK_INTERRUPTIBLE);
        }
 
+       v9ses->transport->close(v9ses->transport);
+
        /* Inform all pending processes about the failure */
        wake_up_all(&v9ses->read_wait);
 
diff -puN fs/9p/mux.h~v9fs-fix-handling-of-malformed-9p-messages fs/9p/mux.h
--- devel/fs/9p/mux.h~v9fs-fix-handling-of-malformed-9p-messages        
2005-08-29 22:22:30.000000000 -0700
+++ devel-akpm/fs/9p/mux.h      2005-08-29 22:22:30.000000000 -0700
@@ -28,6 +28,7 @@
 struct v9fs_rpcreq {
        struct v9fs_fcall *tcall;
        struct v9fs_fcall *rcall;
+       int err;        /* error code if response failed */
 
        /* XXX - could we put scatter/gather buffers here? */
 
diff -puN fs/9p/trans_sock.c~v9fs-fix-handling-of-malformed-9p-messages 
fs/9p/trans_sock.c
--- devel/fs/9p/trans_sock.c~v9fs-fix-handling-of-malformed-9p-messages 
2005-08-29 22:22:30.000000000 -0700
+++ devel-akpm/fs/9p/trans_sock.c       2005-08-29 22:22:30.000000000 -0700
@@ -246,7 +246,12 @@ v9fs_unix_init(struct v9fs_session_info 
 
 static void v9fs_sock_close(struct v9fs_transport *trans)
 {
-       struct v9fs_trans_sock *ts = trans ? trans->priv : NULL;
+       struct v9fs_trans_sock *ts;
+
+       if (!trans)
+               return;
+
+       ts = trans->priv;
 
        if ((ts) && (ts->s)) {
                dprintk(DEBUG_TRANS, "closing the socket %p\n", ts->s);
@@ -256,7 +261,10 @@ static void v9fs_sock_close(struct v9fs_
                dprintk(DEBUG_TRANS, "socket closed\n");
        }
 
-       kfree(ts);
+       if (ts)
+               kfree(ts);
+
+       trans->priv = NULL;
 }
 
 struct v9fs_transport v9fs_trans_tcp = {
_
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to