From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=33148 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrY9N-0005CO-CV for qemu-devel@nongnu.org; Fri, 03 Sep 2010 11:26:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OrY9M-0004ru-66 for qemu-devel@nongnu.org; Fri, 03 Sep 2010 11:25:57 -0400 Received: from mail-pw0-f45.google.com ([209.85.160.45]:57349) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrY9M-0004rV-1e for qemu-devel@nongnu.org; Fri, 03 Sep 2010 11:25:56 -0400 Received: by pwj4 with SMTP id 4so288226pwj.4 for ; Fri, 03 Sep 2010 08:25:54 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4C810F04.6050201@redhat.com> References: <1283514942-7526-1-git-send-email-stefanha@linux.vnet.ibm.com> <4C810F04.6050201@redhat.com> Date: Fri, 3 Sep 2010 16:25:54 +0100 Message-ID: Subject: Re: [Qemu-devel] Re: [PATCH] blkverify: Add block driver for verifying I/O From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Stefan Hajnoczi , qemu-devel@nongnu.org On Fri, Sep 3, 2010 at 4:06 PM, Kevin Wolf wrote: > Am 03.09.2010 13:55, schrieb Stefan Hajnoczi: >> The blkverify block driver makes investigating image format data >> corruption much easier. =A0A raw image initialized with the same content= s >> as the test image (e.g. qcow2 file) must be provided. =A0The 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 >> --- >> Please see docs/blkverify.txt below for a full description. >> >> =A0Makefile.objs =A0 =A0 =A0| =A0 =A02 +- >> =A0block/blkverify.c =A0| =A0309 +++++++++++++++++++++++++++++++++++++++= +++++++++++++ >> =A0docs/blkverify.txt | =A0 69 ++++++++++++ >> =A03 files changed, 379 insertions(+), 1 deletions(-) >> =A0create mode 100644 block/blkverify.c >> =A0create mode 100644 docs/blkverify.txt >> >> diff --git a/Makefile.objs b/Makefile.objs >> index b25f573..40a4594 100644 >> --- a/Makefile.objs >> +++ b/Makefile.objs >> @@ -14,7 +14,7 @@ block-obj-$(CONFIG_LINUX_AIO) +=3D linux-aio.o >> >> =A0block-nested-y +=3D raw.o cow.o cow2.o qcow.o vdi.o vmdk.o cloop.o dm= g.o bochs.o vpc.o vvfat.o >> =A0block-nested-y +=3D qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-sn= apshot.o >> -block-nested-y +=3D parallels.o nbd.o blkdebug.o sheepdog.o >> +block-nested-y +=3D parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o >> =A0block-nested-$(CONFIG_WIN32) +=3D raw-win32.o >> =A0block-nested-$(CONFIG_POSIX) +=3D raw-posix.o >> =A0block-nested-$(CONFIG_CURL) +=3D curl.o > > This hunk doesn't apply, there is no cow2. :-) > >> diff --git a/block/blkverify.c b/block/blkverify.c >> new file mode 100644 >> index 0000000..9cebafe >> --- /dev/null >> +++ b/block/blkverify.c >> @@ -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 l= ater. >> + * See the COPYING file in the top-level directory. >> + */ >> + >> +#include >> +#include "block_int.h" >> + >> +typedef struct { >> + =A0 =A0BlockDriverState *test_file; >> +} BDRVBlkverifyState; >> + >> +typedef struct BlkverifyAIOCB BlkverifyAIOCB; >> +struct BlkverifyAIOCB { >> + =A0 =A0BlockDriverAIOCB common; >> + =A0 =A0QEMUBH *bh; >> + >> + =A0 =A0/* Request metadata */ >> + =A0 =A0bool is_write; >> + =A0 =A0int64_t sector_num; >> + =A0 =A0int nb_sectors; >> + >> + =A0 =A0int ret; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* first comple= ted request's result */ >> + =A0 =A0unsigned int done; =A0 =A0 =A0 =A0 =A0/* completion counter */ >> + >> + =A0 =A0QEMUIOVector *qiov; =A0 =A0 =A0 =A0 /* user I/O vector */ >> + =A0 =A0QEMUIOVector raw_qiov; =A0 =A0 =A0/* cloned I/O vector for raw = file */ >> + =A0 =A0void *buf; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* buffer for raw= file I/O */ >> + >> + =A0 =A0void (*verify)(BlkverifyAIOCB *acb); >> +}; >> + >> +static void blkverify_aio_cancel(BlockDriverAIOCB *acb) >> +{ >> + =A0 =A0qemu_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. You're right, this needs to be done more carefully. I'll send a v2. Thanks for reviewing the patch! Stefan