rfc: 9pfs-proxy simplification/cleanup
v2 cover rfc: 9pfs-proxy simplification/cleanup
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(-)
Signature · 1 line
2.1.4
I forgot to clean up the temp dir so the result is a hmessy mix of 2 patchsets, one from trivial patches and another this 9pfs code (actually it was me executing git-format-patch twice in a row, once with a wrong starting point and next with corrected starting point).
I'm sorry for this. Somehow my handling of patches become quite a bit messy recently. I'll try to make it to work better.
I'll resend the patchset later after doing some more code changes and patch merging.
And oh well, it all started from a tiny cleanup patch by Gonglei... ;)
Thanks,
/mjt