From fce53d2392b35c048fedd637d88a445eb98cdd9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 18 Sep 2016 02:47:24 +0100 Subject: [PATCH] Use more cached values in ResizeVolumeGroupOperation. --- src/ops/resizevolumegroupoperation.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ops/resizevolumegroupoperation.cpp b/src/ops/resizevolumegroupoperation.cpp index b516cd8..daf8c9c 100644 --- a/src/ops/resizevolumegroupoperation.cpp +++ b/src/ops/resizevolumegroupoperation.cpp @@ -60,11 +60,19 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& d, const QList toInsertList.append(p); qint64 currentFreePE = 0; - for (const auto &p : currentList()) - currentFreePE += FS::lvm2_pv::getFreePE(p->partitionPath()); + for (const auto &p : currentList()) { + const FS::lvm2_pv* lvm2PVFs = p->roles().has(PartitionRole::Luks) ? + static_cast(static_cast(&p->fileSystem())->innerFS()) : // LVM inside LUKS partition + static_cast(&p->fileSystem()); // simple LVM + currentFreePE += lvm2PVFs->freePE(); + } qint64 removedFreePE = 0; - for (const auto &p : toRemoveList) // FIXME: qAsConst - removedFreePE += FS::lvm2_pv::getFreePE(p->partitionPath()); + for (const auto &p : toRemoveList) { // FIXME: qAsConst + const FS::lvm2_pv* lvm2PVFs = p->roles().has(PartitionRole::Luks) ? + static_cast(static_cast(&p->fileSystem())->innerFS()) : // LVM inside LUKS partition + static_cast(&p->fileSystem()); // simple LVM + removedFreePE += lvm2PVFs->freePE(); + } qint64 freePE = currentFreePE - removedFreePE; qint64 movePE = 0; for (const auto &p : toRemoveList) { // FIXME: qAsConst