unsigned int check_suspended:1;
unsigned int check_error_target:1;
unsigned int check_reserved:1;
+ unsigned int check_lv:1;
};
/*
}
}
+ 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))) {
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;
}
"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")
#define DEFAULT_VDO_POOL_AUTOEXTEND_THRESHOLD 100
#define DEFAULT_VDO_POOL_AUTOEXTEND_PERCENT 20
+#define DEFAULT_SCAN_LVS 1
+
#endif /* _LVM_DEFAULTS_H */
#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)
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;
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;
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;
ucp.check_suspended = ignore_suspended_devices();
ucp.check_error_target = 0;
ucp.check_reserved = 0;
+ ucp.check_lv = skip_lvs;
break;
}
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)))) {
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;
}
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 */