blkverify: Add block driver for verifying I/O
Subsystems (2)
PATCH 1/1 blkverify: Add block driver for verifying I/O
The blkverify block driver makes investigating image format data corruption much easier. A raw image initialized with the same contents as the test image (e.g. qcow2 file) must be provided. The raw image mirrors read/write operations and is used to verify that data read from the test image is correct.
---
Please see docs/blkverify.txt below for a full description.
Makefile.objs | 2 +- block/blkverify.c | 309 ++++++++++++++++++++++++++++++++++++++++++++++++++++ docs/blkverify.txt | 69 ++++++++++++ 3 files changed, 379 insertions(+), 1 deletions(-) create mode 100644 block/blkverify.c create mode 100644 docs/blkverify.txt
Makefile.objs +1 -1
@@ -14,7 +14,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o block-nested-y += raw.o cow.o cow2.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o -block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o +block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o block-nested-$(CONFIG_WIN32) += raw-win32.o block-nested-$(CONFIG_POSIX) += raw-posix.o block-nested-$(CONFIG_CURL) += curl.o
block/blkverify.c new file +309 -0
309 lines not on this page · raw message
docs/blkverify.txt new file +69 -0
69 lines not on this page · raw message
Signature · 1 line
1.7.1
Am 03.09.2010 13:55, schrieb Stefan Hajnoczi:
Quoted 22 lines
The blkverify block driver makes investigating image format data corruption much easier. A raw image initialized with the same contents as the test image (e.g. qcow2 file) must be provided. The raw image mirrors read/write operations and is used to verify that data read from the test image is correct.
Signed-off-by Stefan Hajnoczi <[email protected]>---
Please seedocs/blkverify.txtbelow for a full description.Makefile.objs | 2 +- block/blkverify.c | 309 ++++++++++++++++++++++++++++++++++++++++++++++++++++ docs/blkverify.txt | 69 ++++++++++++ 3 files changed, 379 insertions(+), 1 deletions(-) create mode 100644 block/blkverify.c create mode 100644 docs/blkverify.txtMakefile.objs +0
-0
Makefile.objs block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o · line 20
Quoted 8 lines
Makefile.objs +1
-1@@ -14,7 +14,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o block-nested-y += raw.o cow.o cow2.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o -block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o +block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o block-nested-$(CONFIG_WIN32) += raw-win32.o block-nested-$(CONFIG_POSIX) += raw-posix.o block-nested-$(CONFIG_CURL) += curl.o
This hunk doesn't apply, there is no cow2. :-)
Quoted 36 lines
block/blkverify.c new file +30
-0@@ -0,0 +1,309 @@ +/* +* Block protocol for block driver correctness testing +* +* Copyright (C) 2010 IBM, Corp. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <stdarg.h> +#include "block_int.h" + +typedef struct { +BlockDriverState *test_file; +}BDRVBlkverifyState ; + +typedef struct BlkverifyAIOCB BlkverifyAIOCB ; +struct BlkverifyAIOCB { +BlockDriverAIOCB common; +QEMUBH *bh; + +/* Request metadata */ +bool is_write; +int64_t sector_num; +int nb_sectors; + +int ret;/* first completed request's result */ +unsigned int done;/* completion counter */ + +QEMUIOVector *qiov;/* user I/O vector */
block/blkverify.c line 40
Quoted 10 lines
block/blkverify.c new file +10
-0+QEMUIOVector raw_qiov;/* cloned I/O vector for raw file */ +void *buf;/* buffer for raw file I/O */ + +void (*verify)(BlkverifyAIOCB *acb); +}; + +static void blkverify_aio_cancel (BlockDriverAIOCB *acb) +{ +qemu_aio_release (acb); +}
I would be surprised if this implementation didn't segfault in one way or another.
I think you'd better cancel the two requests that are combined in this acb. Or wait for their completion actually because you want to have both in the same state.
Other than that the patch looks good me.
Kevin
Quoted 84 lines · Kevin Wolf
Am 03.09.2010 13:55, schrieb Stefan Hajnoczi:
Quoted 27 lines
The blkverify block driver makes investigating image format data corruption much easier. A raw image initialized with the same contents as the test image (e.g. qcow2 file) must be provided. The raw image mirrors read/write operations and is used to verify that data read from the test image is correct.
Signed-off-by Stefan Hajnoczi <[email protected]>---
Please seedocs/blkverify.txtbelow for a full description.Makefile.objs | 2 +-
block/blkverify.c | 309 ++++++++++++++++++++++++++++++++++++++++++++++++++++docs/blkverify.txt| 69 ++++++++++++3 files changed, 379 insertions(+), 1 deletions(-)create mode 100644
block/blkverify.c
create mode 100644docs/blkverify.txtMakefile.objs +0
-0@@ -14,7 +14,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.oblock-nested-y += raw.o cow.o cow2.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o
Makefile.objs +1
-1-block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o +block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.oQuoted 3 lines
block-nested-$(CONFIG_WIN32) += raw-win32.o
block-nested-$(CONFIG_POSIX) += raw-posix.o
block-nested-$(CONFIG_CURL) += curl.oThis hunk doesn't apply, there is no cow2. :-)
Quoted 36 lines
block/blkverify.c new file +30
-0@@ -0,0 +1,309 @@ +/* +* Block protocol for block driver correctness testing +* +* Copyright (C) 2010 IBM, Corp. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <stdarg.h> +#include "block_int.h" + +typedef struct { + BlockDriverState *test_file; +}BDRVBlkverifyState ; + +typedef struct BlkverifyAIOCB BlkverifyAIOCB ; +struct BlkverifyAIOCB { + BlockDriverAIOCB common; + QEMUBH *bh; + + /* Request metadata */ + bool is_write; + int64_t sector_num; + int nb_sectors; + + int ret; /* first completed request's result */ + unsigned int done; /* completion counter */ + + QEMUIOVector *qiov; /* user I/O vector */block/blkverify.c line 40
Quoted 10 lines
block/blkverify.c new file +10
-0+ QEMUIOVector raw_qiov; /* cloned I/O vector for raw file */ + void *buf; /* buffer for raw file I/O */ + + void (*verify)(BlkverifyAIOCB *acb); +}; + +static void blkverify_aio_cancel (BlockDriverAIOCB *acb) +{ + qemu_aio_release(acb); +}I would be surprised if this implementation didn't segfault in one way or another.
Quoted 3 lines
I think you'd better cancel the two requests that are combined in this acb. Or wait for their completion actually because you want to have both in the same state.
You're right, this needs to be done more carefully. I'll send a v2.
Thanks for reviewing the patch!
Stefan