Loading physical volumes for RAID
This commit is contained in:
parent
32eacc4db6
commit
7429ff7527
|
@ -48,7 +48,6 @@ public:
|
||||||
QString m_UUID;
|
QString m_UUID;
|
||||||
|
|
||||||
mutable QStringList m_LVPathList;
|
mutable QStringList m_LVPathList;
|
||||||
QVector <const Partition*> m_PVs;
|
|
||||||
mutable std::unique_ptr<QHash<QString, qint64>> m_LVSizeMap;
|
mutable std::unique_ptr<QHash<QString, qint64>> m_LVSizeMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -550,16 +549,6 @@ QString LvmDevice::UUID() const
|
||||||
return d_ptr->m_UUID;
|
return d_ptr->m_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector <const Partition*>& LvmDevice::physicalVolumes()
|
|
||||||
{
|
|
||||||
return d_ptr->m_PVs;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QVector <const Partition*>& LvmDevice::physicalVolumes() const
|
|
||||||
{
|
|
||||||
return d_ptr->m_PVs;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<QHash<QString, qint64>>& LvmDevice::LVSizeMap() const
|
std::unique_ptr<QHash<QString, qint64>>& LvmDevice::LVSizeMap() const
|
||||||
{
|
{
|
||||||
return d_ptr->m_LVSizeMap;
|
return d_ptr->m_LVSizeMap;
|
||||||
|
|
|
@ -99,8 +99,6 @@ public:
|
||||||
qint64 allocatedPE() const;
|
qint64 allocatedPE() const;
|
||||||
qint64 freePE() const;
|
qint64 freePE() const;
|
||||||
QString UUID() const;
|
QString UUID() const;
|
||||||
QVector <const Partition*>& physicalVolumes();
|
|
||||||
const QVector <const Partition*>& physicalVolumes() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<QHash<QString, qint64>>& LVSizeMap() const;
|
std::unique_ptr<QHash<QString, qint64>>& LVSizeMap() const;
|
||||||
|
|
|
@ -381,11 +381,10 @@ bool SoftwareRAID::createSoftwareRAID(Report &report,
|
||||||
{
|
{
|
||||||
QString path = QStringLiteral("/dev/") + name;
|
QString path = QStringLiteral("/dev/") + name;
|
||||||
|
|
||||||
QStringList args;
|
QStringList args = { QStringLiteral("--create"), path,
|
||||||
args << QStringLiteral("--create") << path;
|
QStringLiteral("--level=") + QString::number(raidLevel),
|
||||||
args << QStringLiteral("--level=") + QString::number(raidLevel);
|
QStringLiteral("--chunk=") + QString::number(chunkSize),
|
||||||
args << QStringLiteral("--chunk=") + QString::number(chunkSize);
|
QStringLiteral("--raid-devices=") + QString::number(devicePathList.size()) };
|
||||||
args << QStringLiteral("--raid-devices=") + QString::number(devicePathList.size());
|
|
||||||
|
|
||||||
for (const QString &p : qAsConst(devicePathList)) {
|
for (const QString &p : qAsConst(devicePathList)) {
|
||||||
eraseDeviceMDSuperblock(p);
|
eraseDeviceMDSuperblock(p);
|
||||||
|
@ -398,7 +397,8 @@ bool SoftwareRAID::createSoftwareRAID(Report &report,
|
||||||
if (!cmd.run(-1) || cmd.exitCode() != 0)
|
if (!cmd.run(-1) || cmd.exitCode() != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
updateConfigurationFile(path);
|
if (updateConfigurationFile(path))
|
||||||
|
qDebug() << QStringLiteral("Updated RAID config: ") + path;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -408,6 +408,12 @@ bool SoftwareRAID::deleteSoftwareRAID(Report &report,
|
||||||
{
|
{
|
||||||
Q_UNUSED(report)
|
Q_UNUSED(report)
|
||||||
Q_UNUSED(raidDevice)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,12 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "core/device_p.h"
|
#include "core/device_p.h"
|
||||||
|
#include "core/partition.h"
|
||||||
#include "core/volumemanagerdevice.h"
|
#include "core/volumemanagerdevice.h"
|
||||||
#include "core/volumemanagerdevice_p.h"
|
#include "core/volumemanagerdevice_p.h"
|
||||||
|
|
||||||
|
#define d_ptr std::static_pointer_cast<VolumeManagerDevicePrivate>(d)
|
||||||
|
|
||||||
/** Constructs an abstract Volume Manager Device with an empty PartitionTable.
|
/** Constructs an abstract Volume Manager Device with an empty PartitionTable.
|
||||||
*
|
*
|
||||||
* @param name the Device's name
|
* @param name the Device's name
|
||||||
|
@ -45,5 +48,15 @@ QString VolumeManagerDevice::prettyDeviceNodeList() const
|
||||||
void VolumeManagerDevice::setTotalLogical(qint64 n)
|
void VolumeManagerDevice::setTotalLogical(qint64 n)
|
||||||
{
|
{
|
||||||
Q_ASSERT(n > 0);
|
Q_ASSERT(n > 0);
|
||||||
d->m_TotalLogical = n;
|
d_ptr->m_TotalLogical = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<const Partition*>& VolumeManagerDevice::physicalVolumes()
|
||||||
|
{
|
||||||
|
return d_ptr->m_PVs;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<const Partition*>& VolumeManagerDevice::physicalVolumes() const
|
||||||
|
{
|
||||||
|
return d_ptr->m_PVs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
class Partition;
|
||||||
class VolumeManagerDevicePrivate;
|
class VolumeManagerDevicePrivate;
|
||||||
|
|
||||||
/** A Volume Manager of physical devices represented as an abstract device.
|
/** A Volume Manager of physical devices represented as an abstract device.
|
||||||
|
@ -91,6 +92,10 @@ public:
|
||||||
* @param n Number of sectors.
|
* @param n Number of sectors.
|
||||||
*/
|
*/
|
||||||
void setTotalLogical(qint64 n);
|
void setTotalLogical(qint64 n);
|
||||||
|
|
||||||
|
QVector<const Partition*>& physicalVolumes();
|
||||||
|
|
||||||
|
const QVector<const Partition*>& physicalVolumes() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,8 +20,14 @@
|
||||||
|
|
||||||
#include "core/device_p.h"
|
#include "core/device_p.h"
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
class Partition;
|
||||||
|
|
||||||
class VolumeManagerDevicePrivate : public DevicePrivate
|
class VolumeManagerDevicePrivate : public DevicePrivate
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
QVector<const Partition*> m_PVs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -64,17 +64,20 @@ void DeactivateVolumeGroupOperation::undo()
|
||||||
*/
|
*/
|
||||||
bool DeactivateVolumeGroupOperation::isDeactivatable(const VolumeManagerDevice* dev)
|
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())
|
for (const auto &p : dev->partitionTable()->children())
|
||||||
if (p->isMounted())
|
if (p->isMounted())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else if (dev->type() == Device::Type::SoftwareRAID_Device) {
|
|
||||||
|
if (dev->type() == Device::Type::SoftwareRAID_Device) {
|
||||||
const SoftwareRAID* raid = static_cast<const SoftwareRAID*>(dev);
|
const SoftwareRAID* raid = static_cast<const SoftwareRAID*>(dev);
|
||||||
return raid->status() == SoftwareRAID::Status::Active;
|
return raid->status() == SoftwareRAID::Status::Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,9 @@ bool SfdiskPartitionTable::commit(quint32 timeout)
|
||||||
|
|
||||||
ExternalCommand(QStringLiteral("udevadm"), { QStringLiteral("settle"), QStringLiteral("--timeout=") + QString::number(timeout) }).run();
|
ExternalCommand(QStringLiteral("udevadm"), { QStringLiteral("settle"), QStringLiteral("--timeout=") + QString::number(timeout) }).run();
|
||||||
ExternalCommand(QStringLiteral("blockdev"), { QStringLiteral("--rereadpt"), m_device->deviceNode() }).run();
|
ExternalCommand(QStringLiteral("blockdev"), { QStringLiteral("--rereadpt"), m_device->deviceNode() }).run();
|
||||||
|
|
||||||
|
QThread::msleep(1000);
|
||||||
|
|
||||||
ExternalCommand(QStringLiteral("udevadm"), { QStringLiteral("trigger") }).run();
|
ExternalCommand(QStringLiteral("udevadm"), { QStringLiteral("trigger") }).run();
|
||||||
|
|
||||||
if (m_device->type() == Device::Type::SoftwareRAID_Device)
|
if (m_device->type() == Device::Type::SoftwareRAID_Device)
|
||||||
|
|
Loading…
Reference in New Issue