diff options
author | David Teigland <teigland@redhat.com> | 2017-08-25 17:21:02 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2017-10-18 14:09:12 -0500 |
commit | 41c479b09a1b04e9e240b94b0a68726abc21bd1e (patch) | |
tree | 10934074949c855bb6dceee4b38aef4f0e5b893e | |
parent | 15568b4a749137f9eaa8cd737efcbd5e83130fff (diff) | |
download | lvm2-41c479b09a1b04e9e240b94b0a68726abc21bd1e.tar.gz |
pvscan: use new dev scanning code
-rw-r--r-- | tools/pvscan.c | 34 |
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; |