[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/37] block: Drop last of the sector-based aio callb
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 07/37] block: Drop last of the sector-based aio callbacks |
Date: |
Tue, 15 May 2018 17:40:03 +0200 |
From: Eric Blake <address@hidden>
We are gradually moving away from sector-based interfaces, towards
byte-based. Now that all drivers with aio callbacks are using the
byte-based interfaces, we can remove the sector-based versions.
Signed-off-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
include/block/block_int.h | 6 ----
block/io.c | 84 ++++++++++++++++++++---------------------------
2 files changed, 36 insertions(+), 54 deletions(-)
diff --git a/include/block/block_int.h b/include/block/block_int.h
index e772e3502b..0bba7ed024 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -141,15 +141,9 @@ struct BlockDriver {
void (*bdrv_refresh_filename)(BlockDriverState *bs, QDict *options);
/* aio */
- BlockAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs,
- int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
- BlockCompletionFunc *cb, void *opaque);
BlockAIOCB *(*bdrv_aio_preadv)(BlockDriverState *bs,
uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags,
BlockCompletionFunc *cb, void *opaque);
- BlockAIOCB *(*bdrv_aio_writev)(BlockDriverState *bs,
- int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
- BlockCompletionFunc *cb, void *opaque);
BlockAIOCB *(*bdrv_aio_pwritev)(BlockDriverState *bs,
uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags,
BlockCompletionFunc *cb, void *opaque);
diff --git a/block/io.c b/block/io.c
index 407bc25df4..6b110b207a 100644
--- a/block/io.c
+++ b/block/io.c
@@ -925,31 +925,14 @@ static int coroutine_fn
bdrv_driver_preadv(BlockDriverState *bs,
return drv->bdrv_co_preadv(bs, offset, bytes, qiov, flags);
}
- /* FIXME - no need to calculate these if .bdrv_aio_preadv exists */
- sector_num = offset >> BDRV_SECTOR_BITS;
- nb_sectors = bytes >> BDRV_SECTOR_BITS;
-
- if (!drv->bdrv_aio_preadv) {
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
- assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);
- }
-
- if (drv->bdrv_co_readv) {
- return drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov);
- } else {
+ if (drv->bdrv_aio_preadv) {
BlockAIOCB *acb;
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
- if (drv->bdrv_aio_preadv) {
- acb = drv->bdrv_aio_preadv(bs, offset, bytes, qiov, flags,
- bdrv_co_io_em_complete, &co);
- } else {
- acb = drv->bdrv_aio_readv(bs, sector_num, qiov, nb_sectors,
- bdrv_co_io_em_complete, &co);
- }
+ acb = drv->bdrv_aio_preadv(bs, offset, bytes, qiov, flags,
+ bdrv_co_io_em_complete, &co);
if (acb == NULL) {
return -EIO;
} else {
@@ -957,6 +940,16 @@ static int coroutine_fn
bdrv_driver_preadv(BlockDriverState *bs,
return co.ret;
}
}
+
+ sector_num = offset >> BDRV_SECTOR_BITS;
+ nb_sectors = bytes >> BDRV_SECTOR_BITS;
+
+ assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
+ assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
+ assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);
+ assert(drv->bdrv_co_readv);
+
+ return drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov);
}
static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs,
@@ -981,45 +974,40 @@ static int coroutine_fn
bdrv_driver_pwritev(BlockDriverState *bs,
goto emulate_flags;
}
- /* FIXME - no need to calculate these if .bdrv_aio_pwritev exists */
- sector_num = offset >> BDRV_SECTOR_BITS;
- nb_sectors = bytes >> BDRV_SECTOR_BITS;
-
- if (!drv->bdrv_aio_pwritev) {
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
- assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);
- }
-
- if (drv->bdrv_co_writev_flags) {
- ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov,
- flags & bs->supported_write_flags);
- flags &= ~bs->supported_write_flags;
- } else if (drv->bdrv_co_writev) {
- assert(!bs->supported_write_flags);
- ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov);
- } else {
+ if (drv->bdrv_aio_pwritev) {
BlockAIOCB *acb;
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
- if (drv->bdrv_aio_pwritev) {
- acb = drv->bdrv_aio_pwritev(bs, offset, bytes, qiov,
- flags & bs->supported_write_flags,
- bdrv_co_io_em_complete, &co);
- flags &= ~bs->supported_write_flags;
- } else {
- assert(!bs->supported_write_flags);
- acb = drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sectors,
- bdrv_co_io_em_complete, &co);
- }
+ acb = drv->bdrv_aio_pwritev(bs, offset, bytes, qiov,
+ flags & bs->supported_write_flags,
+ bdrv_co_io_em_complete, &co);
+ flags &= ~bs->supported_write_flags;
if (acb == NULL) {
ret = -EIO;
} else {
qemu_coroutine_yield();
ret = co.ret;
}
+ goto emulate_flags;
+ }
+
+ sector_num = offset >> BDRV_SECTOR_BITS;
+ nb_sectors = bytes >> BDRV_SECTOR_BITS;
+
+ assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
+ assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
+ assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);
+
+ if (drv->bdrv_co_writev_flags) {
+ ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov,
+ flags & bs->supported_write_flags);
+ flags &= ~bs->supported_write_flags;
+ } else {
+ assert(drv->bdrv_co_writev);
+ assert(!bs->supported_write_flags);
+ ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov);
}
emulate_flags:
--
2.13.6
- [Qemu-devel] [PULL 00/37] Block layer patches, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 05/37] rbd: Switch to byte-based callbacks, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 02/37] block: Support byte-based aio callbacks, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 03/37] file-win32: Switch to byte-based callbacks, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 04/37] null: Switch to byte-based read/write, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 06/37] vxhs: Switch to byte-based callbacks, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 10/37] blockjob: expose error string via query, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 15/37] blockjob: Introduce block_job_ratelimit_get_delay(), Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 07/37] block: Drop last of the sector-based aio callbacks,
Kevin Wolf <=
- [Qemu-devel] [PULL 01/37] block-backend: simplify blk_get_aio_context, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 11/37] blockjob: Fix assertion in block_job_finalize(), Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 16/37] blockjob: Add block_job_driver(), Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 12/37] blockjob: Wrappers for progress counter access, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 08/37] block: Merge .bdrv_co_writev{, _flags} in drivers, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 09/37] hmp: Allow using a qdev id in block_set_io_throttle, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 19/37] specs/qcow2: Clarify that compressed clusters have the COPIED bit reset, Kevin Wolf, 2018/05/15
- [Qemu-devel] [PULL 20/37] qcow2: Give the refcount cache the minimum possible size by default, Kevin Wolf, 2018/05/15