From: Gautham R Shenoy <ego@in.ibm.com>
To: Qemu-development List <qemu-devel@nongnu.org>
Cc: Anthony Liguori <aliguori@linux.vnet.ibm.com>,
Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] [RFC/ PATCH 4/4] virtio-9p: convert lstat to use async infrastructure.
Date: Mon, 24 May 2010 18:23:18 +0530 [thread overview]
Message-ID: <20100524125318.29646.59542.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100524125220.29646.62160.stgit@localhost.localdomain>
This patch converts v9fs_stat() to make use of the async infrastructure.
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 | 4 ++++
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index f8f60d3..a57fffc 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1218,26 +1218,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(struct work_item *work)
+{
+ V9fsStatState *vs = (V9fsStatState *)work->private;
+
+ vs->err = v9fs_do_lstat(vs->s, &vs->fidp->path, &vs->stbuf);
+ vs->v9fs_errno = errno;
+
+ v9fs_async_signal(vs->post_fn, vs);
+}
+
static void v9fs_stat(V9fsState *s, V9fsPDU *pdu)
{
int32_t fid;
@@ -1247,6 +1259,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));
@@ -1258,8 +1271,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, v9fs_stat_do_lstat, &vs->post_fn,
+ v9fs_stat_post_lstat);
return;
out:
@@ -2559,8 +2572,5 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
/* Create async queue. */
async_queue_init(&v9fs_async_struct.virtio_9p_aqueue, 10, 3);
- (void)v9fs_do_async_posix;
- (void)v9fs_async_signal;
-
return &s->vdev;
}
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 992c765..b4a1d46 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -173,6 +173,10 @@ typedef struct V9fsStatState {
V9fsStat v9stat;
V9fsFidState *fidp;
struct stat stbuf;
+ V9fsState *s;
+ int err;
+ int v9fs_errno;
+ void (*post_fn)(void *arg);
} V9fsStatState;
typedef struct V9fsWalkState {
prev parent reply other threads:[~2010-05-24 12:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-24 12:52 [Qemu-devel] [RFC/ PATCH 0/4] qemu: Extend AIO threading framework to a generic one Gautham R Shenoy
2010-05-24 12:53 ` [Qemu-devel] [RFC/ PATCH 1/4] qemu: Generic asynchronous threading framework to offload tasks Gautham R Shenoy
2010-05-24 14:16 ` malc
2010-05-24 14:54 ` Corentin Chary
2010-05-24 12:53 ` [Qemu-devel] [RFC/ PATCH 2/4] qemu: Convert AIO code to use the generic threading infrastructure Gautham R Shenoy
2010-05-24 12:53 ` [Qemu-devel] [RFC/ PATCH 3/4] virtio-9p: Add async helper functions Gautham R Shenoy
2010-05-24 12:53 ` Gautham R Shenoy [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=20100524125318.29646.59542.stgit@localhost.localdomain \
--to=ego@in.ibm.com \
--cc=aliguori@linux.vnet.ibm.com \
--cc=avi@redhat.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).