Patchwork raw-posix: Fix bdrv_flush error return values

login
register
mail settings
Submitter Kevin Wolf
Date Sept. 14, 2011, 9:23 a.m.
Message ID <1315992214-3649-1-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/114608/
State New
Headers show

Comments

Kevin Wolf - Sept. 14, 2011, 9:23 a.m.
bdrv_flush is supposed to use 0/-errno return values

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/raw-posix.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
Markus Armbruster - Sept. 14, 2011, 12:06 p.m.
Kevin Wolf <kwolf@redhat.com> writes:

> bdrv_flush is supposed to use 0/-errno return values

Is it?  Can't find a user that cares...

Documenting what the BlockDriver methods are supposed to do wouldn't
hurt.

> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

Works as advertized, therefore:

Reviewed-by: Markus Armbruster <armbru@redhat.com>

Patch

diff --git a/block/raw-posix.c b/block/raw-posix.c
index a624f56..305998d 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -839,7 +839,14 @@  static int raw_create(const char *filename, QEMUOptionParameter *options)
 static int raw_flush(BlockDriverState *bs)
 {
     BDRVRawState *s = bs->opaque;
-    return qemu_fdatasync(s->fd);
+    int ret;
+
+    ret = qemu_fdatasync(s->fd);
+    if (ret < 0) {
+        return -errno;
+    }
+
+    return 0;
 }
 
 #ifdef CONFIG_XFS