Skip to contentSkip to conversation

master - vgck --updatemetadata is a new command

PATCH David Teigland 1 participant 1 message Jun 7, 2019

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=47effdc025384cef5b3235a9c4b90e7fd74d68a4
Commit:        47effdc025384cef5b3235a9c4b90e7fd74d68a4
Parent:        de3d3b11f493a89ebee2eab7efae70d33face954
Author:        David Teigland <[email protected]>
AuthorDate:    Wed Feb 6 13:39:41 2019 -0600
Committer:     David Teigland <[email protected]>
CommitterDate: Fri Jun 7 15:54:04 2019 -0500

vgck --updatemetadata is a new command

uses vg_write to correct more common or less severe issues, and also adds the ability to repair some metadata corruption that couldn't be handled previously.

---
 lib/format_text/text_label.c     |    3 +
 lib/metadata/metadata-exported.h |    2 +
 lib/metadata/metadata.c          |   83 ++++++++++++++++++++++++++++++++++++++
 lib/metadata/metadata.h          |    1 +
 tools/args.h                     |    3 +
 tools/command-lines.in           |    5 ++
 tools/commands.h                 |    2 +-
 tools/vgck.c                     |   54 ++++++++++++++++++++++++
 8 files changed, 152 insertions(+), 1 deletions(-)
lib/format_text/text_label.c +3 -0
index 42184de..1702934 100644
@@ -341,6 +341,9 @@ static int _read_mda_header_and_metadata(struct metadata_area *mda, void *baton)
 		goto fail;
 	}
 
+	if (mda)
+		mda->header_start = mdah->start;
+
 	mda_set_ignored(mda, rlocn_is_ignored(mdah->raw_locns));
 
 	if (mda_is_ignored(mda)) {
lib/metadata/metadata-exported.h +2 -0
index 219c784..3af8906 100644
@@ -1381,4 +1381,6 @@ int lv_on_pmem(struct logical_volume *lv);
 
 int vg_is_foreign(struct volume_group *vg);
 
+void vg_write_commit_bad_mdas(struct cmd_context *cmd, struct volume_group *vg);
+
 #endif
lib/metadata/metadata.c +83 -0

86 lines not on this page · raw message

lib/metadata/metadata.h +1 -0
index 6d158fe..63ee4a6 100644
@@ -185,6 +185,7 @@ struct metadata_area {
 	struct metadata_area_ops *ops;
 	void *metadata_locn;
 	uint32_t status;
+	uint64_t header_start; /* mda_header.start */
 	int mda_num;
 	uint32_t bad_fields; /* BAD_MDA_ flags are set to indicate errors found when reading */
 	uint32_t ignore_bad_fields; /* BAD_MDA_ flags are set to indicate errors to ignore */
tools/args.h +3 -0
index 69f7e07..e972c7d 100644
@@ -1393,6 +1393,9 @@ arg(thin_ARG, 'T', "thin", 0, 0, 0,
     "See --type thin, --type thin-pool, and --virtualsize.\n"
     "See \\fBlvmthin\\fP(7) for more information about LVM thin provisioning.\n")
 
+arg(updatemetadata_ARG, '\0', "updatemetadata", 0, 0, 0,
+    "Update VG metadata to correct problems.\n")
+
 arg(uuid_ARG, 'u', "uuid", 0, 0, 0,
     "#pvchange\n"
     "Generate new random UUID for specified PVs.\n"
tools/command-lines.in +5 -0
index 03dbf57..4601239 100644
@@ -1624,6 +1624,11 @@ vgck
 OO: --reportformat ReportFmt
 OP: VG|Tag ...
 ID: vgck_general
+DESC: Read and display information about a VG.
+
+vgck --updatemetadata VG
+ID: vgck_update_metadata
+DESC: Rewrite VG metadata to correct problems.
 
 ---
 
tools/commands.h +1 -1
index 612182b..4006fab 100644
@@ -177,7 +177,7 @@ xx(vgchange,
 
 xx(vgck,
    "Check the consistency of volume group(s)",
-   ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | ALLOW_HINTS)
+   ALL_VGS_IS_DEFAULT | LOCKD_VG_SH)
 
 xx(vgconvert,
    "Change volume group metadata format",
tools/vgck.c +54 -0

66 lines not on this page · raw message