Received: from eggs.gnu.org ([2001:4830:134:3::10]:43654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTyio-0003ef-E1 for qemu-devel@nongnu.org; Fri, 06 Mar 2015 15:19:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTyij-0008V9-BU for qemu-devel@nongnu.org; Fri, 06 Mar 2015 15:19:46 -0500 Received: from isrv.corpit.ru ([86.62.121.231]:56788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTyij-0008UV-3o for qemu-devel@nongnu.org; Fri, 06 Mar 2015 15:19:41 -0500 From: Michael Tokarev Date: Fri, 6 Mar 2015 23:18:39 +0300 Message-Id: <1425673176-9819-1-git-send-email-mjt@msgid.tls.msk.ru> Subject: [Qemu-devel] [PATCH v2 0/6] rfc: 9pfs-proxy simplification/cleanup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Aneesh Kumar K.V" Cc: Michael Tokarev , qemu-devel@nongnu.org 9pfs-proxy code is terrible. Not only it does lots of memory allocations for every filesystem operation, the code is also badly written. For example, all filesystem operation methods call a common function, v9fs_request(), and passes all info about method arguments, including argument types, to it. However, the common v9fs_request() function has a switch(filesystem method), unpacks method arguments from the argument stack, and re- request marshalling with a new list of argument types, ignoring what the individual method handler passed to it. When receiving a response, this common function has another per-filesystem-method switch which, in some cases, calls v9fs_read_response(), which also has the same per-method switch. As a result, processing of each request is badly split between several functions, and the whole thing is just ugly. Error handling is also of the same sort. Common v9fs_request() return -errno, and every filesystem method which calls it stores result in errno, instead of letting the common code to do that. Error handling is inconsistent too, some methods return -1 and some return -errno. This is one small attempt to fix this all. So far, addressed is the error handling and arguments of filesystem methods. Note: I haven't actually tested this code, only compile-tested it. Michael Tokarev (6): 9pfs-proxy: simplify v9fs_request() a bit 9pfs-proxy: simplify error handling 9pfs-proxy: rename a few local variables for consistency fsdev: introduce v9fs_vmarshal() and v9fs_vunmarshal() 9pfs-proxy: remove one half of redundrand code 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv fsdev/virtio-9p-marshal.c | 38 +++-- fsdev/virtio-9p-marshal.h | 6 + hw/9pfs/virtio-9p-proxy.c | 411 +++++----------------------------------------- 3 files changed, 79 insertions(+), 376 deletions(-) -- 2.1.4