[gparted] Disallow resizing of LVM2 PVs which are members of exported VGs (#670171)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Disallow resizing of LVM2 PVs which are members of exported VGs (#670171)
- Date: Sat, 1 Sep 2012 17:05:03 +0000 (UTC)
commit ee49891611c9633a6e3c63b9e202b1c20a779b78
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sat Aug 25 20:49:10 2012 +0100
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
include/GParted_Core.h | 1 +
src/Dialog_Partition_Copy.cc | 5 ++++-
src/Dialog_Partition_Resize_Move.cc | 9 +++++++++
src/GParted_Core.cc | 25 ++++++++++++++++++++++++-
4 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 968bdf6..052773b 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -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() ;
diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc
index d46267e..1da5fae 100644
--- a/src/Dialog_Partition_Copy.cc
+++ b/src/Dialog_Partition_Copy.cc
@@ -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
diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc
index b88c53e..0ba677f 100644
--- a/src/Dialog_Partition_Resize_Move.cc
+++ b/src/Dialog_Partition_Resize_Move.cc
@@ -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 )
{
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index a3d0bb9..f076efd 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -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 )
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]