From: Max Reitz <mreitz@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"László Érsek" <lersek@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Max Reitz" <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH for-2.2 2/3] block/raw-posix: Only sync after successful preallocation
Date: Tue, 18 Nov 2014 11:23:05 +0100 [thread overview]
Message-ID: <1416306186-19053-3-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1416306186-19053-1-git-send-email-mreitz@redhat.com>
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 <mreitz@redhat.com>
---
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
next prev parent reply other threads:[~2014-11-18 10:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-18 10:23 [Qemu-devel] [PATCH for-2.2 0/3] block/raw-posix: Fixes for preallocation Max Reitz
2014-11-18 10:23 ` [Qemu-devel] [PATCH for-2.2 1/3] block/raw-posix: Fix preallocating write() loop Max Reitz
2014-11-18 10:23 ` Max Reitz [this message]
2014-11-18 10:23 ` [Qemu-devel] [PATCH for-2.2 3/3] block/raw-posix: Catch fsync() errors Max Reitz
2014-11-18 11:11 ` [Qemu-devel] [PATCH for-2.2 0/3] block/raw-posix: Fixes for preallocation Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1416306186-19053-3-git-send-email-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=lersek@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).