Don't ignore any errors resizing btrfs on Linux >= 3.2 (#669389)

Btrfs file system can be successfully resized to the same size without
failing on Linux 3.2 or higher.

Linux 3.2-rc4 includes commit:
    35bae54a255fbf3eab747b842d300d59f6e1abb4
    Btrfs: Don't error on resizing FS to same size

Closes bug #669389
This commit is contained in:
Mike Fleetwood 2012-02-05 09:08:05 +00:00 committed by Curtis Gedak
parent 5967966ff7
commit 11d044dba0
1 changed files with 26 additions and 16 deletions

View File

@ -23,6 +23,7 @@ namespace GParted
{
bool btrfs_found = false ;
bool resize_to_same_size_fails = true ;
FS btrfs::get_filesystem_support()
{
@ -97,6 +98,10 @@ FS btrfs::get_filesystem_support()
fs .MIN = 256 * MEBIBYTE ;
//Linux before version 3.2 fails when resizing btrfs file system
// to the same size.
resize_to_same_size_fails = ! Utils::kernel_version_at_least( 3, 2, 0 ) ;
return fs ;
}
@ -206,22 +211,27 @@ bool btrfs::resize( const Partition & partition_new, OperationDetail & operation
else
cmd = "btrfsctl -r " + size + " " + mount_point ;
exit_status = execute_command_timed( cmd, operationdetail, false ) ;
//Resizing a btrfs file system to the same size results
// in ioctl() returning -1 EINVAL (Invalid argument)
// from the kernel btrfs code.
// * Btrfs filesystem resize reports this as exit
// status 30:
// ERROR: Unable to resize '/MOUNTPOINT'
// * Btrfsctl -r reports this as exit status 1:
// ioctl:: Invalid argument
// WARNING:
// Ignoring these errors could mask real failures, but
// not ignoring them will cause resizing to the same
// size as part of check operation to fail.
bool resize_succeeded = ( exit_status == 0
|| ( btrfs_found && exit_status == 30<<8 )
|| ( ! btrfs_found && exit_status == 1<<8 )
) ;
bool resize_succeeded = ( exit_status == 0 ) ;
if ( resize_to_same_size_fails )
{
//Linux before version 3.2 fails when resizing a
// btrfs file system to the same size with ioctl()
// returning -1 EINVAL (Invalid argument) from the
// kernel btrfs code.
// * Btrfs filesystem resize reports this as exit
// status 30:
// ERROR: Unable to resize '/MOUNTPOINT'
// * Btrfsctl -r reports this as exit status 1:
// ioctl:: Invalid argument
// WARNING:
// Ignoring these errors could mask real failures,
// but not ignoring them will cause resizing to the
// same size as part of check operation to fail.
resize_succeeded = ( exit_status == 0
|| ( btrfs_found && exit_status == 30<<8 )
|| ( ! btrfs_found && exit_status == 1<<8 )
) ;
}
operationdetail .get_last_child() .set_status( resize_succeeded ? STATUS_SUCCES : STATUS_ERROR ) ;
success &= resize_succeeded ;