From: Tony Breeds <t...@bakeyournoodle.com>

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 <michael_steff...@posteo.de>
Signed-off-by: Tony Breeds <t...@bakeyournoodle.com>
Cc: Kevin Wolf <kw...@redhat.com>
Cc: Markus Armbruster <arm...@redhat.com>
Cc: Stefan Hajnoczi <stefa...@redhat.com>
Cc: Max Reitz <mre...@redhat.com>
Cc: Pádraig Brady <pbr...@redhat.com>
Cc: Eric Blake <ebl...@redhat.com>
Reviewed-by: Eric Blake <ebl...@redhat.com>
Reviewed-by: Max Reitz <mre...@redhat.com>
Signed-off-by: Kevin Wolf <kw...@redhat.com>
---
 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 86ce4f2..d672c73 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1482,7 +1482,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


Reply via email to