From 61b268aa329b87c733bcad3e988f0ac28145c47e Mon Sep 17 00:00:00 2001 Message-Id: <61b268aa329b87c733bcad3e988f0ac28145c47e.1422637807.git.jen@redhat.com> In-Reply-To: References: From: Max Reitz Date: Mon, 19 Jan 2015 14:52:09 -0500 Subject: [CHANGE 08/10] block/raw-posix: Only sync after successful preallocation To: rhvirt-patches@redhat.com, jen@redhat.com RH-Author: Max Reitz Message-id: <1421679130-22714-9-git-send-email-mreitz@redhat.com> Patchwork-id: 63368 O-Subject: [RHEL-6.7 qemu-kvm PATCH 8/9] block/raw-posix: Only sync after successful preallocation Bugzilla: 1040220 RH-Acked-by: Fam Zheng RH-Acked-by: Laszlo Ersek RH-Acked-by: Stefan Hajnoczi BZ: 1040220 The loop which filled the file with zeroes may have been left early due to an error. In that case, the fsync() should be skipped. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf (cherry picked from commit 731de38052b245eab79e417aeac5e1dcebe6437f) Signed-off-by: Max Reitz --- block/raw-posix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Signed-off-by: Jeff E. Nelson --- block/raw-posix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 4941a5f..79a2253 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -678,7 +678,9 @@ static int raw_create(const char *filename, QEMUOptionParameter *options) } left -= result; } - fsync(fd); + if (result >= 0) { + fsync(fd); + } g_free(buf); } else if (prealloc != PREALLOC_MODE_OFF) { result = -EINVAL; -- 2.1.0