]> sourceware.org Git - lvm2.git/commitdiff
Add new --sysinit option for vgchange and lvchange.
authorPeter Rajnoha <prajnoha@redhat.com>
Thu, 6 May 2010 11:15:55 +0000 (11:15 +0000)
committerPeter Rajnoha <prajnoha@redhat.com>
Thu, 6 May 2010 11:15:55 +0000 (11:15 +0000)
A shortcut for --ignorelockingfailure, --ignoremonitoring, --poll n options
and LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES environment variable used all at
once in initialisation scripts (e.g. rc.sysinit or initrd).

12 files changed:
WHATS_NEW
lib/locking/locking.c
lib/locking/locking.h
liblvm/lvm_base.c
man/lvchange.8.in
man/vgchange.8.in
tools/args.h
tools/commands.h
tools/lvchange.c
tools/lvmcmdline.c
tools/toollib.c
tools/vgchange.c

index 5009ee3bb97984a1e5e7188912dd332463bd1cf4..48725f3d881d5f98a577713de3f3683fb8a61080 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.65 - 
 =================================
+  Add new --sysinit option for vgchange and lvchange.
   Suppress duplicate error messages about read failures and missing devices.
   Install plugins to $(libdir)/device-mapper and $(libdir)/lvm2.
   Add dm_list_splice() function to join two lists together.
index a24b4c63016a8f8a8e5221f56d8e7db9a61df856..c663c28536389dbc3a29847a79c38419a7d7e2f3 100644 (file)
@@ -217,10 +217,8 @@ static void _update_vg_lock_count(const char *resource, uint32_t flags)
  * Select a locking type
  * type: locking type; if < 0, then read config tree value
  */
-int init_locking(int type, struct cmd_context *cmd)
+int init_locking(int type, struct cmd_context *cmd, int suppress_messages)
 {
-       int suppress_messages = 0;
-
        if (ignorelockingfailure() && getenv("LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES"))
                suppress_messages = 1;
 
index e7f25b900afae8e5309bd5917bfd80a9df6c084d..7a787accf71ba54f78751cc44e7602bb5f414edc 100644 (file)
@@ -19,7 +19,7 @@
 #include "uuid.h"
 #include "config.h"
 
-int init_locking(int type, struct cmd_context *cmd);
+int init_locking(int type, struct cmd_context *cmd, int suppress_messages);
 void fin_locking(void);
 void reset_locking(void);
 int vg_write_lock_held(void);
index 733d4d54da774d01228cf476ab4dc1189400923e..1b2ed9fc0283f56b4cf09d8788aeea73a96af8ce 100644 (file)
@@ -50,7 +50,7 @@ lvm_t lvm_init(const char *system_dir)
 
        /* FIXME: locking_type config option needed? */
        /* initialize locking */
-       if (!init_locking(-1, cmd)) {
+       if (!init_locking(-1, cmd, 0)) {
                /* FIXME: use EAGAIN as error code here */
                lvm_quit((lvm_t) cmd);
                return NULL;
index c3cb3b289e4d70892d61a313f1d451db4482263f..e269802970469c7e82d0cab96e0dfce7168e7a66 100644 (file)
@@ -13,6 +13,7 @@ lvchange \- change attributes of a logical volume
 [\-\-ignoremonitoring]
 [\-\-monitor {y|n}]
 [\-\-poll {y|n}]
+[\-\-sysinit]
 [\-\-noudevsync]
 [\-M|\-\-persistent y|n] [\-\-minor minor]
 [\-P|\-\-partial]
@@ -71,6 +72,15 @@ process from its last checkpoint.  However, it may not be appropriate to
 immediately poll a logical volume when it is activated, use \fB--poll
 n\fP to defer and then \fB--poll y\fP to restart the process.
 .TP
+.I \-\-sysinit
+Indicates that lvchange(8) is being invoked from early system initialisation
+scripts (e.g. rc.sysinit or an initrd), before writeable filesystems are
+available. As such, some functionality needs to be disabled and this option
+acts as a shortcut which selects an appropriate set of options. Currently
+this is equivalent to using  \fB--ignorelockingfailure\fP, \fB--ignoremonitoring\fP,
+\fB--poll n\fP and setting \fBLVM_SUPPRESS_LOCKING_FAILURE_MESSAGES\fP
+environment variable.
+.TP
 .I \-\-noudevsync
 Disable udev synchronisation. The
 process will not wait for notification from udev.
index 10d6afc9e2afc68766b1b69e460c1afce9716ef0..2fc0f8b3b66f76642ad52e61895085d2a69dd5fc 100644 (file)
@@ -19,6 +19,7 @@ vgchange \- change attributes of a volume group
 .RB [ \-h | \-\-help]
 .RB [ \-\-ignorelockingfailure]
 .RB [ \-\-ignoremonitoring]
+.RB [ \-\-sysinit]
 .RB [ \-\-noudevsync ]
 .RB [ \-l | \-\-logicalvolume
 .IR MaxLogicalVolumes ]
@@ -96,6 +97,15 @@ process from its last checkpoint.  However, it may not be appropriate to
 immediately poll a logical volume when it is activated, use \fB--poll
 n\fP to defer and then \fB--poll y\fP to restart the process.
 .TP
+.BR \-\-sysinit
+Indicates that vgchange(8) is being invoked from early system initialisation
+scripts (e.g. rc.sysinit or an initrd), before writeable filesystems are
+available. As such, some functionality needs to be disabled and this option
+acts as a shortcut which selects an appropriate set of options. Currently
+this is equivalent to using  \fB--ignorelockingfailure\fP, \fB--ignoremonitoring\fP,
+\fB--poll n\fP and setting \fBLVM_SUPPRESS_LOCKING_FAILURE_MESSAGES\fP
+environment variable.
+.TP
 .BR \-\-noudevsync
 Disable udev synchronisation. The
 process will not wait for notification from udev.
index 88d0d059624c7944e4aabc3332a63b9fa50a6f09..76146eef05bb4b2d8b61d322d5bb746b9d62cbf0 100644 (file)
@@ -66,6 +66,7 @@ arg(virtualsize_ARG, '\0', "virtualsize", size_mb_arg, 0)
 arg(noudevsync_ARG, '\0', "noudevsync", NULL, 0)
 arg(poll_ARG, '\0', "poll", yes_no_arg, 0)
 arg(stripes_long_ARG, '\0', "stripes", int_arg, 0)
+arg(sysinit_ARG, '\0', "sysinit", NULL, 0)
 
 /* Allow some variations */
 arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
index 7d0185b9e00f713c470ba3d66b5d6e7a11b146e2..e33cadcb917f474ea76d12346818c783d77c939e 100644 (file)
@@ -80,6 +80,7 @@ xx(lvchange,
    "\t[-r|--readahead ReadAheadSectors|auto|none]\n"
    "\t[--refresh]\n"
    "\t[--resync]\n"
+   "\t[--sysinit]\n"
    "\t[-t|--test]\n"
    "\t[-v|--verbose]\n"
    "\t[-y|--yes]\n"
@@ -90,7 +91,7 @@ xx(lvchange,
    ignorelockingfailure_ARG, ignoremonitoring_ARG, major_ARG, minor_ARG,
    monitor_ARG, noudevsync_ARG, partial_ARG, permission_ARG, persistent_ARG,
    poll_ARG, readahead_ARG, resync_ARG, refresh_ARG, addtag_ARG, deltag_ARG,
-   test_ARG, yes_ARG)
+   sysinit_ARG, test_ARG, yes_ARG)
 
 xx(lvconvert,
    "Change logical volume layout",
@@ -711,6 +712,7 @@ xx(vgchange,
    "\t[--poll {y|n}]\n"
    "\t[--noudevsync]\n"
    "\t[--refresh]\n"
+   "\t[--sysinit]\n"
    "\t[-t|--test]" "\n"
    "\t[-u|--uuid] " "\n"
    "\t[-v|--verbose] " "\n"
@@ -729,7 +731,7 @@ xx(vgchange,
    clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG,
    logicalvolume_ARG, maxphysicalvolumes_ARG, monitor_ARG, noudevsync_ARG,
    partial_ARG, physicalextentsize_ARG, poll_ARG, refresh_ARG, resizeable_ARG,
-   resizable_ARG, test_ARG, uuid_ARG)
+   resizable_ARG, sysinit_ARG, test_ARG, uuid_ARG)
 
 xx(vgck,
    "Check the consistency of volume group(s)",
index 9929740634e5ad695fefc43c3abbd3b4b0fcb5c7..1376bf4cf8683a41cac6b9038aa287e7ef215bc7 100644 (file)
@@ -586,9 +586,12 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
         * should only be started if the LV is not already active. So:
         * 1) change the activation code to say if the LV was actually activated
         * 2) make polling of an LV tightly coupled with LV activation
+        *
+        * Do not initiate any polling if --sysinit option is used.
         */
-       init_background_polling(arg_int_value(cmd, poll_ARG,
-                                             DEFAULT_BACKGROUND_POLLING));
+       init_background_polling(arg_count(cmd, sysinit_ARG) ? 0 :
+                                               arg_int_value(cmd, poll_ARG,
+                                               DEFAULT_BACKGROUND_POLLING));
 
        /* access permission change */
        if (arg_count(cmd, permission_ARG)) {
@@ -730,8 +733,9 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
             arg_count(cmd, addtag_ARG) || arg_count(cmd, deltag_ARG) ||
             arg_count(cmd, resync_ARG) || arg_count(cmd, alloc_ARG));
 
-       if (arg_count(cmd, ignorelockingfailure_ARG) && !avail_only) {
-               log_error("Only -a permitted with --ignorelockingfailure");
+       if ((arg_count(cmd, ignorelockingfailure_ARG) ||
+            arg_count(cmd, sysinit_ARG)) && !avail_only) {
+               log_error("Only -a permitted with --ignorelockingfailure and --sysinit");
                return EINVALID_CMD_LINE;
        }
 
@@ -759,6 +763,11 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
                return EINVALID_CMD_LINE;
        }
 
+       if (arg_count(cmd, poll_ARG) && arg_count(cmd, sysinit_ARG)) {
+               log_error("Only one of --poll and --sysinit permitted");
+               return EINVALID_CMD_LINE;
+       }
+
        return process_each_lv(cmd, argc, argv,
                               avail_only ? 0 : READ_FOR_UPDATE, NULL,
                               &lvchange_single);
index 22a5eef94b326f1b3ce0c85f7edcd64ff48460aa..6a5479d6c389b36672e98f3f05edd12e5703d9c3 100644 (file)
@@ -793,7 +793,7 @@ static int _get_settings(struct cmd_context *cmd)
                          "be activated read-only.");
        }
 
-       if (arg_count(cmd, ignorelockingfailure_ARG))
+       if (arg_count(cmd, ignorelockingfailure_ARG) || arg_count(cmd, sysinit_ARG))
                init_ignorelockingfailure(1);
        else
                init_ignorelockingfailure(0);
@@ -1049,7 +1049,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
        else
                locking_type = -1;
 
-       if (!init_locking(locking_type, cmd)) {
+       if (!init_locking(locking_type, cmd, arg_count(cmd, sysinit_ARG))) {
                ret = ECMD_FAILED;
                goto out;
        }
index 393c5291294b166166d1372a3f002ff310f2be47..735f3b07ed9c3e2ea7de2d2fb1e5273a3f8bf3fe 100644 (file)
@@ -1372,8 +1372,9 @@ int get_activation_monitoring_mode(struct cmd_context *cmd,
        *monitoring_mode = DEFAULT_DMEVENTD_MONITOR;
 
        if (arg_count(cmd, monitor_ARG) &&
-           arg_count(cmd, ignoremonitoring_ARG)) {
-               log_error("Conflicting monitor and ignoremonitoring options");
+           (arg_count(cmd, ignoremonitoring_ARG) ||
+            arg_count(cmd, sysinit_ARG))) {
+               log_error("--ignoremonitoring or --sysinit option not allowed with --monitor option");
                return 0;
        }
 
@@ -1381,6 +1382,7 @@ int get_activation_monitoring_mode(struct cmd_context *cmd,
                *monitoring_mode = arg_int_value(cmd, monitor_ARG,
                                                 DEFAULT_DMEVENTD_MONITOR);
        else if (is_static() || arg_count(cmd, ignoremonitoring_ARG) ||
+                arg_count(cmd, sysinit_ARG) ||
                 !find_config_tree_bool(cmd, "activation/monitoring",
                                        DEFAULT_DMEVENTD_MONITOR))
                *monitoring_mode = DMEVENTD_MONITOR_IGNORE;
index 81c95d1320446c72988f2195d0cd410f93876b7b..a25a373cec6979e3eb6267a3b071b78a0dffeab8 100644 (file)
@@ -540,9 +540,12 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
         * should only be started if the LV is not already active. So:
         * 1) change the activation code to say if the LV was actually activated
         * 2) make polling of an LV tightly coupled with LV activation
+        *
+        * Do not initiate any polling if --sysinit option is used.
         */
-       init_background_polling(arg_int_value(cmd, poll_ARG,
-                                             DEFAULT_BACKGROUND_POLLING));
+       init_background_polling(arg_count(cmd, sysinit_ARG) ? 0 :
+                                               arg_int_value(cmd, poll_ARG,
+                                               DEFAULT_BACKGROUND_POLLING));
 
        if (arg_count(cmd, available_ARG))
                r = _vgchange_available(cmd, vg);
@@ -615,9 +618,14 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
                return EINVALID_CMD_LINE;
        }
 
-       if (arg_count(cmd, ignorelockingfailure_ARG) &&
-           !arg_count(cmd, available_ARG)) {
-               log_error("--ignorelockingfailure only available with -a");
+       if ((arg_count(cmd, ignorelockingfailure_ARG) ||
+            arg_count(cmd, sysinit_ARG)) && !arg_count(cmd, available_ARG)) {
+               log_error("Only -a premitted with --ignorelockingfailure and --sysinit");
+               return EINVALID_CMD_LINE;
+       }
+
+       if (arg_count(cmd, poll_ARG) && arg_count(cmd, sysinit_ARG)) {
+               log_error("Only one of --poll and --sysinit permitted.");
                return EINVALID_CMD_LINE;
        }
 
This page took 0.060001 seconds and 5 git commands to generate.