[gparted] Avoid redundant file system maximize actions (#663980)



commit e8bdb5d7045f71fc19ba8e4651906cdd47ac6774
Author: Curtis Gedak <gedakc gmail com>
Date:   Sun Nov 13 11:24:07 2011 -0700

    Avoid redundant file system maximize actions (#663980)
    
    When GParted performed operations or combinations of operations,
    such as:
      a)  copy to same or smaller size destination partition
      b)  move to same or smaller size due to alignment change
      c)  resize to smaller size
    a redundant maximize file system operation would occur.
    
    Normally these redundant maximize operations to grow the file
    system to take up all the space in the partition were not harmful.
    
    However in situations where libparted failed to inform the kernel
    of partition changes, then the extra maximize operation would
    grow the file system to be the original partition size.  In cases
    where the original partition was larger than the new partition
    size, this caused problems because the file system would be
    larger than the partition on reboot.
    
    This enhancement avoids redundant file system maximize actions on
    copy, move, and resize, and should help reduce problems described
    in the following links:
    
    WARNING! Problem Resizing File Systems with GParted
    http://gparted-forum.surf4.info/viewtopic.php?id=13777
    
    Bug #601574 - ERROR: Current NTFS volume size is bigger than the
                  device size!
    
    Bug #604298 - Problems resizing file systems with
                  gparted-live-0.5.0-3
    
    Closes Bug #663980 - Avoid redundant file system maximize actions
                         on copy, move, and resize

 src/GParted_Core.cc |   41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 9f8ebf3..6414d7a 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1829,10 +1829,16 @@ bool GParted_Core::move( const Device & device,
 		//Make new partition from all encompassing partition
 		succes =  succes && resize_move_partition( partition_all_space, partition_new, operationdetail ) ;
 
-		succes = succes &&
-			update_bootsector( partition_new, operationdetail ) &&
-			check_repair_filesystem( partition_new, operationdetail ) &&
-			maximize_filesystem( partition_new, operationdetail ) ;
+		succes = (    succes
+		          && update_bootsector( partition_new, operationdetail )
+		          && (   //Do not maximize file system if new size <= old
+		                 ( partition_new .get_sector_length() <= partition_old .get_sector_length() )
+		              || (   check_repair_filesystem( partition_new, operationdetail )
+		                  && maximize_filesystem( partition_new, operationdetail )
+		                 )
+		             )
+		         );
+
 	}
 
 	return succes ;
@@ -1972,16 +1978,18 @@ bool GParted_Core::resize( const Partition & partition_old,
 
 		if ( succes && partition_new .get_sector_length() < partition_old .get_sector_length() )
 			succes = resize_filesystem( partition_old, partition_new, operationdetail ) ;
-						
+
 		if ( succes )
 			succes = resize_move_partition( partition_old, partition_new, operationdetail ) ;
-			
-		//these 2 are always executed, however, if 1 of them fails the whole operation fails
-		if ( ! check_repair_filesystem( partition_new, operationdetail ) )
-			succes = false ;
 
 		//expand file system to fit exactly in partition
-		if ( ! maximize_filesystem( partition_new, operationdetail ) )
+		if ( ! (   //Do not maximize file system if new size <= old
+		           ( partition_new .get_sector_length() <= partition_old .get_sector_length() )
+		        || (   check_repair_filesystem( partition_new, operationdetail )
+		            && maximize_filesystem( partition_new, operationdetail )
+		           )
+		       )
+		   )
 			succes = false ;
 			
 		return succes ;
@@ -2300,10 +2308,15 @@ bool GParted_Core::copy( const Partition & partition_src,
 
 			operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
 
-			return succes &&
-			       update_bootsector( partition_dst, operationdetail ) &&
-			       check_repair_filesystem( partition_dst, operationdetail ) &&
-			       maximize_filesystem( partition_dst, operationdetail ) ;
+			return (   succes
+			        && update_bootsector( partition_dst, operationdetail )
+			        && (   //Do not maximize file system if destination size <= source
+			               ( partition_dst .get_sector_length() <= partition_src .get_sector_length() )
+			            || (   check_repair_filesystem( partition_dst, operationdetail )
+			                && maximize_filesystem( partition_dst, operationdetail )
+			               )
+			           )
+			       );
 		}
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]