mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
device_id: fix hints with device ids
Fix some interactions between device IDs and hints. Hints may limit the scanned devices which should not always trigger a search for the PVs that were intentionally not scanned. Hints should also be invalidated if they contain a device that's become excluded by an internal filter such as the device_id filter.
This commit is contained in:
parent
f20be398a1
commit
63b469c160
@ -2342,7 +2342,7 @@ static void _get_devs_with_serial_numbers(struct cmd_context *cmd, struct dm_lis
|
|||||||
* use_devices entries from the devices file.
|
* use_devices entries from the devices file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs, int noupdate)
|
void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs, int noupdate, int using_hints)
|
||||||
{
|
{
|
||||||
struct dm_list wrong_devs;
|
struct dm_list wrong_devs;
|
||||||
struct device *dev = NULL;
|
struct device *dev = NULL;
|
||||||
@ -2768,6 +2768,28 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs,
|
|||||||
} else {
|
} else {
|
||||||
log_debug("Validated device ids: invalid=%d, no update needed.", cmd->device_ids_invalid);
|
log_debug("Validated device ids: invalid=%d, no update needed.", cmd->device_ids_invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* label_scan can use hints to scan only the devs for a specific
|
||||||
|
* VG as an optimization. If that limited subset of devs were
|
||||||
|
* all matched properly in the devices file, then override
|
||||||
|
* device_ids_invalid which may be set due to other entries
|
||||||
|
* not being matched, which this command doesn't care about.
|
||||||
|
*/
|
||||||
|
if (using_hints && scanned_devs) {
|
||||||
|
int found_scanned = 1;
|
||||||
|
dm_list_iterate_items(devl, scanned_devs) {
|
||||||
|
du = get_du_for_dev(cmd, devl->dev);
|
||||||
|
if (du && !memcmp(du->pvid, devl->dev->pvid, ID_LEN))
|
||||||
|
continue;
|
||||||
|
found_scanned = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (found_scanned && cmd->device_ids_invalid) {
|
||||||
|
log_debug("Override device_ids_invalid for complete hints.");
|
||||||
|
cmd->device_ids_invalid = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -33,7 +33,7 @@ void device_id_pvremove(struct cmd_context *cmd, struct device *dev);
|
|||||||
void device_ids_match(struct cmd_context *cmd);
|
void device_ids_match(struct cmd_context *cmd);
|
||||||
int device_ids_match_dev(struct cmd_context *cmd, struct device *dev);
|
int device_ids_match_dev(struct cmd_context *cmd, struct device *dev);
|
||||||
void device_ids_match_device_list(struct cmd_context *cmd);
|
void device_ids_match_device_list(struct cmd_context *cmd);
|
||||||
void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs, int noupdate);
|
void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs, int noupdate, int using_hints);
|
||||||
int device_ids_version_unchanged(struct cmd_context *cmd);
|
int device_ids_version_unchanged(struct cmd_context *cmd);
|
||||||
void device_ids_check_serial(struct cmd_context *cmd, struct dm_list *scan_devs, int *update_needed, int noupdate);
|
void device_ids_check_serial(struct cmd_context *cmd, struct dm_list *scan_devs, int *update_needed, int noupdate);
|
||||||
void device_ids_refresh(struct cmd_context *cmd, struct dm_list *dev_list, int *search_count, int noupdate);
|
void device_ids_refresh(struct cmd_context *cmd, struct dm_list *dev_list, int *search_count, int noupdate);
|
||||||
|
@ -468,6 +468,7 @@ int validate_hints(struct cmd_context *cmd, struct dm_list *hints)
|
|||||||
struct hint *hint;
|
struct hint *hint;
|
||||||
struct dev_iter *iter;
|
struct dev_iter *iter;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
int valid_hints = 0;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
|
|
||||||
/* No commands are using hints. */
|
/* No commands are using hints. */
|
||||||
@ -478,6 +479,8 @@ int validate_hints(struct cmd_context *cmd, struct dm_list *hints)
|
|||||||
if (!cmd->use_hints && !cmd->pvscan_recreate_hints)
|
if (!cmd->use_hints && !cmd->pvscan_recreate_hints)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
log_debug("Validating hints");
|
||||||
|
|
||||||
if (lvmcache_has_duplicate_devs()) {
|
if (lvmcache_has_duplicate_devs()) {
|
||||||
log_debug("Hints not used with duplicate pvs");
|
log_debug("Hints not used with duplicate pvs");
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -504,6 +507,17 @@ int validate_hints(struct cmd_context *cmd, struct dm_list *hints)
|
|||||||
if (!(hint = _find_hint_name(hints, dev_name(dev))))
|
if (!(hint = _find_hint_name(hints, dev_name(dev))))
|
||||||
continue;
|
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. */
|
/* The cmd hasn't needed this hint's dev so it's not been scanned. */
|
||||||
if (!hint->chosen)
|
if (!hint->chosen)
|
||||||
continue;
|
continue;
|
||||||
@ -527,6 +541,8 @@ int validate_hints(struct cmd_context *cmd, struct dm_list *hints)
|
|||||||
dev->pvid, hint->pvid);
|
dev->pvid, hint->pvid);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
valid_hints++;
|
||||||
}
|
}
|
||||||
dev_iter_destroy(iter);
|
dev_iter_destroy(iter);
|
||||||
|
|
||||||
@ -576,6 +592,14 @@ int validate_hints(struct cmd_context *cmd, struct dm_list *hints)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* hints considered invalid if none are used.
|
||||||
|
*/
|
||||||
|
if (!valid_hints) {
|
||||||
|
log_debug("Invalid hints: none used.");
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
/*
|
/*
|
||||||
|
@ -1457,7 +1457,7 @@ int label_scan(struct cmd_context *cmd)
|
|||||||
* Check if the devices_file content is up to date and
|
* Check if the devices_file content is up to date and
|
||||||
* if not update it.
|
* if not update it.
|
||||||
*/
|
*/
|
||||||
device_ids_validate(cmd, &scan_devs, 0);
|
device_ids_validate(cmd, &scan_devs, 0, using_hints);
|
||||||
|
|
||||||
dm_list_iterate_items_safe(devl, devl2, &all_devs) {
|
dm_list_iterate_items_safe(devl, devl2, &all_devs) {
|
||||||
dm_list_del(&devl->list);
|
dm_list_del(&devl->list);
|
||||||
|
@ -230,7 +230,7 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
* from use_devices does not pass the filters that have been
|
* from use_devices does not pass the filters that have been
|
||||||
* run just above.
|
* run just above.
|
||||||
*/
|
*/
|
||||||
device_ids_validate(cmd, NULL, 1);
|
device_ids_validate(cmd, NULL, 1, 0);
|
||||||
if (cmd->device_ids_invalid)
|
if (cmd->device_ids_invalid)
|
||||||
update_needed = 1;
|
update_needed = 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user