Skip to contentSkip to conversation

Add partial mode option in lvm config file

RFC PATCH New Takahiro Yasui 1 participant 1 message Jan 23, 2009

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Add partial mode option in lvm config file

Hi,

I would like to introduce "partial_mode" option in lvm config file. I appreciate any comments on this.

* Introduction

This patch introduces a new configuration parameter, "partial_mode", in lvm configuration file (lvm.conf). This "partial_mode" affects some lvm commands, which already support --partial/-P, and sets them -P option by default.

I think that this partial mode is useful for not only trouble shooting but also usual operation in case of device failures. For example, lvm mirroring is used to make systems stable and keep high availability, and LVs in VGs should be activated even if one of their legs is broken. However, currently LVs are not activated without a partial option.

Root filesystems and other volumes using lvm have to be activated during system boot in order to make system continue to work. I think supporting "partial_mode" in config makes it easy, since we don't have to change mkinitrd and rc.sysinit script for this use.

In addition, a new command line parameter, "--nopartial", is added in order to override a configuration in a command line. This parameter is for users who want to disable partial_mode temporarily for checking LV strictly.

* Example

When "partial_mode" is set to 1, lvm commands work as if -P or --partial options are indicated in its command line.

  global {
    ...
    partial_mode = 1
  }

Thanks,
---
Takahiro Yasui
Hitachi Computer Products (America), Inc.

---
 doc/example.conf   |    6 ++++++
 tools/args.h       |    1 +
 tools/commands.h   |   50 +++++++++++++++++++++++++++++++++-----------------
 tools/lvmcmdline.c |   14 +++++++++++---
 4 files changed, 51 insertions(+), 20 deletions(-)
tools/lvmcmdline.c +11 -3
Index: LVM2.2.02.44-cvs-20090106/tools/lvmcmdline.c
===================================================================
@@ -778,13 +778,21 @@ static int _get_settings(struct cmd_cont
 	cmd->current_settings.archive = arg_int_value(cmd, autobackup_ARG, cmd->current_settings.archive);
 	cmd->current_settings.backup = arg_int_value(cmd, autobackup_ARG, cmd->current_settings.backup);
 	cmd->current_settings.cache_vgmetadata = cmd->command->flags & CACHE_VGMETADATA ? 1 : 0;
-	cmd->partial_activation = 0;
 
-	if (arg_count(cmd, partial_ARG)) {
+	cmd->partial_activation = find_config_tree_int(cmd, "global/partial_mode", 0);
+	if (arg_count(cmd, partial_ARG) && arg_count(cmd, nopartial_ARG)) {
+		log_print("--partial and --nopartial should be used exclusively.");
+		return EINVALID_CMD_LINE;
+	}
+
+	if (arg_count(cmd, partial_ARG))
 		cmd->partial_activation = 1;
+	else if (arg_count(cmd, nopartial_ARG))
+		cmd->partial_activation = 0;
+
+	if (cmd->partial_activation)
 		log_print("Partial mode. Incomplete volume groups will "
 			  "be activated read-only.");
-	}
 
 	if (arg_count(cmd, ignorelockingfailure_ARG))
 		init_ignorelockingfailure(1);
tools/args.h +1 -0
Index: LVM2.2.02.44-cvs-20090106/tools/args.h
===================================================================
@@ -56,6 +56,7 @@ arg(ignoremonitoring_ARG, '\0', "ignorem
 arg(nameprefixes_ARG, '\0', "nameprefixes", NULL, 0)
 arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
 arg(rows_ARG, '\0', "rows", NULL, 0)
+arg(nopartial_ARG, '\0', "nopartial", NULL, 0)
 
 /* Allow some variations */
 arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
doc/example.conf +6 -0
Index: LVM2.2.02.44-cvs-20090106/doc/example.conf
===================================================================
@@ -268,6 +268,12 @@ global {
 
     # The external locking library to load if locking_type is set to 2.
     #   locking_library = "liblvm2clusterlock.so"
+
+    # This option enables LVM commands to be executed in partial mode
+    # by default. If this option is not specified, or is set to "0",
+    # commands work in non-partial mode by default.
+    # The command line override is -P (--partial) or --nopartial
+    #   partial_mode = 1
 }
 
 activation {
tools/commands.h +33 -17

186 lines not on this page · raw message