getPESize does not have to be static.
This commit is contained in:
parent
68539ad97a
commit
b5b5ac9cb4
|
@ -127,7 +127,7 @@ bool lvm2_pv::resize(Report& report, const QString& deviceNode, qint64 length) c
|
|||
|
||||
qint64 lastPE = getTotalPE(deviceNode) - 1; // starts from 0
|
||||
if (lastPE > 0) { // make sure that the PV is already in a VG
|
||||
qint64 targetPE = (length - metadataOffset)/ getPESize(deviceNode) - 1; // starts from 0
|
||||
qint64 targetPE = (length - metadataOffset) / getPESize(deviceNode) - 1; // starts from 0
|
||||
if (targetPE < lastPE) { //shrinking FS
|
||||
qint64 firstMovedPE = qMax(targetPE + 1, getAllocatedPE(deviceNode)); // starts from 1
|
||||
ExternalCommand moveCmd(report,
|
||||
|
@ -206,7 +206,7 @@ qint64 lvm2_pv::getTotalPE(const QStringList& deviceNodeList)
|
|||
{
|
||||
qint64 sum = 0;
|
||||
for (const auto &deviceNode : deviceNodeList) {
|
||||
qint64 totalPE = getTotalPE(deviceNode);
|
||||
qint64 totalPE = getTotalPE(deviceNode);
|
||||
if (totalPE < 0) {
|
||||
sum = -1;
|
||||
break;
|
||||
|
@ -275,7 +275,7 @@ qint64 lvm2_pv::getPVSize(const QStringList& deviceNodeList)
|
|||
return sum;
|
||||
}
|
||||
|
||||
qint64 lvm2_pv::getPESize(const QString& deviceNode)
|
||||
qint64 lvm2_pv::getPESize(const QString& deviceNode) const
|
||||
{
|
||||
QString val = getpvField(QStringLiteral("vg_extent_size"), deviceNode);
|
||||
return val.isEmpty() ? -1 : val.toLongLong();
|
||||
|
@ -313,7 +313,7 @@ QString lvm2_pv::getVGName(const QString& deviceNode)
|
|||
return getpvField(QStringLiteral("vg_name"), deviceNode);
|
||||
}
|
||||
|
||||
const QStringList lvm2_pv::getFreePV()
|
||||
QStringList lvm2_pv::getFreePV()
|
||||
{
|
||||
QStringList rlist;
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
static qint64 getFreePE(const QStringList& deviceNodeList);
|
||||
static qint64 getAllocatedPE(const QString& deviceNode);
|
||||
static qint64 getAllocatedPE(const QStringList& deviceNodeList);
|
||||
static qint64 getPESize(const QString& deviceNode); // return PE size in bytes
|
||||
qint64 getPESize(const QString& deviceNode) const; // return PE size in bytes
|
||||
static qint64 getPVSize(const QString& deviceNode); // return PV size in bytes
|
||||
static qint64 getPVSize(const QStringList& deviceNodeList);
|
||||
|
||||
|
@ -115,7 +115,7 @@ public:
|
|||
static QString getVGName(const QString& deviceNode);
|
||||
static QString getpvField(const QString& fieldName, const QString& deviceNode = QString());
|
||||
|
||||
static const QStringList getFreePV();
|
||||
static QStringList getFreePV();
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
@ -130,6 +130,7 @@ public:
|
|||
static CommandSupportType m_SetLabel;
|
||||
static CommandSupportType m_UpdateUUID;
|
||||
static CommandSupportType m_GetUUID;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -46,14 +46,14 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& d, const QStri
|
|||
m_CurrentSize = FS::lvm2_pv::getPVSize(currentList());
|
||||
|
||||
QStringList toRemoveList = curList;
|
||||
for (QString path : partlist) {
|
||||
for (const QString &path : partlist) {
|
||||
if (toRemoveList.contains(path)) {
|
||||
toRemoveList.removeAll(path);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList toInsertList = partlist;
|
||||
for (QString path : curList) {
|
||||
for (const QString &path : curList) {
|
||||
if (toInsertList.contains(path)) {
|
||||
toInsertList.removeAll(path);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ bool ResizeVolumeGroupOperation::targets(const Device& d) const
|
|||
|
||||
bool ResizeVolumeGroupOperation::targets(const Partition& p) const
|
||||
{
|
||||
for (QString partPath : targetList()) {
|
||||
for (const QString &partPath : targetList()) {
|
||||
if (partPath == p.partitionPath()) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue