All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Teigland <teigland@sourceware.org>
To: lvm-devel@redhat.com
Subject: master - clvm: rescan when VG or PV not found
Date: Mon, 23 Apr 2018 09:56:51 -0400	[thread overview]
Message-ID: <201804231356.w3NDupk8002500@lists01.pubmisc.prod.ext.phx2.redhat.com> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1409c4a1c20319845171b91edb6310e25ae81792
Commit:        1409c4a1c20319845171b91edb6310e25ae81792
Parent:        c42a18d372f314aa51d9d7877342f1d78fd68973
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Fri Apr 20 16:09:49 2018 -0500
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Fri Apr 20 16:09:49 2018 -0500

clvm: rescan when VG or PV not found

Rescan devices to update lvmcache content when
clvmd vg_read doesn't find a VG or PV.
---
 lib/metadata/metadata.c |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 685c589..2df9abe 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4585,6 +4585,7 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
 	if (!(vgname = lvmcache_vgname_from_vgid(cmd->mem, vgid))) {
 		log_debug_metadata("Reading VG by vgid %.8s no VG name found, retrying.", vgid);
 		lvmcache_destroy(cmd, 0, 0);
+		label_scan_destroy(cmd);
 		lvmcache_label_scan(cmd);
 	}
 
@@ -4597,14 +4598,33 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
 
 	label_scan_setup_bcache();
 
-	if ((vg = _vg_read(cmd, vgname, vgid, warn_flags, &consistent, precommitted))) {
-		/* Does it matter if consistent is 0 or 1? */
-		label_scan_destroy(cmd);
-		return vg;
+	if (!(vg = _vg_read(cmd, vgname, vgid, warn_flags, &consistent, precommitted))) {
+		log_error("Rescan devices to look for missing VG.");
+		goto scan;
+	}
+
+	if (vg_missing_pv_count(vg)) {
+		log_error("Rescan devices to look for missing PVs.");
+		release_vg(vg);
+		goto scan;
 	}
 
+	label_scan_destroy(cmd); /* drop bcache to close devs, keep lvmcache */
+	return vg;
+
+ scan:
+	lvmcache_destroy(cmd, 0, 0);
 	label_scan_destroy(cmd);
+	lvmcache_label_scan(cmd);
+
+	if (!(vg = _vg_read(cmd, vgname, vgid, warn_flags, &consistent, precommitted)))
+		goto fail;
+
+	label_scan_destroy(cmd); /* drop bcache to close devs, keep lvmcache */
+	return vg;
 
+ fail:
+	label_scan_destroy(cmd); /* drop bache to close devs, keep lvmcache */
 	log_debug_metadata("Reading VG by vgid %.8s not found.", vgid);
 	return NULL;
 }



             reply	other threads:[~2018-04-23 13:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23 13:56 David Teigland [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-04-23 13:53 master - clvm: rescan when VG or PV not found David Teigland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201804231356.w3NDupk8002500@lists01.pubmisc.prod.ext.phx2.redhat.com \
    --to=teigland@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.