mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
block/io: bdrv_aligned_preadv: use and support qiov_offset
Use and support new API in bdrv_co_do_copy_on_readv. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20190604161514.262241-8-vsementsov@virtuozzo.com Message-Id: <20190604161514.262241-8-vsementsov@virtuozzo.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
2275cc90a1
commit
65cd4424b9
1 changed files with 8 additions and 13 deletions
21
block/io.c
21
block/io.c
|
@ -1376,7 +1376,7 @@ err:
|
||||||
*/
|
*/
|
||||||
static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
|
static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
|
||||||
BdrvTrackedRequest *req, int64_t offset, unsigned int bytes,
|
BdrvTrackedRequest *req, int64_t offset, unsigned int bytes,
|
||||||
int64_t align, QEMUIOVector *qiov, int flags)
|
int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags)
|
||||||
{
|
{
|
||||||
BlockDriverState *bs = child->bs;
|
BlockDriverState *bs = child->bs;
|
||||||
int64_t total_bytes, max_bytes;
|
int64_t total_bytes, max_bytes;
|
||||||
|
@ -1387,7 +1387,6 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
|
||||||
assert(is_power_of_2(align));
|
assert(is_power_of_2(align));
|
||||||
assert((offset & (align - 1)) == 0);
|
assert((offset & (align - 1)) == 0);
|
||||||
assert((bytes & (align - 1)) == 0);
|
assert((bytes & (align - 1)) == 0);
|
||||||
assert(!qiov || bytes == qiov->size);
|
|
||||||
assert((bs->open_flags & BDRV_O_NO_IO) == 0);
|
assert((bs->open_flags & BDRV_O_NO_IO) == 0);
|
||||||
max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX),
|
max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX),
|
||||||
align);
|
align);
|
||||||
|
@ -1425,7 +1424,8 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret || pnum != bytes) {
|
if (!ret || pnum != bytes) {
|
||||||
ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov, 0, flags);
|
ret = bdrv_co_do_copy_on_readv(child, offset, bytes,
|
||||||
|
qiov, qiov_offset, flags);
|
||||||
goto out;
|
goto out;
|
||||||
} else if (flags & BDRV_REQ_PREFETCH) {
|
} else if (flags & BDRV_REQ_PREFETCH) {
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1441,7 +1441,7 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
|
||||||
|
|
||||||
max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align);
|
max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align);
|
||||||
if (bytes <= max_bytes && bytes <= max_transfer) {
|
if (bytes <= max_bytes && bytes <= max_transfer) {
|
||||||
ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0, 0);
|
ret = bdrv_driver_preadv(bs, offset, bytes, qiov, qiov_offset, 0);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1449,17 +1449,12 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
if (max_bytes) {
|
if (max_bytes) {
|
||||||
QEMUIOVector local_qiov;
|
|
||||||
|
|
||||||
num = MIN(bytes_remaining, MIN(max_bytes, max_transfer));
|
num = MIN(bytes_remaining, MIN(max_bytes, max_transfer));
|
||||||
assert(num);
|
assert(num);
|
||||||
qemu_iovec_init(&local_qiov, qiov->niov);
|
|
||||||
qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, num);
|
|
||||||
|
|
||||||
ret = bdrv_driver_preadv(bs, offset + bytes - bytes_remaining,
|
ret = bdrv_driver_preadv(bs, offset + bytes - bytes_remaining,
|
||||||
num, &local_qiov, 0, 0);
|
num, qiov, bytes - bytes_remaining, 0);
|
||||||
max_bytes -= num;
|
max_bytes -= num;
|
||||||
qemu_iovec_destroy(&local_qiov);
|
|
||||||
} else {
|
} else {
|
||||||
num = bytes_remaining;
|
num = bytes_remaining;
|
||||||
ret = qemu_iovec_memset(qiov, bytes - bytes_remaining, 0,
|
ret = qemu_iovec_memset(qiov, bytes - bytes_remaining, 0,
|
||||||
|
@ -1561,7 +1556,7 @@ static int bdrv_padding_rmw_read(BdrvChild *child,
|
||||||
bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL);
|
bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL);
|
||||||
}
|
}
|
||||||
ret = bdrv_aligned_preadv(child, req, req->overlap_offset, bytes,
|
ret = bdrv_aligned_preadv(child, req, req->overlap_offset, bytes,
|
||||||
align, &local_qiov, 0);
|
align, &local_qiov, 0, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1584,7 +1579,7 @@ static int bdrv_padding_rmw_read(BdrvChild *child,
|
||||||
ret = bdrv_aligned_preadv(
|
ret = bdrv_aligned_preadv(
|
||||||
child, req,
|
child, req,
|
||||||
req->overlap_offset + req->overlap_bytes - align,
|
req->overlap_offset + req->overlap_bytes - align,
|
||||||
align, align, &local_qiov, 0);
|
align, align, &local_qiov, 0, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1665,7 +1660,7 @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child,
|
||||||
tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_READ);
|
tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_READ);
|
||||||
ret = bdrv_aligned_preadv(child, &req, offset, bytes,
|
ret = bdrv_aligned_preadv(child, &req, offset, bytes,
|
||||||
bs->bl.request_alignment,
|
bs->bl.request_alignment,
|
||||||
qiov, flags);
|
qiov, 0, flags);
|
||||||
tracked_request_end(&req);
|
tracked_request_end(&req);
|
||||||
bdrv_dec_in_flight(bs);
|
bdrv_dec_in_flight(bs);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue