|
|
218e99 |
From 89e6ba9d5ad137ecb8f981f1ec28ee519812bf50 Mon Sep 17 00:00:00 2001
|
|
|
218e99 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
Date: Wed, 6 Nov 2013 12:37:43 +0100
|
|
|
218e99 |
Subject: [PATCH 12/81] block: introduce bdrv_get_block_status API
|
|
|
218e99 |
|
|
|
218e99 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
Message-id: <1383741463-25811-1-git-send-email-pbonzini@redhat.com>
|
|
|
218e99 |
Patchwork-id: 55521
|
|
|
218e99 |
O-Subject: [RHEL 7.0 qemu-kvm PATCH v2 12/26] block: introduce bdrv_get_block_status API
|
|
|
218e99 |
Bugzilla: 989646
|
|
|
218e99 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
For now, bdrv_get_block_status is just another name for bdrv_is_allocated.
|
|
|
218e99 |
The next patches will add more flags.
|
|
|
218e99 |
|
|
|
218e99 |
This also touches all block drivers with a mostly mechanical rename. The
|
|
|
218e99 |
sole exception is cow; because it calls cow_co_is_allocated from the read
|
|
|
218e99 |
code, we keep that function and make cow_co_get_block_status a wrapper.
|
|
|
218e99 |
|
|
|
218e99 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
218e99 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
(cherry picked from commit b6b8a33354a448ee421f57676c1a93a536a63269)
|
|
|
218e99 |
---
|
|
|
218e99 |
block.c | 46 ++++++++++++++++++++++++++--------------------
|
|
|
218e99 |
block/cow.c | 8 +++++++-
|
|
|
218e99 |
block/qcow.c | 4 ++--
|
|
|
218e99 |
block/qcow2.c | 4 ++--
|
|
|
218e99 |
block/qed.c | 4 ++--
|
|
|
218e99 |
block/raw-posix.c | 4 ++--
|
|
|
218e99 |
block/raw.c | 6 +++---
|
|
|
218e99 |
block/sheepdog.c | 12 ++++++------
|
|
|
218e99 |
block/vdi.c | 4 ++--
|
|
|
218e99 |
block/vmdk.c | 4 ++--
|
|
|
218e99 |
block/vvfat.c | 4 ++--
|
|
|
218e99 |
include/block/block.h | 2 ++
|
|
|
218e99 |
include/block/block_int.h | 2 +-
|
|
|
218e99 |
13 files changed, 59 insertions(+), 45 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block.c | 46 +++++++++++++++++++++++++-------------------
|
|
|
218e99 |
block/cow.c | 8 ++++++-
|
|
|
218e99 |
block/qcow.c | 4 +-
|
|
|
218e99 |
block/qcow2.c | 4 +-
|
|
|
218e99 |
block/qed.c | 4 +-
|
|
|
218e99 |
block/raw-posix.c | 4 +-
|
|
|
218e99 |
block/raw.c | 6 ++--
|
|
|
218e99 |
block/sheepdog.c | 12 +++++-----
|
|
|
218e99 |
block/vdi.c | 4 +-
|
|
|
218e99 |
block/vmdk.c | 4 +-
|
|
|
218e99 |
block/vvfat.c | 4 +-
|
|
|
218e99 |
include/block/block.h | 2 +
|
|
|
218e99 |
include/block/block_int.h | 2 +-
|
|
|
218e99 |
13 files changed, 59 insertions(+), 45 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/block.c b/block.c
|
|
|
218e99 |
index f5d6658..772f5b7 100644
|
|
|
218e99 |
--- a/block.c
|
|
|
218e99 |
+++ b/block.c
|
|
|
218e99 |
@@ -3010,15 +3010,15 @@ int bdrv_has_zero_init(BlockDriverState *bs)
|
|
|
218e99 |
return 1;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-typedef struct BdrvCoIsAllocatedData {
|
|
|
218e99 |
+typedef struct BdrvCoGetBlockStatusData {
|
|
|
218e99 |
BlockDriverState *bs;
|
|
|
218e99 |
BlockDriverState *base;
|
|
|
218e99 |
int64_t sector_num;
|
|
|
218e99 |
int nb_sectors;
|
|
|
218e99 |
int *pnum;
|
|
|
218e99 |
- int ret;
|
|
|
218e99 |
+ int64_t ret;
|
|
|
218e99 |
bool done;
|
|
|
218e99 |
-} BdrvCoIsAllocatedData;
|
|
|
218e99 |
+} BdrvCoGetBlockStatusData;
|
|
|
218e99 |
|
|
|
218e99 |
/*
|
|
|
218e99 |
* Returns true iff the specified sector is present in the disk image. Drivers
|
|
|
218e99 |
@@ -3035,9 +3035,9 @@ typedef struct BdrvCoIsAllocatedData {
|
|
|
218e99 |
* 'nb_sectors' is the max value 'pnum' should be set to. If nb_sectors goes
|
|
|
218e99 |
* beyond the end of the disk image it will be clamped.
|
|
|
218e99 |
*/
|
|
|
218e99 |
-static int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
- int64_t sector_num,
|
|
|
218e99 |
- int nb_sectors, int *pnum)
|
|
|
218e99 |
+static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
+ int64_t sector_num,
|
|
|
218e99 |
+ int nb_sectors, int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
int64_t length;
|
|
|
218e99 |
int64_t n;
|
|
|
218e99 |
@@ -3057,35 +3057,35 @@ static int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
nb_sectors = n;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
- if (!bs->drv->bdrv_co_is_allocated) {
|
|
|
218e99 |
+ if (!bs->drv->bdrv_co_get_block_status) {
|
|
|
218e99 |
*pnum = nb_sectors;
|
|
|
218e99 |
return 1;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
- return bs->drv->bdrv_co_is_allocated(bs, sector_num, nb_sectors, pnum);
|
|
|
218e99 |
+ return bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum);
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-/* Coroutine wrapper for bdrv_is_allocated() */
|
|
|
218e99 |
-static void coroutine_fn bdrv_is_allocated_co_entry(void *opaque)
|
|
|
218e99 |
+/* Coroutine wrapper for bdrv_get_block_status() */
|
|
|
218e99 |
+static void coroutine_fn bdrv_get_block_status_co_entry(void *opaque)
|
|
|
218e99 |
{
|
|
|
218e99 |
- BdrvCoIsAllocatedData *data = opaque;
|
|
|
218e99 |
+ BdrvCoGetBlockStatusData *data = opaque;
|
|
|
218e99 |
BlockDriverState *bs = data->bs;
|
|
|
218e99 |
|
|
|
218e99 |
- data->ret = bdrv_co_is_allocated(bs, data->sector_num, data->nb_sectors,
|
|
|
218e99 |
- data->pnum);
|
|
|
218e99 |
+ data->ret = bdrv_co_get_block_status(bs, data->sector_num, data->nb_sectors,
|
|
|
218e99 |
+ data->pnum);
|
|
|
218e99 |
data->done = true;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
/*
|
|
|
218e99 |
- * Synchronous wrapper around bdrv_co_is_allocated().
|
|
|
218e99 |
+ * Synchronous wrapper around bdrv_co_get_block_status().
|
|
|
218e99 |
*
|
|
|
218e99 |
- * See bdrv_co_is_allocated() for details.
|
|
|
218e99 |
+ * See bdrv_co_get_block_status() for details.
|
|
|
218e99 |
*/
|
|
|
218e99 |
-int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
|
|
218e99 |
- int *pnum)
|
|
|
218e99 |
+int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
+ int nb_sectors, int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
Coroutine *co;
|
|
|
218e99 |
- BdrvCoIsAllocatedData data = {
|
|
|
218e99 |
+ BdrvCoGetBlockStatusData data = {
|
|
|
218e99 |
.bs = bs,
|
|
|
218e99 |
.sector_num = sector_num,
|
|
|
218e99 |
.nb_sectors = nb_sectors,
|
|
|
218e99 |
@@ -3095,9 +3095,9 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
|
|
218e99 |
|
|
|
218e99 |
if (qemu_in_coroutine()) {
|
|
|
218e99 |
/* Fast-path if already in coroutine context */
|
|
|
218e99 |
- bdrv_is_allocated_co_entry(&data);
|
|
|
218e99 |
+ bdrv_get_block_status_co_entry(&data);
|
|
|
218e99 |
} else {
|
|
|
218e99 |
- co = qemu_coroutine_create(bdrv_is_allocated_co_entry);
|
|
|
218e99 |
+ co = qemu_coroutine_create(bdrv_get_block_status_co_entry);
|
|
|
218e99 |
qemu_coroutine_enter(co, &data);
|
|
|
218e99 |
while (!data.done) {
|
|
|
218e99 |
qemu_aio_wait();
|
|
|
218e99 |
@@ -3106,6 +3106,12 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
|
|
218e99 |
return data.ret;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
+int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
+ int nb_sectors, int *pnum)
|
|
|
218e99 |
+{
|
|
|
218e99 |
+ return bdrv_get_block_status(bs, sector_num, nb_sectors, pnum);
|
|
|
218e99 |
+}
|
|
|
218e99 |
+
|
|
|
218e99 |
/*
|
|
|
218e99 |
* Given an image chain: ... -> [BASE] -> [INTER1] -> [INTER2] -> [TOP]
|
|
|
218e99 |
*
|
|
|
218e99 |
diff --git a/block/cow.c b/block/cow.c
|
|
|
218e99 |
index 5a33b46..5e71c76 100644
|
|
|
218e99 |
--- a/block/cow.c
|
|
|
218e99 |
+++ b/block/cow.c
|
|
|
218e99 |
@@ -188,6 +188,12 @@ static int coroutine_fn cow_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
return changed;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
+static int64_t coroutine_fn cow_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
+ int64_t sector_num, int nb_sectors, int *num_same)
|
|
|
218e99 |
+{
|
|
|
218e99 |
+ return cow_co_is_allocated(bs, sector_num, nb_sectors, num_same);
|
|
|
218e99 |
+}
|
|
|
218e99 |
+
|
|
|
218e99 |
static int cow_update_bitmap(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
int nb_sectors)
|
|
|
218e99 |
{
|
|
|
218e99 |
@@ -370,7 +376,7 @@ static BlockDriver bdrv_cow = {
|
|
|
218e99 |
|
|
|
218e99 |
.bdrv_read = cow_co_read,
|
|
|
218e99 |
.bdrv_write = cow_co_write,
|
|
|
218e99 |
- .bdrv_co_is_allocated = cow_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = cow_co_get_block_status,
|
|
|
218e99 |
|
|
|
218e99 |
.create_options = cow_create_options,
|
|
|
218e99 |
};
|
|
|
218e99 |
diff --git a/block/qcow.c b/block/qcow.c
|
|
|
218e99 |
index e2a64c7..05af25c 100644
|
|
|
218e99 |
--- a/block/qcow.c
|
|
|
218e99 |
+++ b/block/qcow.c
|
|
|
218e99 |
@@ -395,7 +395,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
|
|
|
218e99 |
return cluster_offset;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-static int coroutine_fn qcow_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
+static int64_t coroutine_fn qcow_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
int64_t sector_num, int nb_sectors, int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
BDRVQcowState *s = bs->opaque;
|
|
|
218e99 |
@@ -895,7 +895,7 @@ static BlockDriver bdrv_qcow = {
|
|
|
218e99 |
|
|
|
218e99 |
.bdrv_co_readv = qcow_co_readv,
|
|
|
218e99 |
.bdrv_co_writev = qcow_co_writev,
|
|
|
218e99 |
- .bdrv_co_is_allocated = qcow_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = qcow_co_get_block_status,
|
|
|
218e99 |
|
|
|
218e99 |
.bdrv_set_key = qcow_set_key,
|
|
|
218e99 |
.bdrv_make_empty = qcow_make_empty,
|
|
|
218e99 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
218e99 |
index f6e64d2..8d3bf5d 100644
|
|
|
218e99 |
--- a/block/qcow2.c
|
|
|
218e99 |
+++ b/block/qcow2.c
|
|
|
218e99 |
@@ -640,7 +640,7 @@ static int qcow2_reopen_prepare(BDRVReopenState *state,
|
|
|
218e99 |
return 0;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-static int coroutine_fn qcow2_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
+static int64_t coroutine_fn qcow2_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
int64_t sector_num, int nb_sectors, int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
BDRVQcowState *s = bs->opaque;
|
|
|
218e99 |
@@ -1786,7 +1786,7 @@ static BlockDriver bdrv_qcow2 = {
|
|
|
218e99 |
.bdrv_close = qcow2_close,
|
|
|
218e99 |
.bdrv_reopen_prepare = qcow2_reopen_prepare,
|
|
|
218e99 |
.bdrv_create = qcow2_create,
|
|
|
218e99 |
- .bdrv_co_is_allocated = qcow2_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = qcow2_co_get_block_status,
|
|
|
218e99 |
.bdrv_set_key = qcow2_set_key,
|
|
|
218e99 |
.bdrv_make_empty = qcow2_make_empty,
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/block/qed.c b/block/qed.c
|
|
|
218e99 |
index 4651403..a573039 100644
|
|
|
218e99 |
--- a/block/qed.c
|
|
|
218e99 |
+++ b/block/qed.c
|
|
|
218e99 |
@@ -667,7 +667,7 @@ static void qed_is_allocated_cb(void *opaque, int ret, uint64_t offset, size_t l
|
|
|
218e99 |
}
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-static int coroutine_fn bdrv_qed_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
+static int64_t coroutine_fn bdrv_qed_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
int64_t sector_num,
|
|
|
218e99 |
int nb_sectors, int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
@@ -1574,7 +1574,7 @@ static BlockDriver bdrv_qed = {
|
|
|
218e99 |
.bdrv_close = bdrv_qed_close,
|
|
|
218e99 |
.bdrv_reopen_prepare = bdrv_qed_reopen_prepare,
|
|
|
218e99 |
.bdrv_create = bdrv_qed_create,
|
|
|
218e99 |
- .bdrv_co_is_allocated = bdrv_qed_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = bdrv_qed_co_get_block_status,
|
|
|
218e99 |
.bdrv_make_empty = bdrv_qed_make_empty,
|
|
|
218e99 |
.bdrv_aio_readv = bdrv_qed_aio_readv,
|
|
|
218e99 |
.bdrv_aio_writev = bdrv_qed_aio_writev,
|
|
|
218e99 |
diff --git a/block/raw-posix.c b/block/raw-posix.c
|
|
|
218e99 |
index 90ce9f8..9a7c5a8 100644
|
|
|
218e99 |
--- a/block/raw-posix.c
|
|
|
218e99 |
+++ b/block/raw-posix.c
|
|
|
218e99 |
@@ -1084,7 +1084,7 @@ static int raw_create(const char *filename, QEMUOptionParameter *options)
|
|
|
218e99 |
* 'nb_sectors' is the max value 'pnum' should be set to. If nb_sectors goes
|
|
|
218e99 |
* beyond the end of the disk image it will be clamped.
|
|
|
218e99 |
*/
|
|
|
218e99 |
-static int coroutine_fn raw_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
+static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
int64_t sector_num,
|
|
|
218e99 |
int nb_sectors, int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
@@ -1199,7 +1199,7 @@ static BlockDriver bdrv_file = {
|
|
|
218e99 |
.bdrv_reopen_abort = raw_reopen_abort,
|
|
|
218e99 |
.bdrv_close = raw_close,
|
|
|
218e99 |
.bdrv_create = raw_create,
|
|
|
218e99 |
- .bdrv_co_is_allocated = raw_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = raw_co_get_block_status,
|
|
|
218e99 |
|
|
|
218e99 |
.bdrv_aio_readv = raw_aio_readv,
|
|
|
218e99 |
.bdrv_aio_writev = raw_aio_writev,
|
|
|
218e99 |
diff --git a/block/raw.c b/block/raw.c
|
|
|
218e99 |
index f78ff39..844a222 100644
|
|
|
218e99 |
--- a/block/raw.c
|
|
|
218e99 |
+++ b/block/raw.c
|
|
|
218e99 |
@@ -35,11 +35,11 @@ static void raw_close(BlockDriverState *bs)
|
|
|
218e99 |
{
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-static int coroutine_fn raw_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
+static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
int64_t sector_num,
|
|
|
218e99 |
int nb_sectors, int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
- return bdrv_is_allocated(bs->file, sector_num, nb_sectors, pnum);
|
|
|
218e99 |
+ return bdrv_get_block_status(bs->file, sector_num, nb_sectors, pnum);
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
static int coroutine_fn raw_co_write_zeroes(BlockDriverState *bs,
|
|
|
218e99 |
@@ -134,7 +134,7 @@ static BlockDriver bdrv_raw = {
|
|
|
218e99 |
|
|
|
218e99 |
.bdrv_co_readv = raw_co_readv,
|
|
|
218e99 |
.bdrv_co_writev = raw_co_writev,
|
|
|
218e99 |
- .bdrv_co_is_allocated = raw_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = raw_co_get_block_status,
|
|
|
218e99 |
.bdrv_co_write_zeroes = raw_co_write_zeroes,
|
|
|
218e99 |
.bdrv_co_discard = raw_co_discard,
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/block/sheepdog.c b/block/sheepdog.c
|
|
|
218e99 |
index 2758c26..e5398bb 100644
|
|
|
218e99 |
--- a/block/sheepdog.c
|
|
|
218e99 |
+++ b/block/sheepdog.c
|
|
|
218e99 |
@@ -2289,9 +2289,9 @@ static coroutine_fn int sd_co_discard(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
return acb->ret;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-static coroutine_fn int
|
|
|
218e99 |
-sd_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
|
|
218e99 |
- int *pnum)
|
|
|
218e99 |
+static coroutine_fn int64_t
|
|
|
218e99 |
+sd_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
|
|
218e99 |
+ int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
BDRVSheepdogState *s = bs->opaque;
|
|
|
218e99 |
SheepdogInode *inode = &s->inode;
|
|
|
218e99 |
@@ -2356,7 +2356,7 @@ static BlockDriver bdrv_sheepdog = {
|
|
|
218e99 |
.bdrv_co_writev = sd_co_writev,
|
|
|
218e99 |
.bdrv_co_flush_to_disk = sd_co_flush_to_disk,
|
|
|
218e99 |
.bdrv_co_discard = sd_co_discard,
|
|
|
218e99 |
- .bdrv_co_is_allocated = sd_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = sd_co_get_block_status,
|
|
|
218e99 |
|
|
|
218e99 |
.bdrv_snapshot_create = sd_snapshot_create,
|
|
|
218e99 |
.bdrv_snapshot_goto = sd_snapshot_goto,
|
|
|
218e99 |
@@ -2383,7 +2383,7 @@ static BlockDriver bdrv_sheepdog_tcp = {
|
|
|
218e99 |
.bdrv_co_writev = sd_co_writev,
|
|
|
218e99 |
.bdrv_co_flush_to_disk = sd_co_flush_to_disk,
|
|
|
218e99 |
.bdrv_co_discard = sd_co_discard,
|
|
|
218e99 |
- .bdrv_co_is_allocated = sd_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = sd_co_get_block_status,
|
|
|
218e99 |
|
|
|
218e99 |
.bdrv_snapshot_create = sd_snapshot_create,
|
|
|
218e99 |
.bdrv_snapshot_goto = sd_snapshot_goto,
|
|
|
218e99 |
@@ -2410,7 +2410,7 @@ static BlockDriver bdrv_sheepdog_unix = {
|
|
|
218e99 |
.bdrv_co_writev = sd_co_writev,
|
|
|
218e99 |
.bdrv_co_flush_to_disk = sd_co_flush_to_disk,
|
|
|
218e99 |
.bdrv_co_discard = sd_co_discard,
|
|
|
218e99 |
- .bdrv_co_is_allocated = sd_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = sd_co_get_block_status,
|
|
|
218e99 |
|
|
|
218e99 |
.bdrv_snapshot_create = sd_snapshot_create,
|
|
|
218e99 |
.bdrv_snapshot_goto = sd_snapshot_goto,
|
|
|
218e99 |
diff --git a/block/vdi.c b/block/vdi.c
|
|
|
218e99 |
index 2662d89..1252ad4 100644
|
|
|
218e99 |
--- a/block/vdi.c
|
|
|
218e99 |
+++ b/block/vdi.c
|
|
|
218e99 |
@@ -470,7 +470,7 @@ static int vdi_reopen_prepare(BDRVReopenState *state,
|
|
|
218e99 |
return 0;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-static int coroutine_fn vdi_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
+static int64_t coroutine_fn vdi_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
int64_t sector_num, int nb_sectors, int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
/* TODO: Check for too large sector_num (in bdrv_is_allocated or here). */
|
|
|
218e99 |
@@ -779,7 +779,7 @@ static BlockDriver bdrv_vdi = {
|
|
|
218e99 |
.bdrv_close = vdi_close,
|
|
|
218e99 |
.bdrv_reopen_prepare = vdi_reopen_prepare,
|
|
|
218e99 |
.bdrv_create = vdi_create,
|
|
|
218e99 |
- .bdrv_co_is_allocated = vdi_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = vdi_co_get_block_status,
|
|
|
218e99 |
.bdrv_make_empty = vdi_make_empty,
|
|
|
218e99 |
|
|
|
218e99 |
.bdrv_read = vdi_co_read,
|
|
|
218e99 |
diff --git a/block/vmdk.c b/block/vmdk.c
|
|
|
218e99 |
index 66735ab..a30c3b9 100644
|
|
|
218e99 |
--- a/block/vmdk.c
|
|
|
218e99 |
+++ b/block/vmdk.c
|
|
|
218e99 |
@@ -1042,7 +1042,7 @@ static VmdkExtent *find_extent(BDRVVmdkState *s,
|
|
|
218e99 |
return NULL;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-static int coroutine_fn vmdk_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
+static int64_t coroutine_fn vmdk_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
int64_t sector_num, int nb_sectors, int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
BDRVVmdkState *s = bs->opaque;
|
|
|
218e99 |
@@ -1820,7 +1820,7 @@ static BlockDriver bdrv_vmdk = {
|
|
|
218e99 |
.bdrv_close = vmdk_close,
|
|
|
218e99 |
.bdrv_create = vmdk_create,
|
|
|
218e99 |
.bdrv_co_flush_to_disk = vmdk_co_flush,
|
|
|
218e99 |
- .bdrv_co_is_allocated = vmdk_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = vmdk_co_get_block_status,
|
|
|
218e99 |
.bdrv_get_allocated_file_size = vmdk_get_allocated_file_size,
|
|
|
218e99 |
|
|
|
218e99 |
.create_options = vmdk_create_options,
|
|
|
218e99 |
diff --git a/block/vvfat.c b/block/vvfat.c
|
|
|
218e99 |
index 87b0279..510a559 100644
|
|
|
218e99 |
--- a/block/vvfat.c
|
|
|
218e99 |
+++ b/block/vvfat.c
|
|
|
218e99 |
@@ -2874,7 +2874,7 @@ static coroutine_fn int vvfat_co_write(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
return ret;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-static int coroutine_fn vvfat_co_is_allocated(BlockDriverState *bs,
|
|
|
218e99 |
+static int64_t coroutine_fn vvfat_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
int64_t sector_num, int nb_sectors, int* n)
|
|
|
218e99 |
{
|
|
|
218e99 |
BDRVVVFATState* s = bs->opaque;
|
|
|
218e99 |
@@ -2981,7 +2981,7 @@ static BlockDriver bdrv_vvfat = {
|
|
|
218e99 |
|
|
|
218e99 |
.bdrv_read = vvfat_co_read,
|
|
|
218e99 |
.bdrv_write = vvfat_co_write,
|
|
|
218e99 |
- .bdrv_co_is_allocated = vvfat_co_is_allocated,
|
|
|
218e99 |
+ .bdrv_co_get_block_status = vvfat_co_get_block_status,
|
|
|
218e99 |
};
|
|
|
218e99 |
|
|
|
218e99 |
static void bdrv_vvfat_init(void)
|
|
|
218e99 |
diff --git a/include/block/block.h b/include/block/block.h
|
|
|
218e99 |
index ec4d4aa..a733f5f 100644
|
|
|
218e99 |
--- a/include/block/block.h
|
|
|
218e99 |
+++ b/include/block/block.h
|
|
|
218e99 |
@@ -281,6 +281,8 @@ void bdrv_drain_all(void);
|
|
|
218e99 |
int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
|
|
|
218e99 |
int bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
|
|
|
218e99 |
int bdrv_has_zero_init(BlockDriverState *bs);
|
|
|
218e99 |
+int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
+ int nb_sectors, int *pnum);
|
|
|
218e99 |
int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
|
|
218e99 |
int *pnum);
|
|
|
218e99 |
int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
|
|
|
218e99 |
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
|
|
218e99 |
index 267be48..ea2c811 100644
|
|
|
218e99 |
--- a/include/block/block_int.h
|
|
|
218e99 |
+++ b/include/block/block_int.h
|
|
|
218e99 |
@@ -124,7 +124,7 @@ struct BlockDriver {
|
|
|
218e99 |
int64_t sector_num, int nb_sectors);
|
|
|
218e99 |
int coroutine_fn (*bdrv_co_discard)(BlockDriverState *bs,
|
|
|
218e99 |
int64_t sector_num, int nb_sectors);
|
|
|
218e99 |
- int coroutine_fn (*bdrv_co_is_allocated)(BlockDriverState *bs,
|
|
|
218e99 |
+ int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs,
|
|
|
218e99 |
int64_t sector_num, int nb_sectors, int *pnum);
|
|
|
218e99 |
|
|
|
218e99 |
/*
|
|
|
218e99 |
--
|
|
|
218e99 |
1.7.1
|
|
|
218e99 |
|