From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XX2Qx-0000WF-Bz for qemu-devel@nongnu.org; Thu, 25 Sep 2014 02:21:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XX2Qs-0002m3-SZ for qemu-devel@nongnu.org; Thu, 25 Sep 2014 02:21:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XX2Qs-0002kX-H9 for qemu-devel@nongnu.org; Thu, 25 Sep 2014 02:21:38 -0400 From: Markus Armbruster References: <1411622627-22110-1-git-send-email-tony@bakeyournoodle.com> Date: Thu, 25 Sep 2014 08:21:27 +0200 In-Reply-To: <1411622627-22110-1-git-send-email-tony@bakeyournoodle.com> (Tony Breeds's message of "Thu, 25 Sep 2014 15:23:47 +1000") Message-ID: <87d2akdxug.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] block/raw-posix: use seek_hole ahead of fiemap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tony Breeds Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz , =?utf-8?Q?P=C3=A1draig?= Brady , Stefan Hajnoczi , Michael Steffens Please copy Kevin & Stefan for block patches. Doing that for you. I also copy Max, who left his fingerprints on commit 4f11aa8. Tony Breeds writes: > The command > qemu-img convert -O raw inputimage.qcow2 outputimage.raw > > intermittently creates corrupted output images, when the input image is n= ot yet fully synchronized to disk. This patch preferese the use of seek_ho= le checks to determine if the sector is present in the disk image. > > While we're there modify try_fiemap() to set FIEMAP_FLAG_SYNC. > > Reported-By: Michael Steffens > CC: P=C3=A1draig Brady > Signed-off-by: Tony Breeds > --- > block/raw-posix.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/block/raw-posix.c b/block/raw-posix.c > index a253697..b438c54 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -1472,7 +1472,7 @@ static int64_t try_fiemap(BlockDriverState *bs, off= _t start, off_t *data, >=20=20 > f.fm.fm_start =3D start; > f.fm.fm_length =3D (int64_t)nb_sectors * BDRV_SECTOR_SIZE; > - f.fm.fm_flags =3D 0; > + f.fm.fm_flags =3D FIEMAP_FLAG_SYNC; > f.fm.fm_extent_count =3D 1; > f.fm.fm_reserved =3D 0; > if (ioctl(s->fd, FS_IOC_FIEMAP, &f) =3D=3D -1) { > @@ -1561,9 +1561,9 @@ static int64_t coroutine_fn raw_co_get_block_status= (BlockDriverState *bs, >=20=20 > start =3D sector_num * BDRV_SECTOR_SIZE; >=20=20 > - ret =3D try_fiemap(bs, start, &data, &hole, nb_sectors, pnum); > + ret =3D try_seek_hole(bs, start, &data, &hole, pnum); > if (ret < 0) { > - ret =3D try_seek_hole(bs, start, &data, &hole, pnum); > + ret =3D try_fiemap(bs, start, &data, &hole, nb_sectors, pnum); > if (ret < 0) { > /* Assume everything is allocated. */ > data =3D 0;