diff options
author | David Teigland <teigland@redhat.com> | 2017-08-25 17:21:02 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2017-10-16 11:17:12 -0500 |
commit | 22152304289cbf8266b1dafa306fd25fa3b19714 (patch) | |
tree | 0a5026c933d6e608b63381c039e823724badc0e4 | |
parent | accc7e05b9f88642ea9f81686981cd2073013953 (diff) | |
download | lvm2-22152304289cbf8266b1dafa306fd25fa3b19714.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; |