summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-08-25 17:21:02 -0500
committerDavid Teigland <teigland@redhat.com>2017-10-11 10:48:37 -0500
commit5cbb2c8da140f4f8b2c6c31573e28226ba7c52e2 (patch)
tree466706d707a49bb71536aec0c1f0f634a2dbdeac
parentdaa88ae711f95c9ca0fc05ca8331e178ed5e8303 (diff)
downloadlvm2-5cbb2c8da140f4f8b2c6c31573e28226ba7c52e2.tar.gz
pvscan: use new dev scanning code
-rw-r--r--tools/pvscan.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 396e6a4ce..f79b17fa3 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -300,8 +300,10 @@ static int _pvscan_autoactivate(struct cmd_context *cmd, struct pvscan_aa_params
static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
{
struct pvscan_aa_params pp = { 0 };
+ struct dm_list single_devs;
struct dm_list found_vgnames;
struct device *dev;
+ struct device_list *devl;
const char *pv_name;
const char *reason = NULL;
int32_t major = -1;
@@ -315,6 +317,7 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
int add_errors = 0;
int ret = ECMD_PROCESSED;
+ dm_list_init(&single_devs);
dm_list_init(&found_vgnames);
dm_list_init(&pp.changed_vgnames);
@@ -456,13 +459,10 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
/* Add device path to lvmetad. */
log_debug("Scanning dev %s for lvmetad cache.", pv_name);
- /* FIXME: add a label read async for single dev to use here */
- if (!label_read(dev, NULL, 0)) {
- add_errors++;
- continue;
- }
- if (!lvmetad_pvscan_single(cmd, dev, &found_vgnames, &pp.changed_vgnames))
- add_errors++;
+ if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
+ return_0;
+ devl->dev = dev;
+ dm_list_add(&single_devs, &devl->list);
}
} else {
if (sscanf(pv_name, "%d:%d", &major, &minor) != 2) {
@@ -480,13 +480,10 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
/* Add major:minor to lvmetad. */
log_debug("Scanning dev %d:%d for lvmetad cache.", major, minor);
- /* FIXME: add a label read async for single dev to use here */
- if (!label_read(dev, NULL, 0)) {
- add_errors++;
- continue;
- }
- if (!lvmetad_pvscan_single(cmd, dev, &found_vgnames, &pp.changed_vgnames))
- add_errors++;
+ if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
+ return_0;
+ devl->dev = dev;
+ dm_list_add(&single_devs, &devl->list);
}
}
@@ -496,6 +493,15 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
}
}
+ if (!dm_list_empty(&single_devs)) {
+ label_scan_devs(cmd, &single_devs);
+
+ dm_list_iterate_items(devl, &single_devs) {
+ if (!lvmetad_pvscan_single(cmd, devl->dev, &found_vgnames, &pp.changed_vgnames))
+ add_errors++;
+ }
+ }
+
if (!devno_args)
goto activate;