提交 eb9aaa26 编写于 作者: J John Ferlan 提交者: Cole Robinson

storage: Adjust calculation of alloc/capacity for disk

https://bugzilla.redhat.com/show_bug.cgi?id=1247987

Calculation of the extended and logical partition values for the disk
pool is complex. As the bz points out an extended partition should have
it's allocation initialized to 0 (zero) and keep the capacity as the size
dictated by the extents read.  Then for each logical partition found,
adjust the allocation of the extended partition.

Finally, previous logic tried to avoid recalculating things if a logical
partition was deleted; however, since we now have special logic to handle
the allocation of the extended partition, just make life easier by reading
the partition table again - rather than doing the reverse adjustment.

(cherry picked from commit 1895b421)
上级 770ffbf8
......@@ -156,7 +156,8 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
VIR_STORAGE_VOL_OPEN_DEFAULT |
VIR_STORAGE_VOL_OPEN_NOERROR) == -1)
return -1;
vol->target.allocation = vol->target.capacity =
vol->target.allocation = 0;
vol->target.capacity =
(vol->source.extents[0].end - vol->source.extents[0].start);
} else {
if (virStorageBackendUpdateVolInfo(vol, false,
......@@ -164,6 +165,20 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
return -1;
}
/* Find the extended partition and increase the allocation value */
if (vol->source.partType == VIR_STORAGE_VOL_DISK_TYPE_LOGICAL) {
size_t i;
for (i = 0; i < pool->volumes.count; i++) {
if (pool->volumes.objs[i]->source.partType ==
VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) {
pool->volumes.objs[i]->target.allocation +=
vol->target.allocation;
break;
}
}
}
if (STRNEQ(groups[2], "metadata"))
pool->def->allocation += vol->target.allocation;
if (vol->source.extents[0].end > pool->def->capacity)
......@@ -748,17 +763,14 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn,
goto cleanup;
}
/* 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
/* Refreshing the pool is the easiest option as LOGICAL and EXTENDED
* partition allocation/capacity management is handled within
* virStorageBackendDiskMakeDataVol and trying to redo that logic
* here is pointless
*/
if (vol->source.partType != VIR_STORAGE_VOL_DISK_TYPE_LOGICAL) {
virStoragePoolObjClearVols(pool);
if (virStorageBackendDiskRefreshPool(conn, pool) < 0)
goto cleanup;
}
rc = 0;
cleanup:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册