diff options
author | David Teigland <teigland@redhat.com> | 2021-02-08 11:23:42 -0600 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2021-02-08 11:23:42 -0600 |
commit | 018bba897ca13521988eb36a89fd054e15feb231 (patch) | |
tree | 9a23bd65d1703e72c2faa972e43d1593d29e4659 /lib/cache | |
parent | df4c50396bfce6586a063d04861f9d1d8b1aeb31 (diff) | |
download | lvm2-018bba897ca13521988eb36a89fd054e15feb231.tar.gz |
fix for md component detection changes
And some fine tuning of when the checks are applied
in "start" mode.
Diffstat (limited to 'lib/cache')
-rw-r--r-- | lib/cache/lvmcache.c | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 5c573286d..e05530a53 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -1056,7 +1056,8 @@ void lvmcache_extra_md_component_checks(struct cmd_context *cmd) struct device *dev; const char *device_hint; uint64_t devsize, pvsize; - int do_check; + int do_check_size, do_check_name; + int md_check_start; /* * use_full_md_check: if set then no more needs to be done here, @@ -1073,9 +1074,11 @@ void lvmcache_extra_md_component_checks(struct cmd_context *cmd) * function is looking for. */ if (!cmd->md_component_detection || cmd->use_full_md_check || - !strcmp(cmd->md_component_checks, "none") || !strcmp(cmd->md_component_checks, "start")) + !strcmp(cmd->md_component_checks, "none")) return; + md_check_start = !strcmp(cmd->md_component_checks, "start"); + /* * We want to avoid extra scanning for end-of-device md superblocks * whenever possible, since it can add up to a lot of extra io if we're @@ -1093,7 +1096,8 @@ void lvmcache_extra_md_component_checks(struct cmd_context *cmd) device_hint = _get_pvsummary_device_hint(dev->pvid); pvsize = _get_pvsummary_size(dev->pvid); devsize = dev->size; - do_check = 0; + do_check_size = 0; + do_check_name = 0; if (!devsize && !dev_get_size(dev, &devsize)) log_debug("No size for %s.", dev_name(dev)); @@ -1103,23 +1107,43 @@ void lvmcache_extra_md_component_checks(struct cmd_context *cmd) * can be common, but not as often as PV larger. */ if (pvsize && devsize && (pvsize != devsize)) - do_check = 1; - else if (device_hint && !strcmp(device_hint, "/dev/md")) - do_check = 1; + do_check_size = 1; + if (device_hint && !strncmp(device_hint, "/dev/md", 7)) + do_check_name = 1; + + if (!do_check_size && !do_check_name) + continue; - if (do_check) { - log_debug("extra md component check %llu %llu device_hint %s dev %s", + /* + * If only the size is different (which can be fairly + * common for non-md-component devs) and the user has + * set "start" to disable full md checks, then skip it. + * If the size is different, *and* the device name hint + * looks like an md device, then it seems very likely + * to be an md component, so do a full check on it even + * if the user has set "start". + * + * In "auto" mode, do a full check if either the size + * or the name indicates a possible md component. + */ + if (do_check_size && !do_check_name && md_check_start) { + log_debug("extra md component check skip %llu %llu device_hint %s dev %s", (unsigned long long)pvsize, (unsigned long long)devsize, device_hint ?: "none", dev_name(dev)); + continue; + } - if (dev_is_md_component(dev, NULL, 1)) { - log_debug("dropping PV from md component %s", dev_name(dev)); - dev->flags &= ~DEV_SCAN_FOUND_LABEL; - /* lvmcache_del will also delete vginfo if info was last one */ - lvmcache_del(info); - lvmcache_del_dev_from_duplicates(dev); - cmd->filter->wipe(cmd, cmd->filter, dev, NULL); - } + log_debug("extra md component check %llu %llu device_hint %s dev %s", + (unsigned long long)pvsize, (unsigned long long)devsize, + device_hint ?: "none", dev_name(dev)); + + if (dev_is_md_component(dev, NULL, 1)) { + log_debug("dropping PV from md component %s", dev_name(dev)); + dev->flags &= ~DEV_SCAN_FOUND_LABEL; + /* lvmcache_del will also delete vginfo if info was last one */ + lvmcache_del(info); + lvmcache_del_dev_from_duplicates(dev); + cmd->filter->wipe(cmd, cmd->filter, dev, NULL); } } } |