From 366c1ac15b853fe3efc95472c569efc575f1237f Mon Sep 17 00:00:00 2001 From: David Teigland Date: Tue, 30 Apr 2019 14:10:27 -0500 Subject: [PATCH] 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.) --- tools/pvcreate.c | 5 +++-- tools/pvremove.c | 2 ++ tools/toollib.c | 10 ++-------- 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: @@ -5326,13 +5327,6 @@ int pvcreate_each_device(struct cmd_context *cmd, dm_list_add(&pp->arg_devices, &pd->list); } - /* - * 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. */ 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);