]> sourceware.org Git - lvm2.git/commitdiff
device_id: make dmeventd use system.devices by default 1038717006
authorDavid Teigland <teigland@redhat.com>
Mon, 2 Oct 2023 22:15:44 +0000 (17:15 -0500)
committerDavid Teigland <teigland@redhat.com>
Mon, 16 Oct 2023 20:40:11 +0000 (15:40 -0500)
When no dmeventd.devices exists, make it use system.devices
rather than no devices file at all.

lib/device/dev-cache.c
man/lvmdevices.8_des

index 8a002317eb1d862fb706f577ccc2a1444a215d6c..9e11215f5f6b0522121b61a3483eeaa14882adef 100644 (file)
@@ -1777,39 +1777,38 @@ static int _setup_devices_list(struct cmd_context *cmd)
        return 1;
 }
 
+/*
+ * LVs that use dmeventd need to be accessible using system.devices.
+ *
+ * dmeventd will use dmeventd.devices if it exists, otherwise will use
+ * system.devices.  If a VG is covered by dmeventd.devices it should also
+ * be covered by system.devices.  The automated vgchange --monitor and
+ * vgchange -aay commands do not currently consider dmeventd.devices.
+ * dmeventd.devices can be useful to prevent commands run by dmeventd
+ * from reading VGs that do not need the service.
+ *
+ * dmeventd gets events for any applicable dm device in the kernel,
+ * and will attempt to run lvm commands for it.  These commands
+ * will only use dmeventd.devices or system.devices, so if an LV
+ * that dmeventd is watching is not covered by either of these
+ * devices files, the dmeventd-generated command will fail when
+ * it doesn't find the VG.
+ */
 static int _setup_devices_file_dmeventd(struct cmd_context *cmd)
 {
        char path[PATH_MAX];
        struct stat st;
 
-       /*
-        * When command is run by dmeventd there is no --devicesfile
-        * option that can enable/disable the use of a devices file.
-        */
        if (!find_config_tree_bool(cmd, devices_use_devicesfile_CFG, NULL)) {
                cmd->enable_devices_file = 0;
                return 1;
        }
 
-       /*
-        * If /etc/lvm/devices/dmeventd.devices exists, then use that.
-        * The optional dmeventd.devices allows the user to control
-        * which devices dmeventd will look at and use.
-        * Otherwise, disable the devices file because dmeventd should
-        * be able to manage LVs in any VG (i.e. LVs in a non-system
-        * devices file.)
-        */
-       if (dm_snprintf(path, sizeof(path), "%s/devices/dmeventd.devices", cmd->system_dir) < 0) {
-               log_warn("Failed to copy devices path");
-               cmd->enable_devices_file = 0;
-               return 1;
-       }
-
-       if (stat(path, &st)) {
-               /* No dmeventd.devices, so do not use a devices file. */
-               cmd->enable_devices_file = 0;
-               return 1;
-       }
+       if (dm_snprintf(path, sizeof(path), "%s/devices/dmeventd.devices", cmd->system_dir) < 0)
+               return_0;
+       if (stat(path, &st))
+               return 0;
 
        cmd->enable_devices_file = 1;
        (void) dm_strncpy(cmd->devices_file_path, path, sizeof(cmd->devices_file_path));
@@ -1823,8 +1822,9 @@ int setup_devices_file(struct cmd_context *cmd)
        struct stat st;
        int rv;
 
-       if (cmd->run_by_dmeventd)
-               return _setup_devices_file_dmeventd(cmd);
+       /* Use dmeventd.devices if it exists. */
+       if (cmd->run_by_dmeventd && _setup_devices_file_dmeventd(cmd))
+               return 1;
 
        if (cmd->devicesfile) {
                /* --devicesfile <filename> or "" has been set which overrides
index 94a4ccc2dc440d1d88d60a13b7eadce252ea3ac9..a3c1d729bb0e2b11bd9c53250739b16d7cc7ccfe 100644 (file)
@@ -108,6 +108,12 @@ The default choice for device ID type can be overridden using lvmdevices
 device it will be used, otherwise the device will be added using the type
 that would otherwise be chosen.
 
+LVM commands run by dmeventd will use the devices file
+\fI#DEFAULT_SYS_DIR#/devices/dmeventd.devices\fP if it exists,
+otherwise system.devices is used.  VGs that require the dmeventd
+service should be included in system.devices, even if they are
+included in dmeventd.devices.
+
 .SS Device ID refresh
 .P
 A machine identifier is saved in the devices file, and is used to detect
This page took 0.038639 seconds and 5 git commands to generate.