1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cmdline: support ARG_GROUPABLE in merge_synonym

This commit is contained in:
Alasdair G Kergon 2013-07-19 20:37:43 +01:00
parent 90a09559ed
commit ccc29f17b6
4 changed files with 43 additions and 22 deletions

View File

@ -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.

View File

@ -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"

View File

@ -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

View File

@ -801,22 +801,10 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
return 1;
}
static int _merge_synonym(struct cmd_context *cmd, int oldarg, int newarg)
static void _copy_arg_values(struct arg_values *av, int oldarg, int newarg)
{
const struct arg_values *old;
struct arg_values *new;
if (arg_count(cmd, oldarg) && arg_count(cmd, newarg)) {
log_error("%s and %s are synonyms. Please only supply one.",
_cmdline.arg_props[oldarg].long_arg, _cmdline.arg_props[newarg].long_arg);
return 0;
}
if (!arg_count(cmd, oldarg))
return 1;
old = cmd->arg_values + oldarg;
new = cmd->arg_values + newarg;
const struct arg_values *old = av + oldarg;
struct arg_values *new = av + newarg;
new->count = old->count;
new->value = old->value;
@ -825,6 +813,36 @@ static int _merge_synonym(struct cmd_context *cmd, int oldarg, int newarg)
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)
{
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.",
_cmdline.arg_props[oldarg].long_arg, _cmdline.arg_props[newarg].long_arg);
return 0;
}
/* 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;
}
if (arg_count(cmd, oldarg))
cmd->arg_values[newarg].count = cmd->arg_values[oldarg].count;
/* 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;
}