From a0c848d4e4a9b53fa1f9cc7a8330fea6b23c07a8 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 4 Mar 2019 14:25:53 -0600 Subject: [PATCH] pvscan: ignore online for unused PV If an unused PV comes online, ignore it from pvscan --cache. --- tools/pvscan.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/pvscan.c b/tools/pvscan.c index 389aafafc..c48453136 100644 --- a/tools/pvscan.c +++ b/tools/pvscan.c @@ -644,6 +644,8 @@ static int _online_pvscan_one(struct cmd_context *cmd, struct device *dev, const struct format_type *fmt; /* Create a dummy instance. */ struct format_instance_ctx fic = { .type = 0 }; + uint32_t ext_version; + uint32_t ext_flags; int ret = 0; log_debug("pvscan metadata from dev %s", dev_name(dev)); @@ -667,6 +669,14 @@ static int _online_pvscan_one(struct cmd_context *cmd, struct device *dev, return 1; } + ext_version = lvmcache_ext_version(info); + ext_flags = lvmcache_ext_flags(info); + + if ((ext_version >= 2) && !(ext_flags & PV_EXT_USED)) { + log_print("pvscan[%d] PV %s not used.", getpid(), dev_name(dev)); + return 1; + } + fmt = lvmcache_fmt(info); baton.cmd = cmd;