* 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 device *dev = NULL;
} else {
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;
+ }
+ }
}
/*
void device_ids_match(struct cmd_context *cmd);
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_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);
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);
struct hint *hint;
struct dev_iter *iter;
struct device *dev;
+ int valid_hints = 0;
int ret = 1;
/* No commands are using hints. */
if (!cmd->use_hints && !cmd->pvscan_recreate_hints)
return 0;
+ log_debug("Validating hints");
+
if (lvmcache_has_duplicate_devs()) {
log_debug("Hints not used with duplicate pvs");
ret = 0;
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;
dev->pvid, hint->pvid);
ret = 0;
}
+
+ valid_hints++;
}
dev_iter_destroy(iter);
}
}
+ /*
+ * hints considered invalid if none are used.
+ */
+ if (!valid_hints) {
+ log_debug("Invalid hints: none used.");
+ ret = 0;
+ }
+
out:
if (!ret) {
/*
* Check if the devices_file content is up to date and
* 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_del(&devl->list);
* from use_devices does not pass the filters that have been
* run just above.
*/
- device_ids_validate(cmd, NULL, 1);
+ device_ids_validate(cmd, NULL, 1, 0);
if (cmd->device_ids_invalid)
update_needed = 1;