Fix free space handling with LVM LVs.
The previous commit worked for resizing LVM. However, it is better to do special handling of LVMs in insert/removePreviewPartition. BUG: 399772
This commit is contained in:
parent
9fa2d194ae
commit
b06af11357
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "core/partition.h"
|
#include "core/partition.h"
|
||||||
#include "core/device.h"
|
#include "core/device.h"
|
||||||
|
#include "core/lvmdevice.h"
|
||||||
|
|
||||||
#include "jobs/job.h"
|
#include "jobs/job.h"
|
||||||
|
|
||||||
|
@ -51,6 +52,10 @@ void Operation::insertPreviewPartition(Device& device, Partition& p)
|
||||||
device.partitionTable()->removeUnallocated();
|
device.partitionTable()->removeUnallocated();
|
||||||
|
|
||||||
p.parent()->insert(&p);
|
p.parent()->insert(&p);
|
||||||
|
if (device.type() == Device::Type::LVM_Device) {
|
||||||
|
const LvmDevice& lvm = static_cast<const LvmDevice&>(device);
|
||||||
|
lvm.setFreePE(lvm.freePE() - p.length());
|
||||||
|
}
|
||||||
|
|
||||||
device.partitionTable()->updateUnallocated(device);
|
device.partitionTable()->updateUnallocated(device);
|
||||||
}
|
}
|
||||||
|
@ -59,8 +64,14 @@ void Operation::removePreviewPartition(Device& device, Partition& p)
|
||||||
{
|
{
|
||||||
Q_ASSERT(device.partitionTable());
|
Q_ASSERT(device.partitionTable());
|
||||||
|
|
||||||
if (p.parent()->remove(&p))
|
if (p.parent()->remove(&p)) {
|
||||||
|
if (device.type() == Device::Type::LVM_Device) {
|
||||||
|
const LvmDevice& lvm = static_cast<const LvmDevice&>(device);
|
||||||
|
lvm.setFreePE(lvm.freePE() + p.length());
|
||||||
|
}
|
||||||
|
|
||||||
device.partitionTable()->updateUnallocated(device);
|
device.partitionTable()->updateUnallocated(device);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
qWarning() << "failed to remove partition " << p.deviceNode() << " at " << &p << " from preview.";
|
qWarning() << "failed to remove partition " << p.deviceNode() << " at " << &p << " from preview.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,11 +121,6 @@ bool ResizeOperation::targets(const Partition& p) const
|
||||||
|
|
||||||
void ResizeOperation::preview()
|
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
|
// 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
|
// 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.
|
// temporarily set these values back to where they were before the operation was executed.
|
||||||
|
@ -144,11 +139,6 @@ void ResizeOperation::preview()
|
||||||
|
|
||||||
void ResizeOperation::undo()
|
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());
|
removePreviewPartition(targetDevice(), partition());
|
||||||
partition().setFirstSector(origFirstSector());
|
partition().setFirstSector(origFirstSector());
|
||||||
partition().setLastSector(origLastSector());
|
partition().setLastSector(origLastSector());
|
||||||
|
|
Loading…
Reference in New Issue