aboutsummaryrefslogtreecommitdiff
path: root/block/io.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2019-07-25 13:05:48 +0300
committerEric Blake <eblake@redhat.com>2019-08-15 13:22:13 -0500
commit3299e5ecf7e1c9443189e50c949d97e536022c59 (patch)
tree52a4758697875f4e52730b680a826a5a210ad931 /block/io.c
parentaec21d31756cbda4ad1d0fc5c60797d2c1eecf33 (diff)
downloadqemu-3299e5ecf7e1c9443189e50c949d97e536022c59.zip
qemu-3299e5ecf7e1c9443189e50c949d97e536022c59.tar.gz
qemu-3299e5ecf7e1c9443189e50c949d97e536022c59.tar.bz2
block: implement BDRV_REQ_PREFETCH
Do effective copy-on-read request when we don't need data actually. It will be used for block-stream and NBD_CMD_CACHE. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20190725100550.33801-2-vsementsov@virtuozzo.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> [eblake: comment grammar fix] Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block/io.c')
-rw-r--r--block/io.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/block/io.c b/block/io.c
index 06305c6..9d99858 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1167,7 +1167,8 @@ bdrv_driver_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
}
static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
- int64_t offset, unsigned int bytes, QEMUIOVector *qiov)
+ int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
+ int flags)
{
BlockDriverState *bs = child->bs;
@@ -1278,9 +1279,11 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
goto err;
}
- qemu_iovec_from_buf(qiov, progress, bounce_buffer + skip_bytes,
- pnum - skip_bytes);
- } else {
+ if (!(flags & BDRV_REQ_PREFETCH)) {
+ qemu_iovec_from_buf(qiov, progress, bounce_buffer + skip_bytes,
+ pnum - skip_bytes);
+ }
+ } else if (!(flags & BDRV_REQ_PREFETCH)) {
/* Read directly into the destination */
qemu_iovec_init(&local_qiov, qiov->niov);
qemu_iovec_concat(&local_qiov, qiov, progress, pnum - skip_bytes);
@@ -1331,7 +1334,8 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
* potential fallback support, if we ever implement any read flags
* to pass through to drivers. For now, there aren't any
* passthrough flags. */
- assert(!(flags & ~(BDRV_REQ_NO_SERIALISING | BDRV_REQ_COPY_ON_READ)));
+ assert(!(flags & ~(BDRV_REQ_NO_SERIALISING | BDRV_REQ_COPY_ON_READ |
+ BDRV_REQ_PREFETCH)));
/* Handle Copy on Read and associated serialisation */
if (flags & BDRV_REQ_COPY_ON_READ) {
@@ -1359,7 +1363,9 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
}
if (!ret || pnum != bytes) {
- ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov);
+ ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov, flags);
+ goto out;
+ } else if (flags & BDRV_REQ_PREFETCH) {
goto out;
}
}