From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmf1m-0001oz-V4 for qemu-devel@nongnu.org; Fri, 29 Jul 2011 00:50:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qmf1l-0000QG-Px for qemu-devel@nongnu.org; Fri, 29 Jul 2011 00:50:26 -0400 Received: from mail-iy0-f173.google.com ([209.85.210.173]:46817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmf1l-0000NN-9h for qemu-devel@nongnu.org; Fri, 29 Jul 2011 00:50:25 -0400 Received: by mail-iy0-f173.google.com with SMTP id 39so4186308iyb.4 for ; Thu, 28 Jul 2011 21:50:25 -0700 (PDT) From: Devin Nakamura Date: Fri, 29 Jul 2011 00:49:38 -0400 Message-Id: <1311914994-20482-9-git-send-email-devin122@gmail.com> In-Reply-To: <1311914994-20482-1-git-send-email-devin122@gmail.com> References: <1311914994-20482-1-git-send-email-devin122@gmail.com> Subject: [Qemu-devel] [RFC 08/24] qed: add qed_find_cluster_sync() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, Devin Nakamura Signed-off-by: Devin Nakamura --- block/qed-cluster.c | 35 +++++++++++++++++++++++++++++++++++ block/qed.h | 4 ++++ 2 files changed, 39 insertions(+), 0 deletions(-) diff --git a/block/qed-cluster.c b/block/qed-cluster.c index 3e19ad1..063b965 100644 --- a/block/qed-cluster.c +++ b/block/qed-cluster.c @@ -163,3 +163,38 @@ void qed_find_cluster(BDRVQEDState *s, QEDRequest *request, uint64_t pos, qed_read_l2_table(s, request, l2_offset, qed_find_cluster_cb, find_cluster_cb); } + +typedef struct { + int ret; + uint64_t *offset; + size_t *len; +} QEDFindClusterSyncCB; + +static void qed_find_cluster_sync_cb(void *opaque, int ret, uint64_t offset, + size_t len) +{ + QEDFindClusterSyncCB *find_cluster_sync_cb = opaque; + *find_cluster_sync_cb->offset = offset; + *find_cluster_sync_cb->len = len; + find_cluster_sync_cb->ret = ret; +} + +int qed_find_cluster_sync(BDRVQEDState *s, QEDRequest *request, uint64_t pos, + size_t len, uint64_t *offset, + size_t *contiguous_bytes) +{ + QEDFindClusterSyncCB find_cluster_cb; + find_cluster_cb.ret = -EINPROGRESS; + find_cluster_cb.offset = offset; + find_cluster_cb.len = contiguous_bytes; + + async_context_push(); + qed_find_cluster(s, request, pos, len, &qed_find_cluster_sync_cb, + &find_cluster_cb); + while (find_cluster_cb.ret == -EINPROGRESS) { + qemu_aio_wait(); + } + async_context_pop(); + + return find_cluster_cb.ret; +} diff --git a/block/qed.h b/block/qed.h index 388fdb3..c899c15 100644 --- a/block/qed.h +++ b/block/qed.h @@ -239,6 +239,10 @@ int qed_write_l2_table_sync(BDRVQEDState *s, QEDRequest *request, void qed_find_cluster(BDRVQEDState *s, QEDRequest *request, uint64_t pos, size_t len, QEDFindClusterFunc *cb, void *opaque); +int qed_find_cluster_sync(BDRVQEDState *s, QEDRequest *request, uint64_t pos, + size_t len, uint64_t *offset, + size_t *contiguous_bytes); + /** * Consistency check */ -- 1.7.6.rc1