diff options
Diffstat (limited to 'lib/label/label.c')
-rw-r--r-- | lib/label/label.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/lib/label/label.c b/lib/label/label.c index ed6e0171c..455b17123 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -25,6 +25,7 @@ #include "lib/label/hints.h" #include "lib/metadata/metadata.h" #include "lib/format_text/layout.h" +#include "lib/device/device_id.h" #include <sys/stat.h> #include <fcntl.h> @@ -780,16 +781,6 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f, } } - /* - * This will search the system's /dev for new path names and - * could help us reopen the device if it finds a new preferred - * path name for this dev's major:minor. It does that by - * inserting a new preferred path name on dev->aliases. open - * uses the first name from that list. - */ - log_debug_devs("Scanning refreshing device paths."); - dev_cache_scan(); - /* Put devs that failed to open back on the original list to retry. */ dm_list_splice(devs, &reopen_devs); goto scan_more; @@ -911,6 +902,12 @@ static void _prepare_open_file_limit(struct cmd_context *cmd, unsigned int num_d #endif } +/* + * Currently the only caller is pvck which probably doesn't need + * deferred filters checked after the read... it wants to know if + * anything has the pvid, even a dev that might be filtered. + */ + int label_scan_for_pvid(struct cmd_context *cmd, char *pvid, struct device **dev_out) { char buf[LABEL_SIZE] __attribute__((aligned(8))); @@ -923,7 +920,17 @@ int label_scan_for_pvid(struct cmd_context *cmd, char *pvid, struct device **dev dm_list_init(&devs); - dev_cache_scan(); + /* + * Creates a list of available devices, does not open or read any, + * and does not filter them. + */ + setup_devices(cmd); + + /* + * Iterating over all available devices with cmd->filter filters + * devices; those returned from dev_iter_get are the devs that + * pass filters, and are those we can use. + */ if (!(iter = dev_iter_create(cmd->filter, 0))) { log_error("Scanning failed to get devices."); @@ -1006,12 +1013,14 @@ int label_scan(struct cmd_context *cmd) dm_list_init(&hints_list); /* - * dev_cache_scan() creates a list of devices on the system - * (saved in in dev-cache) which we can iterate through to - * search for LVM devs. The dev cache list either comes from - * looking at dev nodes under /dev, or from udev. + * Creates a list of available devices, does not open or read any, + * and does not filter them. The list of all available devices + * is kept in "dev-cache", and comes from /dev entries or libudev. + * The list of devs found here needs to be filtered to get the + * list of devs we can use. The dev_iter calls using cmd->filter + * are what filters the devs. */ - dev_cache_scan(); + setup_devices(cmd); /* * If we know that there will be md components with an end @@ -1213,6 +1222,12 @@ int label_scan(struct cmd_context *cmd) if (create_hints) write_hint_file(cmd, create_hints); + /* + * Check if the devices_file content is up to date and + * if not update it. + */ + device_ids_validate(cmd); + return 1; } @@ -1666,4 +1681,3 @@ void dev_unset_last_byte(struct device *dev) { bcache_unset_last_byte(scan_bcache, dev->bcache_fd); } - |