From patchwork Wed May 25 23:53:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 97465 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 9289DB6F92 for ; Thu, 26 May 2011 09:58:58 +1000 (EST) Received: from localhost ([::1]:36774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPNya-0003ul-1S for incoming@patchwork.ozlabs.org; Wed, 25 May 2011 19:58:56 -0400 Received: from eggs.gnu.org ([140.186.70.92]:49089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPNtW-0008CK-R9 for qemu-devel@nongnu.org; Wed, 25 May 2011 19:53:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QPNtU-0007YL-KZ for qemu-devel@nongnu.org; Wed, 25 May 2011 19:53:42 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:38529) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPNtU-0007Y2-9q for qemu-devel@nongnu.org; Wed, 25 May 2011 19:53:40 -0400 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e36.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4PNllG5025229 for ; Wed, 25 May 2011 17:47:47 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4PNrXQr153574 for ; Wed, 25 May 2011 17:53:33 -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 p4PHr57K018541 for ; Wed, 25 May 2011 11:53:06 -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 p4PHqwLs018178; Wed, 25 May 2011 11:53:05 -0600 From: "Venkateswararao Jujjuri (JV)" To: qemu-devel@nongnu.org Date: Wed, 25 May 2011 16:53:09 -0700 Message-Id: <1306367597-797-22-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.154 Cc: "Venkateswararao Jujjuri \(JV\)" , stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 21/29] [virtio-9p] coroutine and threading for v9fs_do_symlink 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 Signed-off-by: Venkateswararao Jujjuri " --- hw/9pfs/cofs.c | 20 ++++++++++++++++++++ hw/9pfs/virtio-9p-coth.h | 2 ++ hw/9pfs/virtio-9p.c | 31 ++++++++----------------------- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/hw/9pfs/cofs.c b/hw/9pfs/cofs.c index 473ce53..60468bc 100644 --- a/hw/9pfs/cofs.c +++ b/hw/9pfs/cofs.c @@ -169,3 +169,23 @@ int v9fs_co_rename(V9fsState *s, V9fsString *oldpath, V9fsString *newpath) }); return err; } + +int v9fs_co_symlink(V9fsState *s, V9fsFidState *fidp, + const char *oldpath, const char *newpath, gid_t gid) +{ + int err; + FsCred cred; + + cred_init(&cred); + cred.fc_uid = fidp->uid; + cred.fc_gid = gid; + cred.fc_mode = 0777; + v9fs_co_run_in_worker( + { + err = s->ops->symlink(&s->ctx, oldpath, newpath, &cred); + if (err < 0) { + err = -errno; + } + }); + return err; +} diff --git a/hw/9pfs/virtio-9p-coth.h b/hw/9pfs/virtio-9p-coth.h index a3881f3..e394933 100644 --- a/hw/9pfs/virtio-9p-coth.h +++ b/hw/9pfs/virtio-9p-coth.h @@ -86,4 +86,6 @@ extern int v9fs_co_lremovexattr(V9fsState *, V9fsString *, V9fsString *); extern int v9fs_co_closedir(V9fsState *, V9fsFidState *); extern int v9fs_co_close(V9fsState *, V9fsFidState *); extern int v9fs_co_fsync(V9fsState *, V9fsFidState *, int); +extern int v9fs_co_symlink(V9fsState *, V9fsFidState *, const char *, + const char *, gid_t); #endif diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 1e6c2b8..cb11ee6 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -117,18 +117,6 @@ static int v9fs_do_chmod(V9fsState *s, V9fsString *path, mode_t mode) return s->ops->chmod(&s->ctx, path->data, &cred); } -static int v9fs_do_symlink(V9fsState *s, V9fsFidState *fidp, - const char *oldpath, const char *newpath, gid_t gid) -{ - FsCred cred; - cred_init(&cred); - cred.fc_uid = fidp->uid; - cred.fc_gid = gid; - cred.fc_mode = 0777; - - return s->ops->symlink(&s->ctx, oldpath, newpath, &cred); -} - static int v9fs_do_link(V9fsState *s, V9fsString *oldpath, V9fsString *newpath) { return s->ops->link(&s->ctx, oldpath->data, newpath->data); @@ -2030,10 +2018,9 @@ static void v9fs_create(void *opaque) } fidp->fid_type = P9_FID_DIR; } else if (perm & P9_STAT_MODE_SYMLINK) { - err = v9fs_do_symlink(pdu->s, fidp, extension.data, + err = v9fs_co_symlink(pdu->s, fidp, extension.data, fullname.data, -1); if (err < 0) { - err = -errno; goto out; } } else if (perm & P9_STAT_MODE_LINK) { @@ -2142,19 +2129,17 @@ static void v9fs_symlink(void *opaque) } v9fs_string_sprintf(&fullname, "%s/%s", dfidp->path.data, name.data); - err = v9fs_do_symlink(pdu->s, dfidp, symname.data, fullname.data, gid); + err = v9fs_co_symlink(pdu->s, dfidp, symname.data, fullname.data, gid); if (err < 0) { - err = -errno; goto out; } - err = v9fs_do_lstat(pdu->s, &fullname, &stbuf); - if (err == 0) { - stat_to_qid(&stbuf, &qid); - offset += pdu_marshal(pdu, offset, "Q", &qid); - err = offset; - } else { - err = -errno; + err = v9fs_co_lstat(pdu->s, &fullname, &stbuf); + if (err < 0) { + goto out; } + stat_to_qid(&stbuf, &qid); + offset += pdu_marshal(pdu, offset, "Q", &qid); + err = offset; out: complete_pdu(pdu->s, pdu, err); v9fs_string_free(&name);