diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/args.h | 2 | ||||
-rw-r--r-- | tools/commands.h | 6 | ||||
-rw-r--r-- | tools/toollib.c | 21 | ||||
-rw-r--r-- | tools/vgchange.c | 69 | ||||
-rw-r--r-- | tools/vgcreate.c | 1 | ||||
-rw-r--r-- | tools/vgexport.c | 1 | ||||
-rw-r--r-- | tools/vgimport.c | 1 |
7 files changed, 86 insertions, 15 deletions
diff --git a/tools/args.h b/tools/args.h index 531148c95..8540b9a40 100644 --- a/tools/args.h +++ b/tools/args.h @@ -114,6 +114,8 @@ arg(split_ARG, '\0', "split", NULL, 0) arg(readonly_ARG, '\0', "readonly", NULL, 0) arg(atomic_ARG, '\0', "atomic", NULL, 0) arg(activationmode_ARG, '\0', "activationmode", string_arg, 0) +arg(systemid_ARG, '\0', "systemid", string_arg, 0) +arg(systemidsource_ARG, '\0', "systemidsource", string_arg, 0) /* Allow some variations */ diff --git a/tools/commands.h b/tools/commands.h index 2e99fb177..03a1f7bc6 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -954,7 +954,8 @@ xx(vgchange, ignoreskippedcluster_ARG, logicalvolume_ARG, maxphysicalvolumes_ARG, metadataprofile_ARG, monitor_ARG, noudevsync_ARG, metadatacopies_ARG, vgmetadatacopies_ARG, partial_ARG, physicalextentsize_ARG, poll_ARG, - refresh_ARG, resizeable_ARG, resizable_ARG, sysinit_ARG, test_ARG, uuid_ARG) + refresh_ARG, resizeable_ARG, resizable_ARG, sysinit_ARG, test_ARG, uuid_ARG, + systemid_ARG, systemidsource_ARG, force_ARG) xx(vgck, "Check the consistency of volume group(s)", @@ -1016,7 +1017,8 @@ xx(vgcreate, maxphysicalvolumes_ARG, metadataprofile_ARG, metadatatype_ARG, physicalextentsize_ARG, test_ARG, force_ARG, zero_ARG, labelsector_ARG, metadatasize_ARG, pvmetadatacopies_ARG, metadatacopies_ARG, - vgmetadatacopies_ARG, dataalignment_ARG, dataalignmentoffset_ARG) + vgmetadatacopies_ARG, dataalignment_ARG, dataalignmentoffset_ARG, + systemid_ARG, systemidsource_ARG) xx(vgdisplay, "Display volume group information", diff --git a/tools/toollib.c b/tools/toollib.c index 7f656c6e3..397484961 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -17,6 +17,7 @@ #include <sys/stat.h> #include <signal.h> #include <sys/wait.h> +#include <sys/utsname.h> const char *command_name(struct cmd_context *cmd) { @@ -169,6 +170,9 @@ int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsiste if ((read_error == FAILED_INCONSISTENT) && allow_inconsistent) return 0; + if (read_error == FAILED_SYSTEMID) + return 1; + if (read_error == FAILED_NOTFOUND) *ret = ECMD_FAILED; else if (read_error == FAILED_CLUSTERED && vg->cmd->ignore_clustered_vgs) @@ -633,6 +637,7 @@ int vgcreate_params_set_defaults(struct cmd_context *cmd, vp_def->alloc = vg->alloc; vp_def->clustered = vg_is_clustered(vg); vp_def->vgmetadatacopies = vg->mda_copies; + vp_def->system_id = vg->system_id ? dm_pool_strdup(cmd->mem, vg->system_id) : NULL; } else { vp_def->vg_name = NULL; extent_size = find_config_tree_int64(cmd, @@ -647,6 +652,7 @@ int vgcreate_params_set_defaults(struct cmd_context *cmd, vp_def->alloc = DEFAULT_ALLOC_POLICY; vp_def->clustered = DEFAULT_CLUSTERED; vp_def->vgmetadatacopies = DEFAULT_VGMETADATACOPIES; + vp_def->system_id = cmd->system_id ? dm_pool_strdup(cmd->mem, cmd->system_id) : NULL; } return 1; @@ -662,6 +668,9 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd, struct vgcreate_params *vp_new, struct vgcreate_params *vp_def) { + const char *system_id; + const char *system_id_source; + vp_new->vg_name = skip_dev_dir(cmd, vp_def->vg_name, NULL); vp_new->max_lv = arg_uint_value(cmd, maxlogicalvolumes_ARG, vp_def->max_lv); @@ -712,6 +721,18 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd, vp_new->vgmetadatacopies = find_config_tree_int(cmd, metadata_vgmetadatacopies_CFG, NULL); } + if ((system_id = arg_str_value(cmd, systemid_ARG, NULL))) { + vp_new->system_id = system_id_from_string(cmd, system_id); + } else if ((system_id_source = arg_str_value(cmd, systemidsource_ARG, NULL))) { + vp_new->system_id = system_id_from_source(cmd, system_id_source); + } else { + vp_new->system_id = vp_def->system_id; + } + + /* A clustered vg has no system_id unless overriden with the systemid arg. */ + if (!system_id && vp_new->clustered) + vp_new->system_id = NULL; + return 1; } diff --git a/tools/vgchange.c b/tools/vgchange.c index 9a9fe4866..5d4efd81e 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -336,6 +336,9 @@ static int _vgchange_clustered(struct cmd_context *cmd, } } + if (clustered) + vg->system_id = NULL; + if (!vg_set_clustered(vg, clustered)) return_0; @@ -475,6 +478,39 @@ static int _vgchange_profile(struct cmd_context *cmd, return 1; } +static int _vgchange_system_id(struct cmd_context *cmd, struct volume_group *vg) +{ + const char *system_id = arg_str_value(cmd, systemid_ARG, NULL); + const char *source = arg_str_value(cmd, systemidsource_ARG, NULL); + + if (vg->system_id && vg->system_id[0] && !arg_is_set(cmd, force_ARG)) { + log_error("Volume group \"%s\" already has system id \"%s\"", + vg->name, vg->system_id); + return 0; + } + + if (system_id) { + vg->system_id = system_id_from_string(cmd, system_id); + return 1; + } + + if (!source) + return 1; + + if (!strcmp(source, "none")) { + vg->system_id = NULL; + return 1; + } + + if ((system_id = system_id_from_source(cmd, source))) { + vg->system_id = (char *)system_id; + return 1; + } + + log_error("No system_id found from source %s", source); + return 0; +} + static int vgchange_single(struct cmd_context *cmd, const char *vg_name, struct volume_group *vg, void *handle __attribute__((unused))) @@ -498,8 +534,10 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name, { clustered_ARG, &_vgchange_clustered }, { vgmetadatacopies_ARG, &_vgchange_metadata_copies }, { metadataprofile_ARG, &_vgchange_profile }, - { profile_ARG, &_vgchange_profile}, - { detachprofile_ARG, &_vgchange_profile}, + { profile_ARG, &_vgchange_profile }, + { detachprofile_ARG, &_vgchange_profile }, + { systemid_ARG, &_vgchange_system_id }, + { systemidsource_ARG, &_vgchange_system_id }, }; if (vg_is_exported(vg)) { @@ -593,13 +631,19 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name, int vgchange(struct cmd_context *cmd, int argc, char **argv) { - /* Update commands that can be combined */ + int noupdate = + arg_count(cmd, activate_ARG) || + arg_count(cmd, monitor_ARG) || + arg_count(cmd, poll_ARG) || + arg_count(cmd, refresh_ARG); + int update_partial_safe = arg_count(cmd, deltag_ARG) || arg_count(cmd, addtag_ARG) || arg_count(cmd, metadataprofile_ARG) || arg_count(cmd, profile_ARG) || arg_count(cmd, detachprofile_ARG); + int update_partial_unsafe = arg_count(cmd, logicalvolume_ARG) || arg_count(cmd, maxphysicalvolumes_ARG) || @@ -608,18 +652,14 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv) arg_count(cmd, physicalextentsize_ARG) || arg_count(cmd, clustered_ARG) || arg_count(cmd, alloc_ARG) || - arg_count(cmd, vgmetadatacopies_ARG); + arg_count(cmd, vgmetadatacopies_ARG) || + arg_count(cmd, systemid_ARG) || + arg_count(cmd, systemidsource_ARG); + int update = update_partial_safe || update_partial_unsafe; - if (!update && - !arg_count(cmd, activate_ARG) && - !arg_count(cmd, monitor_ARG) && - !arg_count(cmd, poll_ARG) && - !arg_count(cmd, refresh_ARG)) { - log_error("Need 1 or more of -a, -c, -l, -p, -s, -x, " - "--refresh, --uuid, --alloc, --addtag, --deltag, " - "--monitor, --poll, --vgmetadatacopies or " - "--metadatacopies"); + if (!update && !noupdate) { + log_error("Need one or more command options."); return EINVALID_CMD_LINE; } @@ -709,6 +749,9 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv) if (!update || !update_partial_unsafe) cmd->handles_missing_pvs = 1; + if (arg_is_set(cmd, systemid_ARG) && arg_is_set(cmd, force_ARG)) + cmd->skip_systemid_check = 1; + return process_each_vg(cmd, argc, argv, update ? READ_FOR_UPDATE : 0, NULL, &vgchange_single); } diff --git a/tools/vgcreate.c b/tools/vgcreate.c index 01bf421f6..b49414852 100644 --- a/tools/vgcreate.c +++ b/tools/vgcreate.c @@ -71,6 +71,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) !vg_set_max_pv(vg, vp_new.max_pv) || !vg_set_alloc_policy(vg, vp_new.alloc) || !vg_set_clustered(vg, vp_new.clustered) || + !vg_set_system_id(vg, vp_new.system_id) || !vg_set_mda_copies(vg, vp_new.vgmetadatacopies)) goto bad_orphan; diff --git a/tools/vgexport.c b/tools/vgexport.c index d9f8efadc..f40784a02 100644 --- a/tools/vgexport.c +++ b/tools/vgexport.c @@ -32,6 +32,7 @@ static int vgexport_single(struct cmd_context *cmd __attribute__((unused)), goto_bad; vg->status |= EXPORTED_VG; + vg->system_id = NULL; dm_list_iterate_items(pvl, &vg->pvs) pvl->pv->status |= EXPORTED_VG; diff --git a/tools/vgimport.c b/tools/vgimport.c index 7cb93378f..23f802eb2 100644 --- a/tools/vgimport.c +++ b/tools/vgimport.c @@ -37,6 +37,7 @@ static int vgimport_single(struct cmd_context *cmd __attribute__((unused)), goto_bad; vg->status &= ~EXPORTED_VG; + vg->system_id = dm_pool_strdup(cmd->mem, cmd->system_id); dm_list_iterate_items(pvl, &vg->pvs) { pv = pvl->pv; |