[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/53] block: include supported_read_flags into BDS structure
From: |
Max Reitz |
Subject: |
[PULL 08/53] block: include supported_read_flags into BDS structure |
Date: |
Tue, 26 Jan 2021 15:19:31 +0100 |
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Add the new member supported_read_flags to the BlockDriverState
structure. It will control the flags set for copy-on-read operations.
Make the block generic layer evaluate supported read flags before they
go to a block driver.
Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
[vsementsov: use assert instead of abort]
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20201216061703.70908-8-vsementsov@virtuozzo.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
include/block/block_int.h | 4 ++++
block/io.c | 10 ++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/block/block_int.h b/include/block/block_int.h
index f3d0a0e60a..92d3754ead 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -881,6 +881,10 @@ struct BlockDriverState {
/* I/O Limits */
BlockLimits bl;
+ /*
+ * Flags honored during pread
+ */
+ unsigned int supported_read_flags;
/* Flags honored during pwrite (so far: BDRV_REQ_FUA,
* BDRV_REQ_WRITE_UNCHANGED).
* If a driver does not support BDRV_REQ_WRITE_UNCHANGED, those
diff --git a/block/io.c b/block/io.c
index 95b1c56c06..d203435a73 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1453,6 +1453,9 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild
*child,
if (flags & BDRV_REQ_COPY_ON_READ) {
int64_t pnum;
+ /* The flag BDRV_REQ_COPY_ON_READ has reached its addressee */
+ flags &= ~BDRV_REQ_COPY_ON_READ;
+
ret = bdrv_is_allocated(bs, offset, bytes, &pnum);
if (ret < 0) {
goto out;
@@ -1474,9 +1477,11 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild
*child,
goto out;
}
+ assert(!(flags & ~bs->supported_read_flags));
+
max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align);
if (bytes <= max_bytes && bytes <= max_transfer) {
- ret = bdrv_driver_preadv(bs, offset, bytes, qiov, qiov_offset, 0);
+ ret = bdrv_driver_preadv(bs, offset, bytes, qiov, qiov_offset, flags);
goto out;
}
@@ -1489,7 +1494,8 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild
*child,
ret = bdrv_driver_preadv(bs, offset + bytes - bytes_remaining,
num, qiov,
- qiov_offset + bytes - bytes_remaining, 0);
+ qiov_offset + bytes - bytes_remaining,
+ flags);
max_bytes -= num;
} else {
num = bytes_remaining;
--
2.29.2
- [PULL 00/53] Block patches, Max Reitz, 2021/01/26
- [PULL 01/53] iotests: fix _check_o_direct, Max Reitz, 2021/01/26
- [PULL 02/53] copy-on-read: support preadv/pwritev_part functions, Max Reitz, 2021/01/26
- [PULL 03/53] block: add API function to insert a node, Max Reitz, 2021/01/26
- [PULL 04/53] copy-on-read: add filter drop function, Max Reitz, 2021/01/26
- [PULL 05/53] qapi: add filter-node-name to block-stream, Max Reitz, 2021/01/26
- [PULL 06/53] qapi: copy-on-read filter: add 'bottom' option, Max Reitz, 2021/01/26
- [PULL 08/53] block: include supported_read_flags into BDS structure,
Max Reitz <=
- [PULL 09/53] copy-on-read: skip non-guest reads if no copy needed, Max Reitz, 2021/01/26
- [PULL 11/53] qapi: block-stream: add "bottom" argument, Max Reitz, 2021/01/26
- [PULL 07/53] iotests: add #310 to test bottom node in COR driver, Max Reitz, 2021/01/26
- [PULL 10/53] stream: rework backing-file changing, Max Reitz, 2021/01/26
- [PULL 13/53] block/stream: add s->target_bs, Max Reitz, 2021/01/26
- [PULL 16/53] iotests/297: Rewrite in Python and extend reach, Max Reitz, 2021/01/26
- [PULL 12/53] iotests: 30: prepare to COR filter insertion by stream job, Max Reitz, 2021/01/26
- [PULL 14/53] block: apply COR-filter to block-stream jobs, Max Reitz, 2021/01/26