storage: When delete volume avoid disk backend removal

For a disk backend, the deleteVol code will clear all the
volumes in the pool and perform a pool refresh, thus the
storageVolDeleteInternal should not use access @voldef
after deleteVol succeeds.
This commit is contained in:
John Ferlan 2018-01-09 08:40:24 -05:00
parent b427cf4831
commit ec24d2905b

View File

@ -1670,15 +1670,21 @@ storageVolDeleteInternal(virStorageVolPtr vol,
if (backend->deleteVol(vol->conn, obj, voldef, flags) < 0) if (backend->deleteVol(vol->conn, obj, voldef, flags) < 0)
goto cleanup; goto cleanup;
/* The disk backend updated the pool data including removing the
* voldef from the pool (for both the deleteVol and the createVol
* failure path. */
if (def->type == VIR_STORAGE_POOL_DISK) {
ret = 0;
goto cleanup;
}
/* Update pool metadata - don't update meta data from error paths /* 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. * Ignore the disk backend since it updates the pool values.
*/ */
if (updateMeta) { if (updateMeta) {
if (def->type != VIR_STORAGE_POOL_DISK) { def->allocation -= voldef->target.allocation;
def->allocation -= voldef->target.allocation; def->available += voldef->target.allocation;
def->available += voldef->target.allocation;
}
} }
virStoragePoolObjRemoveVol(obj, voldef); virStoragePoolObjRemoveVol(obj, voldef);