diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2019-06-04 19:15:11 +0300 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2019-08-27 14:58:42 +0100 |
commit | 1acc3466a2fbbeb988b91f2ac05bb9cde1fc8e9d (patch) | |
tree | 63a0dfba6d70bf5bcefa518760315d9546e74f9c | |
parent | 28c4da28695bdbe04b336b2c9c463876cc3aaa6d (diff) | |
download | qemu-1acc3466a2fbbeb988b91f2ac05bb9cde1fc8e9d.zip qemu-1acc3466a2fbbeb988b91f2ac05bb9cde1fc8e9d.tar.gz qemu-1acc3466a2fbbeb988b91f2ac05bb9cde1fc8e9d.tar.bz2 |
block/io: introduce bdrv_co_p{read, write}v_part
Introduce extended variants of bdrv_co_preadv and bdrv_co_pwritev
with qiov_offset parameter.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20190604161514.262241-10-vsementsov@virtuozzo.com
Message-Id: <20190604161514.262241-10-vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-rw-r--r-- | block/io.c | 29 | ||||
-rw-r--r-- | include/block/block_int.h | 6 |
2 files changed, 29 insertions, 6 deletions
@@ -1614,7 +1614,8 @@ static void bdrv_padding_destroy(BdrvRequestPadding *pad) * * Function always succeeds. */ -static bool bdrv_pad_request(BlockDriverState *bs, QEMUIOVector **qiov, +static bool bdrv_pad_request(BlockDriverState *bs, + QEMUIOVector **qiov, size_t *qiov_offset, int64_t *offset, unsigned int *bytes, BdrvRequestPadding *pad) { @@ -1623,11 +1624,12 @@ static bool bdrv_pad_request(BlockDriverState *bs, QEMUIOVector **qiov, } qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head, - *qiov, 0, *bytes, + *qiov, *qiov_offset, *bytes, pad->buf + pad->buf_len - pad->tail, pad->tail); *bytes += pad->head + pad->tail; *offset -= pad->head; *qiov = &pad->local_qiov; + *qiov_offset = 0; return true; } @@ -1636,6 +1638,14 @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { + return bdrv_co_preadv_part(child, offset, bytes, qiov, 0, flags); +} + +int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, + int64_t offset, unsigned int bytes, + QEMUIOVector *qiov, size_t qiov_offset, + BdrvRequestFlags flags) +{ BlockDriverState *bs = child->bs; BdrvTrackedRequest req; BdrvRequestPadding pad; @@ -1655,12 +1665,12 @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child, flags |= BDRV_REQ_COPY_ON_READ; } - bdrv_pad_request(bs, &qiov, &offset, &bytes, &pad); + bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad); tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_READ); ret = bdrv_aligned_preadv(child, &req, offset, bytes, bs->bl.request_alignment, - qiov, 0, flags); + qiov, qiov_offset, flags); tracked_request_end(&req); bdrv_dec_in_flight(bs); @@ -2024,6 +2034,13 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { + return bdrv_co_pwritev_part(child, offset, bytes, qiov, 0, flags); +} + +int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, + int64_t offset, unsigned int bytes, QEMUIOVector *qiov, size_t qiov_offset, + BdrvRequestFlags flags) +{ BlockDriverState *bs = child->bs; BdrvTrackedRequest req; uint64_t align = bs->bl.request_alignment; @@ -2054,14 +2071,14 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, goto out; } - if (bdrv_pad_request(bs, &qiov, &offset, &bytes, &pad)) { + if (bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad)) { mark_request_serialising(&req, align); wait_serialising_requests(&req); bdrv_padding_rmw_read(child, &req, &pad, false); } ret = bdrv_aligned_pwritev(child, &req, offset, bytes, align, - qiov, 0, flags); + qiov, qiov_offset, flags); bdrv_padding_destroy(&pad); diff --git a/include/block/block_int.h b/include/block/block_int.h index 79a1fdb..0422acd 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -959,9 +959,15 @@ extern BlockDriver bdrv_qcow2; int coroutine_fn bdrv_co_preadv(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); +int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, + int64_t offset, unsigned int bytes, + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); int coroutine_fn bdrv_co_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); +int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, + int64_t offset, unsigned int bytes, + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); static inline int coroutine_fn bdrv_co_pread(BdrvChild *child, int64_t offset, unsigned int bytes, void *buf, BdrvRequestFlags flags) |