From patchwork Thu May 19 02:57:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 96297 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 63D09B6F7C for ; Thu, 19 May 2011 13:03:20 +1000 (EST) Received: from localhost ([::1]:53746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMtW9-0007D8-MX for incoming@patchwork.ozlabs.org; Wed, 18 May 2011 23:03:17 -0400 Received: from eggs.gnu.org ([140.186.70.92]:54164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMtQo-0005hj-W6 for qemu-devel@nongnu.org; Wed, 18 May 2011 22:57:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QMtQo-0004xm-1L for qemu-devel@nongnu.org; Wed, 18 May 2011 22:57:46 -0400 Received: from e32.co.us.ibm.com ([32.97.110.150]:44338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMtQn-0004xi-SK for qemu-devel@nongnu.org; Wed, 18 May 2011 22:57:45 -0400 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e32.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4J2kIKM019565 for ; Wed, 18 May 2011 20:46:18 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4J2vf4R130370 for ; Wed, 18 May 2011 20:57:41 -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 p4IKvDce016173 for ; Wed, 18 May 2011 14:57:13 -0600 Received: from oc6675851006.ibm.com (sig-9-65-27-236.mts.ibm.com [9.65.27.236]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4IKuo4d014807; Wed, 18 May 2011 14:57:12 -0600 From: "Venkateswararao Jujjuri (JV)" To: qemu-devel@nongnu.org Date: Wed, 18 May 2011 19:57:08 -0700 Message-Id: <1305773834-16359-19-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1305773834-16359-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1305773834-16359-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.150 Cc: aliguori@us.ibm.com, "Venkateswararao Jujjuri \"" , stefanha@linux.vnet.ibm.com, "Aneesh Kumar K.V" Subject: [Qemu-devel] [V3 18/24] hw/9pfs: Update v9fs_xattrcreate 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 | 53 +++++++++++++++++++++++++-------------------------- hw/9pfs/virtio-9p.h | 11 ---------- 2 files changed, 26 insertions(+), 38 deletions(-) diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 5336b8b..112b0f7 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -3317,43 +3317,42 @@ out: static void v9fs_xattrcreate(void *opaque) { - V9fsPDU *pdu = opaque; - V9fsState *s = pdu->s; int flags; int32_t fid; + int64_t size; ssize_t err = 0; - V9fsXattrState *vs; - - vs = qemu_malloc(sizeof(*vs)); - vs->pdu = pdu; - vs->offset = 7; + V9fsString name; + size_t offset = 7; + V9fsFidState *file_fidp; + V9fsFidState *xattr_fidp; + V9fsPDU *pdu = opaque; + V9fsState *s = pdu->s; - pdu_unmarshal(vs->pdu, vs->offset, "dsqd", - &fid, &vs->name, &vs->size, &flags); + pdu_unmarshal(pdu, offset, "dsqd", + &fid, &name, &size, &flags); - vs->file_fidp = lookup_fid(s, fid); - if (vs->file_fidp == NULL) { + file_fidp = lookup_fid(s, fid); + if (file_fidp == NULL) { err = -EINVAL; goto out; } - /* Make the file fid point to xattr */ - vs->xattr_fidp = vs->file_fidp; - vs->xattr_fidp->fid_type = P9_FID_XATTR; - vs->xattr_fidp->fs.xattr.copied_len = 0; - vs->xattr_fidp->fs.xattr.len = vs->size; - vs->xattr_fidp->fs.xattr.flags = flags; - v9fs_string_init(&vs->xattr_fidp->fs.xattr.name); - v9fs_string_copy(&vs->xattr_fidp->fs.xattr.name, &vs->name); - if (vs->size) - vs->xattr_fidp->fs.xattr.value = qemu_malloc(vs->size); - else - vs->xattr_fidp->fs.xattr.value = NULL; - + xattr_fidp = file_fidp; + xattr_fidp->fid_type = P9_FID_XATTR; + xattr_fidp->fs.xattr.copied_len = 0; + xattr_fidp->fs.xattr.len = size; + xattr_fidp->fs.xattr.flags = flags; + v9fs_string_init(&xattr_fidp->fs.xattr.name); + v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name); + if (size) { + xattr_fidp->fs.xattr.value = qemu_malloc(size); + } else { + xattr_fidp->fs.xattr.value = NULL; + } + err = offset; out: - complete_pdu(s, vs->pdu, err); - v9fs_string_free(&vs->name); - qemu_free(vs); + complete_pdu(s, pdu, err); + v9fs_string_free(&name); } static void v9fs_readlink(void *opaque) diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 2976433..d57d5ae 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -399,17 +399,6 @@ typedef struct V9fsRenameState { V9fsString name; } V9fsRenameState; -typedef struct V9fsXattrState -{ - V9fsPDU *pdu; - size_t offset; - V9fsFidState *file_fidp; - V9fsFidState *xattr_fidp; - V9fsString name; - int64_t size; - int flags; - void *value; -} V9fsXattrState; #define P9_LOCK_SUCCESS 0 #define P9_LOCK_BLOCKED 1