Fix free space handling when resizing LVM LVs.
BUG: 399772
This commit is contained in:
parent
5dc4986bc9
commit
3e31ec1431
|
@ -545,6 +545,11 @@ qint64 LvmDevice::freePE() const
|
|||
return d_ptr->m_freePE;
|
||||
}
|
||||
|
||||
void LvmDevice::setFreePE(qint64 freePE) const
|
||||
{
|
||||
d_ptr->m_freePE = freePE;
|
||||
}
|
||||
|
||||
QString LvmDevice::UUID() const
|
||||
{
|
||||
return d_ptr->m_UUID;
|
||||
|
|
|
@ -98,6 +98,7 @@ public:
|
|||
qint64 totalPE() const;
|
||||
qint64 allocatedPE() const;
|
||||
qint64 freePE() const;
|
||||
void setFreePE(qint64 freePE) const;
|
||||
QString UUID() const;
|
||||
QVector <const Partition*>& physicalVolumes();
|
||||
const QVector <const Partition*>& physicalVolumes() const;
|
||||
|
|
|
@ -67,7 +67,7 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6
|
|||
m_GrowSetGeomJob(nullptr),
|
||||
m_CheckResizedJob(nullptr)
|
||||
{
|
||||
if(CheckOperation::canCheck(&partition()))
|
||||
if (CheckOperation::canCheck(&partition()))
|
||||
addJob(checkOriginalJob());
|
||||
|
||||
if (partition().roles().has(PartitionRole::Extended)) {
|
||||
|
@ -121,6 +121,11 @@ bool ResizeOperation::targets(const Partition& p) const
|
|||
|
||||
void ResizeOperation::preview()
|
||||
{
|
||||
if (targetDevice().type() == Device::Type::LVM_Device) {
|
||||
const LvmDevice& lvm = static_cast<const LvmDevice&>(targetDevice());
|
||||
lvm.setFreePE(lvm.freePE() + partition().lastSector() - newLastSector());
|
||||
}
|
||||
|
||||
// If the operation has already been executed, the partition will of course have newFirstSector and
|
||||
// newLastSector as first and last sector. But to remove it from its original position, we need to
|
||||
// temporarily set these values back to where they were before the operation was executed.
|
||||
|
@ -139,6 +144,11 @@ void ResizeOperation::preview()
|
|||
|
||||
void ResizeOperation::undo()
|
||||
{
|
||||
if (targetDevice().type() == Device::Type::LVM_Device) {
|
||||
const LvmDevice& lvm = static_cast<const LvmDevice&>(targetDevice());
|
||||
lvm.setFreePE(lvm.freePE() - origLastSector() + partition().lastSector());
|
||||
}
|
||||
|
||||
removePreviewPartition(targetDevice(), partition());
|
||||
partition().setFirstSector(origFirstSector());
|
||||
partition().setLastSector(origLastSector());
|
||||
|
|
Loading…
Reference in New Issue