All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Teigland <teigland@sourceware.org>
To: lvm-devel@redhat.com
Subject: master - lvmetad: more fixes related to bcache
Date: Mon, 23 Apr 2018 09:55:55 -0400	[thread overview]
Message-ID: <201804231355.w3NDtt8t001852@lists01.pubmisc.prod.ext.phx2.redhat.com> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a9b0aa5c178a6d8bb708ed35f833c648f7437ae3
Commit:        a9b0aa5c178a6d8bb708ed35f833c648f7437ae3
Parent:        e351f8bc66d49fecaa0ab78f8413d50a4674604a
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Fri Mar 9 11:39:12 2018 -0600
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Fri Apr 20 11:22:48 2018 -0500

lvmetad: more fixes related to bcache

Need to open devs prior to bcache io.
---
 lib/label/label.c       |   25 +++++++++++++++++--------
 lib/metadata/metadata.c |   12 ++++++++++++
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/lib/label/label.c b/lib/label/label.c
index 9401067..14a7e90 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -515,7 +515,7 @@ static int _scan_list(struct dm_list *devs, int *failed)
 		bb = NULL;
 
 		if (!bcache_get(scan_bcache, devl->dev->bcache_fd, 0, 0, &bb)) {
-			log_error("Scan failed to read %s.", dev_name(devl->dev));
+			log_debug_devs("Scan failed to read %s.", dev_name(devl->dev));
 			scan_failed_count++;
 			scan_failed = 1;
 			lvmcache_del_dev(devl->dev);
@@ -525,7 +525,7 @@ static int _scan_list(struct dm_list *devs, int *failed)
 			ret = _process_block(devl->dev, bb, &is_lvm_device);
 
 			if (!ret && is_lvm_device) {
-				log_error("Scan failed to process %s", dev_name(devl->dev));
+				log_debug_devs("Scan failed to process %s", dev_name(devl->dev));
 				scan_failed_count++;
 				scan_failed = 1;
 				lvmcache_del_dev(devl->dev);
@@ -893,8 +893,11 @@ bool dev_read_bytes(struct device *dev, off_t start, size_t len, void *data)
 	}
 
 	if (dev->bcache_fd <= 0) {
-		log_error("dev_read_bytes %s with invalid fd %d", dev_name(dev), dev->bcache_fd);
-		return false;
+		/* This is not often needed, perhaps only with lvmetad. */
+		if (!label_scan_open(dev)) {
+			log_error("dev_read_bytes %s cannot open dev", dev_name(dev));
+			return false;
+		}
 	}
 
 	if (!bcache_read_bytes(scan_bcache, dev->bcache_fd, start, len, data)) {
@@ -924,8 +927,11 @@ bool dev_write_bytes(struct device *dev, off_t start, size_t len, void *data)
 	}
 
 	if (dev->bcache_fd <= 0) {
-		log_error("dev_write_bytes %s with invalid fd %d", dev_name(dev), dev->bcache_fd);
-		return false;
+		/* This is not often needed, perhaps only with lvmetad. */
+		if (!label_scan_open(dev)) {
+			log_error("dev_write_bytes %s cannot open dev", dev_name(dev));
+			return false;
+		}
 	}
 
 	if (!bcache_write_bytes(scan_bcache, dev->bcache_fd, start, len, data)) {
@@ -954,8 +960,11 @@ bool dev_write_zeros(struct device *dev, off_t start, size_t len)
 	}
 
 	if (dev->bcache_fd <= 0) {
-		log_error("dev_write_zeros %s with invalid fd %d", dev_name(dev), dev->bcache_fd);
-		return false;
+		/* This is not often needed, perhaps only with lvmetad. */
+		if (!label_scan_open(dev)) {
+			log_error("dev_write_zeros %s cannot open dev", dev_name(dev));
+			return false;
+		}
 	}
 
 	if (!bcache_write_zeros(scan_bcache, dev->bcache_fd, start, len)) {
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 462c391..8cb06be 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3809,6 +3809,18 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
 				release_vg(correct_vg);
 				return_NULL;
 			}
+
+			/*
+		 	 * When a command reads the vg from lvmetad, and then
+			 * writes the vg, the write path does some disk reads
+		 	 * of the devs.
+		 	 * FIXME: when a command is going to write the vg,
+		 	 * we should just read the vg from disk entirely
+		 	 * and skip reading it from lvmetad.
+		 	 */
+			dm_list_iterate_items(pvl, &correct_vg->pvs)
+				label_scan_open(pvl->pv->dev);
+
 		}
 
 		return correct_vg;



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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23 13:55 David Teigland [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-04-23 13:52 master - lvmetad: more fixes related to bcache 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=201804231355.w3NDtt8t001852@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.