[PATCH 2/3] storage: Need to update freeExtent at delete primary partition

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

 



Commit id '471e1c4e' only considered updating the pool if the extended
partition was removed. As it turns out removing a primary partition
would also need to update the freeExtent list otherwise the following
sequence would fail (assuming a "fresh" disk pool for /dev/sde of 500M):

$  virsh pool-info disk-pool
...
Capacity:       509.88 MiB
Allocation:     0.00 B
Available:      509.84 MiB

$ virsh vol-create-as disk-pool sde1 --capacity 300M
$ virsh vol-delete --pool disk-pool sde1
$ virsh vol-create-as disk-pool sde1 --capacity 300M
error: Failed to create vol sde1
error: internal error: no large enough free extent

$

This patch will refresh the pool, rereading the partitions, and
return

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

diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index ba928d8..17c6492 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -746,10 +746,13 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn,
             goto cleanup;
     }
 
-    /* If this was the extended partition, then all the logical partitions
-     * are then lost. Make it easy on ourselves and just refresh the pool
+    /* If this is not a logical partition, then either we've removed an
+     * extended partition or a primary partion - refresh the pool which
+     * includes resetting the [n]freeExtents data so a subsequent allocation
+     * might be able to use what was deleted.  A logical partition is part
+     * of an extended partition and handled differently
      */
-    if (vol->source.partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) {
+    if (vol->source.partType != VIR_STORAGE_VOL_DISK_TYPE_LOGICAL) {
         virStoragePoolObjClearVols(pool);
         if (virStorageBackendDiskRefreshPool(conn, pool) < 0)
             goto cleanup;
-- 
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]