]> xenbits.xensource.com Git - libvirt.git/commitdiff
iscsi_direct: Reset pool capacity and allocation just before refresh
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 28 Feb 2019 11:02:06 +0000 (12:02 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 28 Feb 2019 12:55:38 +0000 (13:55 +0100)
Jirka reported a bug that with every 'virsh pool-refresh' an
iscsi-direct pool would grow and grow. The problem is that
virISCSIDirectRefreshVol() only adds to def->capacity and
def->allocation but nothing clears it out to begin with.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/storage/storage_backend_iscsi_direct.c

index 4ac4ad471cc37ac6b0c78703dc373566228615c6..20997d5c5d23f7a4c5f5cb7d5b8867ba92bbbad6 100644 (file)
@@ -341,6 +341,7 @@ virISCSIDirectReportLuns(virStoragePoolObjPtr pool,
                          struct iscsi_context *iscsi,
                          char *portal)
 {
+    virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     struct scsi_task *task = NULL;
     struct scsi_reportluns_list *list = NULL;
     int full_size;
@@ -373,6 +374,8 @@ virISCSIDirectReportLuns(virStoragePoolObjPtr pool,
         goto cleanup;
     }
 
+    def->capacity = 0;
+    def->allocation = 0;
     for (i = 0; i < list->num; i++) {
         if (virISCSIDirectRefreshVol(pool, iscsi, list->luns[i], portal) < 0)
             goto cleanup;