diff options
author | Alasdair G Kergon <agk@redhat.com> | 2013-07-19 20:37:43 +0100 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2013-07-19 20:37:43 +0100 |
commit | ccc29f17b61b60aa4c5b2286ed8b530234435d8a (patch) | |
tree | e1c41360a55ab9b983a8fc1a3e1e93ebc2a5a8fa | |
parent | 90a09559ed689cbd62021ef0ff875913d43bc989 (diff) | |
download | lvm2-ccc29f17b61b60aa4c5b2286ed8b530234435d8a.tar.gz |
cmdline: support ARG_GROUPABLE in merge_synonym
-rw-r--r-- | WHATS_NEW | 1 | ||||
-rw-r--r-- | tools/commands.h | 2 | ||||
-rw-r--r-- | tools/lvchange.c | 14 | ||||
-rw-r--r-- | tools/lvmcmdline.c | 42 |
4 files changed, 40 insertions, 19 deletions
@@ -1,5 +1,6 @@ Version 2.02.99 - =================================== + Support ARG_GROUPABLE with merge_synonym (for --raidwritemostly). Fix segfault when reporting raid_syncaction for older kernels. Add LV reporting fields raid_mismatch_count, raid_sync_action, raid_write_behind. Add LV reporting fields raid_min_recovery_rate, raid_max_recovery_rate. diff --git a/tools/commands.h b/tools/commands.h index 1330c8d1f..841a6b65a 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -96,7 +96,7 @@ xx(lvchange, "\t[--[raid]maxrecoveryrate Rate]\n" "\t[--[raid]syncaction {check|repair}\n" "\t[--[raid]writebehind IOCount]\n" - "\t[--[raid]writemostly PhysicalVolume]\n" + "\t[--[raid]writemostly PhysicalVolume[:{t|n|y}]]\n" "\t[-r|--readahead ReadAheadSectors|auto|none]\n" "\t[--refresh]\n" "\t[--resync]\n" diff --git a/tools/lvchange.c b/tools/lvchange.c index b3207d09a..3b40659a5 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -702,6 +702,7 @@ static int lvchange_writemostly(struct logical_volume *lv) int s, pv_count, i = 0; char **pv_names; const char *tmp_str; + size_t tmp_str_len; struct pv_list *pvl; struct arg_value_group_list *group; struct cmd_context *cmd = lv->vg->cmd; @@ -743,14 +744,15 @@ static int lvchange_writemostly(struct logical_volume *lv) * We allocate strlen + 3 to add our own ':{t|n|y}' if * not present plus the trailing '\0'. */ - if (!(pv_names[i] = dm_pool_zalloc(lv->vg->vgmem, - strlen(tmp_str) + 3))) + tmp_str_len = strlen(tmp_str); + if (!(pv_names[i] = dm_pool_zalloc(lv->vg->vgmem, tmp_str_len + 3))) return_0; - if ((tmp_str[strlen(tmp_str) - 2] != ':') && - ((tmp_str[strlen(tmp_str) - 1] != 't') || - (tmp_str[strlen(tmp_str) - 1] != 'y') || - (tmp_str[strlen(tmp_str) - 1] != 'n'))) + if (tmp_str_len < 3 || + (tmp_str[tmp_str_len - 2] != ':') && + ((tmp_str[tmp_str_len - 1] != 't') || + (tmp_str[tmp_str_len - 1] != 'y') || + (tmp_str[tmp_str_len - 1] != 'n'))) /* Default to 'y' if no mode specified */ sprintf(pv_names[i], "%s:y", tmp_str); else diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 66c453642..a155d212e 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -801,10 +801,24 @@ static int _process_command_line(struct cmd_context *cmd, int *argc, return 1; } +static void _copy_arg_values(struct arg_values *av, int oldarg, int newarg) +{ + const struct arg_values *old = av + oldarg; + struct arg_values *new = av + newarg; + + new->count = old->count; + new->value = old->value; + new->i_value = old->i_value; + new->ui_value = old->ui_value; + new->i64_value = old->i64_value; + new->ui64_value = old->ui64_value; + new->sign = old->sign; +} + static int _merge_synonym(struct cmd_context *cmd, int oldarg, int newarg) { - const struct arg_values *old; - struct arg_values *new; + struct arg_values *av; + struct arg_value_group_list *current_group; if (arg_count(cmd, oldarg) && arg_count(cmd, newarg)) { log_error("%s and %s are synonyms. Please only supply one.", @@ -812,19 +826,23 @@ static int _merge_synonym(struct cmd_context *cmd, int oldarg, int newarg) return 0; } - if (!arg_count(cmd, oldarg)) + /* Not groupable? */ + if (!(_cmdline.arg_props[oldarg].flags & ARG_GROUPABLE)) { + if (arg_count(cmd, oldarg)) + _copy_arg_values(cmd->arg_values, oldarg, newarg); return 1; + } - old = cmd->arg_values + oldarg; - new = cmd->arg_values + newarg; + if (arg_count(cmd, oldarg)) + cmd->arg_values[newarg].count = cmd->arg_values[oldarg].count; - new->count = old->count; - new->value = old->value; - new->i_value = old->i_value; - new->ui_value = old->ui_value; - new->i64_value = old->i64_value; - new->ui64_value = old->ui64_value; - new->sign = old->sign; + /* Groupable */ + dm_list_iterate_items(current_group, &cmd->arg_value_groups) { + av = current_group->arg_values; + if (!grouped_arg_count(av, oldarg)) + continue; + _copy_arg_values(av, oldarg, newarg); + } return 1; } |