]> sourceware.org Git - lvm2.git/commitdiff
Add LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES environment variable to suppress error
authorPeter Rajnoha <prajnoha@redhat.com>
Mon, 15 Feb 2010 16:46:56 +0000 (16:46 +0000)
committerPeter Rajnoha <prajnoha@redhat.com>
Mon, 15 Feb 2010 16:46:56 +0000 (16:46 +0000)
and warning mesages while --ignorelockingfailure is used.

WHATS_NEW
lib/locking/locking.c
lib/log/log.h

index 65a937f7666440a7a3fb3fc15f6553ac29f2a1e5..d6b2821f39688f235e22d17811bb954922bb028e 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.61 - 
 ===================================
+  Add LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES env. var. to suppress error and warning mesages.
   Remove hard-coded rule to skip _mimage devices in 11-dm-lvm.rules.
   Use udev transactions in testsuite.
   Don't use LVM_UDEV_DISABLE_CHECKING env. var. anymore and set the state automatically.
index 54e5e25ae5112d909a8d3acbce895d96b67af82c..a636f7c76abb0c1cfcdcd90fe0f549f883c5587d 100644 (file)
@@ -219,6 +219,11 @@ static void _update_vg_lock_count(const char *resource, uint32_t flags)
  */
 int init_locking(int type, struct cmd_context *cmd)
 {
+       int suppress_messages = 0;
+
+       if (ignorelockingfailure() && getenv("LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES"))
+               suppress_messages = 1;
+
        if (type < 0)
                type = find_config_tree_int(cmd, "global/locking_type", 1);
 
@@ -237,7 +242,8 @@ int init_locking(int type, struct cmd_context *cmd)
                                 _blocking_supported ? "" : "Non-blocking ");
 
                if (!init_file_locking(&_locking, cmd)) {
-                       log_error("File-based locking initialisation failed.");
+                       log_error_suppress(suppress_messages,
+                                          "File-based locking initialisation failed.");
                        break;
                }
                return 1;
@@ -264,7 +270,8 @@ int init_locking(int type, struct cmd_context *cmd)
        case 3:
                log_very_verbose("Cluster locking selected.");
                if (!init_cluster_locking(&_locking, cmd)) {
-                       log_error("Internal cluster locking initialisation failed.");
+                       log_error_suppress(suppress_messages,
+                                          "Internal cluster locking initialisation failed.");
                        break;
                }
                return 1;
@@ -286,13 +293,16 @@ int init_locking(int type, struct cmd_context *cmd)
            find_config_tree_int(cmd, "locking/fallback_to_local_locking",
                    find_config_tree_int(cmd, "global/fallback_to_local_locking",
                                         DEFAULT_FALLBACK_TO_LOCAL_LOCKING))) {
-               log_warn("WARNING: Falling back to local file-based locking.");
-               log_warn("Volume Groups with the clustered attribute will "
-                         "be inaccessible.");
+               log_warn_suppress(suppress_messages,
+                                 "WARNING: Falling back to local file-based locking.");
+               log_warn_suppress(suppress_messages,
+                                 "Volume Groups with the clustered attribute will "
+                                 "be inaccessible.");
                if (init_file_locking(&_locking, cmd))
                        return 1;
                else
-                       log_error("File-based locking initialisation failed.");
+                       log_error_suppress(suppress_messages,
+                                          "File-based locking initialisation failed.");
        }
 
        if (!ignorelockingfailure())
index 079a010696f98dedb0151a5291bb4a42acd1d1fb..4c3b476c2ad7023586631ead18d8e9804c2e55c6 100644 (file)
@@ -59,7 +59,9 @@
 #define log_info(x...) LOG_LINE(_LOG_INFO, x)
 #define log_notice(x...) LOG_LINE(_LOG_NOTICE, x)
 #define log_warn(x...) LOG_LINE(_LOG_WARN | _LOG_STDERR, x)
+#define log_warn_suppress(s, x...) LOG_LINE(s ? _LOG_NOTICE : _LOG_WARN | _LOG_STDERR, x)
 #define log_err(x...) LOG_LINE_WITH_ERRNO(_LOG_ERR, EUNCLASSIFIED, x)
+#define log_err_suppress(s, x...) LOG_LINE_WITH_ERRNO(s ? _LOG_NOTICE : _LOG_ERR, EUNCLASSIFIED, x)
 #define log_fatal(x...) LOG_LINE_WITH_ERRNO(_LOG_FATAL, EUNCLASSIFIED, x)
 
 #define stack log_debug("<backtrace>") /* Backtrace on error */
@@ -67,6 +69,7 @@
 #define log_verbose(args...) log_notice(args)
 #define log_print(args...) LOG_LINE(_LOG_WARN, args)
 #define log_error(args...) log_err(args)
+#define log_error_suppress(s, args...) log_err_suppress(s, args)
 #define log_errno(args...) LOG_LINE_WITH_ERRNO(_LOG_ERR, args)
 
 /* System call equivalents */
This page took 0.042673 seconds and 5 git commands to generate.