On 04.12.20 23:07, Vladimir Sementsov-Ogievskiy wrote:
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>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
include/block/block_int.h | 4 ++++
block/io.c | 12 ++++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
[...]
diff --git a/block/io.c b/block/io.c
index ec5e152bb7..e28b11c42b 100644
--- a/block/io.c
+++ b/block/io.c
[...]
@@ -1426,9 +1429,13 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild
*child,
goto out;
}
+ if (flags & ~bs->supported_read_flags) {
+ abort();
+ }
I’d prefer an assert(!(flags & ~bs->supported_read_flags)), so in case we do
abort, there’s going to be an error message that immediately tells what the problem is.
Apart from that:
Reviewed-by: Max Reitz <mreitz@redhat.com>
+
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;
}