From patchwork Wed May 25 23:52:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 97447 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 682E2B6F94 for ; Thu, 26 May 2011 09:54:12 +1000 (EST) Received: from localhost ([::1]:44577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPNtx-0008VG-TQ for incoming@patchwork.ozlabs.org; Wed, 25 May 2011 19:54:09 -0400 Received: from eggs.gnu.org ([140.186.70.92]:48905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPNtP-0007w2-V2 for qemu-devel@nongnu.org; Wed, 25 May 2011 19:53:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QPNtO-0007Tq-JR for qemu-devel@nongnu.org; Wed, 25 May 2011 19:53:35 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:41317) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPNtO-0007TK-Dm for qemu-devel@nongnu.org; Wed, 25 May 2011 19:53:34 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e37.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4PNoZ4V028807 for ; Wed, 25 May 2011 17:50:35 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id p4PNrRWR158670 for ; Wed, 25 May 2011 17:53:27 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4PHr0uh018278 for ; Wed, 25 May 2011 11:53:00 -0600 Received: from oc6675851006.ibm.com (dyn9041079012.austin.ibm.com [9.41.79.12]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4PHqwLc018178; Wed, 25 May 2011 11:52:59 -0600 From: "Venkateswararao Jujjuri (JV)" To: qemu-devel@nongnu.org Date: Wed, 25 May 2011 16:52:53 -0700 Message-Id: <1306367597-797-6-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1306367597-797-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1306367597-797-1-git-send-email-jvrao@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 32.97.110.158 Cc: "Venkateswararao Jujjuri \"" , stefanha@linux.vnet.ibm.com, "Aneesh Kumar K.V" Subject: [Qemu-devel] [PATCH 05/29] hw/9pfs: Update v9fs_getlock to use coroutines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Aneesh Kumar K.V Signed-off-by: Aneesh Kumar K.V Signed-off-by: Venkateswararao Jujjuri " --- 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 1729422..e6032cd 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -3052,42 +3052,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);