[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 11/37] qcow: Switch to .bdrv_co_block_status()
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 11/37] qcow: Switch to .bdrv_co_block_status() |
Date: |
Fri, 2 Mar 2018 19:54:22 +0100 |
From: Eric Blake <address@hidden>
We are gradually moving away from sector-based interfaces, towards
byte-based. Update the qcow driver accordingly. There is no
intent to optimize based on the want_zero flag for this format.
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/block/qcow.c b/block/qcow.c
index 8631155ac8..dead5029c6 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -524,23 +524,28 @@ static int get_cluster_offset(BlockDriverState *bs,
return 1;
}
-static int64_t coroutine_fn qcow_co_get_block_status(BlockDriverState *bs,
- int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file)
+static int coroutine_fn qcow_co_block_status(BlockDriverState *bs,
+ bool want_zero,
+ int64_t offset, int64_t bytes,
+ int64_t *pnum, int64_t *map,
+ BlockDriverState **file)
{
BDRVQcowState *s = bs->opaque;
- int index_in_cluster, n, ret;
+ int index_in_cluster, ret;
+ int64_t n;
uint64_t cluster_offset;
qemu_co_mutex_lock(&s->lock);
- ret = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0, &cluster_offset);
+ ret = get_cluster_offset(bs, offset, 0, 0, 0, 0, &cluster_offset);
qemu_co_mutex_unlock(&s->lock);
if (ret < 0) {
return ret;
}
- index_in_cluster = sector_num & (s->cluster_sectors - 1);
- n = s->cluster_sectors - index_in_cluster;
- if (n > nb_sectors)
- n = nb_sectors;
+ index_in_cluster = offset & (s->cluster_size - 1);
+ n = s->cluster_size - index_in_cluster;
+ if (n > bytes) {
+ n = bytes;
+ }
*pnum = n;
if (!cluster_offset) {
return 0;
@@ -548,9 +553,9 @@ static int64_t coroutine_fn
qcow_co_get_block_status(BlockDriverState *bs,
if ((cluster_offset & QCOW_OFLAG_COMPRESSED) || s->crypto) {
return BDRV_BLOCK_DATA;
}
- cluster_offset |= (index_in_cluster << BDRV_SECTOR_BITS);
+ *map = cluster_offset | index_in_cluster;
*file = bs->file->bs;
- return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | cluster_offset;
+ return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;
}
static int decompress_buffer(uint8_t *out_buf, int out_buf_size,
@@ -1128,7 +1133,7 @@ static BlockDriver bdrv_qcow = {
.bdrv_co_readv = qcow_co_readv,
.bdrv_co_writev = qcow_co_writev,
- .bdrv_co_get_block_status = qcow_co_get_block_status,
+ .bdrv_co_block_status = qcow_co_block_status,
.bdrv_make_empty = qcow_make_empty,
.bdrv_co_pwritev_compressed = qcow_co_pwritev_compressed,
--
2.13.6
- [Qemu-block] [PULL 04/37] file-posix: Switch to .bdrv_co_block_status(), (continued)
- [Qemu-block] [PULL 04/37] file-posix: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 02/37] nvme: Drop pointless .bdrv_co_get_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 06/37] iscsi: Switch cluster_sectors to byte-based, Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 03/37] block: Switch passthrough drivers to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 07/37] iscsi: Switch iscsi_allocmap_update() to byte-based, Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 01/37] block: Add .bdrv_co_block_status() callback, Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 05/37] gluster: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 08/37] iscsi: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 09/37] null: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 10/37] parallels: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 11/37] qcow: Switch to .bdrv_co_block_status(),
Kevin Wolf <=
- [Qemu-block] [PULL 12/37] qcow2: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 13/37] qed: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 14/37] raw: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 15/37] sheepdog: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 16/37] vdi: Avoid bitrot of debugging code, Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 17/37] vdi: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 18/37] vmdk: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 19/37] vpc: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 20/37] vvfat: Switch to .bdrv_co_block_status(), Kevin Wolf, 2018/03/02
- [Qemu-block] [PULL 21/37] block: Drop unused .bdrv_co_get_block_status(), Kevin Wolf, 2018/03/02