From 2e89059b6b49c02a2226ab859367ad1754e39d24 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Tue, 18 Nov 2014 15:41:31 +0100 Subject: [PATCH 04/10] block/raw-posix: Fix disk corruption in try_fiemap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-id: <1416325296-5397-2-git-send-email-mreitz@redhat.com> Patchwork-id: 62444 O-Subject: [RHEV-7.1 qemu-kvm-rhev PATCH v2 1/6] block/raw-posix: Fix disk corruption in try_fiemap Bugzilla: 1142331 RH-Acked-by: Paolo Bonzini RH-Acked-by: Kevin Wolf RH-Acked-by: Markus Armbruster From: Tony Breeds 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ádraig Brady Cc: Eric Blake Reviewed-by: Eric Blake Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf (cherry picked from commit 38c4d0aea3e1264c86e282d99560330adf2b6e25) Signed-off-by: Max Reitz Signed-off-by: Miroslav Rezanina --- 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 87fc170..9fbc3eb 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1419,7 +1419,7 @@ static int64_t try_fiemap(BlockDriverState *bs, off_t start, off_t *data, f.fm.fm_start = start; f.fm.fm_length = (int64_t)nb_sectors * BDRV_SECTOR_SIZE; - f.fm.fm_flags = 0; + f.fm.fm_flags = FIEMAP_FLAG_SYNC; f.fm.fm_extent_count = 1; f.fm.fm_reserved = 0; if (ioctl(s->fd, FS_IOC_FIEMAP, &f) == -1) { -- 1.8.3.1