char *write_buf; /* buffer containing metadata text to write to disk */
uint32_t write_buf_size; /* mem size of write_buf, increases in 64K multiples */
uint32_t new_metadata_size; /* size of text metadata in buf */
+ unsigned preserve:1;
};
+void preserve_text_fidtc(struct volume_group *vg)
+{
+ struct format_instance *fid = vg->fid;
+ struct text_fid_context *fidtc = (struct text_fid_context *)fid->private;
+
+ if (fidtc)
+ fidtc->preserve = 1;
+}
+
+void free_text_fidtc(struct volume_group *vg)
+{
+ struct format_instance *fid = vg->fid;
+ struct text_fid_context *fidtc = (struct text_fid_context *)fid->private;
+
+ if (!fidtc)
+ return;
+
+ fidtc->preserve = 0;
+
+ if (fidtc->write_buf)
+ free(fidtc->write_buf);
+ fidtc->write_buf = NULL;
+ fidtc->write_buf_size = 0;
+ fidtc->new_metadata_size = 0;
+}
+
int rlocn_is_ignored(const struct raw_locn *rlocn)
{
return (rlocn->flags & RAW_LOCN_IGNORED ? 1 : 0);
r = 1;
out:
- if (!precommit) {
+ if (!precommit && !fidtc->preserve) {
free(fidtc->write_buf);
fidtc->write_buf = NULL;
fidtc->write_buf_size = 0;
int text_wipe_outdated_pv_mda(struct cmd_context *cmd, struct device *dev,
struct metadata_area *mda);
+void preserve_text_fidtc(struct volume_group *vg);
+void free_text_fidtc(struct volume_group *vg);
+
#endif
*/
#include "tools.h"
+#include "lib/format_text/format-text.h"
/*
* TODO: we cannot yet repair corruption in label_header, pv_header/locations,
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;
*/
vg_write_commit_bad_mdas(cmd, vg);
+ /*
+ * Now free the metadata buffer that was
+ * preserved above.
+ */
+ free_text_fidtc(vg);
+
return 1;
}