Disallow resizing of LVM2 PVs which are members of exported VGs (#670171)
When an inactive LVM2 Volume Group is exported it makes it unknown to the local system, ready for moving the member Physical Volumes to another system, where the VG can be imported and used. In this state a PV can't be resized. # lvm pvresize /dev/sda10 Volume group Test-VG1 is exported Unable to read volume group "Test-VG1". 0 physical volume(s) resized / 1 physical volume(s) not resized # echo $? 5 Fix this by preventing resizing of such a PV. This has been coded in a generic way using new function filesystem_resize_disallowed() to determine whether a file system is allowed to be resized or not. For a file system which can be resized, but is currently not allowed to be resized, the behaviour is as follows: 1) Pasting into unallocated space is limited to creating a new partition which is the same size as the copied partition. 2) Resizing the partition is disallowed, only moving the partition is allowed. 3) Pasting into an existing partition will only copy the file system. If the destination partition is larger a warning will report that growing the file system is not currently allowed. 4) Checking a partition will also report a warning that growing the file system is not currently allowed. This is exactly the same behaviour as for a file system which does not implement resizing, except for a different warning message. Bug #670171 - Add LVM PV read-write support
This commit is contained in:
parent
96c9fc129c
commit
ee49891611
|
@ -62,6 +62,7 @@ public:
|
|||
Glib::ustring get_thread_status_message() ;
|
||||
|
||||
FileSystem * get_filesystem_object( const FILESYSTEM & filesystem ) ;
|
||||
static bool filesystem_resize_disallowed( const Partition & partition ) ;
|
||||
private:
|
||||
//detectionstuff..
|
||||
void init_maps() ;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "../include/Dialog_Partition_Copy.h"
|
||||
#include "../include/GParted_Core.h"
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
@ -60,7 +61,9 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
frame_resizer_base ->set_used(
|
||||
Utils::round( Utils::sector_to_unit( min_resize, copied_partition .sector_size, UNIT_MIB ) / (TOTAL_MB/500.00) ) ) ;
|
||||
|
||||
if ( fs .grow )
|
||||
//Only allow pasting into a new larger partition if growing the file
|
||||
// system is implemented and resizing it is currently allowed.
|
||||
if ( fs .grow && ! GParted_Core::filesystem_resize_disallowed( copied_partition ) )
|
||||
if ( ! fs .MAX || fs .MAX > ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) )
|
||||
fs .MAX = ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) ;
|
||||
else
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "../include/Dialog_Partition_Resize_Move.h"
|
||||
#include "../include/GParted_Core.h"
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
@ -68,6 +69,14 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
|||
selected_partition .filesystem != FS_LINUX_SWAP )
|
||||
fs .shrink = GParted::FS::NONE ;
|
||||
|
||||
//Disable resizing as it's currently disallowed for the file system in this partition.
|
||||
// (Updates this class's copy of file system support information).
|
||||
if ( GParted_Core::filesystem_resize_disallowed( selected_partition ) )
|
||||
{
|
||||
fs .shrink = FS::NONE ;
|
||||
fs .grow = FS::NONE ;
|
||||
}
|
||||
|
||||
//see if we need a fixed_start
|
||||
if ( fs .move )
|
||||
{
|
||||
|
|
|
@ -2484,7 +2484,16 @@ bool GParted_Core::maximize_filesystem( const Partition & partition, OperationDe
|
|||
operationdetail .get_last_child() .set_status( STATUS_N_A ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
else if ( filesystem_resize_disallowed( partition ) )
|
||||
{
|
||||
|
||||
operationdetail .get_last_child() .add_child(
|
||||
OperationDetail( _("growing the file system is currently disallowed"),
|
||||
STATUS_NONE, FONT_ITALIC ) ) ;
|
||||
operationdetail .get_last_child() .set_status( STATUS_N_A ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
return resize_filesystem( partition, partition, operationdetail, true ) ;
|
||||
}
|
||||
|
||||
|
@ -3214,6 +3223,20 @@ FileSystem * GParted_Core::get_filesystem_object( const FILESYSTEM & filesystem
|
|||
return NULL ;
|
||||
}
|
||||
|
||||
bool GParted_Core::filesystem_resize_disallowed( const Partition & partition )
|
||||
{
|
||||
if ( partition .filesystem == FS_LVM2_PV )
|
||||
{
|
||||
//The LVM2 PV can't be resized when it's a member of an export VG
|
||||
LVM2_PV_Info lvm2_pv_info ;
|
||||
Glib::ustring vgname = lvm2_pv_info .get_vg_name( partition .get_path() ) ;
|
||||
if ( vgname .empty() )
|
||||
return false ;
|
||||
return lvm2_pv_info .is_vg_exported( vgname ) ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
#ifndef HAVE_LIBPARTED_3_0_0_PLUS
|
||||
bool GParted_Core::erase_filesystem_signatures( const Partition & partition )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue