summaryrefslogtreecommitdiff
path: root/tools/vgck.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2019-10-08 14:36:55 -0500
committerDavid Teigland <teigland@redhat.com>2019-10-11 12:57:32 -0500
commitd6ffc990523468e46ae03a462ef1ec73067f9934 (patch)
tree679c23c76bd4dd0e52187a486decfa08140f23cd /tools/vgck.c
parentfe16d296b058333fddd5102afbebf95a18f85468 (diff)
downloadlvm2-d6ffc990523468e46ae03a462ef1ec73067f9934.tar.gz
vgck: fix updatemetadata writing different descriptions
vgck --updatemetadata would write the same correct metadata to good mdas, and then to bad mdas, but the sequence of vg_write/vg_commit calls betwen good and bad mdas could cause a different description field to be generated for good/bad mdas. (The description field describing the command was recently included in the ondisk copy of the metadata text.)
Diffstat (limited to 'tools/vgck.c')
-rw-r--r--tools/vgck.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/vgck.c b/tools/vgck.c
index 46ad59499..4e797e717 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -14,6 +14,7 @@
*/
#include "tools.h"
+#include "lib/format_text/format-text.h"
/*
* TODO: we cannot yet repair corruption in label_header, pv_header/locations,
@@ -39,6 +40,14 @@ static int _update_metadata_single(struct cmd_context *cmd __attribute__((unused
return 0;
}
+ /*
+ * Prevent vg_commit from freeing the metadata
+ * buffer that vg_write wrote to disk so that
+ * vg_write_commit_bad_mdas() can use the same
+ * metadata buffer to write to the bad mdas.
+ */
+ preserve_text_fidtc(vg);
+
if (!vg_commit(vg)) {
log_error("Failed to commit VG.");
return 0;
@@ -53,6 +62,12 @@ static int _update_metadata_single(struct cmd_context *cmd __attribute__((unused
*/
vg_write_commit_bad_mdas(cmd, vg);
+ /*
+ * Now free the metadata buffer that was
+ * preserved above.
+ */
+ free_text_fidtc(vg);
+
return 1;
}