]> sourceware.org Git - lvm2.git/commitdiff
filter: add config setting to skip scanning LVs
authorDavid Teigland <teigland@redhat.com>
Wed, 29 Aug 2018 18:14:18 +0000 (13:14 -0500)
committerDavid Teigland <teigland@redhat.com>
Thu, 30 Aug 2018 14:59:50 +0000 (09:59 -0500)
devices/scan_lvs (default 1) determines whether lvm
will scan LVs for layered PVs.  The lvm behavior has
always been to scan LVs, but it's rare for LVs to have
layered PVs, and much more common for there to be many
LVs that substantially slow down scanning with no benefit.

This is implemented in the usable filter, and has the
same effect as listing all LVs in the global_filter.

lib/activate/activate.h
lib/activate/dev_manager.c
lib/commands/toolcontext.c
lib/config/config_settings.h
lib/config/defaults.h
lib/filters/filter-usable.c
lib/filters/filter.h

index cca25040c5abae87b8bfef27329f0c6d5898e1a7..9530c36495e740c68857d800c86f3f0fecf6a1ad 100644 (file)
@@ -240,6 +240,7 @@ struct dev_usable_check_params {
        unsigned int check_suspended:1;
        unsigned int check_error_target:1;
        unsigned int check_reserved:1;
+       unsigned int check_lv:1;
 };
 
 /*
index 43dba8c169f3adfad51b38d44afdbfe2f352d66c..67a49bef3eeafdac35b0b3580ed76c50984c603e 100644 (file)
@@ -648,6 +648,11 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
                }
        }
 
+       if (check.check_lv && uuid && !strncmp(uuid, "LVM-", 4)) {
+               /* Skip LVs */
+               goto out;
+       }
+
        if (check.check_reserved && uuid &&
            (!strncmp(uuid, CRYPT_TEMP, sizeof(CRYPT_TEMP) - 1) ||
             !strncmp(uuid, STRATIS, sizeof(STRATIS) - 1))) {
index 961962cd8c32d58ec819d1088e9105cf1c5fa07c..fa87bccd7b9746be8b422e1a285ba82867b5d40f 100644 (file)
@@ -1088,7 +1088,7 @@ static struct dev_filter *_init_lvmetad_filter_chain(struct cmd_context *cmd)
        nr_filt++;
 
        /* usable device filter. Required. */
-       if (!(filters[nr_filt] = usable_filter_create(cmd->dev_types, FILTER_MODE_NO_LVMETAD))) {
+       if (!(filters[nr_filt] = usable_filter_create(cmd, cmd->dev_types, FILTER_MODE_NO_LVMETAD))) {
                log_error("Failed to create usabled device filter");
                goto bad;
        }
index 1d0cc790ce178eea8c57d9b6ee7eda39ff6671aa..b47b225b7444809ea62353676c6d3bd585aad2ad 100644 (file)
@@ -337,6 +337,9 @@ cfg(devices_sysfs_scan_CFG, "sysfs_scan", devices_CFG_SECTION, 0, CFG_TYPE_BOOL,
        "This is a quick way of filtering out block devices that are not\n"
        "present on the system. sysfs must be part of the kernel and mounted.)\n")
 
+cfg(devices_scan_lvs_CFG, "scan_lvs", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_SCAN_LVS, vsn(2, 2, 182), NULL, 0, NULL,
+       "Scan LVM LVs for layered PVs.\n")
+
 cfg(devices_multipath_component_detection_CFG, "multipath_component_detection", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MULTIPATH_COMPONENT_DETECTION, vsn(2, 2, 89), NULL, 0, NULL,
        "Ignore devices that are components of DM multipath devices.\n")
 
index 9928fb19e7f10f2c57ae09ac328dddb16fe41b50..9fbe8c2f285a0006931a1794ab3da9bbf703da08 100644 (file)
 #define DEFAULT_VDO_POOL_AUTOEXTEND_THRESHOLD 100
 #define DEFAULT_VDO_POOL_AUTOEXTEND_PERCENT 20
 
+#define DEFAULT_SCAN_LVS 1
+
 #endif                         /* _LVM_DEFAULTS_H */
index ab5c02f12c4147a1ecd7ce45a864d3f7c8a02667..699736893d93a029718e29b3b44c152318c48449 100644 (file)
 #include "lib/device/dev-ext-udev-constants.h"
 #endif
 
+struct filter_data {
+       filter_mode_t mode;
+       int skip_lvs;
+};
+
 static const char *_too_small_to_hold_pv_msg = "Too small to hold a PV";
 
 static int _native_check_pv_min_size(struct device *dev)
@@ -102,7 +107,9 @@ static int _check_pv_min_size(struct device *dev)
 
 static int _passes_usable_filter(struct cmd_context *cmd, struct dev_filter *f, struct device *dev)
 {
-       filter_mode_t mode = *((filter_mode_t *) f->private);
+       struct filter_data *data = f->private;
+       filter_mode_t mode = data->mode;
+       int skip_lvs = data->skip_lvs;
        struct dev_usable_check_params ucp = {0};
        int r = 1;
 
@@ -115,6 +122,7 @@ static int _passes_usable_filter(struct cmd_context *cmd, struct dev_filter *f,
                        ucp.check_suspended = ignore_suspended_devices();
                        ucp.check_error_target = 1;
                        ucp.check_reserved = 1;
+                       ucp.check_lv = skip_lvs;
                        break;
                case FILTER_MODE_PRE_LVMETAD:
                        ucp.check_empty = 1;
@@ -122,6 +130,7 @@ static int _passes_usable_filter(struct cmd_context *cmd, struct dev_filter *f,
                        ucp.check_suspended = 0;
                        ucp.check_error_target = 1;
                        ucp.check_reserved = 1;
+                       ucp.check_lv = skip_lvs;
                        break;
                case FILTER_MODE_POST_LVMETAD:
                        ucp.check_empty = 0;
@@ -129,6 +138,7 @@ static int _passes_usable_filter(struct cmd_context *cmd, struct dev_filter *f,
                        ucp.check_suspended = ignore_suspended_devices();
                        ucp.check_error_target = 0;
                        ucp.check_reserved = 0;
+                       ucp.check_lv = skip_lvs;
                        break;
                }
 
@@ -162,8 +172,9 @@ static void _usable_filter_destroy(struct dev_filter *f)
        free(f);
 }
 
-struct dev_filter *usable_filter_create(struct dev_types *dt __attribute__((unused)), filter_mode_t mode)
+struct dev_filter *usable_filter_create(struct cmd_context *cmd, struct dev_types *dt __attribute__((unused)), filter_mode_t mode)
 {
+       struct filter_data *data;
        struct dev_filter *f;
 
        if (!(f = zalloc(sizeof(struct dev_filter)))) {
@@ -174,14 +185,20 @@ struct dev_filter *usable_filter_create(struct dev_types *dt __attribute__((unus
        f->passes_filter = _passes_usable_filter;
        f->destroy = _usable_filter_destroy;
        f->use_count = 0;
-       if (!(f->private = zalloc(sizeof(filter_mode_t)))) {
+
+       if (!(data = zalloc(sizeof(struct filter_data)))) {
                log_error("Usable device filter mode allocation failed");
                free(f);
                return NULL;
        }
-       *((filter_mode_t *) f->private) = mode;
 
-       log_debug_devs("Usable device filter initialised.");
+       data->mode = mode;
+
+       data->skip_lvs = !find_config_tree_bool(cmd, devices_scan_lvs_CFG, NULL);
+
+       f->private = data;
+
+       log_debug_devs("Usable device filter initialised (scan_lvs %d).", !data->skip_lvs);
 
        return f;
 }
index cdd5a14d7fb2c5d182ee1895a3847b5b34c46d7e..7333cfe3c52e6dc801a1f207599b2bc8b9f61479 100644 (file)
@@ -50,6 +50,6 @@ typedef enum {
        FILTER_MODE_PRE_LVMETAD,
        FILTER_MODE_POST_LVMETAD
 } filter_mode_t;
-struct dev_filter *usable_filter_create(struct dev_types *dt, filter_mode_t mode);
+struct dev_filter *usable_filter_create(struct cmd_context *cmd, struct dev_types *dt, filter_mode_t mode);
 
 #endif         /* _LVM_FILTER_H */
This page took 0.083509 seconds and 5 git commands to generate.