[gparted] Stop recreating linux-swap twice when shrinking a partition (#741211)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Stop recreating linux-swap twice when shrinking a partition (#741211)
- Date: Sat, 13 Dec 2014 18:29:19 +0000 (UTC)
commit 99f770ddb0c14a3771a00499ccc30f2de76dc9a6
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sat Dec 6 23:48:35 2014 +0000
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
src/GParted_Core.cc | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index f357191..f1f9e69 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -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 ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]