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
This commit is contained in:
Curtis Gedak 2011-11-13 11:24:07 -07:00
parent 9309127876
commit e8bdb5d704
1 changed files with 27 additions and 14 deletions

View File

@ -1829,10 +1829,16 @@ bool GParted_Core::move( const Device & device,
//Make new partition from all encompassing partition //Make new partition from all encompassing partition
succes = succes && resize_move_partition( partition_all_space, partition_new, operationdetail ) ; succes = succes && resize_move_partition( partition_all_space, partition_new, operationdetail ) ;
succes = succes && succes = ( succes
update_bootsector( partition_new, operationdetail ) && && update_bootsector( partition_new, operationdetail )
check_repair_filesystem( partition_new, operationdetail ) && && ( //Do not maximize file system if new size <= old
maximize_filesystem( partition_new, operationdetail ) ; ( partition_new .get_sector_length() <= partition_old .get_sector_length() )
|| ( check_repair_filesystem( partition_new, operationdetail )
&& maximize_filesystem( partition_new, operationdetail )
)
)
);
} }
return succes ; return succes ;
@ -1976,12 +1982,14 @@ bool GParted_Core::resize( const Partition & partition_old,
if ( succes ) if ( succes )
succes = resize_move_partition( partition_old, partition_new, operationdetail ) ; 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 //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 ; succes = false ;
return succes ; 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 ) ; operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
return succes && return ( succes
update_bootsector( partition_dst, operationdetail ) && && update_bootsector( partition_dst, operationdetail )
check_repair_filesystem( partition_dst, operationdetail ) && && ( //Do not maximize file system if destination size <= source
maximize_filesystem( partition_dst, operationdetail ) ; ( partition_dst .get_sector_length() <= partition_src .get_sector_length() )
|| ( check_repair_filesystem( partition_dst, operationdetail )
&& maximize_filesystem( partition_dst, operationdetail )
)
)
);
} }
} }