All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 0/3] RFC: 9pfs-proxy: simplify/cleanup
Date: Tue, 10 Mar 2015 07:49:39 +0300	[thread overview]
Message-ID: <54FE77E3.2040304@msgid.tls.msk.ru> (raw)
In-Reply-To: <cover.1425678142.git.mjt@msgid.tls.msk.ru>

Now when I reviewed the whole thing, I'd drop the error
handling change too, and fold it into even bigger change.
What I'm thinking is to refactor this code to look
significantly different, namely:

For the proxy code:

 o each filesystem method first call proxy_send_request(type, fmt, ...),
   and proxy_send_request() locks the proxy object, marshals the
   arguments according to fmt and sends the request out.

 o after sending the request, each method calls
   proxy_receive_reply(fmt, ...) (or proxy_receive_fd() -- there's
   no need in proxy_receive_status(), it is proxy_recive_reply()
   with fmt=NULL).  This proxy_receive_reply() receives the
   reply according to the fmt argument and unlocks the
   proxy object.

This way. locking code will be split into two methods, but
_all_ filesystem-method-specific code, for each method,
will be in the same function which is the only place which
"knows" everything about the method.

For proxy code it might also be a good idea to have two
v9fs_string objects embedded in the proxy structure, to
be used by the methods, so there's no need to init and
free the local-to-function strings in every method.

At the general level, v9fs_string handling is bad, it
shouldn't really free+alloc a string every time something
gets printed into it.  v9fs_path type should be dropped
completely and replaced with v9fs_string, especially since
one is often being type-cast to another.

marshal/unmarshal interface should be printf-like with %s,
so that the compiler will be able to check if the arguments
are of the right type.  Alternatively, it should be re-
factored to accept just one, typed, argument to pack/unpack,
without vararg part.  Here, an iovec iterator might be used
(to keep current position in iovec) to speed things up.

marshal/unmarshal interface should not allocate/free strings
frantically like it does now -- this allocation/freeing takes
significant time and slows down 9pfs code.  The same is true
for some other parts of 9pfs too.

Also marshal/unmarshal interface - is it really necessary to
support I/O where individual eiements (a file name, size of
that file name, or even all the fields of some guest-visible
structure) are split between several iovec elements?  Can't
we say that a single element (with some definition of "element",
which can be a single string or this string together with its
size in front, one element of a structure like stat or whole
stat structure, etc) must not be split into multiple iovecs?
If it's possible, this code can be simplified and sped up
greatly, for example, we won't need to copy the strings to
a temp buffer (especially multiple times!) and can just point
inside of a single iovec...

That's just some random thoughts.  All without acually understanding
how 9pfs communicates with the guest...  Can you describe this part
briefly please?  Or maybe I should just shut up and pretend I never
seen this code.. ;)  (which is, actually, a good possibility - I don't
really have much time to deal with it, and 9pfs is not my big interest... ;)

Thanks,

/mjt

07.03.2015 00:43, Michael Tokarev wrote:
> Try to make the code a bit less ugly.  First by moving
> errno = -retval to a common place, and second by simplifying
> common place a lot.  What's left is v9fs_receive_response().
> 
> V3: merge several small patches into larger ones,
>     drop trivial stuff
> 
> Michael Tokarev (3):
>   9pfs-proxy: simplify error handling
>   fsdev: introduce v9fs_vmarshal() and v9fs_vunmarshal()
>   9pfs-proxy: remove one half of redundrand code
> 
>  fsdev/virtio-9p-marshal.c |  38 +++--
>  fsdev/virtio-9p-marshal.h |   6 +
>  hw/9pfs/virtio-9p-proxy.c | 405 +++++-----------------------------------------
>  3 files changed, 77 insertions(+), 372 deletions(-)
> 

      parent reply	other threads:[~2015-03-10  4:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06 21:43 [Qemu-devel] [PATCH v3 0/3] RFC: 9pfs-proxy: simplify/cleanup Michael Tokarev
2015-03-06 21:43 ` [Qemu-devel] [PATCH 1/3] 9pfs-proxy: simplify error handling Michael Tokarev
2015-03-07 20:37   ` Eric Blake
2015-03-07 22:10     ` Michael Tokarev
2015-03-07 22:11       ` Michael Tokarev
2015-03-08 16:27       ` Aneesh Kumar K.V
2015-03-10  4:23         ` Michael Tokarev
2015-03-10 17:41           ` Aneesh Kumar K.V
2015-03-11  5:58             ` Michael Tokarev
2015-03-11  8:46               ` Aneesh Kumar K.V
2015-03-11 20:05                 ` Michael Tokarev
2015-03-11 20:08                   ` Michael Tokarev
2015-03-08 16:21   ` Aneesh Kumar K.V
2015-03-06 21:43 ` [Qemu-devel] [PATCH 2/3] fsdev: introduce v9fs_vmarshal() and v9fs_vunmarshal() Michael Tokarev
2015-03-06 21:43 ` [Qemu-devel] [PATCH 3/3] 9pfs-proxy: remove one half of redundrand code Michael Tokarev
2015-03-06 21:46   ` Michael Tokarev
2015-03-07 20:39   ` Eric Blake
2015-03-10  4:49 ` Michael Tokarev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54FE77E3.2040304@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.