[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 40/58] blkdebug: Sanity check block layer guarantees
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 40/58] blkdebug: Sanity check block layer guarantees |
Date: |
Thu, 11 May 2017 16:32:43 +0200 |
From: Eric Blake <address@hidden>
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>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
block/blkdebug.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 3c08893..a562e2e 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -429,6 +429,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;
@@ -453,6 +460,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;
--
1.8.3.1
- [Qemu-devel] [PULL 28/58] migration: Unify block node activation error handling, (continued)
- [Qemu-devel] [PULL 28/58] migration: Unify block node activation error handling, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 29/58] block: New BdrvChildRole.activate() for blk_resume_after_migration(), Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 34/58] qemu-img: wait for convert coroutines to complete, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 30/58] block: Drop permissions when migration completes, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 35/58] nvme: Implement Write Zeroes, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 36/58] blockdev: use drained_begin/end for qmp_block_resize, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 31/58] block: Inactivate parents before children, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 33/58] file-posix: Remove .bdrv_inactivate/invalidate_cache, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 32/58] block: Fix write/resize permissions for inactive images, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 38/58] qemu-io: Switch 'alloc' command to byte-based length, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 40/58] blkdebug: Sanity check block layer guarantees,
Kevin Wolf <=
- [Qemu-devel] [PULL 37/58] qemu-io: Improve alignment checks, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 41/58] blkdebug: Refactor error injection, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 42/58] blkdebug: Add pass-through write_zero and discard support, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 39/58] qemu-io: Switch 'map' output to byte-based reporting, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 43/58] blkdebug: Simplify override logic, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 44/58] blkdebug: Add ability to override unmap geometries, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 47/58] qcow2: Use consistent switch indentation, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 45/58] tests: Add coverage for recent block geometry fixes, Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 46/58] qcow2: Nicer variable names in qcow2_update_snapshot_refcount(), Kevin Wolf, 2017/05/11
- [Qemu-devel] [PULL 48/58] block: Update comments on BDRV_BLOCK_* meanings, Kevin Wolf, 2017/05/11