master - archives: Preserve format type in file.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4e6f3e5162e06de09c38e360cbd1d348939ad7f0 Commit: 4e6f3e5162e06de09c38e360cbd1d348939ad7f0 Parent: 24774959221ab75038c336074470108a0727e672 Author: Alasdair G Kergon <[email protected]> AuthorDate: Wed Mar 4 00:30:26 2015 +0000 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Wed Mar 4 00:30:26 2015 +0000
archives: Preserve format type in file.
format_text processes both lvm2 on-disk metadata and metadata read from other sources such as backup files. Add original_fmt field to retain the format type of the original metadata.
Before this patch, /etc/lvm/archives would contain backups of lvm1 metadata with format = "lvm2" unless the source was lvm1 on-disk metadata.
--- WHATS_NEW | 1 + lib/format_text/export.c | 9 +++++++-- lib/format_text/import_vsn1.c | 9 ++++++++- lib/metadata/vg.h | 1 + 4 files changed, 17 insertions(+), 3 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.117 - ==================================== + Preserve original format type field when processing backup files. Implement status action for lvm2-monitor initscript to display monitored LVs. Allow lvchange -p to change kernel state only if metadata state differs. Fix incorrect persistent .cache after report with label fields only (2.02.106).
lib/format_text/export.c +7 -2
@@ -393,6 +393,7 @@ static int _out_tags(struct formatter *f, struct dm_list *tagsl)static int _print_vg (struct formatter *f,struct volume_group *vg) {char buffer[4096 ]; +const struct format_type *fmt =NULL ;if (!id_write_format (&vg->id, buffer,sizeof (buffer))) return_0;
@@ -401,8 +402,12 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)outf (f,"seqno = %u" , vg->seqno); -if (vg->fid && vg->fid->fmt) -outfc (f,"# informational" ,"format = \"%s\"" , vg->fid->fmt->name); +if (vg->original_fmt) + fmt = vg->original_fmt; +else if (vg->fid) + fmt = vg->fid->fmt; +if (fmt) +outfc (f,"# informational" ,"format = \"%s\"" , fmt->name);if (!_print_flag_config (f, vg->status,VG_FLAGS )) return_0;
lib/format_text/import_vsn1.c +8 -1
@@ -733,7 +733,7 @@ static struct volume_group *_read_vg(struct format_instance *fid, {const struct dm_config_node *vgn;const struct dm_config_value *cv; -const char *str; +const char *str, *format_str;struct volume_group *vg;struct dm_hash_table *pv_hash =NULL , *lv_hash =NULL ;unsigned scan_done_once = use_cached_pvs;
@@ -775,6 +775,13 @@ static struct volume_group *_read_vg(struct format_instance *fid, vgn = vgn->child; +/* A backup file might be a backup of a different format */ +if (dm_config_get_str (vgn,"format" , &format_str) && + !(vg->original_fmt =get_format_by_name (fid->fmt->cmd, format_str))) { +log_error ("Unrecognised format %s for volume group %s." , format_str, vg->name); + goto bad; + } +if (dm_config_get_str (vgn,"system_id" , &str))strncpy (system_id, str,NAME_LEN );
lib/metadata/vg.h +1 -0
@@ -44,6 +44,7 @@ struct volume_group {struct cmd_context *cmd;struct dm_pool *vgmem;struct format_instance *fid; +const struct format_type *original_fmt;/* Set when processing backup files */ struct lvmcache_vginfo *vginfo;struct dm_list *cmd_vgs;/* List of wanted/locked and opened VGs */ uint32_t cmd_missing_vgs;/* Flag marks missing VG */