Received: from eggs.gnu.org ([2001:4830:134:3::10]:55251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXIHf-000819-JT for qemu-devel@nongnu.org; Thu, 25 Sep 2014 19:17:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXIHY-0004Jx-NA for qemu-devel@nongnu.org; Thu, 25 Sep 2014 19:17:11 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:59075) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXIHY-0004H7-B7 for qemu-devel@nongnu.org; Thu, 25 Sep 2014 19:17:04 -0400 From: Tony Breeds Date: Fri, 26 Sep 2014 09:14:11 +1000 Message-Id: <1411686852-26487-1-git-send-email-tony@bakeyournoodle.com> In-Reply-To: <1411622627-22110-1-git-send-email-tony@bakeyournoodle.com> References: <1411622627-22110-1-git-send-email-tony@bakeyournoodle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 1/2] block/raw-posix: Fix disk corruption in try_fiemap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Markus Armbruster , Tony Breeds , Max Reitz , =?UTF-8?q?P=C3=A1draig=20Brady?= , Stefan Hajnoczi Using fiemap without FIEMAP_FLAG_SYNC is a known corrupter. Add the FIEMAP_FLAG_SYNC flag to the FS_IOC_FIEMAP ioctl. This has the downside of significantly reducing performance. Reported-By: Michael Steffens Signed-off-by: Tony Breeds Cc: Kevin Wolf Cc: Markus Armbruster Cc: Stefan Hajnoczi Cc: Max Reitz Cc: P=C3=A1draig Brady Cc: Eric Blake --- Changes since v1: - split in to 2 patches - tried to make the commit messages better block/raw-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index a253697..b8203e9 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 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) { --=20 1.9.3