lvm2/bug-1158861_07-vgck-let-updatemetadata-repair-mismatched-metadata.patch

119 lines
4.6 KiB
Diff
Raw Normal View History

Accepting request 755483 from home:hmzhao:branches:openSUSE:Factory - backport patches for lvm2 to avoid software abnormal work (bsc#1158861) + bug-1158861_01-config-remove-filter-typo.patch + bug-1158861_02-config-Fix-default-option-which-makes-no-sense.patch + bug-1158861_03-vgchange-don-t-fail-monitor-command-if-vg-is-exporte.patch + bug-1158861_04-fix-duplicate-pv-size-check.patch + bug-1158861_05-hints-fix-copy-of-filter.patch + bug-1158861_06-fix-segfault-for-invalid-characters-in-vg-name.patch + bug-1158861_07-vgck-let-updatemetadata-repair-mismatched-metadata.patch + bug-1158861_08-hints-fix-mem-leaking-buffers.patch + bug-1158861_09-pvcreate-pvremove-fix-reacquiring-global-lock-after.patch - add necessary patches for passing lvm2 testsuite (bsc#1158628) + bug-1158628_01-tests-replaces-grep-q-usage.patch + bug-1158628_02-tests-fix-ra-checking.patch + bug-1158628_03-tests-simplify-some-var-settings.patch + bug-1158628-04-pvmove-correcting-read_ahead-setting.patch + bug-1158628_05-activation-add-synchronization-point.patch + bug-1158628_06-pvmove-add-missing-synchronization.patch + bug-1158628_07-activation-extend-handling-of-pending_delete.patch + bug-1158628_08-lv_manip-add-synchronizations.patch + bug-1158628_09-lvconvert-improve-validation-thin-and-cache-pool-con.patch + bug-1158628_10-thin-activate-layer-pool-aas-read-only-LV.patch + bug-1158628_11-tests-mdadm-stop-in-test-cleanup.patch + bug-1158628_12-test-increase-size-of-raid10-LV-allowing-tests-to-su.patch + bug-1158628_13-lvconvert-fix-return-value-when-zeroing-fails.patch + bug-1158628_14-tests-add-extra-settle.patch + bug-1158628_15-test-Fix-handling-leftovers-from-previous-tests.patch OBS-URL: https://build.opensuse.org/request/show/755483 OBS-URL: https://build.opensuse.org/package/show/Base:System/lvm2?expand=0&rev=260
2019-12-10 10:29:09 +01:00
From bd21736e8b082319e1a9a29e75badd906ee277f6 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 8 Oct 2019 14:44:24 -0500
Subject: [PATCH] vgck: let updatemetadata repair mismatched metadata
Let vgck --updatemetadata repair cases where different mdas
hold indepedently valid but unmatching copies of the metadata,
i.e. different text metadata checksums or text metadata sizes.
---
lib/cache/lvmcache.c | 1 +
lib/cache/lvmcache.h | 1 +
lib/format_text/text_label.c | 25 +++++++++++++++++++------
lib/metadata/metadata.c | 3 +++
lib/metadata/metadata.h | 1 +
5 files changed, 25 insertions(+), 6 deletions(-)
heming.zhao@suse.com NOTE:
lib/cache/lvmcache.h patch lines had been modified for patch happy.
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 316624fe52..f6e792459b 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1649,6 +1649,7 @@ int lvmcache_update_vgname_and_id(struct lvmcache_info *info, struct lvmcache_vg
vgsummary->mda_checksum, vgsummary->mda_size,
vginfo->mda_checksum, vginfo->mda_size);
vginfo->scan_summary_mismatch = true;
+ vgsummary->mismatch = 1;
return 0;
}
diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h
index 1401974be6..d614e5469e 100644
--- a/lib/cache/lvmcache.h
+++ b/lib/cache/lvmcache.h
@@ -63,6 +63,7 @@ struct lvmcache_vgsummary {
int mda_num; /* 1 = summary from mda1, 2 = summary from mda2 */
unsigned mda_ignored:1;
unsigned zero_offset:1;
+ unsigned mismatch:1; /* lvmcache sets if this summary differs from previous values */
};
int lvmcache_init(struct cmd_context *cmd);
diff --git a/lib/format_text/text_label.c b/lib/format_text/text_label.c
index 41276be731..246fb7b4ad 100644
--- a/lib/format_text/text_label.c
+++ b/lib/format_text/text_label.c
@@ -507,10 +507,17 @@ static int _text_read(struct labeller *labeller, struct device *dev, void *label
if (rv1 && !vgsummary.zero_offset && !vgsummary.mda_ignored) {
if (!lvmcache_update_vgname_and_id(info, &vgsummary)) {
/* I believe this is only an internal error. */
- log_warn("WARNING: Scanning %s mda1 failed to save internal summary.", dev_name(dev));
dm_list_del(&mda1->list);
- bad_fields |= BAD_MDA_INTERNAL;
+
+ /* Are there other cases besides mismatch and internal error? */
+ if (vgsummary.mismatch) {
+ log_warn("WARNING: Scanning %s mda1 found mismatch with other metadata.", dev_name(dev));
+ bad_fields |= BAD_MDA_MISMATCH;
+ } else {
+ log_warn("WARNING: Scanning %s mda1 failed to save internal summary.", dev_name(dev));
+ bad_fields |= BAD_MDA_INTERNAL;
+ }
mda1->bad_fields = bad_fields;
lvmcache_save_bad_mda(info, mda1);
mda1 = NULL;
@@ -550,11 +557,17 @@ static int _text_read(struct labeller *labeller, struct device *dev, void *label
if (rv2 && !vgsummary.zero_offset && !vgsummary.mda_ignored) {
if (!lvmcache_update_vgname_and_id(info, &vgsummary)) {
- /* I believe this is only an internal error. */
- log_warn("WARNING: Scanning %s mda2 failed to save internal summary.", dev_name(dev));
-
dm_list_del(&mda2->list);
- bad_fields |= BAD_MDA_INTERNAL;
+
+ /* Are there other cases besides mismatch and internal error? */
+ if (vgsummary.mismatch) {
+ log_warn("WARNING: Scanning %s mda2 found mismatch with other metadata.", dev_name(dev));
+ bad_fields |= BAD_MDA_MISMATCH;
+ } else {
+ log_warn("WARNING: Scanning %s mda2 failed to save internal summary.", dev_name(dev));
+ bad_fields |= BAD_MDA_INTERNAL;
+ }
+
mda2->bad_fields = bad_fields;
lvmcache_save_bad_mda(info, mda2);
mda2 = NULL;
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 39544e66a8..b09f4b35ed 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4518,6 +4518,9 @@ void vg_write_commit_bad_mdas(struct cmd_context *cmd, struct volume_group *vg)
* above.
*
* TEXT: general error related to text metadata, we can repair.
+ *
+ * MISMATCH: different values between instances of metadata,
+ * can repair.
*/
if (!mda->bad_fields ||
(mda->bad_fields & BAD_MDA_READ) ||
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 6516e627c0..ac18879b0b 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -179,6 +179,7 @@ struct metadata_area_ops {
#define BAD_MDA_MAGIC 0x00000020
#define BAD_MDA_VERSION 0x00000040
#define BAD_MDA_START 0x00000080
+#define BAD_MDA_MISMATCH 0x00000100 /* lvmcache found difference from prev metadata */
struct metadata_area {
struct dm_list list;
--
2.24.0