1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

hints: correct fix for hints with device ids

Fixes commit 63b469c160
"device_id: fix hints with device ids"

It's not correct for internal filtering to be a factor
in validating the set of devs that are the basis for hints.

Instead, look for inconsistencies between a hint entry and
the corresponding devices file entry.
This commit is contained in:
David Teigland 2023-10-16 14:08:28 -05:00
parent d12e843e4a
commit e6c6713a1b

View File

@ -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;
}