Add optional destination partitions to LVM movePV. This also helps preventing moving data back and forth when resizing.

This commit is contained in:
Chantara Tith 2016-07-11 20:00:44 +07:00
parent fcf65fda18
commit 271b59a30b
3 changed files with 21 additions and 6 deletions

View File

@ -333,7 +333,7 @@ bool LvmDevice::insertPV(Report& report, LvmDevice& dev, const QString& pvPath)
return (cmd.run(-1) && cmd.exitCode() == 0);
}
bool LvmDevice::movePV(Report& report, LvmDevice& dev, const QString& pvPath)
bool LvmDevice::movePV(Report& report, LvmDevice& dev, const QString& pvPath, const QStringList& destinations)
{
Q_UNUSED(dev);
@ -341,9 +341,16 @@ bool LvmDevice::movePV(Report& report, LvmDevice& dev, const QString& pvPath)
return true;
}
ExternalCommand cmd(report, QStringLiteral("lvm"),
{ QStringLiteral("pvmove"),
pvPath});
QStringList args = QStringList();
args << QStringLiteral("pvmove");
args << pvPath;
if (!destinations.isEmpty()) {
foreach (QString destPath, destinations) {
args << destPath.trimmed();
}
}
ExternalCommand cmd(report, QStringLiteral("lvm"), args);
return (cmd.run(-1) && cmd.exitCode() == 0);
}

View File

@ -70,7 +70,7 @@ public:
static bool removePV(Report& report, LvmDevice& dev, const QString& pvPath);
static bool insertPV(Report& report, LvmDevice& dev, const QString& pvPath);
static bool movePV(Report& report, LvmDevice& dev, const QString& pvPath);
static bool movePV(Report& report, LvmDevice& dev, const QString& pvPath, const QStringList& destinations = QStringList());
static bool removeVG(Report& report, LvmDevice& dev);
static bool createVG(Report& report, const QString vgname, const QStringList pvlist);

View File

@ -41,8 +41,16 @@ bool MovePhysicalVolumeJob::run(Report& parent)
Report* report = jobStarted(parent);
//TODO:check that the provided list is legal
QStringList destinations = LvmDevice::getPVs(device().name());
foreach (QString partPath, partList()) {
rval = LvmDevice::movePV(*report, device(), partPath);
if (destinations.contains(partPath)) {
destinations.removeAll(partPath);
}
}
foreach (QString partPath, partList()) {
rval = LvmDevice::movePV(*report, device(), partPath, destinations);
if (rval == false) {
break;
}