summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-08-04 16:41:25 -0500
committerDavid Teigland <teigland@redhat.com>2017-10-18 10:03:57 -0500
commitb63378b11a8d4af490b2100a504da579878ef8ee (patch)
treef7bb025181d1e05e2634c245c3d623c66ea8dee6
parent30e380a5b85492135539cec424d21d6a160def23 (diff)
downloadlvm2-b63378b11a8d4af490b2100a504da579878ef8ee.tar.gz
label_scan: pull out to top level
label_scan is a primary step that a command performs, following the standard pattern for command processing. It was being called as a side effect of a utility/helper function, which made it less obvious and made it easier to be called without realizing it. Pull it up to a prominent top level in the sequence of primary steps. label_scan is not something that should be done in various low level places as needed.
-rw-r--r--lib/cache/lvmcache.c2
-rw-r--r--lib/metadata/metadata.c4
-rw-r--r--tools/toollib.c27
3 files changed, 23 insertions, 10 deletions
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index e9a68f18f..51bbb1d3f 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1325,8 +1325,6 @@ int lvmcache_get_vgnameids(struct cmd_context *cmd, int include_internal,
struct vgnameid_list *vgnl;
struct lvmcache_vginfo *vginfo;
- lvmcache_label_scan(cmd);
-
dm_list_iterate_items(vginfo, &_vginfos) {
if (!include_internal && is_orphan_vg(vginfo->vgname))
continue;
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index a3ef69e67..b5aaa4963 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -783,6 +783,10 @@ bad:
* . pvremove_single()
* . find_pv_by_name()
* . get_pvs()
+ * . get_vgids()
+ * . get_vgnames()
+ * . lvmcache_get_vgids()
+ * . lvmcache_get_vgnames()
* . the vg->pvs_to_write list and pv_to_write struct
* . vg_reduce()
*/
diff --git a/tools/toollib.c b/tools/toollib.c
index 79829f4df..5bc362846 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2216,14 +2216,10 @@ int process_each_vg(struct cmd_context *cmd,
}
/*
- * First rescan for available devices, then force the next
- * label scan to be done. get_vgnameids() will scan labels
- * (when not using lvmetad).
+ * Scan all devices to populate lvmcache with initial
+ * list of PVs and VGs.
*/
- if (cmd->cname->flags & REQUIRES_FULL_LABEL_SCAN) {
- dev_cache_full_scan(cmd->full_filter);
- lvmcache_force_next_label_scan();
- }
+ lvmcache_label_scan(cmd);
/*
* A list of all VGs on the system is needed when:
@@ -3759,6 +3755,12 @@ int process_each_lv(struct cmd_context *cmd,
}
/*
+ * Scan all devices to populate lvmcache with initial
+ * list of PVs and VGs.
+ */
+ lvmcache_label_scan(cmd);
+
+ /*
* A list of all VGs on the system is needed when:
* . processing all VGs on the system
* . A VG name is specified which may refer to one
@@ -4467,7 +4469,12 @@ int process_each_pv(struct cmd_context *cmd,
if (!trust_cache() && !orphans_locked) {
log_debug("Scanning for available devices");
lvmcache_destroy(cmd, 1, 0);
- dev_cache_full_scan(cmd->full_filter);
+
+ /*
+ * Scan all devices to populate lvmcache with initial
+ * list of PVs and VGs.
+ */
+ lvmcache_label_scan(cmd);
}
if (!get_vgnameids(cmd, &all_vgnameids, only_this_vgname, 1)) {
@@ -5481,6 +5488,8 @@ int pvcreate_each_device(struct cmd_context *cmd,
dev_cache_full_scan(cmd->full_filter);
+ lvmcache_label_scan(cmd);
+
/*
* Translate arg names into struct device's.
*/
@@ -5635,6 +5644,8 @@ int pvcreate_each_device(struct cmd_context *cmd,
goto out;
}
+ lvmcache_label_scan(cmd);
+
/*
* The device args began on the arg_devices list, then the first check
* loop moved those entries to arg_process as they were found. Devices