Originally the storage volume files were opened with O_DSYNC to make
sure they were flushed to disk immediately. It turned out that this
was extremely slow in some cases, so the O_DSYNC was removed in favor
of just calling fsync() after all the data had been written. However,
this call to fsync was inside the block that is executed to zero-fill
the end of the volume file. In cases where the new volume is copied
from an old volume, and they are the same length, this fsync would
never take place.

Now the fsync is *always* done, unless there is an error (in which
case it isn't important, and is most likely inappropriate.
---
 src/storage/storage_backend.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 1eb8e33..730ca7b 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -324,12 +324,13 @@ static int createRawFileOpHook(int fd, void *data) {
             }
         }
 
-        if (fsync(fd) < 0) {
-            ret = errno;
-            virReportSystemError(errno, _("cannot sync data to file '%s'"),
-                                 hdata->vol->target.path);
-            goto cleanup;
-        }
+    }
+
+    if (fsync(fd) < 0) {
+        ret = errno;
+        virReportSystemError(errno, _("cannot sync data to file '%s'"),
+                             hdata->vol->target.path);
+        goto cleanup;
     }
 
 cleanup:
-- 
1.7.1.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to