diff --git a/src/ops/deleteoperation.cpp b/src/ops/deleteoperation.cpp index 0a83c96..d1ec00c 100644 --- a/src/ops/deleteoperation.cpp +++ b/src/ops/deleteoperation.cpp @@ -16,12 +16,13 @@ * along with this program. If not, see .* *************************************************************************/ -#include "ops/createvolumegroupoperation.h" #include "ops/deleteoperation.h" #include "core/partition.h" #include "core/device.h" +#include "core/lvmdevice.h" #include "core/partitiontable.h" +#include "core/raid/softwareraid.h" #include "fs/luks.h" #include "jobs/deletepartitionjob.h" @@ -111,7 +112,7 @@ void DeleteOperation::checkAdjustLogicalNumbers(Partition& p, bool undo) @param p the Partition in question, may be nullptr. @return true if @p p can be deleted. */ -bool DeleteOperation::canDelete(const Partition* p, const QList pendingOps) +bool DeleteOperation::canDelete(const Partition* p) { if (p == nullptr) return false; @@ -120,11 +121,12 @@ bool DeleteOperation::canDelete(const Partition* p, const QList pen return false; if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV) { - // See if there is a newly created VG targeting this partition - for (Operation *op : qAsConst(pendingOps)) { - if (dynamic_cast(op) && op->targets(*p)) - return false; - } + if (LvmDevice::s_DirtyPVs.contains(p)) + return false; + } + else if (p->fileSystem().type() == FileSystem::Type::LinuxRaidMember) { + if (SoftwareRAID::isRaidMember(p->partitionPath())) + return false; } else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) { // See if innerFS is LVM @@ -132,11 +134,12 @@ bool DeleteOperation::canDelete(const Partition* p, const QList pen if (fs) { if (fs->type() == FileSystem::Type::Lvm2_PV) { - // See if there is a newly created VG targeting this partition - for (Operation *op : qAsConst(pendingOps)) { - if (dynamic_cast(op) && op->targets(*p)) - return false; - } + if (LvmDevice::s_DirtyPVs.contains(p)) + return false; + } + else if (fs->type() == FileSystem::Type::LinuxRaidMember) { + if (SoftwareRAID::isRaidMember(p->partitionPath())) + return false; } } } diff --git a/src/ops/deleteoperation.h b/src/ops/deleteoperation.h index 39faccd..682abd2 100644 --- a/src/ops/deleteoperation.h +++ b/src/ops/deleteoperation.h @@ -68,7 +68,7 @@ public: bool targets(const Device& d) const override; bool targets(const Partition& p) const override; - static bool canDelete(const Partition* p, const QList pendingOps = QList()); + static bool canDelete(const Partition* p); protected: Device& targetDevice() { diff --git a/src/ops/resizeoperation.cpp b/src/ops/resizeoperation.cpp index d73df26..249f2b1 100644 --- a/src/ops/resizeoperation.cpp +++ b/src/ops/resizeoperation.cpp @@ -20,6 +20,7 @@ #include "core/partition.h" #include "core/device.h" +#include "core/lvmdevice.h" #include "core/partitiontable.h" #include "core/copysourcedevice.h" #include "core/copytargetdevice.h" @@ -30,7 +31,6 @@ #include "jobs/movefilesystemjob.h" #include "ops/checkoperation.h" -#include "ops/createvolumegroupoperation.h" #include "fs/filesystem.h" #include "fs/luks.h" @@ -329,12 +329,12 @@ bool ResizeOperation::grow(Report& report) @param p the Partition in question, may be nullptr. @return true if @p p can be grown. */ -bool ResizeOperation::canGrow(const Partition* p, const QList pendingOps) +bool ResizeOperation::canGrow(const Partition* p) { if (p == nullptr) return false; - if (isLVMPVinNewlyVG(p, pendingOps)) + if (isLVMPVinNewlyVG(p)) return false; // we can always grow, shrink or move a partition not yet written to disk @@ -351,12 +351,12 @@ bool ResizeOperation::canGrow(const Partition* p, const QList pendi @param p the Partition in question, may be nullptr. @return true if @p p can be shrunk. */ -bool ResizeOperation::canShrink(const Partition* p, const QList pendingOps) +bool ResizeOperation::canShrink(const Partition* p) { if (p == nullptr) return false; - if (isLVMPVinNewlyVG(p, pendingOps)) + if (isLVMPVinNewlyVG(p)) return false; // we can always grow, shrink or move a partition not yet written to disk @@ -376,12 +376,12 @@ bool ResizeOperation::canShrink(const Partition* p, const QList pen @param p the Partition in question, may be nullptr. @return true if @p p can be moved. */ -bool ResizeOperation::canMove(const Partition* p, const QList pendingOps) +bool ResizeOperation::canMove(const Partition* p) { if (p == nullptr) return false; - if (isLVMPVinNewlyVG(p, pendingOps)) + if (isLVMPVinNewlyVG(p)) return false; // we can always grow, shrink or move a partition not yet written to disk @@ -399,14 +399,11 @@ bool ResizeOperation::canMove(const Partition* p, const QList pendi return p->fileSystem().supportMove() != FileSystem::cmdSupportNone; } -bool ResizeOperation::isLVMPVinNewlyVG(const Partition *p, const QList pendingOps) +bool ResizeOperation::isLVMPVinNewlyVG(const Partition *p) { if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV) { - // See if there is a newly created VG targeting this partition - for (Operation *op : qAsConst(pendingOps)) { - if (dynamic_cast(op) && op->targets(*p)) - return true; - } + if (LvmDevice::s_DirtyPVs.contains(p)) + return true; } else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) { // See if innerFS is LVM @@ -414,11 +411,8 @@ bool ResizeOperation::isLVMPVinNewlyVG(const Partition *p, const QListtype() == FileSystem::Type::Lvm2_PV) { - // See if there is a newly created VG targeting this partition - for (Operation *op : qAsConst(pendingOps)) { - if (dynamic_cast(op) && op->targets(*p)) - return true; - } + if (LvmDevice::s_DirtyPVs.contains(p)) + return true; } } } diff --git a/src/ops/resizeoperation.h b/src/ops/resizeoperation.h index 975d08f..c8bf148 100644 --- a/src/ops/resizeoperation.h +++ b/src/ops/resizeoperation.h @@ -85,9 +85,9 @@ public: bool targets(const Device& d) const override; bool targets(const Partition& p) const override; - static bool canGrow(const Partition* p, const QList pendingOps = QList()); - static bool canShrink(const Partition* p, const QList pendingOps = QList()); - static bool canMove(const Partition* p, const QList pendingOps = QList()); + static bool canGrow(const Partition* p); + static bool canShrink(const Partition* p); + static bool canMove(const Partition* p); protected: Device& targetDevice() { @@ -159,7 +159,7 @@ protected: } private: - static bool isLVMPVinNewlyVG(const Partition* p, const QList pendingOps); + static bool isLVMPVinNewlyVG(const Partition* p); private: Device& m_TargetDevice;