From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=60438 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzRek-0008SR-30 for qemu-devel@nongnu.org; Tue, 15 Mar 2011 06:39:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzRei-00044h-UJ for qemu-devel@nongnu.org; Tue, 15 Mar 2011 06:39:13 -0400 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:41049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzRei-00044W-66 for qemu-devel@nongnu.org; Tue, 15 Mar 2011 06:39:12 -0400 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by e28smtp09.in.ibm.com (8.14.4/8.13.1) with ESMTP id p2F9gkOc006127 for ; Tue, 15 Mar 2011 15:12:46 +0530 Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2FAd3Zo3002618 for ; Tue, 15 Mar 2011 16:09:03 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2FAd3qA015246 for ; Tue, 15 Mar 2011 21:39:03 +1100 Date: Tue, 15 Mar 2011 16:09:01 +0530 From: Arun R Bharadwaj Message-ID: <20110315103901.GD23922@linux.vnet.ibm.com> References: <20110315103453.GA23922@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20110315103453.GA23922@linux.vnet.ibm.com> Subject: [Qemu-devel] [v1 PATCH 3/3]: Convert v9fs_stat to threaded model. Reply-To: arun@linux.vnet.ibm.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, aliguori@us.ibm.com, jvrao@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, Arun Bharadwaj * Arun R Bharadwaj [2011-03-15 16:04:53]: Author: Harsh Prateek Bora Date: Mon Mar 14 13:55:37 2011 +0530 Convert v9fs_stat to threaded model. This patch converts v9fs_stat syscall of 9pfs to threaded model by making use of the helper routines provided created by the previous patch. Signed-off-by: Harsh Prateek Bora Signed-off-by: Arun R Bharadwaj diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index cf61345..a328e97 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -1458,26 +1458,35 @@ out: v9fs_string_free(&aname); } -static void v9fs_stat_post_lstat(V9fsState *s, V9fsStatState *vs, int err) +static void v9fs_stat_post_lstat(void *opaque) { - if (err == -1) { - err = -errno; + V9fsStatState *vs = (V9fsStatState *)opaque; + if (vs->err == -1) { + vs->err = -(vs->v9fs_errno); goto out; } - err = stat_to_v9stat(s, &vs->fidp->fsmap.path, &vs->stbuf, &vs->v9stat); - if (err) { + vs->err = stat_to_v9stat(vs->s, &vs->fidp->fsmap.path, &vs->stbuf, &vs->v9stat); + if (vs->err) { goto out; } vs->offset += pdu_marshal(vs->pdu, vs->offset, "wS", 0, &vs->v9stat); - err = vs->offset; + vs->err = vs->offset; out: - complete_pdu(s, vs->pdu, err); + complete_pdu(vs->s, vs->pdu, vs->err); v9fs_stat_free(&vs->v9stat); qemu_free(vs); } +static void v9fs_stat_do_lstat(V9fsRequest *request) +{ + V9fsStatState *vs = container_of(request, V9fsStatState, request); + + vs->err = v9fs_do_lstat(vs->s, &vs->fidp->fsmap.path, &vs->stbuf); + vs->v9fs_errno = errno; +} + static void v9fs_stat(V9fsState *s, V9fsPDU *pdu) { int32_t fid; @@ -1487,6 +1496,10 @@ static void v9fs_stat(V9fsState *s, V9fsPDU *pdu) vs = qemu_malloc(sizeof(*vs)); vs->pdu = pdu; vs->offset = 7; + vs->s = s; + vs->request.func = v9fs_stat_do_lstat; + vs->request.post_op.func = v9fs_stat_post_lstat; + vs->request.post_op.arg = vs; memset(&vs->v9stat, 0, sizeof(vs->v9stat)); @@ -1498,8 +1511,11 @@ static void v9fs_stat(V9fsState *s, V9fsPDU *pdu) goto out; } + /* err = v9fs_do_lstat(s, &vs->fidp->fsmap.path, &vs->stbuf); v9fs_stat_post_lstat(s, vs, err); + */ + v9fs_qemu_submit_request(&vs->request); return; out: diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index e7d2326..1d6c17c 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -271,6 +271,10 @@ typedef struct V9fsStatState { V9fsStat v9stat; V9fsFidState *fidp; struct stat stbuf; + V9fsState *s; + int err; + int v9fs_errno; + V9fsRequest request; } V9fsStatState; typedef struct V9fsStatDotl {