From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqfwR-0007Gl-KQ for qemu-devel@nongnu.org; Tue, 18 Nov 2014 05:23:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XqfwL-0008Pf-3P for qemu-devel@nongnu.org; Tue, 18 Nov 2014 05:23:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38063) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqfwK-0008Pb-SQ for qemu-devel@nongnu.org; Tue, 18 Nov 2014 05:23:17 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAIANGsJ022772 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 18 Nov 2014 05:23:16 -0500 From: Max Reitz Date: Tue, 18 Nov 2014 11:23:05 +0100 Message-Id: <1416306186-19053-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1416306186-19053-1-git-send-email-mreitz@redhat.com> References: <1416306186-19053-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH for-2.2 2/3] 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: Kevin Wolf , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Stefan Hajnoczi , 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 --- 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 4e6552f..f67fb11 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1459,7 +1459,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.9.3