]> sourceware.org Git - lvm2.git/commitdiff
udev: add a warning message if DM_DISABLE_UDEV set and udev running
authorPeter Rajnoha <prajnoha@redhat.com>
Thu, 29 Nov 2012 14:50:52 +0000 (15:50 +0100)
committerPeter Rajnoha <prajnoha@redhat.com>
Thu, 29 Nov 2012 14:57:43 +0000 (15:57 +0100)
$ export DM_DISABLE_UDEV=1

$ dmsetup create test --table "0 1 zero"
Udev is running and DM_DISABLE_UDEV environment variable is set. Bypassing udev, device-mapper library will manage device nodes in device directory.

$ lvchange -ay vg/lvol0
  Udev is running and DM_DISABLE_UDEV environment variable is set. Bypassing udev, LVM will manage logical volume symlinks in device directory.
  Udev is running and DM_DISABLE_UDEV environment variable is set. Bypassing udev, LVM will obtain device list by scanning device directory.
  Udev is running and DM_DISABLE_UDEV environment variable is set. Bypassing udev, device-mapper library will manage device nodes in device directory.

lib/commands/toolcontext.c
libdm/libdm-common.c

index 57ce1fe4b6a78b4ed20d467e7493a329009a946b..14152b7604e4028a524a52af9fa4166b882f670c 100644 (file)
@@ -211,6 +211,21 @@ static void _init_logging(struct cmd_context *cmd)
        reset_lvm_errno(1);
 }
 
+static int _check_disable_udev(const char *msg) {
+       if (getenv("DM_DISABLE_UDEV")) {
+               log_very_verbose("DM_DISABLE_UDEV environment variable set. "
+                                "Overriding configuration to use "
+                                "udev_rules=0, udev_sync=0, verify_udev_operations=1.");
+               if (udev_is_running())
+                       log_warn("Udev is running and DM_DISABLE_UDEV environment variable is set. "
+                                "Bypassing udev, LVM will %s.", msg);
+
+               return 1;
+       }
+
+       return 0;
+}
+
 #ifdef UDEV_SYNC_SUPPORT
 /*
  * Until the DM_UEVENT_GENERATED_FLAG was introduced in kernel patch 
@@ -318,12 +333,7 @@ static int _process_config(struct cmd_context *cmd)
         *   - udev_sync = 0
         *   - udev_fallback = 1
         */
-       if (getenv("DM_DISABLE_UDEV")) {
-               log_very_verbose("DM_DISABLE_UDEV environment variable set. "
-                                "Overriding configuration to use "
-                                "udev_rules=0, udev_sync=0, verify_udev_operations=1.");
-               udev_disabled = 1;
-       }
+       udev_disabled = _check_disable_udev("manage logical volume symlinks in device directory");
 
        cmd->default_settings.udev_rules = udev_disabled ? 0 :
                find_config_tree_int(cmd, "activation/udev_rules", DEFAULT_UDEV_RULES);
@@ -709,12 +719,9 @@ static int _init_dev_cache(struct cmd_context *cmd)
         *   - udev is not running
         *   - udev is disabled using DM_DISABLE_UDEV environment variable
         */
-       if (getenv("DM_DISABLE_UDEV")) {
-               log_very_verbose("DM_DISABLE_UDEV environment variable set. "
-                                "Overriding configuration to use "
-                                "device_list_from_udev=0");
+       if (_check_disable_udev("obtain device list by scanning device directory"))
                device_list_from_udev = 0;
-       else
+       else
                device_list_from_udev = udev_is_running() ?
                        find_config_tree_bool(cmd, "devices/obtain_device_list_from_udev",
                                              DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV) : 0;
index 527124fbe58381d72e5cf39af152ea5e1985ff5e..075fba8354179e2124faaaf67d213470f58771cb 100644 (file)
@@ -1933,8 +1933,13 @@ static void _check_udev_sync_requirements_once(void)
        if (_semaphore_supported < 0)
                _semaphore_supported = _check_semaphore_is_supported();
 
-       if (_udev_running < 0)
+       if (_udev_running < 0) {
                _udev_running = _check_udev_is_running();
+               if (_udev_disabled && _udev_running)
+                       log_warn("Udev is running and DM_DISABLE_UDEV environment variable is set. "
+                                "Bypassing udev, device-mapper library will manage device "
+                                "nodes in device directory.");
+       }
 }
 
 void dm_udev_set_sync_support(int sync_with_udev)
@@ -1945,13 +1950,10 @@ void dm_udev_set_sync_support(int sync_with_udev)
 
 int dm_udev_get_sync_support(void)
 {
-       if (_udev_disabled)
-               return 0;
-
        _check_udev_sync_requirements_once();
 
-       return _semaphore_supported && dm_cookie_supported() &&
-               _udev_running && _sync_with_udev;
+       return !_udev_disabled && _semaphore_supported &&
+               dm_cookie_supported() &&_udev_running && _sync_with_udev;
 }
 
 void dm_udev_set_checking(int checking)
This page took 0.047658 seconds and 5 git commands to generate.