master - move wipe_outdated_pvs to vg_write
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ab61a6d85da4e4f1d540e40ebac77999bf3c9a57 Commit: ab61a6d85da4e4f1d540e40ebac77999bf3c9a57 Parent: 45b164f62cae25da3ac4b9f0d4f87ecaee1575fa Author: David Teigland <[email protected]> AuthorDate: Wed Feb 6 12:32:26 2019 -0600 Committer: David Teigland <[email protected]> CommitterDate: Fri Jun 7 15:54:04 2019 -0500
move wipe_outdated_pvs to vg_write
and implement it based on a device, not based on a pv struct (which is not available when the device is not a part of the vg.)
currently only the vgremove command wipes outdated pvs until more advanced recovery is added in a subsequent commit
--- lib/commands/toolcontext.h | 1 + lib/format_text/format-text.c | 33 +++++++++++ lib/format_text/format-text.h | 3 + lib/metadata/metadata.c | 123 +++++++++++++++++++++++------------------ tools/vgremove.c | 2 + 5 files changed, 109 insertions(+), 53 deletions(-)
lib/commands/toolcontext.h +1 -0
@@ -179,6 +179,7 @@ struct cmd_context { unsigned use_hints:1; /* if hints are enabled this cmd can use them */ unsigned pvscan_recreate_hints:1; /* enable special case hint handling for pvscan --cache */ unsigned scan_lvs:1; + unsigned wipe_outdated_pvs:1;/* * Devices and filtering.
lib/format_text/format-text.c +33 -0
@@ -2463,3 +2463,36 @@ bad:return NULL ; } + +int text_wipe_outdated_pv_mda (struct cmd_context *cmd,struct device *dev, +struct metadata_area *mda) +{ +struct mda_context *mdac = mda->metadata_locn; +uint64_t start_byte = mdac->area.start; +struct mda_header *mdab; +struct raw_locn *rlocn_slot0; +struct raw_locn *rlocn_slot1; +uint32_t bad_fields =0 ; + +if (!(mdab =raw_read_mda_header (cmd->fmt, &mdac->area,mda_is_primary (mda),0 , &bad_fields))) { +log_error ("Failed to read outdated pv mda header on %s" ,dev_name (dev)); +return 0 ; + } + + rlocn_slot0 = &mdab->raw_locns[0 ]; + rlocn_slot1 = &mdab->raw_locns[1 ]; + + rlocn_slot0->offset =0 ; + rlocn_slot0->size =0 ; + rlocn_slot0->checksum =0 ; + rlocn_slot1->offset =0 ; + rlocn_slot1->size =0 ; + rlocn_slot1->checksum =0 ; + +if (!_raw_write_mda_header (cmd->fmt, dev,mda_is_primary (mda), start_byte, mdab)) { +log_error ("Failed to write outdated pv mda header on %s" ,dev_name (dev)); +return 0 ; + } + +return 1 ; +}
lib/format_text/format-text.h +3 -0
@@ -77,4 +77,7 @@ struct data_area_list { struct disk_locn disk_locn; }; +int text_wipe_outdated_pv_mda (struct cmd_context *cmd,struct device *dev, +struct metadata_area *mda); +#endif
lib/metadata/metadata.c +70 -53
157 lines not on this page · raw message
tools/vgremove.c +2 -0
@@ -99,6 +99,8 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)clear_hint_file (cmd); + cmd->wipe_outdated_pvs =1 ; + cmd->handles_missing_pvs =1 ; ret = process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE, 0,