Skip to contentSkip to conversation

master - cmdline: support ARG_GROUPABLE in merge_synonym

PATCH Alasdair Kergon 1 participant 1 message Jul 19, 2013

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ccc29f17b61b60aa4c5b2286ed8b530234435d8a
Commit:        ccc29f17b61b60aa4c5b2286ed8b530234435d8a
Parent:        90a09559ed689cbd62021ef0ff875913d43bc989
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Fri Jul 19 20:37:43 2013 +0100
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Fri Jul 19 20:37:43 2013 +0100

cmdline: support ARG_GROUPABLE in merge_synonym

---
 WHATS_NEW          |    1 +
 tools/commands.h   |    2 +-
 tools/lvchange.c   |   14 ++++++++------
 tools/lvmcmdline.c |   42 ++++++++++++++++++++++++++++++------------
 4 files changed, 40 insertions(+), 19 deletions(-)
WHATS_NEW +1 -0
index 83a593e..1cce9c9 100644
@@ -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.
tools/commands.h +1 -1
index 1330c8d..841a6b6 100644
@@ -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"
tools/lvchange.c +8 -6
index b3207d0..3b40659 100644
@@ -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
tools/lvmcmdline.c +30 -12

59 lines not on this page · raw message