From: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 6/6] This patch converts v9fs_walk() to make use of the threadlets infrastructure.
Date: Wed, 13 Oct 2010 22:40:31 +0530 [thread overview]
Message-ID: <20101013171031.23885.86603.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20101013165321.23885.81012.stgit@localhost6.localdomain6>
From: Gautham R Shenoy <ego@in.ibm.com>
This patch offloads all the blocking calls invoked for v9fs_walk onto the
helper threads belonging to the threadlets infrastructure. The handling of
the v9fs_post_*walk* calls is done from the io-thread context.
Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
---
hw/virtio-9p.c | 78 +++++++++++++++++++++++++++++++++++++-------------------
hw/virtio-9p.h | 5 ++++
2 files changed, 57 insertions(+), 26 deletions(-)
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 75d4be3..e95bf50 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1615,6 +1615,29 @@ out:
qemu_free(vs);
}
+/************************* v9fs_walk calls *****************************/
+static void v9fs_walk_do_lstat_old(ThreadletWork *work)
+{
+ V9fsWalkState *vs;
+
+ vs = container_of(work, V9fsWalkState, 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_walk_do_lstat_new(ThreadletWork *work)
+{
+ V9fsWalkState *vs;
+
+ vs = container_of(work, V9fsWalkState, work);
+ vs->err = v9fs_do_lstat(vs->s, &vs->newfidp->path, &vs->stbuf);
+ vs->v9fs_errno = errno;
+
+ v9fs_async_helper_done(vs->post_fn, vs);
+}
+
static void v9fs_walk_complete(V9fsState *s, V9fsWalkState *vs, int err)
{
complete_pdu(s, vs->pdu, err);
@@ -1640,13 +1663,14 @@ static void v9fs_walk_marshal(V9fsWalkState *vs)
}
}
-static void v9fs_walk_post_newfid_lstat(V9fsState *s, V9fsWalkState *vs,
- int err)
+static void v9fs_walk_post_newfid_lstat(void *opaque)
{
- if (err == -1) {
- free_fid(s, vs->newfidp->fid);
+ V9fsWalkState *vs = (V9fsWalkState *)opaque;
+
+ if (vs->err == -1) {
+ free_fid(vs->s, vs->newfidp->fid);
v9fs_string_free(&vs->path);
- err = -ENOENT;
+ vs->err = -ENOENT;
goto out;
}
@@ -1658,24 +1682,25 @@ static void v9fs_walk_post_newfid_lstat(V9fsState *s, V9fsWalkState *vs,
vs->wnames[vs->name_idx].data);
v9fs_string_copy(&vs->newfidp->path, &vs->path);
- err = v9fs_do_lstat(s, &vs->newfidp->path, &vs->stbuf);
- v9fs_walk_post_newfid_lstat(s, vs, err);
+ v9fs_do_async_posix(&vs->work, v9fs_walk_do_lstat_new, &vs->post_fn,
+ v9fs_walk_post_newfid_lstat);
return;
}
v9fs_string_free(&vs->path);
v9fs_walk_marshal(vs);
- err = vs->offset;
+ vs->err = vs->offset;
out:
- v9fs_walk_complete(s, vs, err);
+ v9fs_walk_complete(vs->s, vs, vs->err);
}
-static void v9fs_walk_post_oldfid_lstat(V9fsState *s, V9fsWalkState *vs,
- int err)
+static void v9fs_walk_post_oldfid_lstat(void *opaque)
{
- if (err == -1) {
+ V9fsWalkState *vs = (V9fsWalkState *)opaque;
+
+ if (vs->err == -1) {
v9fs_string_free(&vs->path);
- err = -ENOENT;
+ vs->err = -ENOENT;
goto out;
}
@@ -1687,23 +1712,22 @@ static void v9fs_walk_post_oldfid_lstat(V9fsState *s, V9fsWalkState *vs,
vs->fidp->path.data, vs->wnames[vs->name_idx].data);
v9fs_string_copy(&vs->fidp->path, &vs->path);
- err = v9fs_do_lstat(s, &vs->fidp->path, &vs->stbuf);
- v9fs_walk_post_oldfid_lstat(s, vs, err);
+ v9fs_do_async_posix(&vs->work, v9fs_walk_do_lstat_old, &vs->post_fn,
+ v9fs_walk_post_oldfid_lstat);
return;
}
v9fs_string_free(&vs->path);
v9fs_walk_marshal(vs);
- err = vs->offset;
+ vs->err = vs->offset;
out:
- v9fs_walk_complete(s, vs, err);
+ v9fs_walk_complete(vs->s, vs, vs->err);
}
static void v9fs_walk(V9fsState *s, V9fsPDU *pdu)
{
int32_t fid, newfid;
V9fsWalkState *vs;
- int err = 0;
int i;
vs = qemu_malloc(sizeof(*vs));
@@ -1711,6 +1735,8 @@ static void v9fs_walk(V9fsState *s, V9fsPDU *pdu)
vs->wnames = NULL;
vs->qids = NULL;
vs->offset = 7;
+ vs->err = 0;
+ vs->s = s;
vs->offset += pdu_unmarshal(vs->pdu, vs->offset, "ddw", &fid,
&newfid, &vs->nwnames);
@@ -1728,7 +1754,7 @@ static void v9fs_walk(V9fsState *s, V9fsPDU *pdu)
vs->fidp = lookup_fid(s, fid);
if (vs->fidp == NULL) {
- err = -ENOENT;
+ vs->err = -ENOENT;
goto out;
}
@@ -1744,14 +1770,14 @@ static void v9fs_walk(V9fsState *s, V9fsPDU *pdu)
vs->fidp->path.data, vs->wnames[vs->name_idx].data);
v9fs_string_copy(&vs->fidp->path, &vs->path);
- err = v9fs_do_lstat(s, &vs->fidp->path, &vs->stbuf);
- v9fs_walk_post_oldfid_lstat(s, vs, err);
+ v9fs_do_async_posix(&vs->work, v9fs_walk_do_lstat_old,
+ &vs->post_fn, v9fs_walk_post_oldfid_lstat);
return;
}
} else {
vs->newfidp = alloc_fid(s, newfid);
if (vs->newfidp == NULL) {
- err = -EINVAL;
+ vs->err = -EINVAL;
goto out;
}
@@ -1765,16 +1791,16 @@ static void v9fs_walk(V9fsState *s, V9fsPDU *pdu)
vs->wnames[vs->name_idx].data);
v9fs_string_copy(&vs->newfidp->path, &vs->path);
- err = v9fs_do_lstat(s, &vs->newfidp->path, &vs->stbuf);
- v9fs_walk_post_newfid_lstat(s, vs, err);
+ v9fs_do_async_posix(&vs->work, v9fs_walk_do_lstat_new,
+ &vs->post_fn, v9fs_walk_post_newfid_lstat);
return;
}
}
v9fs_walk_marshal(vs);
- err = vs->offset;
+ vs->err = vs->offset;
out:
- v9fs_walk_complete(s, vs, err);
+ v9fs_walk_complete(s, vs, vs->err);
}
/********************* v9fs_open calls *********************************/
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 294de83..f88b5fc 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -296,6 +296,11 @@ typedef struct V9fsWalkState {
V9fsString path;
V9fsString *wnames;
struct stat stbuf;
+ V9fsState *s;
+ int err;
+ int v9fs_errno;
+ ThreadletWork work;
+ void (*post_fn)(void *arg);
} V9fsWalkState;
typedef struct V9fsOpenState {
next prev parent reply other threads:[~2010-10-13 17:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 17:09 ` [Qemu-devel] [PATCH 2/6] This patch converts v9fs_wstat() " Arun R Bharadwaj
2010-10-13 17:09 ` [Qemu-devel] [PATCH 3/6] This patch converts v9fs_read() " Arun R Bharadwaj
2010-10-13 17:10 ` [Qemu-devel] [PATCH 4/6] This patch converts v9fs_write() " Arun R Bharadwaj
2010-10-13 17:10 ` [Qemu-devel] [PATCH 5/6] This patch converts v9fs_open() " Arun R Bharadwaj
2010-10-13 17:10 ` Arun R Bharadwaj [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-10-13 17:20 [Qemu-devel] [RFC PATCH 0/6] First threading model Arun R Bharadwaj
2010-10-13 17:23 ` [Qemu-devel] [PATCH 6/6] This patch converts v9fs_walk() 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:38 ` [Qemu-devel] [PATCH 6/6] This patch converts v9fs_walk() 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=20101013171031.23885.86603.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).