diff options
author | David Teigland <teigland@redhat.com> | 2019-04-30 14:10:27 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2019-04-30 14:10:27 -0500 |
commit | 366c1ac15b853fe3efc95472c569efc575f1237f (patch) | |
tree | f762b3b79d37373d1e716a416f47fb6115f4324b | |
parent | 6d0f09f4783061054152ae0013d7ebfad949c343 (diff) | |
download | lvm2-366c1ac15b853fe3efc95472c569efc575f1237f.tar.gz |
pvcreate: call label scan prior to pvcreate_each_device
and don't call it from inside pvcreate_each_device.
This avoids having to repeat it for users of
pvcreate_each_device (pvcreate/pvremove/vgcreate/vgextend.)
-rw-r--r-- | tools/pvcreate.c | 5 | ||||
-rw-r--r-- | tools/pvremove.c | 2 | ||||
-rw-r--r-- | tools/toollib.c | 10 | ||||
-rw-r--r-- | tools/vgextend.c | 4 |
4 files changed, 10 insertions, 11 deletions
diff --git a/tools/pvcreate.c b/tools/pvcreate.c index 10d1a37c3..5b59a79b5 100644 --- a/tools/pvcreate.c +++ b/tools/pvcreate.c @@ -145,6 +145,8 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv) clear_hint_file(cmd); + lvmcache_label_scan(cmd); + if (!(handle = init_processing_handle(cmd, NULL))) { log_error("Failed to initialize processing handle."); return ECMD_FAILED; @@ -152,9 +154,8 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv) if (!pvcreate_each_device(cmd, handle, &pp)) ret = ECMD_FAILED; - else { + else ret = ECMD_PROCESSED; - } destroy_processing_handle(cmd, handle); return ret; diff --git a/tools/pvremove.c b/tools/pvremove.c index 4ad1f42b6..2dfdbd016 100644 --- a/tools/pvremove.c +++ b/tools/pvremove.c @@ -45,6 +45,8 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv) clear_hint_file(cmd); + lvmcache_label_scan(cmd); + /* When forcibly clearing a PV we don't care about a VG lock. */ if (pp.force == DONT_PROMPT_OVERRIDE) cmd->lockd_vg_disable = 1; diff --git a/tools/toollib.c b/tools/toollib.c index b8be826db..b35283916 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -2243,7 +2243,8 @@ int process_each_vg(struct cmd_context *cmd, * Scan all devices to populate lvmcache with initial * list of PVs and VGs. */ - lvmcache_label_scan(cmd); + if (!(read_flags & PROCESS_SKIP_SCAN)) + lvmcache_label_scan(cmd); /* * A list of all VGs on the system is needed when: @@ -5327,13 +5328,6 @@ int pvcreate_each_device(struct cmd_context *cmd, } /* - * Scan before calling process_each_pv so we can set up the PV args - * first. We can then skip the scan that would normally occur at the - * beginning of process_each_pv. - */ - lvmcache_label_scan(cmd); - - /* * Translate arg names into struct device's. */ dm_list_iterate_items(pd, &pp->arg_devices) diff --git a/tools/vgextend.c b/tools/vgextend.c index 02da3a867..785be3fa3 100644 --- a/tools/vgextend.c +++ b/tools/vgextend.c @@ -162,6 +162,8 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) clear_hint_file(cmd); + lvmcache_label_scan(cmd); + if (!(handle = init_processing_handle(cmd, NULL))) { log_error("Failed to initialize processing handle."); return ECMD_FAILED; @@ -185,7 +187,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) handle->custom_handle = &vp; ret = process_each_vg(cmd, 0, NULL, vg_name, NULL, - READ_FOR_UPDATE, 0, handle, + READ_FOR_UPDATE | PROCESS_SKIP_SCAN, 0, handle, restoremissing ? &_vgextend_restoremissing : &_vgextend_single); destroy_processing_handle(cmd, handle); |