[libvirt] [PATCH 2/9] storage: Always assume we are tracking alloc progress in FS backend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We do support allocation progress now, so have the code accomodate.
---
 src/storage_backend_fs.c |   49 +++++++++++++++-------------------------------
 1 files changed, 16 insertions(+), 33 deletions(-)

diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c
index 64a7130..c7c1c9c 100644
--- a/src/storage_backend_fs.c
+++ b/src/storage_backend_fs.c
@@ -72,8 +72,6 @@ typedef int (*createFile)(virConnectPtr conn,
                           virStorageVolDefPtr vol,
                           virStorageVolDefPtr inputvol);
 
-static int track_allocation_progress = 0;
-
 /* Either 'magic' or 'extension' *must* be provided */
 struct FileTypeInfo {
     int type;           /* One of the constants above */
@@ -1108,38 +1106,23 @@ static int createRaw(virConnectPtr conn,
 
     /* Pre-allocate any data if requested */
     /* XXX slooooooooooooooooow on non-extents-based file systems */
-    if (remain) {
-        if (track_allocation_progress) {
-
-            while (remain) {
-                /* Allocate in chunks of 512MiB: big-enough chunk
-                 * size and takes approx. 9s on ext3. A progress
-                 * update every 9s is a fair-enough trade-off
-                 */
-                unsigned long long bytes = 512 * 1024 * 1024;
-                int r;
-
-                if (bytes > remain)
-                    bytes = remain;
-                if ((r = safezero(fd, 0, vol->allocation - remain,
-                                  bytes)) != 0) {
-                    virReportSystemError(conn, r,
-                                         _("cannot fill file '%s'"),
-                                         vol->target.path);
-                    goto cleanup;
-                }
-                remain -= bytes;
-            }
-        } else { /* No progress bars to be shown */
-            int r;
-
-            if ((r = safezero(fd, 0, 0, remain)) != 0) {
-                virReportSystemError(conn, r,
-                                     _("cannot fill file '%s'"),
-                                     vol->target.path);
-                goto cleanup;
-            }
+    while (remain) {
+        /* Allocate in chunks of 512MiB: big-enough chunk
+         * size and takes approx. 9s on ext3. A progress
+         * update every 9s is a fair-enough trade-off
+         */
+        unsigned long long bytes = 512 * 1024 * 1024;
+        int r;
+
+        if (bytes > remain)
+            bytes = remain;
+        if ((r = safezero(fd, 0, vol->allocation - remain, bytes)) != 0) {
+            virReportSystemError(conn, r,
+                                 _("cannot fill file '%s'"),
+                                 vol->target.path);
+            goto cleanup;
         }
+        remain -= bytes;
     }
 
     if (close(fd) < 0) {
-- 
1.6.0.6

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

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]