From ed21b11576a4fd09e2afaae4aa5d21cd35d5aaae Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 27 Apr 2016 15:06:43 -0500 Subject: pvscan: fix errors for single dev scan while lvmetad is disabled While lvmetad was disabled, 'pvscan --cache dev' would produce confusing error messages. --- tools/pvscan.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/pvscan.c b/tools/pvscan.c index d93773a1c..50753fdc0 100644 --- a/tools/pvscan.c +++ b/tools/pvscan.c @@ -257,6 +257,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv) int ret = ECMD_PROCESSED; struct device *dev; const char *pv_name; + const char *reason = NULL; int32_t major = -1; int32_t minor = -1; int devno_args = 0; @@ -308,6 +309,18 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv) goto out; } + /* + * When lvmetad is disabled, all devices need to be rescanned, + * i.e. the !argc case above, pvscan --cache. + */ + if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) { + log_warn("WARNING: Not using lvmetad because %s.", reason); + log_warn("WARNING: Rescan all devices to update lvmetad cache (pvscan --cache)."); + log_error("Failed to update cache."); + ret = ECMD_FAILED; + goto out; + } + /* * FIXME: when specific devs are named, we generally don't * want to scan any other devs, but if lvmetad is not yet -- cgit v1.2.1