master - systemid: Init and merge lvm2 and lvm1 fields.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3562b5ab39b32bd27c81f57185e397facb7690f5 Commit: 3562b5ab39b32bd27c81f57185e397facb7690f5 Parent: dcba4781eaa5545981a831c3c27374d3fce085fe Author: Alasdair G Kergon <[email protected]> AuthorDate: Wed Mar 4 01:00:51 2015 +0000 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Wed Mar 4 01:00:51 2015 +0000
systemid: Init and merge lvm2 and lvm1 fields.
Use system_id field in preference to lvm1_system_id. Initialise both for now.
--- lib/display/display.c | 2 +- lib/format1/import-export.c | 4 +++- lib/format_text/export.c | 4 +++- lib/format_text/import_vsn1.c | 2 -- lib/metadata/vg.c | 5 +++++ lib/report/report.c | 2 +- tools/toollib.c | 5 +++-- tools/vgchange.c | 3 +++ 8 files changed, 19 insertions(+), 8 deletions(-)
lib/display/display.c +1 -1
@@ -695,7 +695,7 @@ void vgdisplay_full(const struct volume_group *vg)log_print ("--- Volume group ---" );log_print ("VG Name %s" , vg->name); -log_print ("System ID %s" , vg->system_id); +log_print ("System ID %s" , (vg->system_id && *vg->system_id) ? vg->system_id : vg->lvm1_system_id ? :"" );log_print ("Format %s" , vg->fid->fmt->name);if (vg->fid->fmt->features &FMT_MDAS ) { log_print("Metadata Areas %d",
lib/format1/import-export.c +3 -1
@@ -156,8 +156,10 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute__((unused }/* Preserve existing system_id if it exists */ -if (vg && *vg->lvm1_system_id) +if (vg && vg->lvm1_system_id && *vg->lvm1_system_id)strncpy ((char *)pvd->system_id, vg->lvm1_system_id,sizeof (pvd->system_id)); +else if (vg && vg->system_id && *vg->system_id) +strncpy ((char *)pvd->system_id, vg->system_id,sizeof (pvd->system_id));/* Is VG already exported or being exported? */ if (vg &&vg_is_exported (vg)) {
lib/format_text/export.c +3 -1
@@ -414,9 +414,11 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)if (!_out_tags (f, &vg->tags)) return_0; - +if (vg->system_id && *vg->system_id)outf (f,"system_id = \"%s\"" , vg->system_id); +else if (vg->lvm1_system_id && *vg->lvm1_system_id) +outf (f,"system_id = \"%s\"" , vg->lvm1_system_id);outsize (f, (uint64_t ) vg->extent_size,"extent_size = %u" , vg->extent_size);
lib/format_text/import_vsn1.c +0 -2
@@ -883,8 +883,6 @@ static struct volume_group *_read_vg(struct format_instance *fid,dm_hash_destroy (pv_hash);dm_hash_destroy (lv_hash); -/* FIXME Determine format type from file contents */ -/* eg Set to instance of fmt1 here if reading a format1 backup? */ vg_set_fid (vg, fid);/*
lib/metadata/vg.c +5 -0
@@ -47,6 +47,8 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,return NULL ; } + vg->system_id ="" ; + vg->cmd = cmd; vg->vgmem = vgmem; vg->alloc =ALLOC_NORMAL ;
@@ -627,6 +629,9 @@ int vg_set_system_id(struct volume_group *vg, const char *system_id)return 0 ; } +if (vg->lvm1_system_id) + *vg->lvm1_system_id ='\0' ; +return 1 ; }
lib/report/report.c +1 -1
@@ -989,7 +989,7 @@ static int _vgsystemid_disp(struct dm_report *rh, struct dm_pool *mem, const void *data, void *private) { const struct volume_group *vg = (const struct volume_group *) data; -const char *repstr = vg->system_id ? : vg->lvm1_system_id ? :"" ; +const char *repstr = (vg->system_id && *vg->system_id) ? vg->system_id : vg->lvm1_system_id ? :"" ;return _string_disp (rh, mem, field, &repstr, private); }
tools/toollib.c +3 -2
@@ -200,8 +200,9 @@ static int _ignore_vg(struct volume_group *vg, const char *vg_name,*/ if (read_error &FAILED_SYSTEMID ) {if (arg_vgnames &&str_list_match_item (arg_vgnames, vg->name)) { -log_error ("Cannot access VG %s with system ID %s with local system ID %s." , - vg->name, vg->system_id, vg->cmd->system_id); +log_error ("Cannot access VG %s with system ID %s with %slocal system ID%s%s." , + vg->name, vg->system_id, vg->cmd->system_id ?"" :"unknown " , + vg->cmd->system_id ?" " :"" , vg->cmd->system_id ? vg->cmd->system_id :"" );return 1 ; }else { read_error &= ~FAILED_SYSTEMID ;/* Check for other errors */
tools/vgchange.c +3 -0
@@ -575,6 +575,9 @@ static int _vgchange_system_id(struct cmd_context *cmd, struct volume_group *vg) vg->name, vg->system_id, system_id); vg->system_id = system_id; + +if (vg->lvm1_system_id) + *vg->lvm1_system_id ='\0' ;return 1 ; }