Received: from eggs.gnu.org ([140.186.70.92]:59920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqTJV-0006eA-RI for qemu-devel@nongnu.org; Mon, 08 Aug 2011 13:08:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QqTJF-0002HD-Be for qemu-devel@nongnu.org; Mon, 08 Aug 2011 13:08:29 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:55369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqTJE-00022G-K2 for qemu-devel@nongnu.org; Mon, 08 Aug 2011 13:08:13 -0400 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247]) by e23smtp01.au.ibm.com (8.14.4/8.13.1) with ESMTP id p78H2YrX027552 for ; Tue, 9 Aug 2011 03:02:34 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p78H6A2S1306682 for ; Tue, 9 Aug 2011 03:06:10 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p78H775Q026308 for ; Tue, 9 Aug 2011 03:07:07 +1000 From: "Aneesh Kumar K.V" Date: Mon, 8 Aug 2011 22:36:31 +0530 Message-Id: <1312823215-28675-5-git-send-email-aneesh.kumar@linux.vnet.ibm.com> In-Reply-To: <1312823215-28675-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1312823215-28675-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH -V4 04/28] hw/9pfs: Update v9fs_getlock to use coroutines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, "Aneesh Kumar K.V" Signed-off-by: Aneesh Kumar K.V --- hw/9pfs/virtio-9p.c | 42 +++++++++++++++++++----------------------- hw/9pfs/virtio-9p.h | 9 --------- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index c8dfa16..d9a55de 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -3049,42 +3049,38 @@ out: * When a TGETLOCK request comes, always return success because all lock * handling is done by client's VFS layer. */ - static void v9fs_getlock(void *opaque) { + size_t offset = 7; + struct stat stbuf; + V9fsFidState *fidp; + V9fsGetlock *glock; + int32_t fid, err = 0; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; - int32_t fid, err = 0; - V9fsGetlockState *vs; - vs = qemu_mallocz(sizeof(*vs)); - vs->pdu = pdu; - vs->offset = 7; - - vs->glock = qemu_malloc(sizeof(*vs->glock)); - pdu_unmarshal(vs->pdu, vs->offset, "dbqqds", &fid, &vs->glock->type, - &vs->glock->start, &vs->glock->length, &vs->glock->proc_id, - &vs->glock->client_id); + glock = qemu_malloc(sizeof(*glock)); + pdu_unmarshal(pdu, offset, "dbqqds", &fid, &glock->type, + &glock->start, &glock->length, &glock->proc_id, + &glock->client_id); - vs->fidp = lookup_fid(s, fid); - if (vs->fidp == NULL) { + fidp = lookup_fid(s, fid); + if (fidp == NULL) { err = -ENOENT; goto out; } - - err = v9fs_do_fstat(s, vs->fidp->fs.fd, &vs->stbuf); + err = v9fs_co_fstat(s, fidp->fs.fd, &stbuf); if (err < 0) { - err = -errno; goto out; } - vs->glock->type = F_UNLCK; - vs->offset += pdu_marshal(vs->pdu, vs->offset, "bqqds", vs->glock->type, - vs->glock->start, vs->glock->length, vs->glock->proc_id, - &vs->glock->client_id); + glock->type = F_UNLCK; + offset += pdu_marshal(pdu, offset, "bqqds", glock->type, + glock->start, glock->length, glock->proc_id, + &glock->client_id); + err = offset; out: - complete_pdu(s, vs->pdu, err); - qemu_free(vs->glock); - qemu_free(vs); + complete_pdu(s, pdu, err); + qemu_free(glock); } static void v9fs_mkdir(void *opaque) diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 0c1e3ee..edf3413 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -412,15 +412,6 @@ typedef struct V9fsGetlock V9fsString client_id; } V9fsGetlock; -typedef struct V9fsGetlockState -{ - V9fsPDU *pdu; - size_t offset; - struct stat stbuf; - V9fsFidState *fidp; - V9fsGetlock *glock; -} V9fsGetlockState; - size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count, size_t offset, size_t size, int pack); -- 1.7.4.1