|
|
d7c356 |
lib/cache/lvmetad.c | 44 ++++++++++++++++++++++++--------------------
|
|
|
d7c356 |
tools/pvscan.c | 9 ++++-----
|
|
|
d7c356 |
2 files changed, 28 insertions(+), 25 deletions(-)
|
|
|
d7c356 |
|
|
|
d7c356 |
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
|
|
|
d7c356 |
index 2a2d7ea..da8c027 100644
|
|
|
d7c356 |
--- a/lib/cache/lvmetad.c
|
|
|
d7c356 |
+++ b/lib/cache/lvmetad.c
|
|
|
d7c356 |
@@ -312,6 +312,7 @@ retry:
|
|
|
d7c356 |
* The caller should do a disk scan to populate lvmetad.
|
|
|
d7c356 |
*/
|
|
|
d7c356 |
if (!strcmp(daemon_token, "none")) {
|
|
|
d7c356 |
+ log_debug_lvmetad("lvmetad initialization needed.");
|
|
|
d7c356 |
ret = 0;
|
|
|
d7c356 |
goto out;
|
|
|
d7c356 |
}
|
|
|
d7c356 |
@@ -323,10 +324,16 @@ retry:
|
|
|
d7c356 |
* our global filter.
|
|
|
d7c356 |
*/
|
|
|
d7c356 |
if (strcmp(daemon_token, _lvmetad_token)) {
|
|
|
d7c356 |
+ log_debug_lvmetad("lvmetad initialization needed for different filter.");
|
|
|
d7c356 |
ret = 0;
|
|
|
d7c356 |
goto out;
|
|
|
d7c356 |
}
|
|
|
d7c356 |
|
|
|
d7c356 |
+ if (wait_start)
|
|
|
d7c356 |
+ log_debug_lvmetad("lvmetad initialized during wait.");
|
|
|
d7c356 |
+ else
|
|
|
d7c356 |
+ log_debug_lvmetad("lvmetad initialized previously.");
|
|
|
d7c356 |
+
|
|
|
d7c356 |
out:
|
|
|
d7c356 |
daemon_reply_destroy(reply);
|
|
|
d7c356 |
return ret;
|
|
|
d7c356 |
@@ -2362,28 +2369,11 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait)
|
|
|
d7c356 |
replacing_other_update = 1;
|
|
|
d7c356 |
}
|
|
|
d7c356 |
|
|
|
d7c356 |
- label_scan(cmd);
|
|
|
d7c356 |
-
|
|
|
d7c356 |
- lvmcache_pvscan_duplicate_check(cmd);
|
|
|
d7c356 |
-
|
|
|
d7c356 |
- if (lvmcache_found_duplicate_pvs()) {
|
|
|
d7c356 |
- log_warn("WARNING: Scan found duplicate PVs.");
|
|
|
d7c356 |
- return 0;
|
|
|
d7c356 |
- }
|
|
|
d7c356 |
-
|
|
|
d7c356 |
- log_verbose("Scanning all devices to update lvmetad.");
|
|
|
d7c356 |
-
|
|
|
d7c356 |
- if (!(iter = dev_iter_create(cmd->lvmetad_filter, 1))) {
|
|
|
d7c356 |
- log_error("dev_iter creation failed");
|
|
|
d7c356 |
- return 0;
|
|
|
d7c356 |
- }
|
|
|
d7c356 |
-
|
|
|
d7c356 |
future_token = _lvmetad_token;
|
|
|
d7c356 |
_lvmetad_token = (char *) LVMETAD_TOKEN_UPDATE_IN_PROGRESS;
|
|
|
d7c356 |
|
|
|
d7c356 |
if (!_token_update(&replaced_update)) {
|
|
|
d7c356 |
- log_error("Failed to update lvmetad which had an update in progress.");
|
|
|
d7c356 |
- dev_iter_destroy(iter);
|
|
|
d7c356 |
+ log_error("Failed to start lvmetad update.");
|
|
|
d7c356 |
_lvmetad_token = future_token;
|
|
|
d7c356 |
return 0;
|
|
|
d7c356 |
}
|
|
|
d7c356 |
@@ -2399,16 +2389,18 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait)
|
|
|
d7c356 |
if (do_wait && !retries) {
|
|
|
d7c356 |
retries = 1;
|
|
|
d7c356 |
log_warn("WARNING: lvmetad update in progress, retrying update.");
|
|
|
d7c356 |
- dev_iter_destroy(iter);
|
|
|
d7c356 |
_lvmetad_token = future_token;
|
|
|
d7c356 |
goto retry;
|
|
|
d7c356 |
}
|
|
|
d7c356 |
log_warn("WARNING: lvmetad update in progress, skipping update.");
|
|
|
d7c356 |
- dev_iter_destroy(iter);
|
|
|
d7c356 |
_lvmetad_token = future_token;
|
|
|
d7c356 |
return 0;
|
|
|
d7c356 |
}
|
|
|
d7c356 |
|
|
|
d7c356 |
+ log_verbose("Scanning all devices to initialize lvmetad.");
|
|
|
d7c356 |
+
|
|
|
d7c356 |
+ label_scan(cmd);
|
|
|
d7c356 |
+
|
|
|
d7c356 |
log_debug_lvmetad("Telling lvmetad to clear its cache");
|
|
|
d7c356 |
reply = _lvmetad_send(cmd, "pv_clear_all", NULL);
|
|
|
d7c356 |
if (!_lvmetad_handle_reply(reply, "pv_clear_all", "", NULL))
|
|
|
d7c356 |
@@ -2418,6 +2410,11 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait)
|
|
|
d7c356 |
was_silent = silent_mode();
|
|
|
d7c356 |
init_silent(1);
|
|
|
d7c356 |
|
|
|
d7c356 |
+ if (!(iter = dev_iter_create(cmd->lvmetad_filter, 1))) {
|
|
|
d7c356 |
+ log_error("dev_iter creation failed");
|
|
|
d7c356 |
+ return 0;
|
|
|
d7c356 |
+ }
|
|
|
d7c356 |
+
|
|
|
d7c356 |
while ((dev = dev_iter_get(iter))) {
|
|
|
d7c356 |
if (sigint_caught()) {
|
|
|
d7c356 |
ret = 0;
|
|
|
d7c356 |
@@ -2453,6 +2450,13 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait)
|
|
|
d7c356 |
return 0;
|
|
|
d7c356 |
}
|
|
|
d7c356 |
|
|
|
d7c356 |
+ /* This will disable lvmetad if label scan found duplicates. */
|
|
|
d7c356 |
+ lvmcache_pvscan_duplicate_check(cmd);
|
|
|
d7c356 |
+ if (lvmcache_found_duplicate_pvs()) {
|
|
|
d7c356 |
+ log_warn("WARNING: Scan found duplicate PVs.");
|
|
|
d7c356 |
+ return 0;
|
|
|
d7c356 |
+ }
|
|
|
d7c356 |
+
|
|
|
d7c356 |
/*
|
|
|
d7c356 |
* If lvmetad is disabled, and no lvm1 metadata was seen and no
|
|
|
d7c356 |
* duplicate PVs were seen, then re-enable lvmetad.
|
|
|
d7c356 |
diff --git a/tools/pvscan.c b/tools/pvscan.c
|
|
|
d7c356 |
index cdccfb5..a5e01b3 100644
|
|
|
d7c356 |
--- a/tools/pvscan.c
|
|
|
d7c356 |
+++ b/tools/pvscan.c
|
|
|
d7c356 |
@@ -381,7 +381,7 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
|
|
|
d7c356 |
all_vgs = 1;
|
|
|
d7c356 |
goto activate;
|
|
|
d7c356 |
}
|
|
|
d7c356 |
-
|
|
|
d7c356 |
+
|
|
|
d7c356 |
/*
|
|
|
d7c356 |
* FIXME: when specific devs are named, we generally don't want to scan
|
|
|
d7c356 |
* any other devs, but if lvmetad is not yet populated, the first
|
|
|
d7c356 |
@@ -390,11 +390,10 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
|
|
|
d7c356 |
* never scan any devices other than those specified.
|
|
|
d7c356 |
*/
|
|
|
d7c356 |
if (!lvmetad_token_matches(cmd)) {
|
|
|
d7c356 |
- log_verbose("Scanning all devices to initialize lvmetad.");
|
|
|
d7c356 |
-
|
|
|
d7c356 |
if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, 0)) {
|
|
|
d7c356 |
- log_warn("WARNING: Not using lvmetad because cache update failed.");
|
|
|
d7c356 |
- lvmetad_make_unused(cmd);
|
|
|
d7c356 |
+ log_warn("WARNING: Not updating lvmetad because cache update failed.");
|
|
|
d7c356 |
+ ret = ECMD_FAILED;
|
|
|
d7c356 |
+ goto out;
|
|
|
d7c356 |
}
|
|
|
d7c356 |
if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
|
|
|
d7c356 |
log_warn("WARNING: Not using lvmetad because %s.", reason);
|