master - display: show monitoring status
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=91a8e4a3d81989...
Commit: 91a8e4a3d8198990ddffcfa9916ba22dcb0c033d
Parent: e6168b8d70935004e38bc2f1ac9d57cc0bf6df10
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Apr 28 11:53:56 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 28 12:39:03 2014 +0200
display: show monitoring status
When displaying segments (lvdisplay --maps)
show monitoring status when supported by segment.
---
WHATS_NEW | 1 +
lib/display/display.c | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index cd649da..de9ef23 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Display monitoring status for monitorable segments in 'lvdisplay --maps'.
Display virtual extents for virtual LVs in 'lvdisplay --maps'.
Make vgsplit fail cleanly when not all PVs are specified for RAID 4/5/6.
Make vgsplit work on mirrors with logs that share PVs with images.
diff --git a/lib/display/display.c b/lib/display/display.c
index a34d947..d824150 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -667,6 +667,10 @@ int lvdisplay_segments(const struct logical_volume *lv)
log_print(" Type\t\t%s", seg->segtype->ops->name(seg));
+ if (seg->segtype->ops->target_monitored)
+ log_print(" Monitoring\t\t%s",
+ lvseg_monitor_dup(lv->vg->cmd->mem, seg));
+
if (seg->segtype->ops->display)
seg->segtype->ops->display(seg);
}
10 years
master - display: use Virtual for virtual LV
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e6168b8d709350...
Commit: e6168b8d70935004e38bc2f1ac9d57cc0bf6df10
Parent: 5b28cbd7c2cd8413c189fff1286a579174ca082a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Apr 28 11:19:51 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 28 12:37:50 2014 +0200
display: use Virtual for virtual LV
Emphesize virtual extents for virtual LVs and for
those use 'Virtual extents' instead of 'Logical extents',
so it's immeditatelly visible, which extents do have
straighforward physical backend.
---
WHATS_NEW | 1 +
lib/display/display.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3f879c9..cd649da 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Display virtual extents for virtual LVs in 'lvdisplay --maps'.
Make vgsplit fail cleanly when not all PVs are specified for RAID 4/5/6.
Make vgsplit work on mirrors with logs that share PVs with images.
Use devices/ignore_suspended_devices=0 by default if not defined in lvm.conf.
diff --git a/lib/display/display.c b/lib/display/display.c
index c93b2b3..a34d947 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -661,7 +661,8 @@ int lvdisplay_segments(const struct logical_volume *lv)
log_print("--- Segments ---");
dm_list_iterate_items(seg, &lv->segments) {
- log_print("Logical extent %u to %u:",
+ log_print("%s extents %u to %u:",
+ lv_is_virtual(lv) ? "Virtual" : "Logical",
seg->le, seg->le + seg->len - 1);
log_print(" Type\t\t%s", seg->segtype->ops->name(seg));
10 years
master - cleanup: _move_pv is static
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5b28cbd7c2cd84...
Commit: 5b28cbd7c2cd8413c189fff1286a579174ca082a
Parent: 4360fdf89c7f38c5de0d3e6d612f67ee915cba15
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Apr 28 12:11:44 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Apr 28 12:11:44 2014 +0200
cleanup: _move_pv is static
metadata/metadata.c:363:5: warning: no previous prototype for '_move_pv' [-Wmissing-prototypes]
---
lib/metadata/metadata.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index edc55ef..e2abba7 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -360,8 +360,8 @@ out:
return r;
}
-int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
- const char *pv_name, int enforce_pv_from_source)
+static int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
+ const char *pv_name, int enforce_pv_from_source)
{
struct physical_volume *pv;
struct pv_list *pvl;
10 years
master - libdevmapper: add dm_units_to_factor for size unit parsing
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4360fdf89c7f38...
Commit: 4360fdf89c7f38c5de0d3e6d612f67ee915cba15
Parent: 75d399800ab60264d1201ad3fa1f9283542459f6
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Apr 28 10:25:43 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Apr 28 10:25:43 2014 +0200
libdevmapper: add dm_units_to_factor for size unit parsing
Actually moving the existing code from LVM to libdm for reuse.
---
WHATS_NEW_DM | 1 +
lib/commands/toolcontext.c | 4 +-
lib/display/display.c | 99 -----------------------------------------
lib/display/display.h | 2 -
libdm/libdevmapper.h | 44 ++++++++++++++++++
libdm/libdm-string.c | 106 ++++++++++++++++++++++++++++++++++++++++++++
tools/lvmcmdline.c | 4 +-
7 files changed, 155 insertions(+), 105 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 6a983a7..c81d354 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.88 -
=================================
+ Add dm_units_to_factor for size unit parsing.
Increase bitset size for minors for thin dmeventd plugin.
Version 1.02.85 - 10th April 2014
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index d62fb8a..b2f8293 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -282,8 +282,8 @@ static int _check_config(struct cmd_context *cmd)
int process_profilable_config(struct cmd_context *cmd) {
if (!(cmd->default_settings.unit_factor =
- units_to_bytes(find_config_tree_str(cmd, global_units_CFG, NULL),
- &cmd->default_settings.unit_type))) {
+ dm_units_to_factor(find_config_tree_str(cmd, global_units_CFG, NULL),
+ &cmd->default_settings.unit_type, 1, NULL))) {
log_error("Invalid units specification");
return 0;
}
diff --git a/lib/display/display.c b/lib/display/display.c
index b7fbf1a..c93b2b3 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -20,8 +20,6 @@
#include "toolcontext.h"
#include "segtype.h"
#include "defaults.h"
-#include <math.h> /* fabs() */
-#include <float.h> /* DBL_EPSILON */
#include <stdarg.h>
#define SIZE_BUF 128
@@ -44,103 +42,6 @@ static const struct {
static const int _num_policies = DM_ARRAY_SIZE(_policies);
-/* Test if the doubles are close enough to be considered equal */
-static int _close_enough(double d1, double d2)
-{
- return fabs(d1 - d2) < DBL_EPSILON;
-}
-
-uint64_t units_to_bytes(const char *units, char *unit_type)
-{
- char *ptr = NULL;
- uint64_t v;
- double custom_value = 0;
- uint64_t multiplier;
-
- if (isdigit(*units)) {
- custom_value = strtod(units, &ptr);
- if (ptr == units)
- return 0;
- v = (uint64_t) strtoull(units, NULL, 10);
- if (_close_enough((double) v, custom_value))
- custom_value = 0; /* Use integer arithmetic */
- units = ptr;
- } else
- v = 1;
-
- /* Only one units char permitted. */
- if (units[0] && units[1])
- return 0;
-
- if (v == 1)
- *unit_type = *units;
- else
- *unit_type = 'U';
-
- switch (*units) {
- case 'h':
- case 'H':
- multiplier = v = UINT64_C(1);
- *unit_type = *units;
- break;
- case 'b':
- case 'B':
- multiplier = UINT64_C(1);
- break;
-#define KILO UINT64_C(1024)
- case 's':
- case 'S':
- multiplier = (KILO/2);
- break;
- case 'k':
- multiplier = KILO;
- break;
- case 'm':
- multiplier = KILO * KILO;
- break;
- case 'g':
- multiplier = KILO * KILO * KILO;
- break;
- case 't':
- multiplier = KILO * KILO * KILO * KILO;
- break;
- case 'p':
- multiplier = KILO * KILO * KILO * KILO * KILO;
- break;
- case 'e':
- multiplier = KILO * KILO * KILO * KILO * KILO * KILO;
- break;
-#undef KILO
-#define KILO UINT64_C(1000)
- case 'K':
- multiplier = KILO;
- break;
- case 'M':
- multiplier = KILO * KILO;
- break;
- case 'G':
- multiplier = KILO * KILO * KILO;
- break;
- case 'T':
- multiplier = KILO * KILO * KILO * KILO;
- break;
- case 'P':
- multiplier = KILO * KILO * KILO * KILO * KILO;
- break;
- case 'E':
- multiplier = KILO * KILO * KILO * KILO * KILO * KILO;
- break;
-#undef KILO
- default:
- return 0;
- }
-
- if (_close_enough(custom_value, 0.))
- return v * multiplier; /* Use integer arithmetic */
- else
- return (uint64_t) (custom_value * multiplier);
-}
-
char alloc_policy_char(alloc_policy_t alloc)
{
int i;
diff --git a/lib/display/display.h b/lib/display/display.h
index 41fba03..d5c0efa 100644
--- a/lib/display/display.h
+++ b/lib/display/display.h
@@ -22,8 +22,6 @@
#include <stdint.h>
-uint64_t units_to_bytes(const char *units, char *unit_type);
-
/* Specify size in KB */
const char *display_size(const struct cmd_context *cmd, uint64_t size);
const char *display_size_long(const struct cmd_context *cmd, uint64_t size);
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 5f7b14c..8ffa145 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1454,6 +1454,50 @@ void dm_unescape_colons_and_at_signs(char *src,
*/
int dm_strncpy(char *dest, const char *src, size_t n);
+/*
+ * Recognize unit specifier in the 'units' arg and return a factor
+ * representing that unit. If the 'units' contains a prefix with digits,
+ * the 'units' is considered to be a custom unit.
+ *
+ * Also, set 'unit_type' output arg to the character that represents
+ * the unit specified. The 'unit_type' character equals to the unit
+ * character itself recognized in the 'units' arg for canonical units.
+ * Otherwise, the 'unit_type' character is set to 'U' for custom unit.
+ *
+ * An example for k/K canonical units and 8k/8K custom units:
+ *
+ * units unit_type return value (factor)
+ * k k 1024
+ * K K 1000
+ * 8k U 1024*8
+ * 8K U 1000*8
+ * etc...
+ *
+ * Recognized units:
+ *
+ * h/H - human readable (returns 1 for both)
+ * b/B - byte (returns 1 for both)
+ * s/S - sector (returns 512 for both)
+ * k/K - kilo (returns 1024/1000 respectively)
+ * m/M - mega (returns 1024^2/1000^2 respectively)
+ * g/G - giga (returns 1024^3/1000^3 respectively)
+ * t/T - tera (returns 1024^4/1000^4 respectively)
+ * p/P - peta (returns 1024^5/1000^5 respectively)
+ * e/E - exa (returns 1024^6/1000^6 respectively)
+ *
+ * Only one units character is allowed in the 'units' arg
+ * if strict mode is enabled by 'strict' arg.
+ *
+ * The 'endptr' output arg, if not NULL, saves the pointer
+ * in the 'units' string which follows the unit specifier
+ * recognized (IOW the position where the parsing of the
+ * unit specifier stopped).
+ *
+ * Returns the unit factor or 0 if no unit is recognized.
+ */
+uint64_t dm_units_to_factor(const char *units, char *unit_type,
+ int strict, char **endptr);
+
/**************************
* file/stream manipulation
**************************/
diff --git a/libdm/libdm-string.c b/libdm/libdm-string.c
index 64a9792..7336e6b 100644
--- a/libdm/libdm-string.c
+++ b/libdm/libdm-string.c
@@ -16,6 +16,8 @@
#include <ctype.h>
#include <stdarg.h>
+#include <math.h> /* fabs() */
+#include <float.h> /* DBL_EPSILON */
/*
* consume characters while they match the predicate function.
@@ -434,3 +436,107 @@ int dm_strncpy(char *dest, const char *src, size_t n)
return 0;
}
+
+/* Test if the doubles are close enough to be considered equal */
+static int _close_enough(double d1, double d2)
+{
+ return fabs(d1 - d2) < DBL_EPSILON;
+}
+
+uint64_t dm_units_to_factor(const char *units, char *unit_type,
+ int strict, char **endptr)
+{
+ char *ptr = NULL;
+ uint64_t v;
+ double custom_value = 0;
+ uint64_t multiplier;
+
+ if (endptr)
+ *endptr = (char *) units;
+
+ if (isdigit(*units)) {
+ custom_value = strtod(units, &ptr);
+ if (ptr == units)
+ return 0;
+ v = (uint64_t) strtoull(units, NULL, 10);
+ if (_close_enough((double) v, custom_value))
+ custom_value = 0; /* Use integer arithmetic */
+ units = ptr;
+ } else
+ v = 1;
+
+ /* Only one units char permitted in strict mode. */
+ if (strict && units[0] && units[1])
+ return 0;
+
+ if (v == 1)
+ *unit_type = *units;
+ else
+ *unit_type = 'U';
+
+ switch (*units) {
+ case 'h':
+ case 'H':
+ multiplier = v = UINT64_C(1);
+ *unit_type = *units;
+ break;
+ case 'b':
+ case 'B':
+ multiplier = UINT64_C(1);
+ break;
+#define KILO UINT64_C(1024)
+ case 's':
+ case 'S':
+ multiplier = (KILO/2);
+ break;
+ case 'k':
+ multiplier = KILO;
+ break;
+ case 'm':
+ multiplier = KILO * KILO;
+ break;
+ case 'g':
+ multiplier = KILO * KILO * KILO;
+ break;
+ case 't':
+ multiplier = KILO * KILO * KILO * KILO;
+ break;
+ case 'p':
+ multiplier = KILO * KILO * KILO * KILO * KILO;
+ break;
+ case 'e':
+ multiplier = KILO * KILO * KILO * KILO * KILO * KILO;
+ break;
+#undef KILO
+#define KILO UINT64_C(1000)
+ case 'K':
+ multiplier = KILO;
+ break;
+ case 'M':
+ multiplier = KILO * KILO;
+ break;
+ case 'G':
+ multiplier = KILO * KILO * KILO;
+ break;
+ case 'T':
+ multiplier = KILO * KILO * KILO * KILO;
+ break;
+ case 'P':
+ multiplier = KILO * KILO * KILO * KILO * KILO;
+ break;
+ case 'E':
+ multiplier = KILO * KILO * KILO * KILO * KILO * KILO;
+ break;
+#undef KILO
+ default:
+ return 0;
+ }
+
+ if (endptr)
+ *endptr = (char *) units + 1;
+
+ if (_close_enough(custom_value, 0.))
+ return v * multiplier; /* Use integer arithmetic */
+ else
+ return (uint64_t) (custom_value * multiplier);
+}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 758c429..7e4d9a6 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -923,8 +923,8 @@ static int _get_settings(struct cmd_context *cmd)
if (arg_count(cmd, units_ARG))
if (!(cmd->current_settings.unit_factor =
- units_to_bytes(arg_str_value(cmd, units_ARG, ""),
- &cmd->current_settings.unit_type))) {
+ dm_units_to_factor(arg_str_value(cmd, units_ARG, ""),
+ &cmd->current_settings.unit_type, 1, NULL))) {
log_error("Invalid units specification");
return EINVALID_CMD_LINE;
}
10 years
master - NIX: Use VM images with the correct root module list.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=75d399800ab602...
Commit: 75d399800ab60264d1201ad3fa1f9283542459f6
Parent: 3bce3ad52a6c1fafd55573c465486faed3bb0a77
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sat Apr 26 13:45:23 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sat Apr 26 13:46:25 2014 +0200
NIX: Use VM images with the correct root module list.
---
nix/default.nix | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/nix/default.nix b/nix/default.nix
index faf179a..228047f 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -147,10 +147,10 @@ let
[ "loop" "dm_mod" "dm_snapshot" "dm_mirror" "dm_zero" "dm_raid" "dm_thin_pool" ]; };
release = import "${nixpkgs}/pkgs/build-support/release/default.nix" {
pkgs = pkgs // { vmTools = tools; }; };
- imgs = pkgs.vmTools.diskImageFuns //
+ imgs = tools.diskImageFuns //
mapAttrs (n: a: b: pkgs.vmTools.makeImageFromRPMDist (a // b)) extra_distros;
- rpmdistros = pkgs.vmTools.rpmDistros // extra_distros;
- rpmbuild = pkgs.vmTools.buildRPM;
+ rpmdistros = tools.rpmDistros // extra_distros;
+ rpmbuild = tools.buildRPM;
};
extra_rpms = rec {
10 years
master - test: Add the new vgsplit RAID test file forgotten in the last commit
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3bce3ad52a6c1f...
Commit: 3bce3ad52a6c1fafd55573c465486faed3bb0a77
Parent: c671be434c15bf10b624ba8aaa43a378833179d5
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Apr 25 16:59:09 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Fri Apr 25 16:59:09 2014 -0500
test: Add the new vgsplit RAID test file forgotten in the last commit
---
test/shell/vgsplit-raid.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/test/shell/vgsplit-raid.sh b/test/shell/vgsplit-raid.sh
new file mode 100644
index 0000000..898fc9a
--- /dev/null
+++ b/test/shell/vgsplit-raid.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Test vgsplit operation, including different LV types
+
+. lib/test
+
+COMM() {
+ LAST_TEST="$@"
+}
+
+create_vg_() {
+ vgcreate -s 64k "$@"
+}
+
+aux target_at_least dm-raid 1 1 0 || skip
+
+aux prepare_pvs 5 10
+
+#
+# vgsplit can be done into a new or existing VG
+#
+for i in new existing
+do
+ #
+ # We can have PVs or LVs on the cmdline
+ #
+ for j in PV LV
+ do
+COMM "vgsplit correctly splits RAID LV into $i VG ($j args)"
+ create_vg_ $vg1 "$dev1" "$dev2" "$dev3"
+ test $i = existing && create_vg_ $vg2 "$dev5"
+
+ lvcreate -an -Zn -l 64 --type raid5 -i 2 -n $lv1 $vg1
+ if [ $j = PV ]; then
+ not vgsplit $vg1 $vg2 "$dev1"
+ not vgsplit $vg1 $vg2 "$dev2"
+ not vgsplit $vg1 $vg2 "$dev1" "$dev2"
+ vgsplit $vg1 $vg2 "$dev1" "$dev2" "$dev3"
+ else
+ vgsplit -n $lv1 $vg1 $vg2
+ fi
+ if [ $i = existing ]; then
+ check pvlv_counts $vg2 4 1 0
+ else
+ check pvlv_counts $vg2 3 1 0
+ fi
+ vgremove -f $vg2
+ done
+done
10 years
master - test: Move the RAID vgsplit test into a separate file
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c671be434c15bf...
Commit: c671be434c15bf10b624ba8aaa43a378833179d5
Parent: 3c4234f825c93c9cd61409ade9039ba4033c8008
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Apr 25 16:57:43 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Fri Apr 25 16:57:43 2014 -0500
test: Move the RAID vgsplit test into a separate file
---
test/shell/vgsplit-operation.sh | 22 ----------------------
1 files changed, 0 insertions(+), 22 deletions(-)
diff --git a/test/shell/vgsplit-operation.sh b/test/shell/vgsplit-operation.sh
index 3a8a51a..201ad17 100644
--- a/test/shell/vgsplit-operation.sh
+++ b/test/shell/vgsplit-operation.sh
@@ -230,28 +230,6 @@ COMM "vgsplit correctly splits linear LV but not mirror LV into $i VG ($j args)"
check pvlv_counts $vg2 1 1 0
fi
vgremove -f $vg1 $vg2
-
-if aux target_at_least dm-raid 1 1 0; then
-COMM "vgsplit correctly splits RAID LV into $i VG ($j args)"
- create_vg_ $vg1 "$dev1" "$dev2" "$dev3"
- test $i = existing && create_vg_ $vg2 "$dev5"
-
- lvcreate -an -Zn -l 64 --type raid5 -i 2 -n $lv1 $vg1
- if [ $j = PV ]; then
- not vgsplit $vg1 $vg2 "$dev1"
- not vgsplit $vg1 $vg2 "$dev2"
- not vgsplit $vg1 $vg2 "$dev1" "$dev2"
- vgsplit $vg1 $vg2 "$dev1" "$dev2" "$dev3"
- else
- vgsplit -n $lv1 $vg1 $vg2
- fi
- if [ $i = existing ]; then
- check pvlv_counts $vg2 4 1 0
- else
- check pvlv_counts $vg2 3 1 0
- fi
- vgremove -f $vg2
-fi
done
done
10 years
master - vgsplit: Make RAID 4/5/6 fail cleanly when too few PV specified
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3c4234f825c93c...
Commit: 3c4234f825c93c9cd61409ade9039ba4033c8008
Parent: 4dffb9fca9dba16bba0ec41ecc16ed42fe2dd4cf
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Apr 25 16:24:50 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Fri Apr 25 16:24:50 2014 -0500
vgsplit: Make RAID 4/5/6 fail cleanly when too few PV specified
While the 'raid1/10' segment types were being handled inadvertently
by '_move_mirrors()', the parity RAIDs were not being properly checked
to ensure that the user had specified all necessary PVs when moving
them. Thus, internal errors were being triggered when only part of
a RAID LV was moved to the new VG. I've added a new function,
'_move_raid()', which properly checks over any affected RAID LVs and
ensures that all the necessary PVs are being moved.
---
WHATS_NEW | 1 +
test/shell/vgsplit-operation.sh | 6 ++--
tools/vgsplit.c | 47 +++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index af9f6c3..3f879c9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Make vgsplit fail cleanly when not all PVs are specified for RAID 4/5/6.
Make vgsplit work on mirrors with logs that share PVs with images.
Use devices/ignore_suspended_devices=0 by default if not defined in lvm.conf.
Use proper libmem mempool for allocation of unknown segment name.
diff --git a/test/shell/vgsplit-operation.sh b/test/shell/vgsplit-operation.sh
index 5dbff69..3a8a51a 100644
--- a/test/shell/vgsplit-operation.sh
+++ b/test/shell/vgsplit-operation.sh
@@ -238,9 +238,9 @@ COMM "vgsplit correctly splits RAID LV into $i VG ($j args)"
lvcreate -an -Zn -l 64 --type raid5 -i 2 -n $lv1 $vg1
if [ $j = PV ]; then
-# not vgsplit $vg1 $vg2 "$dev1"
-# not vgsplit $vg1 $vg2 "$dev2"
-# not vgsplit $vg1 $vg2 "$dev1" "$dev2"
+ not vgsplit $vg1 $vg2 "$dev1"
+ not vgsplit $vg1 $vg2 "$dev2"
+ not vgsplit $vg1 $vg2 "$dev1" "$dev2"
vgsplit $vg1 $vg2 "$dev1" "$dev2" "$dev3"
else
vgsplit -n $lv1 $vg1 $vg2
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 9d26079..fb67919 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -66,6 +66,9 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
if ((lv->status & SNAPSHOT))
continue;
+ if (lv_is_raid(lv))
+ continue;
+
if ((lv->status & MIRRORED))
continue;
@@ -184,6 +187,9 @@ static int _move_mirrors(struct volume_group *vg_from,
dm_list_iterate_safe(lvh, lvht, &vg_from->lvs) {
lv = dm_list_item(lvh, struct lv_list)->lv;
+ if (lv_is_raid(lv))
+ continue;
+
if (!(lv->status & MIRRORED))
continue;
@@ -226,6 +232,43 @@ static int _move_mirrors(struct volume_group *vg_from,
return 1;
}
+static int _move_raid(struct volume_group *vg_from,
+ struct volume_group *vg_to)
+{
+ struct dm_list *lvh, *lvht;
+ struct logical_volume *lv;
+ struct lv_segment *seg;
+ unsigned s, seg_in;
+
+ dm_list_iterate_safe(lvh, lvht, &vg_from->lvs) {
+ lv = dm_list_item(lvh, struct lv_list)->lv;
+
+ if (!lv_is_raid(lv))
+ continue;
+
+ seg = first_seg(lv);
+
+ seg_in = 0;
+ for (s = 0; s < seg->area_count; s++) {
+ if (_lv_is_in_vg(vg_to, seg_lv(seg, s)))
+ seg_in++;
+ if (_lv_is_in_vg(vg_to, seg_metalv(seg, s)))
+ seg_in++;
+ }
+
+ if (seg_in && seg_in != (seg->area_count * 2)) {
+ log_error("Can't split RAID %s between "
+ "two Volume Groups", lv->name);
+ return 0;
+ }
+
+ if (!_move_one_lv(vg_from, vg_to, lvh))
+ return_0;
+ }
+
+ return 1;
+}
+
static int _move_thins(struct volume_group *vg_from,
struct volume_group *vg_to)
{
@@ -547,6 +590,10 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
goto_bad;
/* FIXME Separate the 'move' from the 'validation' to fix dev stacks */
+ /* Move required RAID across */
+ if (!(_move_raid(vg_from, vg_to)))
+ goto_bad;
+
/* Move required mirrors across */
if (!(_move_mirrors(vg_from, vg_to)))
goto_bad;
10 years
master - test/vgsplit-operation.sh: Add vgsplit tests for RAID
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4dffb9fca9dba1...
Commit: 4dffb9fca9dba16bba0ec41ecc16ed42fe2dd4cf
Parent: 76687f4cacd6ca3f8953d4ee915efc159838cd91
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Apr 25 16:22:40 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Fri Apr 25 16:22:40 2014 -0500
test/vgsplit-operation.sh: Add vgsplit tests for RAID
vgsplit of RAID volumes was problematic because the metadata area
and data areas were always on the same PVs. This problem is similar
to one that was just fixed for mirrors that had log and images sharing
a PV (commit 9ac858f). We can now add RAID LVs to the tests for
vgsplit.
Note that there still seems to be an issue when specifying an
incomplete set of PVs when moving RAID LVs.
---
test/shell/vgsplit-operation.sh | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/test/shell/vgsplit-operation.sh b/test/shell/vgsplit-operation.sh
index 097f0f5..5dbff69 100644
--- a/test/shell/vgsplit-operation.sh
+++ b/test/shell/vgsplit-operation.sh
@@ -231,6 +231,27 @@ COMM "vgsplit correctly splits linear LV but not mirror LV into $i VG ($j args)"
fi
vgremove -f $vg1 $vg2
+if aux target_at_least dm-raid 1 1 0; then
+COMM "vgsplit correctly splits RAID LV into $i VG ($j args)"
+ create_vg_ $vg1 "$dev1" "$dev2" "$dev3"
+ test $i = existing && create_vg_ $vg2 "$dev5"
+
+ lvcreate -an -Zn -l 64 --type raid5 -i 2 -n $lv1 $vg1
+ if [ $j = PV ]; then
+# not vgsplit $vg1 $vg2 "$dev1"
+# not vgsplit $vg1 $vg2 "$dev2"
+# not vgsplit $vg1 $vg2 "$dev1" "$dev2"
+ vgsplit $vg1 $vg2 "$dev1" "$dev2" "$dev3"
+ else
+ vgsplit -n $lv1 $vg1 $vg2
+ fi
+ if [ $i = existing ]; then
+ check pvlv_counts $vg2 4 1 0
+ else
+ check pvlv_counts $vg2 3 1 0
+ fi
+ vgremove -f $vg2
+fi
done
done
10 years
master - WHATS_NEW: Add message for commit 9ac858f
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=76687f4cacd6ca...
Commit: 76687f4cacd6ca3f8953d4ee915efc159838cd91
Parent: 9ac858fe6b56318cee821e86e4a5edede75d5134
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Apr 25 14:55:32 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Fri Apr 25 14:55:32 2014 -0500
WHATS_NEW: Add message for commit 9ac858f
WHATS_NEW for commit:
9ac858f vgsplit: Make vgsplit work on mirrors with leg and log on same PV
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1615f37..af9f6c3 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Make vgsplit work on mirrors with logs that share PVs with images.
Use devices/ignore_suspended_devices=0 by default if not defined in lvm.conf.
Use proper libmem mempool for allocation of unknown segment name.
Add --readonly to reporting and display tools for lock-free metadata access.
10 years