@@ -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;
+}
@@ -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
*/
Signed-off-by: Devin Nakamura <devin122@gmail.com> --- block/qed-cluster.c | 35 +++++++++++++++++++++++++++++++++++ block/qed.h | 4 ++++ 2 files changed, 39 insertions(+), 0 deletions(-)