master - commands: fixes for recent raid changes
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8d0df0c011f23095cf0...
Commit: 8d0df0c011f23095cf028c556db15b531ca91ea5
Parent: 27384c52cf6a55ec7c8d64deecff2a81536193c7
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Feb 24 16:43:05 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Feb 27 14:44:00 2017 -0600
commands: fixes for recent raid changes
- Combine the equivalent lvconvert --type raid defs.
(Two cmd defs must be different without relying
on LV type, which are not known at the time the
cmd def is matched.)
- Remove unused optional options from lvconvert --stripes,
and lvconvert --stripesize.
- Use Number for --stripes_long val type.
- Combine the cmd def for raid reshape cleanup into the
existing start_poll cmd def (they were duplicate defs).
Calls into the raid code from a poll opertion will be
added.
---
tools/command-lines.in | 30 ++++++++++--------------------
1 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index c3d684e..f8e0db7 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -338,19 +338,16 @@ ID: lvconvert_raid_types
DESC: Convert LV to type mirror (also see type raid1).
RULE: all not lv_is_locked lv_is_pvmove
+# When LV is already raid, this changes the raid layout
+# (changing layout of raid0 and raid1 not allowed.)
+
lvconvert --type raid LV
OO: OO_LVCONVERT_RAID, OO_LVCONVERT
OP: PV ...
ID: lvconvert_raid_types
-DESC: Convert LV to raid.
-RULE: all not lv_is_locked lv_is_pvmove
-
-lvconvert --type raid LV_raid
-OO: OO_LVCONVERT_RAID, OO_LVCONVERT
-ID: lvconvert_raid_types
-DESC: Convert raid LV to different layout algorithm.
+DESC: Convert LV to raid or change raid layout.
RULE: all not lv_is_locked lv_is_pvmove
-RULE: all not LV_raid0 LV_raid1
+RULE: LV_raid not LV_raid0 LV_raid1
lvconvert --mirrors SNumber LV
OO: OO_LVCONVERT_RAID, OO_LVCONVERT, --mirrorlog MirrorLog
@@ -359,8 +356,8 @@ ID: lvconvert_raid_types
DESC: Convert LV to raid1 or mirror, or change number of mirror images.
RULE: all not lv_is_locked lv_is_pvmove
-lvconvert --stripes_long SNumber LV_raid
-OO: OO_LVCONVERT_RAID, OO_LVCONVERT
+lvconvert --stripes_long Number LV_raid
+OO: OO_LVCONVERT, --interval Number, --regionsize RegionSize, --stripesize SizeKB
OP: PV ...
ID: lvconvert_raid_types
DESC: Convert raid LV to change number of stripe images.
@@ -368,7 +365,7 @@ RULE: all not lv_is_locked lv_is_pvmove
RULE: all not LV_raid0 LV_raid1
lvconvert --stripesize SizeKB LV_raid
-OO: OO_LVCONVERT_RAID, OO_LVCONVERT
+OO: OO_LVCONVERT, --interval Number, --regionsize RegionSize
ID: lvconvert_raid_types
DESC: Convert raid LV to change the stripe size.
RULE: all not lv_is_locked lv_is_pvmove
@@ -381,13 +378,6 @@ DESC: Change the region size of an LV.
RULE: all not lv_is_locked lv_is_pvmove
RULE: all not LV_raid0
-lvconvert LV_mirror_raid
-OO: OO_LVCONVERT
-ID: lvconvert_raid_types
-DESC: Remove out-of-place reshape space
-RULE: all not lv_is_locked lv_is_pvmove
-RULE: all not LV_raid0 LV_raid1
-
---
# lvconvert raid-related utilities
@@ -677,7 +667,7 @@ RULE: all not lv_is_locked lv_is_pvmove
# This command just (re)starts the polling process on the LV
# to continue a previous conversion.
-lvconvert --startpoll LV_mirror
+lvconvert --startpoll LV_mirror_raid
OO: OO_LVCONVERT
ID: lvconvert_start_poll
DESC: Poll LV to continue conversion.
@@ -685,7 +675,7 @@ RULE: all and lv_is_converting
# alternate form of lvconvert --startpoll, this is only kept
# for compat since this was how it used to be done.
-lvconvert LV_mirror
+lvconvert LV_mirror_raid
OO: OO_LVCONVERT
ID: lvconvert_start_poll
DESC: Poll LV to continue conversion.
7 years, 1 month
master - lvconvert: limit libdm to maximum of 64 RAID devices
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=27384c52cf6a55ec7c8...
Commit: 27384c52cf6a55ec7c8d64deecff2a81536193c7
Parent: c41e99948819e896d9d06b4a8192ec7a63facf65
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Mon Feb 27 21:42:15 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Mon Feb 27 21:42:15 2017 +0100
lvconvert: limit libdm to maximum of 64 RAID devices
Commit 64a2fad5d6c6 raised the maximum number of RAID devices to 64.
Commit e2354ea344c2 introduced RAID_BITMAP_SIZE as 4 to have
256 bits (4 * 64 bit array members), thus changing the libdm API
unnecessarilly for the time being.
To not change the API, reduce RAID_BITMAP_SIZE to 1.
Remove an unneeded definition of it from libdm-common.h.
If we ever decide to raise past 64, we'll version the API.
Related: rhbz834579
Related: rhbz1191935
Related: rhbz1191978
---
libdm/libdevmapper.h | 11 ++++++++++-
libdm/libdm-common.h | 2 --
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 7fccac5..7136261 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1739,7 +1739,16 @@ int dm_tree_node_add_raid_target(struct dm_tree_node *node,
*/
#define DM_CACHE_METADATA_MAX_SECTORS DM_THIN_METADATA_MAX_SECTORS
-#define RAID_BITMAP_SIZE 4
+/*
+ * Define number of elements in rebuild and writemostly arrays
+ * 'of struct dm_tree_node_raid_params'.
+ *
+ * Set to one to keep the current libdm API!
+ *
+ * If we ever raise the maximum number of RAID devices past 64 thus
+ * changing the API, we have to version it for backwards API compatibility.
+ */
+#define RAID_BITMAP_SIZE 1
struct dm_tree_node_raid_params {
const char *raid_type;
diff --git a/libdm/libdm-common.h b/libdm/libdm-common.h
index a064db8..4dc1870 100644
--- a/libdm/libdm-common.h
+++ b/libdm/libdm-common.h
@@ -23,8 +23,6 @@
#define DEV_NAME(dmt) (dmt->mangled_dev_name ? : dmt->dev_name)
#define DEV_UUID(DMT) (dmt->mangled_uuid ? : dmt->uuid)
-#define RAID_BITMAP_SIZE 4
-
int mangle_string(const char *str, const char *str_name, size_t len,
char *buf, size_t buf_len, dm_string_mangling_t mode);
7 years, 1 month
master - man: change option sorting in synopsis
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4f7631b4adb9c6...
Commit: 4f7631b4adb9c6fff5cd47b5bd733ee716d05c8f
Parent: 5f6bdf707db24e882b3c3f86f8a5f2e2d2007c98
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Feb 24 15:11:18 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Feb 24 15:11:18 2017 -0600
man: change option sorting in synopsis
The options list was sorted as:
- options with both long and short forms, alphabetically
- options with only long form, alphabetically
This was done only for the visual effect. Change to
sort alphabetically by long opt, without regard to
short forms.
---
tools/command.c | 55 +++++++------------------------------------------------
1 files changed, 7 insertions(+), 48 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index 5dd0298..59818f9 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -2533,10 +2533,7 @@ static void print_man_option_desc(struct command_name *cname, int opt_enum)
}
/*
- * Print a list of all options names for a given
- * command name, listed by:
- * options with short+long names, alphabetically,
- * then options with only long names, alphabetically
+ * Print a list of all options names for a given command name.
*/
void print_man_all_options_list(struct command_name *cname)
@@ -2545,63 +2542,25 @@ void print_man_all_options_list(struct command_name *cname)
int sep = 0;
int i;
- /* print those with both short and long opts */
for (i = 0; i < ARG_COUNT; i++) {
opt_enum = opt_names_alpha[i]->opt_enum;
-
if (!cname->all_options[opt_enum])
continue;
- if (!opt_names[opt_enum].short_opt)
- continue;
-
if (sep)
printf(".br\n");
printf(".ad l\n");
- printf(" \\fB-%c\\fP|\\fB%s\\fP",
- opt_names[opt_enum].short_opt,
- man_long_opt_name(cname->name, opt_enum));
-
- val_enum = opt_names[opt_enum].val_enum;
-
- if (!val_names[val_enum].fn) {
- /* takes no arg */
- } else if (!val_names[val_enum].usage) {
- printf(" ");
- printf("\\fI");
- printf("%s", val_names[val_enum].name);
- printf("\\fP");
+ if (opt_names[opt_enum].short_opt) {
+ printf(" \\fB-%c\\fP|\\fB%s\\fP",
+ opt_names[opt_enum].short_opt,
+ man_long_opt_name(cname->name, opt_enum));
} else {
- printf(" ");
- print_val_man(val_names[val_enum].usage);
+ /* spaces for alignment without short opt */
+ printf(" \\fB%s\\fP", man_long_opt_name(cname->name, opt_enum));
}
- printf("\n.ad b\n");
-
- sep = 1;
- }
-
- /* print those without short opts */
- for (i = 0; i < ARG_COUNT; i++) {
- opt_enum = opt_names_alpha[i]->opt_enum;
-
- if (!cname->all_options[opt_enum])
- continue;
-
- if (opt_names[opt_enum].short_opt)
- continue;
-
- if (sep)
- printf(".br\n");
- printf(".ad l\n");
-
- /* space alignment without short opt */
- printf(" ");
-
- printf(" \\fB%s\\fP", man_long_opt_name(cname->name, opt_enum));
-
val_enum = opt_names[opt_enum].val_enum;
if (!val_names[val_enum].fn) {
7 years, 1 month
master - man: add ENVIRONMENT VARIABLES section
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5f6bdf707db24e...
Commit: 5f6bdf707db24e882b3c3f86f8a5f2e2d2007c98
Parent: 84cceaf9b9f0f323c78e9818c2b54c97d71b392f
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Feb 24 15:05:17 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Feb 24 15:05:17 2017 -0600
man: add ENVIRONMENT VARIABLES section
---
tools/command.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index 4e7c009..5dd0298 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -2825,8 +2825,7 @@ void print_man_all_positions_desc(struct command_name *cname)
"(This should not be confused with the output control --units, where\n"
"capital letters mean multiple of 1000.)\n");
- printf("\n.HP\n");
- printf("Environment");
+ printf(".SH ENVIRONMENT VARIABLES");
printf("\n");
printf(".br\n");
printf("See \\fBlvm\\fP(8) for information about environment variables used by lvm.\n"
7 years, 1 month
master - lvconvert: fix handling args in combining snapshots
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=84cceaf9b9f0f3...
Commit: 84cceaf9b9f0f323c78e9818c2b54c97d71b392f
Parent: 74ba326007205ebbb5afca7c8f74a8b19e9dcb50
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Feb 24 14:17:58 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Feb 24 14:17:58 2017 -0600
lvconvert: fix handling args in combining snapshots
Fixes commit 286d39ee3c433, which was correct except
for a reversed strstr. Now uses strchr, and modifies
a copy of the name so the original argv is preserved.
---
tools/lvconvert.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 183421a..c82dab2 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3668,8 +3668,9 @@ static int _lvconvert_combine_split_snapshot_single(struct cmd_context *cmd,
int lvconvert_combine_split_snapshot_cmd(struct cmd_context *cmd, int argc, char **argv)
{
const char *vgname = NULL;
- const char *lvname1;
- const char *lvname2;
+ const char *lvname1_orig;
+ const char *lvname2_orig;
+ const char *lvname1_split;
char *vglv;
int vglv_sz;
@@ -3687,20 +3688,25 @@ int lvconvert_combine_split_snapshot_cmd(struct cmd_context *cmd, int argc, char
* This is the only instance in all commands.
*/
- lvname1 = cmd->position_argv[0];
- lvname2 = cmd->position_argv[1];
+ lvname1_orig = cmd->position_argv[0];
+ lvname2_orig = cmd->position_argv[1];
- if (strstr("/", lvname1) && !strstr("/", lvname2) && !getenv("LVM_VG_NAME")) {
- if (!validate_lvname_param(cmd, &vgname, &lvname1))
+ if (strchr(lvname1_orig, '/') && !strchr(lvname2_orig, '/') && !getenv("LVM_VG_NAME")) {
+ if (!(lvname1_split = dm_pool_strdup(cmd->mem, lvname1_orig)))
return_ECMD_FAILED;
- vglv_sz = strlen(vgname) + strlen(lvname2) + 2;
+ if (!validate_lvname_param(cmd, &vgname, &lvname1_split))
+ return_ECMD_FAILED;
+
+ vglv_sz = strlen(vgname) + strlen(lvname2_orig) + 2;
if (!(vglv = dm_pool_alloc(cmd->mem, vglv_sz)) ||
- dm_snprintf(vglv, vglv_sz, "%s/%s", vgname, lvname2) < 0) {
+ dm_snprintf(vglv, vglv_sz, "%s/%s", vgname, lvname2_orig) < 0) {
log_error("vg/lv string alloc failed.");
return_ECMD_FAILED;
}
+ /* vglv is now vgname/lvname2 and replaces lvname2_orig */
+
cmd->position_argv[1] = vglv;
}
7 years, 1 month
master - man: use Size variable for a number with unit
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=74ba326007205e...
Commit: 74ba326007205ebbb5afca7c8f74a8b19e9dcb50
Parent: 189fa647931834b0d9cb30c20d16785b8e8923c9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Feb 24 13:44:05 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Feb 24 13:44:05 2017 -0600
man: use Size variable for a number with unit
Define a separate variable type Size to represent
a number that takes an optional UNIT.
---
tools/args.h | 2 +-
tools/command.c | 25 +++++++++++++++----------
tools/lvmcmdline.c | 4 ++--
tools/tools.h | 2 +-
tools/vals.h | 22 +++++++++++-----------
5 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index 036aa87..dd25007 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -987,7 +987,7 @@ arg(logicalvolume_ARG, 'l', "logicalvolume", uint32_VAL, 0, 0,
arg(maxlogicalvolumes_ARG, 'l', "maxlogicalvolumes", uint32_VAL, 0, 0,
"Sets the maximum number of LVs allowed in a VG.\n")
-arg(extents_ARG, 'l', "extents", numsignedper_VAL, 0, 0,
+arg(extents_ARG, 'l', "extents", extents_VAL, 0, 0,
"#lvcreate\n"
"Specifies the size of the new LV in logical extents.\n"
"The --size and --extents options are alternate methods of specifying size.\n"
diff --git a/tools/command.c b/tools/command.c
index 8d5a96b..4e7c009 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -79,7 +79,7 @@ static inline int size_mb_arg_with_percent(struct cmd_context *cmd, struct arg_v
static inline int int_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int uint32_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int int_arg_with_sign(struct cmd_context *cmd, struct arg_values *av) { return 0; }
-static inline int int_arg_with_sign_and_percent(struct cmd_context *cmd, struct arg_values *av) { return 0; }
+static inline int extents_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int major_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int minor_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int string_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
@@ -1792,13 +1792,13 @@ static void print_val_man(const char *str)
* that isn't already obvious.
*/
- if (!strcmp(str, "Number[k|UNIT]")) {
- printf("\\fINumber\\fP[k|UNIT]");
+ if (!strcmp(str, "Size[k|UNIT]")) {
+ printf("\\fISize\\fP[k|UNIT]");
return;
}
- if (!strcmp(str, "Number[m|UNIT]")) {
- printf("\\fINumber\\fP[m|UNIT]");
+ if (!strcmp(str, "Size[m|UNIT]")) {
+ printf("\\fISize\\fP[m|UNIT]");
return;
}
@@ -2807,16 +2807,21 @@ void print_man_all_positions_desc(struct command_name *cname)
printf(".br\n");
printf("See the option description for information about the string content.\n");
- /* Nearly every command uses a number arg somewhere. */
+ /*
+ * We could possibly check if the command accepts any option that
+ * uses Size, and only print this in those cases, but this seems
+ * so common that we should probably always print it.
+ */
printf("\n.HP\n");
- printf("\\fINumber\\fP, UNIT");
+ printf("\\fISize\\fP[UNIT]");
printf("\n");
printf(".br\n");
- printf("Input units are always treated as base two values, regardless of unit\n"
+ printf("Size is an input number that accepts an optional unit.\n"
+ "Input units are always treated as base two values, regardless of\n"
"capitalization, e.g. 'k' and 'K' both refer to 1024.\n"
- "The default input unit is specified by letter, followed by |UNIT\n"
- "which represents other possible input units: \\fBbBsSkKmMgGtTpPeE\\fP.\n"
+ "The default input unit is specified by letter, followed by |UNIT.\n"
+ "UNIT represents other possible input units: \\fBbBsSkKmMgGtTpPeE\\fP.\n"
"(This should not be confused with the output control --units, where\n"
"capital letters mean multiple of 1000.)\n");
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 02266c9..9b20d9f 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -672,8 +672,8 @@ int int_arg_with_sign(struct cmd_context *cmd __attribute__((unused)), struct ar
return 1;
}
-int int_arg_with_sign_and_percent(struct cmd_context *cmd __attribute__((unused)),
- struct arg_values *av)
+int extents_arg(struct cmd_context *cmd __attribute__((unused)),
+ struct arg_values *av)
{
char *ptr;
diff --git a/tools/tools.h b/tools/tools.h
index 62db506..1e1e7f1 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -188,7 +188,7 @@ int size_mb_arg_with_percent(struct cmd_context *cmd, struct arg_values *av);
int int_arg(struct cmd_context *cmd, struct arg_values *av);
int uint32_arg(struct cmd_context *cmd, struct arg_values *av);
int int_arg_with_sign(struct cmd_context *cmd, struct arg_values *av);
-int int_arg_with_sign_and_percent(struct cmd_context *cmd, struct arg_values *av);
+int extents_arg(struct cmd_context *cmd, struct arg_values *av);
int major_arg(struct cmd_context *cmd, struct arg_values *av);
int minor_arg(struct cmd_context *cmd, struct arg_values *av);
int string_arg(struct cmd_context *cmd, struct arg_values *av);
diff --git a/tools/vals.h b/tools/vals.h
index a94f81b..d485926 100644
--- a/tools/vals.h
+++ b/tools/vals.h
@@ -79,13 +79,13 @@
* options included in the usage text below that should
* be removed? Should "lvm1" be removed?
*
- * For Number args that take optional units, a full usage
- * could be "Number[bBsSkKmMgGtTpPeE]" (with implied |),
- * but repeating this full specification produces cluttered
- * output, and doesn't indicate which unit is the default.
- * "Number[Units]" would be cleaner, as would a subset of
- * common units, e.g. "Number[kmg...]", but neither helps
- * with default. "Number[k|UNIT]" and "Number[m|UNIT]" show
+ * Size is a Number that takes an optional unit.
+ * A full usage could be "Size[b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E]"
+ * but repeating this full specification produces long and
+ * cluttered output, and doesn't indicate which unit is the default.
+ * "Size[Units]" would be cleaner, as would a subset of
+ * common units, e.g. "Size[kmg...]", but neither helps
+ * with default. "Size[k|UNIT]" and "Size[m|UNIT]" show
* the default, and "UNIT" indicates that other units
* are possible without listing them all. This also
* suggests using the preferred lower case letters, because
@@ -115,11 +115,11 @@ val(activation_VAL, activation_arg, "Active", "y|n|ay")
val(cachemode_VAL, cachemode_arg, "CacheMode", "writethrough|writeback")
val(discards_VAL, discards_arg, "Discards", "passdown|nopassdown|ignore")
val(mirrorlog_VAL, mirrorlog_arg, "MirrorLog", "core|disk")
-val(sizekb_VAL, size_kb_arg, "SizeKB", "Number[k|UNIT]")
-val(sizemb_VAL, size_mb_arg, "SizeMB", "Number[m|UNIT]")
-val(regionsize_VAL, regionsize_arg, "RegionSize", "Number[m|UNIT]")
+val(sizekb_VAL, size_kb_arg, "SizeKB", "Size[k|UNIT]")
+val(sizemb_VAL, size_mb_arg, "SizeMB", "Size[m|UNIT]")
+val(regionsize_VAL, regionsize_arg, "RegionSize", "Size[m|UNIT]")
val(numsigned_VAL, int_arg_with_sign, "SNumber", "[+|-]Number")
-val(numsignedper_VAL, int_arg_with_sign_and_percent, "SNumberP", "[+|-]Number[%VG|%PVS|%FREE]")
+val(extents_VAL, extents_arg, "Extents", "[+|-]Number[%VG|%PVS|%FREE]")
val(permission_VAL, permission_arg, "Permission", "rw|r")
val(metadatatype_VAL, metadatatype_arg, "MetadataType", "lvm2|lvm1")
val(units_VAL, string_arg, "Units", "r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E")
7 years, 1 month
master - lvconvert: impose region size constraints
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=189fa647931834...
Commit: 189fa647931834b0d9cb30c20d16785b8e8923c9
Parent: 3bdc4045c2abbf9ea11000b76eeefab9fed16033
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Feb 24 07:27:43 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Feb 24 07:27:43 2017 +0100
lvconvert: impose region size constraints
When requesting a regionsize change during conversions, check
for constraints or the command may fail in the kernel n case
the region size is too smalle or too large thus leaving any
new SubLVs behind.
Related: rhbz834579
Related: rhbz1191935
Related: rhbz1191978
---
lib/metadata/raid_manip.c | 86 +++++++++++++++++++++++++++++++-------------
tools/lvconvert.c | 2 +
2 files changed, 62 insertions(+), 26 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 34567bd..34e8856 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -94,6 +94,27 @@ uint32_t raid_ensure_min_region_size(const struct logical_volume *lv, uint64_t r
return region_size;
}
+/* check constraints on region size vs. stripe and LV size on @lv */
+static int _check_region_size_constraints(struct logical_volume *lv,
+ const struct segment_type *segtype,
+ uint32_t region_size,
+ uint32_t stripe_size)
+{
+ if (region_size < stripe_size) {
+ log_error("Regionsize may not be smaller than stripe size on %s LV %s.",
+ segtype->name, display_lvname(lv));
+ return 0;
+ }
+
+ if (region_size * 8 > lv->size) {
+ log_error("Regionsize too large for %s LV %s.",
+ segtype->name, display_lvname(lv));
+ return 0;
+ }
+
+ return 1;
+}
+
/*
* Check for maximum number of raid devices.
* Constrained by kernel MD maximum device limits _and_ dm-raid superblock
@@ -2142,6 +2163,9 @@ static int _raid_reshape(struct logical_volume *lv,
if (!_check_max_raid_devices(new_image_count))
return_0;
+ if (!_check_region_size_constraints(lv, new_segtype, new_region_size, new_stripe_size))
+ return 0;
+
if (!_raid_in_sync(lv)) {
log_error("Unable to convert %s while it is not in-sync.",
display_lvname(lv));
@@ -4772,6 +4796,9 @@ static int _takeover_downconvert_wrapper(TAKEOVER_FN_ARGS)
return 0;
}
+ if (!_check_region_size_constraints(lv, new_segtype, new_region_size, new_stripe_size))
+ return 0;
+
if (seg_is_any_raid10(seg) && (seg->area_count % seg->data_copies)) {
log_error("Can't convert %s LV %s to %s with odd number of stripes.",
lvseg_name(seg), display_lvname(lv), new_segtype->name);
@@ -4853,7 +4880,8 @@ static int _takeover_downconvert_wrapper(TAKEOVER_FN_ARGS)
seg->region_size = 0;
if (!(seg->segtype = get_segtype_from_flag(lv->vg->cmd, SEG_RAID0_META)))
return_0;
- }
+ } else
+ seg->region_size = new_region_size;
if (segtype_is_striped_target(new_segtype)) {
if (!_convert_raid0_to_striped(lv, 0, &removal_lvs))
@@ -5035,6 +5063,11 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS)
new_stripe_size = 128;
}
+ region_size = seg->region_size;
+
+ if (!_check_region_size_constraints(lv, new_segtype, new_region_size, new_stripe_size))
+ return 0;
+
/* Archive metadata */
if (!archive(lv->vg))
return_0;
@@ -5065,7 +5098,6 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS)
extents_copied = seg->extents_copied;
- region_size = seg->region_size;
seg_len = seg->len;
stripe_size = seg->stripe_size;
@@ -5221,21 +5253,24 @@ static int _takeover_from_raid0_to_raid10(TAKEOVER_FN_ARGS)
{
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count * 2 /* new_image_count */,
- 2 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
+ 2 /* data_copies */, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
static int _takeover_from_raid0_to_raid45(TAKEOVER_FN_ARGS)
{
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count + 1 /* new_image_count */,
- 2 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
+ 2 /* data_copies */, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
static int _takeover_from_raid0_to_raid6(TAKEOVER_FN_ARGS)
{
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count + 2 /* new_image_count */,
- 3 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
+ 3 /* data_copies */, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
static int _takeover_from_raid0_to_striped(TAKEOVER_FN_ARGS)
@@ -5273,21 +5308,24 @@ static int _takeover_from_raid0_meta_to_raid10(TAKEOVER_FN_ARGS)
{
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count * 2 /* new_image_count */,
- 2 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
+ 2 /* data_copies */, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
static int _takeover_from_raid0_meta_to_raid45(TAKEOVER_FN_ARGS)
{
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count + 1 /* new_image_count */,
- 2 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
+ 2 /* data_copies */, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
static int _takeover_from_raid0_meta_to_raid6(TAKEOVER_FN_ARGS)
{
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count + 2 /* new_image_count */,
- 3 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
+ 3 /* data_copies */, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
static int _takeover_from_raid0_meta_to_striped(TAKEOVER_FN_ARGS)
@@ -5332,7 +5370,8 @@ static int _takeover_from_raid1_to_raid5(TAKEOVER_FN_ARGS)
{
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count /* unchanged new_image_count */,
- 2 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
+ 2 /* data_copies */, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
static int _takeover_from_raid1_to_striped(TAKEOVER_FN_ARGS)
@@ -5369,7 +5408,7 @@ static int _takeover_from_raid5_to_raid1(TAKEOVER_FN_ARGS)
{
return _takeover_downconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count,
- 2 /* data_copies */, 0, 0, 0, allocate_pvs);
+ 2 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
}
static int _takeover_from_raid45_to_raid54(TAKEOVER_FN_ARGS)
@@ -5390,7 +5429,8 @@ static int _takeover_from_raid45_to_raid6(TAKEOVER_FN_ARGS)
}
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count + 1 /* new_image_count */,
- 3 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
+ 3 /* data_copies */, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
static int _takeover_from_raid45_to_striped(TAKEOVER_FN_ARGS)
@@ -5411,14 +5451,14 @@ static int _takeover_from_raid6_to_raid0_meta(TAKEOVER_FN_ARGS)
{
return _takeover_downconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count - 2,
- 1 /* data_copies */, 0, 0, 0, allocate_pvs);
+ 1 /* data_copies */, 0, 0, 0, allocate_pvs);
}
static int _takeover_from_raid6_to_raid45(TAKEOVER_FN_ARGS)
{
return _takeover_downconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count - 1,
- 2 /* data_copies */, 0, 0, 0, allocate_pvs);
+ 2 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
}
static int _takeover_from_raid6_to_striped(TAKEOVER_FN_ARGS)
@@ -5453,20 +5493,23 @@ static int _takeover_from_striped_to_raid10(TAKEOVER_FN_ARGS)
{
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count * 2 /* new_image_count */,
- 2 /* FIXME: variable data_copies */, 0, 0, new_region_size, allocate_pvs);
+ 2 /* FIXME: variable data_copies */, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
static int _takeover_from_striped_to_raid45(TAKEOVER_FN_ARGS)
{
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force, first_seg(lv)->area_count + 1,
- 2 /* data_copies*/, 0, 0, new_region_size, allocate_pvs);
+ 2 /* data_copies*/, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
static int _takeover_from_striped_to_raid6(TAKEOVER_FN_ARGS)
{
return _takeover_upconvert_wrapper(lv, new_segtype, yes, force,
first_seg(lv)->area_count + 2 /* new_image_count */,
- 3 /* data_copies */, 0, 0, new_region_size, allocate_pvs);
+ 3 /* data_copies */, 0, new_stripe_size,
+ new_region_size, allocate_pvs);
}
/*
@@ -5725,17 +5768,8 @@ static int _region_size_change_requested(struct logical_volume *lv, int yes, con
return 1;
}
- if (region_size * 8 > lv->size) {
- log_error("Requested region size too large for LV %s size %s.",
- display_lvname(lv), display_size(lv->vg->cmd, lv->size));
+ if (!_check_region_size_constraints(lv, seg->segtype, region_size, seg->stripe_size))
return 0;
- }
-
- if (region_size < seg->stripe_size) {
- log_error("Requested region size for LV %s is smaller than stripe size.",
- display_lvname(lv));
- return 0;
- }
if (!_raid_in_sync(lv)) {
log_error("Unable to change region size on %s LV %s while it is not in-sync.",
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 0db10cb..183421a 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1401,6 +1401,8 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
lp->stripes = 0;
if (!arg_is_set(cmd, type_ARG))
lp->segtype = NULL;
+ if (!arg_is_set(cmd, regionsize_ARG))
+ lp->region_size = 0;
if (!lv_raid_convert(lv, lp->segtype,
lp->yes, lp->force, lp->stripes, lp->stripe_size_supplied, lp->stripe_size,
7 years, 1 month
master - lvconvert: fix 2 issues identified in intesting
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3bdc4045c2abbf...
Commit: 3bdc4045c2abbf9ea11000b76eeefab9fed16033
Parent: d768fbe010914161e3e7bfff6e4e6e0e2cd3907d
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Feb 24 05:58:45 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Feb 24 05:58:45 2017 +0100
lvconvert: fix 2 issues identified in intesting
Allow regionsize on upconvert from linear:
fix related commit 2574d3257ad41 to actually work
Related: rhbz1394427
Remove setting raid5_n on conversions from raid1
as of commit 932db3db5357 because any raid5 mapping
may be requested.
Related: rhbz834579
Related: rhbz1191935
Related: rhbz1191978
---
lib/metadata/raid_manip.c | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index ab0bfab..34567bd 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -2696,12 +2696,14 @@ static int _raid_add_images(struct logical_volume *lv,
int commit, int use_existing_area_len)
{
int rebuild_flag_cleared = 0;
- struct lv_segment *seg;
- uint32_t s;
+ struct lv_segment *seg = first_seg(lv);
+ uint32_t region_size = seg->region_size, s;
if (!_raid_add_images_without_commit(lv, new_count, pvs, use_existing_area_len))
return_0;
+ first_seg(lv)->region_size = region_size;
+
if (!commit)
return 1;
@@ -5623,7 +5625,7 @@ static uint64_t _raid_seg_flag_6_to_5(const struct lv_segment *seg)
return _get_r56_flag(seg, 1);
}
-/* Change segtype for raid4 <-> raid5 <-> raid6 or raid1 <-> raid5 takeover where necessary. */
+/* Change segtype for raid4 <-> raid5 <-> raid6 where necessary. */
static int _set_convenient_raid1456_segtype_to(const struct lv_segment *seg_from,
const struct segment_type **segtype,
int yes)
@@ -5650,12 +5652,6 @@ static int _set_convenient_raid1456_segtype_to(const struct lv_segment *seg_from
goto replaced;
}
- /* raid1 -> raid5_n with 2 areas */
- } else if (seg_is_raid1(seg_from) && seg_from->area_count == 2 &&
- segtype_is_any_raid5(*segtype) && !segtype_is_raid5_n(*segtype)) {
- seg_flag = SEG_RAID5_N;
- goto replaced;
-
/* raid4 -> raid5_n */
} else if (seg_is_raid4(seg_from) && segtype_is_any_raid5(*segtype)) {
seg_flag = SEG_RAID5_N;
7 years, 1 month