Stop recreating linux-swap twice when shrinking a partition (#741211)
Shrinking swap partition operation performs these steps: Shrink /dev/sdb2 from 2.00 GiB to 1.00 GiB + calibrate /dev/sdb2 + check file system on /dev/sdb2 for errors and (if possible) fix them checking is not available for this file system + shrink file system + create new linux-swap file system + mkswap -L "test-swap" -U "bd381eba-5df7-42e2-8e0e-411e9701c995" /dev/sdb2 + shrink partition from 2.00 GiB to 1.00 GiB + create new linux-swap file system + mkswap -L "test-swap" -U "bd381eba-5df7-42e2-8e0e-411e9701c995" /dev/sdb2 Resizing a linux-swap partition was partially special cased in GParted_Core::resize(). Make it fully special cased so that it just does the following steps. No more skipped file system checks or extra resizing. 1) Resize partition, 2) Recreate linux-swap. This existing call chain recreates the linux-swap: GParted_Core::resize_filesystem() linux_swap::resize() A compound move and resize operation still performs unnecessary checks and recreates of linux-swap, but less than before. Bug 741211 - Remove unnecessary duplicate actions when resizing a partition
This commit is contained in:
parent
b4acb14ff1
commit
99f770ddb0
|
@ -2389,7 +2389,15 @@ bool GParted_Core::resize( const Partition & partition_old,
|
|||
}
|
||||
|
||||
bool succes = false ;
|
||||
if ( partition_new. busy || check_repair_filesystem( partition_new, operationdetail ) )
|
||||
if ( partition_new.filesystem == FS_LINUX_SWAP )
|
||||
{
|
||||
// linux-swap is recreated, not resize
|
||||
succes = resize_move_partition( partition_old, partition_new, operationdetail )
|
||||
&& resize_filesystem( partition_old, partition_new, operationdetail );
|
||||
|
||||
return succes;
|
||||
}
|
||||
else if ( partition_new.busy || check_repair_filesystem( partition_new, operationdetail ) )
|
||||
{
|
||||
succes = true ;
|
||||
|
||||
|
@ -2399,13 +2407,8 @@ bool GParted_Core::resize( const Partition & partition_old,
|
|||
if ( succes )
|
||||
succes = resize_move_partition( partition_old, partition_new, operationdetail ) ;
|
||||
|
||||
//expand file system to fit exactly in partition
|
||||
if ( succes
|
||||
&& ( //Maximize file system if linux-swap or new size > old
|
||||
partition_new .filesystem == FS_LINUX_SWAP //linux-swap is recreated, not resized
|
||||
|| partition_new .get_sector_length() > partition_old .get_sector_length()
|
||||
)
|
||||
)
|
||||
// Maximize file system if growing
|
||||
if ( succes && partition_new .get_sector_length() > partition_old .get_sector_length() )
|
||||
succes = maximize_filesystem( partition_new, operationdetail );
|
||||
|
||||
return succes ;
|
||||
|
|
Loading…
Reference in New Issue