[PATCH 3/3] Shrink volume even with ALLOCATE flag

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

 



Calling fallocate on the new (smaller) capacity ensures
that the whole file is allocated, but it does not reduce
the file size.

Also call ftruncate after fallocate.

https://bugzilla.redhat.com/show_bug.cgi?id=1366446
---
 src/util/virstoragefile.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 5df1ea0b8..80a33b1a6 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1338,12 +1338,12 @@ virStorageFileResize(const char *path,
             }
             goto cleanup;
         }
-    } else {
-        if (ftruncate(fd, capacity) < 0) {
-            virReportSystemError(errno,
-                                 _("Failed to truncate file '%s'"), path);
-            goto cleanup;
-        }
+    }
+
+    if (ftruncate(fd, capacity) < 0) {
+        virReportSystemError(errno,
+                             _("Failed to truncate file '%s'"), path);
+        goto cleanup;
     }
 
     if (VIR_CLOSE(fd) < 0) {
-- 
2.13.0

--
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]
  Powered by Linux