diff --git a/lib/label/hints.c b/lib/label/hints.c index 1e382198b..d6682617a 100644 --- a/lib/label/hints.c +++ b/lib/label/hints.c @@ -507,17 +507,6 @@ int validate_hints(struct cmd_context *cmd, struct dm_list *hints) if (!(hint = _find_hint_name(hints, dev_name(dev)))) continue; - /* - * If this dev is excluded by any filter then hints invalid. - * use cmd->filter->passes_filter(cmd, cmd->filter, dev, "persistent") ? - */ - if (dev->filtered_flags) { - log_debug("Hints invalid for filtered %s: %s", - dev_name(dev), dev_filtered_reason(dev)); - ret = 0; - break; - } - /* The cmd hasn't needed this hint's dev so it's not been scanned. */ if (!hint->chosen) continue; @@ -705,8 +694,9 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int * char devpath[PATH_MAX]; FILE *fp; struct dev_iter *iter; + struct dev_use *du; struct hint hint; - struct hint *alloc_hint; + struct hint *alloc_hint, *hp; struct device *dev; char *split[HINT_LINE_WORDS]; char *name, *pvid, *devn, *vgname, *p, *filter_str = NULL; @@ -910,6 +900,32 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int * return 1; } + /* + * Check that the dev in each hint is a dev that's matched to a + * devices file entry. + */ + if (cmd->enable_devices_file) { + dm_list_iterate_items(hp, hints) { + if (!(du = get_du_for_devname(cmd, hp->name))) { + log_debug("ignore hints: no devices file entry for %s", hp->name); + *needs_refresh = 1; + return 1; + } + if (!du->dev) { + log_debug("ignore hints: no device matches devices file entry for %s", hp->name); + *needs_refresh = 1; + return 1; + } + if (hp->devt != du->dev->dev) { + log_debug("ignore hints: devno %d:%d does not match %d:%d for %s", + (int)MAJOR(hp->devt), (int)MINOR(hp->devt), + (int)MAJOR(du->dev->dev), (int)MINOR(du->dev->dev), hp->name); + *needs_refresh = 1; + return 1; + } + } + } + log_debug("accept hints found %d", dm_list_size(hints)); return 1; }