Mark LVM PV as mounted if it is part of Volume Group.

* Add support for online LVM PV resize and check actions.
* Fix support for online actions inside LUKS container.
This commit is contained in:
Andrius Štikonas 2016-10-30 01:46:38 +01:00
parent b539f835b1
commit e765316f9e
7 changed files with 57 additions and 22 deletions

View File

@ -143,7 +143,7 @@ bool FileSystem::detectMountStatus(FileSystem* fs, const QString& partitionPath)
bool mounted = false; bool mounted = false;
if (fs->type() == FileSystem::Lvm2_PV) { if (fs->type() == FileSystem::Lvm2_PV) {
mounted = false; mounted = FS::lvm2_pv::getVGName(partitionPath) != QString(); // FIXME: VG name is scanned twice
} else { } else {
mounted = isMounted(partitionPath); mounted = isMounted(partitionPath);
} }
@ -166,8 +166,8 @@ QString FileSystem::readLabel(const QString& deviceNode) const
*/ */
bool FileSystem::create(Report& report, const QString& deviceNode) bool FileSystem::create(Report& report, const QString& deviceNode)
{ {
Q_UNUSED(report); Q_UNUSED(report)
Q_UNUSED(deviceNode); Q_UNUSED(deviceNode)
return true; return true;
} }
@ -188,9 +188,9 @@ void FileSystem::scan(const QString& deviceNode)
*/ */
bool FileSystem::resize(Report& report, const QString& deviceNode, qint64 newLength) const bool FileSystem::resize(Report& report, const QString& deviceNode, qint64 newLength) const
{ {
Q_UNUSED(report); Q_UNUSED(report)
Q_UNUSED(deviceNode); Q_UNUSED(deviceNode)
Q_UNUSED(newLength); Q_UNUSED(newLength)
return true; return true;
} }

View File

@ -151,6 +151,9 @@ public:
virtual CommandSupportType supportCheck() const { virtual CommandSupportType supportCheck() const {
return cmdSupportNone; /**< @return CommandSupportType for checking */ return cmdSupportNone; /**< @return CommandSupportType for checking */
} }
virtual CommandSupportType supportCheckOnline() const {
return cmdSupportNone; /**< @return CommandSupportType for checking */
}
virtual CommandSupportType supportCopy() const { virtual CommandSupportType supportCopy() const {
return cmdSupportNone; /**< @return CommandSupportType for copying */ return cmdSupportNone; /**< @return CommandSupportType for copying */
} }

View File

@ -64,6 +64,13 @@ public:
return m_innerFs->supportGrow(); return m_innerFs->supportGrow();
return cmdSupportNone; return cmdSupportNone;
} }
CommandSupportType supportGrowOnline() const override {
if (!m_isCryptOpen)
return cmdSupportNone;
if (m_Grow && m_innerFs)
return m_innerFs->supportGrowOnline();
return cmdSupportNone;
}
CommandSupportType supportShrink() const override { CommandSupportType supportShrink() const override {
if (!m_isCryptOpen) if (!m_isCryptOpen)
return cmdSupportNone; return cmdSupportNone;
@ -71,6 +78,13 @@ public:
return m_innerFs->supportShrink(); return m_innerFs->supportShrink();
return cmdSupportNone; return cmdSupportNone;
} }
CommandSupportType supportShrinkOnline() const override {
if (!m_isCryptOpen)
return cmdSupportNone;
if (m_Shrink && m_innerFs)
return m_innerFs->supportShrinkOnline();
return cmdSupportNone;
}
CommandSupportType supportMove() const override { CommandSupportType supportMove() const override {
if (m_isCryptOpen) if (m_isCryptOpen)
return cmdSupportNone; return cmdSupportNone;
@ -83,6 +97,13 @@ public:
return m_innerFs->supportCheck(); return m_innerFs->supportCheck();
return cmdSupportNone; return cmdSupportNone;
} }
CommandSupportType supportCheckOnline() const override {
if (!m_isCryptOpen)
return cmdSupportNone;
if (m_Check && m_innerFs)
return m_innerFs->supportCheckOnline();
return cmdSupportNone;
}
CommandSupportType supportCopy() const override { CommandSupportType supportCopy() const override {
if (m_isCryptOpen) if (m_isCryptOpen)
return cmdSupportNone; return cmdSupportNone;

View File

@ -78,14 +78,11 @@ bool lvm2_pv::supportToolFound() const
{ {
return return
m_GetUsed != cmdSupportNone && m_GetUsed != cmdSupportNone &&
// m_GetLabel != cmdSupportNone &&
// m_SetLabel != cmdSupportNone &&
m_Create != cmdSupportNone && m_Create != cmdSupportNone &&
m_Check != cmdSupportNone && m_Check != cmdSupportNone &&
m_UpdateUUID != cmdSupportNone && m_UpdateUUID != cmdSupportNone &&
m_Grow != cmdSupportNone && m_Grow != cmdSupportNone &&
m_Shrink != cmdSupportNone && m_Shrink != cmdSupportNone &&
// m_Copy != cmdSupportNone &&
m_Move != cmdSupportNone && m_Move != cmdSupportNone &&
m_Backup != cmdSupportNone && m_Backup != cmdSupportNone &&
m_GetUUID != cmdSupportNone; m_GetUUID != cmdSupportNone;
@ -158,6 +155,12 @@ bool lvm2_pv::resize(Report& report, const QString& deviceNode, qint64 length) c
return rval && cmd.run(-1) && cmd.exitCode() == 0; return rval && cmd.run(-1) && cmd.exitCode() == 0;
} }
bool lvm2_pv::resizeOnline(Report& report, const QString& deviceNode, const QString& mountPoint, qint64 length) const
{
Q_UNUSED(mountPoint)
return resize(report, deviceNode, length);
}
bool lvm2_pv::updateUUID(Report& report, const QString& deviceNode) const bool lvm2_pv::updateUUID(Report& report, const QString& deviceNode) const
{ {
ExternalCommand cmd(report, QStringLiteral("lvm"), { QStringLiteral("pvchange"), QStringLiteral("--uuid"), deviceNode }); ExternalCommand cmd(report, QStringLiteral("lvm"), { QStringLiteral("pvchange"), QStringLiteral("--uuid"), deviceNode });

View File

@ -53,6 +53,7 @@ public:
bool create(Report& report, const QString& deviceNode) override; bool create(Report& report, const QString& deviceNode) override;
bool remove(Report& report, const QString& deviceNode) const override; bool remove(Report& report, const QString& deviceNode) const override;
bool resize(Report& report, const QString& deviceNode, qint64 length) const override; bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
bool resizeOnline(Report& report, const QString& deviceNode, const QString& mountPoint, qint64 length) const override;
// bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; // bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
bool updateUUID(Report& report, const QString& deviceNode) const override; bool updateUUID(Report& report, const QString& deviceNode) const override;
QString readUUID(const QString& deviceNode) const override; QString readUUID(const QString& deviceNode) const override;
@ -76,15 +77,24 @@ public:
CommandSupportType supportGrow() const override { CommandSupportType supportGrow() const override {
return m_Grow; return m_Grow;
} }
CommandSupportType supportGrowOnline() const override {
return m_Grow;
}
CommandSupportType supportShrink() const override { CommandSupportType supportShrink() const override {
return m_Shrink; return m_Shrink;
} }
CommandSupportType supportShrinkOnline() const override {
return m_Shrink;
}
CommandSupportType supportMove() const override { CommandSupportType supportMove() const override {
return m_Move; return m_Move;
} }
CommandSupportType supportCheck() const override { CommandSupportType supportCheck() const override {
return m_Check; return m_Check;
} }
CommandSupportType supportCheckOnline() const override {
return m_Check;
}
CommandSupportType supportCopy() const override { CommandSupportType supportCopy() const override {
return m_Copy; return m_Copy;
} }

View File

@ -70,7 +70,7 @@ bool CheckOperation::canCheck(const Partition* p)
return false; return false;
if (p->isMounted()) if (p->isMounted())
return false; return p->fileSystem().supportCheckOnline() != FileSystem::cmdSupportNone;
return p->fileSystem().supportCheck() != FileSystem::cmdSupportNone; return p->fileSystem().supportCheck() != FileSystem::cmdSupportNone;
} }

View File

@ -29,6 +29,8 @@
#include "jobs/resizefilesystemjob.h" #include "jobs/resizefilesystemjob.h"
#include "jobs/movefilesystemjob.h" #include "jobs/movefilesystemjob.h"
#include "ops/checkoperation.h"
#include "fs/filesystem.h" #include "fs/filesystem.h"
#include "util/capacity.h" #include "util/capacity.h"
@ -63,7 +65,7 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6
m_GrowSetGeomJob(nullptr), m_GrowSetGeomJob(nullptr),
m_CheckResizedJob(nullptr) m_CheckResizedJob(nullptr)
{ {
if(!partition().isMounted()) // FIXME: add support for checkOnline for file systems that support it. if(CheckOperation::canCheck(&partition()))
addJob(checkOriginalJob()); addJob(checkOriginalJob());
if (partition().roles().has(PartitionRole::Extended)) { if (partition().roles().has(PartitionRole::Extended)) {
@ -100,7 +102,7 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6
m_CheckResizedJob = new CheckFileSystemJob(partition()); m_CheckResizedJob = new CheckFileSystemJob(partition());
if(!partition().isMounted()) // FIXME: add support for checkOnline for file systems that support it. if(CheckOperation::canCheck(&partition()))
addJob(checkResizedJob()); addJob(checkResizedJob());
} }
} }
@ -143,13 +145,11 @@ void ResizeOperation::undo()
bool ResizeOperation::execute(Report& parent) bool ResizeOperation::execute(Report& parent)
{ {
bool rval = false; bool rval = true;
Report* report = parent.newChild(description()); Report* report = parent.newChild(description());
if (partition().isMounted()) // FIXME: add support for checkOnline for file systems that support it. if (CheckOperation::canCheck(&partition()))
rval = true;
else
rval = checkOriginalJob()->run(*report); rval = checkOriginalJob()->run(*report);
if (rval) { if (rval) {
@ -165,13 +165,11 @@ bool ResizeOperation::execute(Report& parent)
rval = shrink(*report) && move(*report) && grow(*report); rval = shrink(*report) && move(*report) && grow(*report);
if (rval) { if (rval) {
if (partition().isMounted()) // FIXME: add support for checkOnline for file systems that support it. if (CheckOperation::canCheck(&partition())) {
rval = true;
else
rval = checkResizedJob()->run(*report); rval = checkResizedJob()->run(*report);
if (!rval)
if (!rval) report->line() << xi18nc("@info:status", "Checking partition <filename>%1</filename> after resize/move failed.", partition().deviceNode());
report->line() << xi18nc("@info:status", "Checking partition <filename>%1</filename> after resize/move failed.", partition().deviceNode()); }
} else } else
report->line() << xi18nc("@info:status", "Resizing/moving partition <filename>%1</filename> failed.", partition().deviceNode()); report->line() << xi18nc("@info:status", "Resizing/moving partition <filename>%1</filename> failed.", partition().deviceNode());
} }