diff --git a/src/core/lvmdevice.cpp b/src/core/lvmdevice.cpp index 203fb0b..1b1d1e3 100644 --- a/src/core/lvmdevice.cpp +++ b/src/core/lvmdevice.cpp @@ -48,7 +48,6 @@ public: QString m_UUID; mutable QStringList m_LVPathList; - QVector m_PVs; mutable std::unique_ptr> m_LVSizeMap; }; @@ -550,16 +549,6 @@ QString LvmDevice::UUID() const return d_ptr->m_UUID; } -QVector & LvmDevice::physicalVolumes() -{ - return d_ptr->m_PVs; -} - -const QVector & LvmDevice::physicalVolumes() const -{ - return d_ptr->m_PVs; -} - std::unique_ptr>& LvmDevice::LVSizeMap() const { return d_ptr->m_LVSizeMap; diff --git a/src/core/lvmdevice.h b/src/core/lvmdevice.h index 089719b..bbf608f 100644 --- a/src/core/lvmdevice.h +++ b/src/core/lvmdevice.h @@ -99,8 +99,6 @@ public: qint64 allocatedPE() const; qint64 freePE() const; QString UUID() const; - QVector & physicalVolumes(); - const QVector & physicalVolumes() const; protected: std::unique_ptr>& LVSizeMap() const; diff --git a/src/core/raid/softwareraid.cpp b/src/core/raid/softwareraid.cpp index bb19d88..fdc32b5 100644 --- a/src/core/raid/softwareraid.cpp +++ b/src/core/raid/softwareraid.cpp @@ -381,11 +381,10 @@ bool SoftwareRAID::createSoftwareRAID(Report &report, { QString path = QStringLiteral("/dev/") + name; - QStringList args; - args << QStringLiteral("--create") << path; - args << QStringLiteral("--level=") + QString::number(raidLevel); - args << QStringLiteral("--chunk=") + QString::number(chunkSize); - args << QStringLiteral("--raid-devices=") + QString::number(devicePathList.size()); + QStringList args = { QStringLiteral("--create"), path, + QStringLiteral("--level=") + QString::number(raidLevel), + QStringLiteral("--chunk=") + QString::number(chunkSize), + QStringLiteral("--raid-devices=") + QString::number(devicePathList.size()) }; for (const QString &p : qAsConst(devicePathList)) { eraseDeviceMDSuperblock(p); @@ -398,7 +397,8 @@ bool SoftwareRAID::createSoftwareRAID(Report &report, if (!cmd.run(-1) || cmd.exitCode() != 0) return false; - updateConfigurationFile(path); + if (updateConfigurationFile(path)) + qDebug() << QStringLiteral("Updated RAID config: ") + path; return true; } @@ -408,6 +408,12 @@ bool SoftwareRAID::deleteSoftwareRAID(Report &report, { Q_UNUSED(report) Q_UNUSED(raidDevice) + + // TODO: Need to stop and remove it from config file + // Erase md superblock for every physical partition of it + // The device should be removed from config file + // according to its UID, not by name + return false; } diff --git a/src/core/volumemanagerdevice.cpp b/src/core/volumemanagerdevice.cpp index 7c339af..aadc660 100644 --- a/src/core/volumemanagerdevice.cpp +++ b/src/core/volumemanagerdevice.cpp @@ -17,9 +17,12 @@ *************************************************************************/ #include "core/device_p.h" +#include "core/partition.h" #include "core/volumemanagerdevice.h" #include "core/volumemanagerdevice_p.h" +#define d_ptr std::static_pointer_cast(d) + /** Constructs an abstract Volume Manager Device with an empty PartitionTable. * * @param name the Device's name @@ -45,5 +48,15 @@ QString VolumeManagerDevice::prettyDeviceNodeList() const void VolumeManagerDevice::setTotalLogical(qint64 n) { Q_ASSERT(n > 0); - d->m_TotalLogical = n; + d_ptr->m_TotalLogical = n; +} + +QVector& VolumeManagerDevice::physicalVolumes() +{ + return d_ptr->m_PVs; +} + +const QVector& VolumeManagerDevice::physicalVolumes() const +{ + return d_ptr->m_PVs; } diff --git a/src/core/volumemanagerdevice.h b/src/core/volumemanagerdevice.h index f1750dd..6f3aa69 100644 --- a/src/core/volumemanagerdevice.h +++ b/src/core/volumemanagerdevice.h @@ -26,6 +26,7 @@ #include #include +class Partition; class VolumeManagerDevicePrivate; /** A Volume Manager of physical devices represented as an abstract device. @@ -91,6 +92,10 @@ public: * @param n Number of sectors. */ void setTotalLogical(qint64 n); + + QVector& physicalVolumes(); + + const QVector& physicalVolumes() const; }; #endif diff --git a/src/core/volumemanagerdevice_p.h b/src/core/volumemanagerdevice_p.h index 6061c26..32afe04 100644 --- a/src/core/volumemanagerdevice_p.h +++ b/src/core/volumemanagerdevice_p.h @@ -20,8 +20,14 @@ #include "core/device_p.h" +#include + +class Partition; + class VolumeManagerDevicePrivate : public DevicePrivate { +public: + QVector m_PVs; }; #endif diff --git a/src/ops/deactivatevolumegroupoperation.cpp b/src/ops/deactivatevolumegroupoperation.cpp index ad7551f..71784e7 100644 --- a/src/ops/deactivatevolumegroupoperation.cpp +++ b/src/ops/deactivatevolumegroupoperation.cpp @@ -64,17 +64,20 @@ void DeactivateVolumeGroupOperation::undo() */ bool DeactivateVolumeGroupOperation::isDeactivatable(const VolumeManagerDevice* dev) { - if (dev->type() == Device::Type::LVM_Device) { + if (dev->type() != Device::Type::SoftwareRAID_Device && + dev->type() != Device::Type::LVM_Device) + return false; + + if (dev->partitionTable()) { for (const auto &p : dev->partitionTable()->children()) if (p->isMounted()) return false; - - return true; } - else if (dev->type() == Device::Type::SoftwareRAID_Device) { + + if (dev->type() == Device::Type::SoftwareRAID_Device) { const SoftwareRAID* raid = static_cast(dev); return raid->status() == SoftwareRAID::Status::Active; } - return false; + return true; } diff --git a/src/plugins/sfdisk/sfdiskpartitiontable.cpp b/src/plugins/sfdisk/sfdiskpartitiontable.cpp index 470e783..2f0fd7e 100644 --- a/src/plugins/sfdisk/sfdiskpartitiontable.cpp +++ b/src/plugins/sfdisk/sfdiskpartitiontable.cpp @@ -58,6 +58,9 @@ bool SfdiskPartitionTable::commit(quint32 timeout) ExternalCommand(QStringLiteral("udevadm"), { QStringLiteral("settle"), QStringLiteral("--timeout=") + QString::number(timeout) }).run(); ExternalCommand(QStringLiteral("blockdev"), { QStringLiteral("--rereadpt"), m_device->deviceNode() }).run(); + + QThread::msleep(1000); + ExternalCommand(QStringLiteral("udevadm"), { QStringLiteral("trigger") }).run(); if (m_device->type() == Device::Type::SoftwareRAID_Device)