[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/6] qed: add qed_find_cluster_sync()
From: |
Devin Nakamura |
Subject: |
[Qemu-devel] [PATCH 1/6] qed: add qed_find_cluster_sync() |
Date: |
Mon, 12 Sep 2011 10:47:19 -0400 |
Signed-off-by: Devin Nakamura <address@hidden>
---
block/qed-cluster.c | 33 +++++++++++++++++++++++++++++++++
block/qed.h | 4 ++++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/block/qed-cluster.c b/block/qed-cluster.c
index f64b2af..6e68ba7 100644
--- a/block/qed-cluster.c
+++ b/block/qed-cluster.c
@@ -163,3 +163,36 @@ 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;
+
+ qed_find_cluster(s, request, pos, len, &qed_find_cluster_sync_cb,
+ &find_cluster_cb);
+ while (find_cluster_cb.ret == -EINPROGRESS) {
+ qemu_aio_wait();
+ }
+
+ 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