From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqh4C-0000A2-Pe for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:35:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xqh46-0007Gb-Bc for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:35:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqh46-0007GO-5W for qemu-devel@nongnu.org; Tue, 18 Nov 2014 06:35:22 -0500 From: Kevin Wolf Date: Tue, 18 Nov 2014 12:35:07 +0100 Message-Id: <1416310508-5122-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1416310508-5122-1-git-send-email-kwolf@redhat.com> References: <1416310508-5122-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 5/6] block/raw-posix: Only sync after successful preallocation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, mreitz@redhat.com From: Max Reitz 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 --- 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 e0e48c5..d106fc4 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1453,7 +1453,9 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp) } left -= result; } - fsync(fd); + if (result >= 0) { + fsync(fd); + } g_free(buf); break; } -- 1.8.3.1