[PATCH v2 2/3] storage: Don't adjust pool alloc/avail values for disk backend

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

 



Commit id '2ac0e647' for https://bugzilla.redhat.com/show_bug.cgi?id=1206521
was meant to be a generic check for the CreateVol, CreateVolFrom, and
DeleteVol paths to check if the storage backend's changed the pool's view
of allocation or available values.

Unfortunately as it turns out this caused a side effect when the disk backend
created an extended partition there would be no actual storage removed from
the pool, thus the changes would not find any change in allocation or
available and incorrectly update the pool values using the size of the
extended partition. A subsequent refresh of the pool would reset the
values appropriately.

This patch modifies those checks in order to specifically not update the
pool allocation and available for only the disk backend rather than be
generic before and after checks.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_driver.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 30e0969..a9f66d1 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1646,11 +1646,14 @@ storageVolDeleteInternal(virStorageVolPtr obj,
         goto cleanup;
 
     /* Update pool metadata - don't update meta data from error paths
-     * in this module since the allocation/available weren't adjusted yet
+     * in this module since the allocation/available weren't adjusted yet.
+     * Ignore the disk backend since it updates the pool values.
      */
     if (updateMeta) {
-        pool->def->allocation -= vol->target.allocation;
-        pool->def->available += vol->target.allocation;
+        if (pool->def->type != VIR_STORAGE_POOL_DISK) {
+            pool->def->allocation -= vol->target.allocation;
+            pool->def->available += vol->target.allocation;
+        }
     }
 
     for (i = 0; i < pool->volumes.count; i++) {
@@ -1872,9 +1875,13 @@ storageVolCreateXML(virStoragePoolPtr obj,
         backend->refreshVol(obj->conn, pool, voldef) < 0)
         goto cleanup;
 
-    /* Update pool metadata */
-    pool->def->allocation += buildvoldef->target.allocation;
-    pool->def->available -= buildvoldef->target.allocation;
+    /* Update pool metadata ignoring the disk backend since
+     * it updates the pool values.
+     */
+    if (pool->def->type != VIR_STORAGE_POOL_DISK) {
+        pool->def->allocation += buildvoldef->target.allocation;
+        pool->def->available -= buildvoldef->target.allocation;
+    }
 
     VIR_INFO("Creating volume '%s' in storage pool '%s'",
              volobj->name, pool->def->name);
@@ -2056,9 +2063,13 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
     }
     newvol = NULL;
 
-    /* Updating pool metadata */
-    pool->def->allocation += allocation;
-    pool->def->available -= allocation;
+    /* Updating pool metadata ignoring the disk backend since
+     * it updates the pool values
+     */
+    if (pool->def->type != VIR_STORAGE_POOL_DISK) {
+        pool->def->allocation += allocation;
+        pool->def->available -= allocation;
+    }
 
     VIR_INFO("Creating volume '%s' in storage pool '%s'",
              volobj->name, pool->def->name);
-- 
2.1.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]