From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com,
mreitz@redhat.com, stefanha@redhat.com, den@openvz.org,
jsnow@redhat.com
Subject: [Qemu-devel] [PATCH v2 08/12] block/io: bdrv_aligned_pwritev: use and support qiov_offset
Date: Tue, 4 Jun 2019 19:15:10 +0300 [thread overview]
Message-ID: <20190604161514.262241-9-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20190604161514.262241-1-vsementsov@virtuozzo.com>
Use and support new API in bdrv_aligned_pwritev.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block/io.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/block/io.c b/block/io.c
index 0cc80e2d5a..660c96527d 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1792,7 +1792,7 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, uint64_t bytes,
*/
static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
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;
BlockDriver *drv = bs->drv;
@@ -1812,7 +1812,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
assert(is_power_of_2(align));
assert((offset & (align - 1)) == 0);
assert((bytes & (align - 1)) == 0);
- assert(!qiov || bytes == qiov->size);
+ assert(!qiov || qiov_offset + bytes <= qiov->size);
max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX),
align);
@@ -1820,7 +1820,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
if (!ret && bs->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF &&
!(flags & BDRV_REQ_ZERO_WRITE) && drv->bdrv_co_pwrite_zeroes &&
- qemu_iovec_is_zero(qiov, 0, qiov->size)) {
+ qemu_iovec_is_zero(qiov, qiov_offset, bytes)) {
flags |= BDRV_REQ_ZERO_WRITE;
if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) {
flags |= BDRV_REQ_MAY_UNMAP;
@@ -1833,15 +1833,15 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO);
ret = bdrv_co_do_pwrite_zeroes(bs, offset, bytes, flags);
} else if (flags & BDRV_REQ_WRITE_COMPRESSED) {
- ret = bdrv_driver_pwritev_compressed(bs, offset, bytes, qiov, 0);
+ ret = bdrv_driver_pwritev_compressed(bs, offset, bytes,
+ qiov, qiov_offset);
} else if (bytes <= max_transfer) {
bdrv_debug_event(bs, BLKDBG_PWRITEV);
- ret = bdrv_driver_pwritev(bs, offset, bytes, qiov, 0, flags);
+ ret = bdrv_driver_pwritev(bs, offset, bytes, qiov, qiov_offset, flags);
} else {
bdrv_debug_event(bs, BLKDBG_PWRITEV);
while (bytes_remaining) {
int num = MIN(bytes_remaining, max_transfer);
- QEMUIOVector local_qiov;
int local_flags = flags;
assert(num);
@@ -1851,12 +1851,10 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
* need to flush on the last iteration */
local_flags &= ~BDRV_REQ_FUA;
}
- qemu_iovec_init(&local_qiov, qiov->niov);
- qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, num);
ret = bdrv_driver_pwritev(bs, offset + bytes - bytes_remaining,
- num, &local_qiov, 0, local_flags);
- qemu_iovec_destroy(&local_qiov);
+ num, qiov, bytes - bytes_remaining,
+ local_flags);
if (ret < 0) {
break;
}
@@ -1899,7 +1897,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child,
qemu_iovec_init_buf(&local_qiov, pad.buf, write_bytes);
ret = bdrv_aligned_pwritev(child, req, aligned_offset, write_bytes,
- align, &local_qiov,
+ align, &local_qiov, 0,
flags & ~BDRV_REQ_ZERO_WRITE);
if (ret < 0 || pad.merge_reads) {
/* Error or all work is done */
@@ -1915,7 +1913,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child,
/* Write the aligned part in the middle. */
uint64_t aligned_bytes = bytes & ~(align - 1);
ret = bdrv_aligned_pwritev(child, req, offset, aligned_bytes, align,
- NULL, flags);
+ NULL, 0, flags);
if (ret < 0) {
goto out;
}
@@ -1929,7 +1927,8 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child,
qemu_iovec_init_buf(&local_qiov, pad.tail_buf, align);
ret = bdrv_aligned_pwritev(child, req, offset, align, align,
- &local_qiov, flags & ~BDRV_REQ_ZERO_WRITE);
+ &local_qiov, 0,
+ flags & ~BDRV_REQ_ZERO_WRITE);
}
out:
@@ -1982,7 +1981,7 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child,
}
ret = bdrv_aligned_pwritev(child, &req, offset, bytes, align,
- qiov, flags);
+ qiov, 0, flags);
bdrv_padding_destroy(&pad);
--
2.18.0
next prev parent reply other threads:[~2019-06-04 16:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 16:15 [Qemu-devel] [PATCH v2 00/12] block: qiov_offset parameter for io Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 01/12] util/iov: introduce qemu_iovec_init_extended Vladimir Sementsov-Ogievskiy
2019-06-05 11:54 ` Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 02/12] util/iov: improve qemu_iovec_is_zero Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 03/12] block/io: refactor padding Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 04/12] block: define .*_part io handlers in BlockDriver Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 05/12] block/io: bdrv_co_do_copy_on_readv: use and support qiov_offset Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 06/12] block/io: bdrv_co_do_copy_on_readv: lazy allocation Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 07/12] block/io: bdrv_aligned_preadv: use and support qiov_offset Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` Vladimir Sementsov-Ogievskiy [this message]
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 09/12] block/io: introduce bdrv_co_p{read, write}v_part Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 10/12] block/qcow2: refactor qcow2_co_preadv to use buffer-based io Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 11/12] block/qcow2: implement .bdrv_co_preadv_part Vladimir Sementsov-Ogievskiy
2019-06-04 16:15 ` [Qemu-devel] [PATCH v2 12/12] block/qcow2: implement .bdrv_co_pwritev(_compressed)_part Vladimir Sementsov-Ogievskiy
2019-06-04 17:48 ` [Qemu-devel] [PATCH v2 00/12] block: qiov_offset parameter for io no-reply
2019-06-28 8:43 ` Stefan Hajnoczi
2019-07-25 8:28 ` Vladimir Sementsov-Ogievskiy
2019-07-29 15:24 ` Stefan Hajnoczi
2019-07-29 15:34 ` Vladimir Sementsov-Ogievskiy
2019-08-15 11:12 ` Vladimir Sementsov-Ogievskiy
2019-08-22 14:48 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2019-08-22 15:50 ` [Qemu-devel] " Stefan Hajnoczi
2019-08-22 17:24 ` Vladimir Sementsov-Ogievskiy
2019-08-22 17:39 ` Vladimir Sementsov-Ogievskiy
2019-08-22 17:59 ` Vladimir Sementsov-Ogievskiy
2019-08-23 16:21 ` Stefan Hajnoczi
2019-08-24 10:15 ` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190604161514.262241-9-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=den@openvz.org \
--cc=fam@euphon.net \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).