qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/6] This patch converts v9fs_stat() to make use of the threadlets infrastructure.
Date: Wed, 13 Oct 2010 22:51:22 +0530	[thread overview]
Message-ID: <20101013172122.24213.3788.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20101013172020.24213.72216.stgit@localhost6.localdomain6>

From: Gautham R Shenoy <ego@in.ibm.com>

Every call to v9fs_stat() is processed in the context of the vcpu thread before
offloading the actual stat operation onto an async-thread. The post operation is
handled in the context of the io-thread which in turn does the complete()
operation for this particular v9fs_stat() operation.

Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
---
 hw/virtio-9p.c |   34 ++++++++++++++++++++++------------
 hw/virtio-9p.h |    6 ++++++
 2 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 174300d..5f6ce56 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1356,26 +1356,38 @@ out:
     v9fs_string_free(&aname);
 }
 
-static void v9fs_stat_post_lstat(V9fsState *s, V9fsStatState *vs, int err)
+static void v9fs_stat_post_lstat(void *opaque)
 {
-    if (err == -1) {
-        err = -errno;
+    V9fsStatState *vs = (V9fsStatState *)opaque;
+
+    if (vs->err == -1) {
+        vs->err = -(vs->v9fs_errno);
         goto out;
     }
 
-    err = stat_to_v9stat(s, &vs->fidp->path, &vs->stbuf, &vs->v9stat);
-    if (err) {
+    vs->err = stat_to_v9stat(vs->s, &vs->fidp->path, &vs->stbuf, &vs->v9stat);
+    if (vs->err) {
         goto out;
     }
     vs->offset += pdu_marshal(vs->pdu, vs->offset, "wS", 0, &vs->v9stat);
-    err = vs->offset;
+    vs->err = vs->offset;
 
 out:
-    complete_pdu(s, vs->pdu, err);
+    complete_pdu(vs->s, vs->pdu, vs->err);
     v9fs_stat_free(&vs->v9stat);
     qemu_free(vs);
 }
 
+static void v9fs_stat_do_lstat(ThreadletWork *work)
+{
+    V9fsStatState *vs = container_of(work, V9fsStatState, work);
+
+    vs->err = v9fs_do_lstat(vs->s, &vs->fidp->path, &vs->stbuf);
+    vs->v9fs_errno = errno;
+
+    v9fs_async_helper_done(vs->post_fn, vs);
+}
+
 static void v9fs_stat(V9fsState *s, V9fsPDU *pdu)
 {
     int32_t fid;
@@ -1385,6 +1397,7 @@ static void v9fs_stat(V9fsState *s, V9fsPDU *pdu)
     vs = qemu_malloc(sizeof(*vs));
     vs->pdu = pdu;
     vs->offset = 7;
+    vs->s = s;
 
     memset(&vs->v9stat, 0, sizeof(vs->v9stat));
 
@@ -1396,8 +1409,8 @@ static void v9fs_stat(V9fsState *s, V9fsPDU *pdu)
         goto out;
     }
 
-    err = v9fs_do_lstat(s, &vs->fidp->path, &vs->stbuf);
-    v9fs_stat_post_lstat(s, vs, err);
+    v9fs_do_async_posix(&vs->work, v9fs_stat_do_lstat, &vs->post_fn,
+                        v9fs_stat_post_lstat);
     return;
 
 out:
@@ -3882,8 +3895,5 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
     qemu_mutex_init(&(v9fs_async_struct.lock));
     /* Create async queue. */
 
-    (void)v9fs_do_async_posix;
-    (void)v9fs_async_helper_done;
-
     return &s->vdev;
 }
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 6c23319..769d3fc 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -7,6 +7,7 @@
 #include <utime.h>
 
 #include "file-op-9p.h"
+#include "qemu-threadlets.h"
 
 /* The feature bitmap for virtio 9P */
 /* The mount point is specified in a config variable */
@@ -246,6 +247,11 @@ typedef struct V9fsStatState {
     V9fsStat v9stat;
     V9fsFidState *fidp;
     struct stat stbuf;
+    V9fsState *s;
+    int err;
+    int v9fs_errno;
+    ThreadletWork work;
+    void (*post_fn)(void *arg);
 } V9fsStatState;
 
 typedef struct V9fsStatDotl {

  reply	other threads:[~2010-10-13 17:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-13 17:20 [Qemu-devel] [RFC PATCH 0/6] First threading model Arun R Bharadwaj
2010-10-13 17:21 ` Arun R Bharadwaj [this message]
2010-10-13 17:21 ` [Qemu-devel] [PATCH 2/6] This patch converts v9fs_wstat() to make use of the threadlets infrastructure Arun R Bharadwaj
2010-10-13 17:22 ` [Qemu-devel] [PATCH 3/6] This patch converts v9fs_read() " Arun R Bharadwaj
2010-10-13 17:22 ` [Qemu-devel] [PATCH 4/6] This patch converts v9fs_write() " Arun R Bharadwaj
2010-10-13 17:23 ` [Qemu-devel] [PATCH 5/6] This patch converts v9fs_open() " Arun R Bharadwaj
2010-10-13 17:23 ` [Qemu-devel] [PATCH 6/6] This patch converts v9fs_walk() " Arun R Bharadwaj
  -- strict thread matches above, loose matches on Subject: below --
2010-10-13 17:09 [Qemu-devel] [RFC PATCH 0/6] First Threading Model Arun R Bharadwaj
2010-10-13 17:09 ` [Qemu-devel] [PATCH 1/6] This patch converts v9fs_stat() to make use of the threadlets infrastructure Arun R Bharadwaj
2010-10-13 15:36 [Qemu-devel] [PATCH 0/6] First threading model Arun R Bharadwaj
2010-10-13 15:36 ` [Qemu-devel] [PATCH 1/6] This patch converts v9fs_stat() to make use of the threadlets infrastructure Arun R Bharadwaj

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=20101013172122.24213.3788.stgit@localhost6.localdomain6 \
    --to=arun@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).