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 3/3] block/raw-posix: Catch fsync() errors
Date: Tue, 18 Nov 2014 11:23:06 +0100 [thread overview]
Message-ID: <1416306186-19053-4-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1416306186-19053-1-git-send-email-mreitz@redhat.com>
fsync() may fail, and that case should be handled.
Reported-by: László Érsek <lersek@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block/raw-posix.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index f67fb11..666cdec 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1460,7 +1460,12 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
left -= result;
}
if (result >= 0) {
- fsync(fd);
+ result = fsync(fd);
+ if (result < 0) {
+ result = -errno;
+ error_setg_errno(errp, -result,
+ "Could not flush new file to disk");
+ }
}
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 ` [Qemu-devel] [PATCH for-2.2 2/3] block/raw-posix: Only sync after successful preallocation Max Reitz
2014-11-18 10:23 ` Max Reitz [this message]
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-4-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).