All of lore.kernel.org
 help / color / mirror / Atom feed
* master - vgremove: fix force remove on devs with damaged metadata
@ 2018-04-23 13:50 David Teigland
  0 siblings, 0 replies; 2+ messages in thread
From: David Teigland @ 2018-04-23 13:50 UTC (permalink / raw)
  To: lvm-devel

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6e580465b50edcd5fef0eb95180a620cb785d835
Commit:        6e580465b50edcd5fef0eb95180a620cb785d835
Parent:        37471bb4777f3f407d2cd942995b45c326ea221a
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Wed Feb 14 14:47:28 2018 -0600
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500

vgremove: fix force remove on devs with damaged metadata

The improved detection of bad metadata when scanning
(where errors were ignored before) means we now have to
override some errors when forcibly erasing damaged metadata.
---
 lib/format_text/format-text.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index f33451f..8a42213 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -865,12 +865,28 @@ static int _vg_remove_raw(struct format_instance *fid, struct volume_group *vg,
 	int r = 0;
 	int noprecommit = 0;
 
-	if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area, mda_is_primary(mda))))
-		goto_out;
+	if (!(mdah = dm_pool_alloc(fid->fmt->cmd->mem, MDA_HEADER_SIZE))) {
+		log_error("struct mda_header allocation failed");
+		return 0;
+	}
 
-	if (!(rlocn = _read_metadata_location_vg(&mdac->area, mdah, mda_is_primary(mda), vg->name, &noprecommit))) {
+	/*
+	 * FIXME: what's the point of reading the mda_header and metadata,
+	 * since we zero the rlocn fields whether we can read them or not.
+	 */
+
+	if (!_raw_read_mda_header(mdah, &mdac->area, mda_is_primary(mda))) {
+		log_warn("WARNING: Removing metadata location on %s with bad mda header.",
+			  dev_name(mdac->area.dev));
 		rlocn = &mdah->raw_locns[0];
 		mdah->raw_locns[1].offset = 0;
+	} else {
+		if (!(rlocn = _read_metadata_location_vg(&mdac->area, mdah, mda_is_primary(mda), vg->name, &noprecommit))) {
+			log_warn("WARNING: Removing metadata location on %s with bad metadata.",
+				 dev_name(mdac->area.dev));
+			rlocn = &mdah->raw_locns[0];
+			mdah->raw_locns[1].offset = 0;
+		}
 	}
 
 	rlocn->offset = 0;



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* master - vgremove: fix force remove on devs with damaged metadata
@ 2018-04-23 13:54 David Teigland
  0 siblings, 0 replies; 2+ messages in thread
From: David Teigland @ 2018-04-23 13:54 UTC (permalink / raw)
  To: lvm-devel

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6e580465b50edcd5fef0eb95180a620cb785d835
Commit:        6e580465b50edcd5fef0eb95180a620cb785d835
Parent:        37471bb4777f3f407d2cd942995b45c326ea221a
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Wed Feb 14 14:47:28 2018 -0600
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500

vgremove: fix force remove on devs with damaged metadata

The improved detection of bad metadata when scanning
(where errors were ignored before) means we now have to
override some errors when forcibly erasing damaged metadata.
---
 lib/format_text/format-text.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index f33451f..8a42213 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -865,12 +865,28 @@ static int _vg_remove_raw(struct format_instance *fid, struct volume_group *vg,
 	int r = 0;
 	int noprecommit = 0;
 
-	if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area, mda_is_primary(mda))))
-		goto_out;
+	if (!(mdah = dm_pool_alloc(fid->fmt->cmd->mem, MDA_HEADER_SIZE))) {
+		log_error("struct mda_header allocation failed");
+		return 0;
+	}
 
-	if (!(rlocn = _read_metadata_location_vg(&mdac->area, mdah, mda_is_primary(mda), vg->name, &noprecommit))) {
+	/*
+	 * FIXME: what's the point of reading the mda_header and metadata,
+	 * since we zero the rlocn fields whether we can read them or not.
+	 */
+
+	if (!_raw_read_mda_header(mdah, &mdac->area, mda_is_primary(mda))) {
+		log_warn("WARNING: Removing metadata location on %s with bad mda header.",
+			  dev_name(mdac->area.dev));
 		rlocn = &mdah->raw_locns[0];
 		mdah->raw_locns[1].offset = 0;
+	} else {
+		if (!(rlocn = _read_metadata_location_vg(&mdac->area, mdah, mda_is_primary(mda), vg->name, &noprecommit))) {
+			log_warn("WARNING: Removing metadata location on %s with bad metadata.",
+				 dev_name(mdac->area.dev));
+			rlocn = &mdah->raw_locns[0];
+			mdah->raw_locns[1].offset = 0;
+		}
 	}
 
 	rlocn->offset = 0;



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-23 13:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-23 13:50 master - vgremove: fix force remove on devs with damaged metadata David Teigland
2018-04-23 13:54 David Teigland

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.