[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v10 12/17] blkdebug: Sanity check block layer guaran
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v10 12/17] blkdebug: Sanity check block layer guarantees |
Date: |
Wed, 26 Apr 2017 20:46:21 -0500 |
Commits 04ed95f4 and 1a62d0ac updated the block layer to auto-fragment
any I/O to fit within device boundaries. Additionally, when using a
minimum alignment of 4k, we want to ensure the block layer does proper
read-modify-write rather than requesting I/O on a slice of a sector.
Let's enforce that the contract is obeyed when using blkdebug. For
now, blkdebug only allows alignment overrides, and just inherits other
limits from whatever device it is wrapping, but a future patch will
further enhance things.
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
v10: no change
v5-v9: no change
v4: no change
v3: rebase to byte-based interfaces
v2: new patch
---
block/blkdebug.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index c795ae9..14d3fc5 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -431,6 +431,13 @@ blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset,
uint64_t bytes,
BDRVBlkdebugState *s = bs->opaque;
BlkdebugRule *rule = NULL;
+ /* Sanity check block layer guarantees */
+ assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment));
+ assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment));
+ if (bs->bl.max_transfer) {
+ assert(bytes <= bs->bl.max_transfer);
+ }
+
QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
uint64_t inject_offset = rule->options.inject.offset;
@@ -455,6 +462,13 @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset,
uint64_t bytes,
BDRVBlkdebugState *s = bs->opaque;
BlkdebugRule *rule = NULL;
+ /* Sanity check block layer guarantees */
+ assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment));
+ assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment));
+ if (bs->bl.max_transfer) {
+ assert(bytes <= bs->bl.max_transfer);
+ }
+
QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
uint64_t inject_offset = rule->options.inject.offset;
--
2.9.3
- [Qemu-devel] [PATCH v10 07/17] qemu-io: Switch 'alloc' command to byte-based length, (continued)
[Qemu-devel] [PATCH v10 05/17] iotests: Add test 179 to cover write zeroes with unmap, Eric Blake, 2017/04/26
[Qemu-devel] [PATCH v10 10/17] qcow2: Assert that cluster operations are aligned, Eric Blake, 2017/04/26
[Qemu-devel] [PATCH v10 12/17] blkdebug: Sanity check block layer guarantees,
Eric Blake <=
[Qemu-devel] [PATCH v10 11/17] qcow2: Discard/zero clusters by byte count, Eric Blake, 2017/04/26
[Qemu-devel] [PATCH v10 08/17] qemu-io: Switch 'map' output to byte-based reporting, Eric Blake, 2017/04/26
[Qemu-devel] [PATCH v10 13/17] blkdebug: Refactor error injection, Eric Blake, 2017/04/26
[Qemu-devel] [PATCH v10 09/17] qcow2: Optimize write zero of unaligned tail cluster, Eric Blake, 2017/04/26
[Qemu-devel] [PATCH v10 14/17] blkdebug: Add pass-through write_zero and discard support, Eric Blake, 2017/04/26
[Qemu-devel] [PATCH v10 16/17] blkdebug: Add ability to override unmap geometries, Eric Blake, 2017/04/26