master - fsadm: always detect mounted fs with extX
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2b7ac2bfb3461073486...
Commit: 2b7ac2bfb3461073486a7b296a76ef26b0d5d733
Parent: a29e7843b1b9fe10af0e5bef8304c65a176e394f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 22 14:39:10 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon May 22 15:10:16 2017 +0200
fsadm: always detect mounted fs with extX
Since we add more validation to 'detect_mounted' function make sure
we always use it even with 'resize' action, so numerous validations
are not skipped.
---
scripts/fsadm.sh | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index 534aac1..831b3ca 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -318,6 +318,9 @@ validate_parsing() {
# - unmounted for downsize
####################################
resize_ext() {
+ local IS_MOUNTED=0
+ detect_mounted && IS_MOUNTED=1
+
verbose "Parsing $TUNE_EXT -l \"$VOLUME\""
for i in $(LC_ALL=C "$TUNE_EXT" -l "$VOLUME"); do
case "$i" in
@@ -330,7 +333,7 @@ resize_ext() {
FSFORCE=$FORCE
if [ "$NEWBLOCKCOUNT" -lt "$BLOCKCOUNT" -o "$EXTOFF" -eq 1 ]; then
- detect_mounted && verbose "$RESIZE_EXT needs unmounted filesystem" && try_umount
+ test $IS_MOUNTED -eq 1 && verbose "$RESIZE_EXT needs unmounted filesystem" && try_umount
REMOUNT=$MOUNTED
if test -n "$MOUNTED" ; then
# Forced fsck -f for umounted extX filesystem.
6 years, 11 months
master - man lvmraid: indirect conversions
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a29e7843b1b9fe10af0...
Commit: a29e7843b1b9fe10af0e5bef8304c65a176e394f
Parent: 2bf01c2f3797d52f1ace72e32028912337918223
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu May 18 16:47:37 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu May 18 16:47:37 2017 -0500
man lvmraid: indirect conversions
Start documenting multi-step conversions.
Don't number examples.
---
man/lvmraid.7_main | 81 +++++++++++++++++++++++++--------------------------
1 files changed, 40 insertions(+), 41 deletions(-)
diff --git a/man/lvmraid.7_main b/man/lvmraid.7_main
index f0d28f5..6e0287a 100644
--- a/man/lvmraid.7_main
+++ b/man/lvmraid.7_main
@@ -896,7 +896,7 @@ between linear and raid1.
.IP \(bu 3
between mirror and raid1.
.IP \(bu 3
-between 2-legged raid1 and raid4/5.
+between raid1 with two images and raid4/5.
.IP \(bu 3
between striped/raid0 and raid4.
.IP \(bu 3
@@ -912,39 +912,46 @@ between striped/raid0 and raid10.
.IP \(bu 3
between striped and raid4.
-.SS Examples
+.SS Indirect conversions
-1. Converting an LV from \fBlinear\fP to \fBraid1\fP.
+Converting from one raid level to another may require multiple steps,
+converting first to intermediate raid levels.
-.nf
-# lvs -a -o name,segtype,size vg
- LV Type LSize
- lv linear 300.00g
+.B linear to raid6
-# lvconvert --type raid1 --mirrors 1 vg/lv
+To convert an LV from linear to raid6:
+.br
+1. convert to raid1 with two images
+.br
+2. convert to raid5 (internally raid5_ls) with two images
+.br
+3. convert to raid5 with three or more stripes (reshape)
+.br
+4. convert to raid6 (internally raid6_ls_6)
+.br
+5. convert to raid6 (internally raid6_zr, reshape)
-# lvs -a -o name,segtype,size vg
- LV Type LSize
- lv raid1 300.00g
- [lv_rimage_0] linear 300.00g
- [lv_rimage_1] linear 300.00g
- [lv_rmeta_0] linear 3.00m
- [lv_rmeta_1] linear 3.00m
-.fi
+The commands to perform the steps above are:
+.br
+1. lvconvert --type raid1 --mirrors 1 LV
+.br
+2. lvconvert --type raid5 LV
+.br
+3. lvconvert --stripes 3 LV
+.br
+4. lvconvert --type raid6 LV
+.br
+5. lvconvert --type raid6 LV
-2. Converting an LV from \fBmirror\fP to \fBraid1\fP.
+The final conversion from raid6_ls_6 to raid6_zr is done to avoid the
+potential write/recovery performance reduction in raid6_ls_6 because of
+the dedicated parity device. raid6_zr rotates data and parity blocks to
+avoid this.
-.nf
-# lvs -a -o name,segtype,size vg
- LV Type LSize
- lv mirror 100.00g
- [lv_mimage_0] linear 100.00g
- [lv_mimage_1] linear 100.00g
- [lv_mlog] linear 3.00m
.SS Examples
-1. Converting an LV from \fBlinear\fP to \fBraid1\fP.
+Converting an LV from \fBlinear\fP to \fBraid1\fP.
.nf
# lvs -a -o name,segtype,size vg
@@ -962,7 +969,7 @@ between striped and raid4.
[lv_rmeta_1] linear 3.00m
.fi
-2. Converting an LV from \fBmirror\fP to \fBraid1\fP.
+Converting an LV from \fBmirror\fP to \fBraid1\fP.
.nf
# lvs -a -o name,segtype,size vg
@@ -983,28 +990,17 @@ between striped and raid4.
[lv_rmeta_1] linear 3.00m
.fi
-3. Converting an LV from \fBlinear\fP to \fBraid1\fP (with 3 images).
+Converting an LV from \fBlinear\fP to \fBraid1\fP (with 3 images).
.nf
-Start with a linear LV:
-
-# lvcreate -L1G -n lv vg
-
-Convert the linear LV to raid1 with three images
-(original linear image plus 2 mirror images):
-
# lvconvert --type raid1 --mirrors 2 vg/lv
.fi
-4. Converting an LV from \fBstriped\fP (with 4 stripes) to \fBraid6_n_6\fP.
+Converting an LV from \fBstriped\fP (with 4 stripes) to \fBraid6_n_6\fP.
.nf
-Start with a striped LV:
-
# lvcreate --stripes 4 -L64M -n lv vg
-Convert the striped LV to raid6_n_6:
-
# lvconvert --type raid6 vg/lv
# lvs -a -o lv_name,segtype,sync_percent,data_copies
@@ -1051,7 +1047,9 @@ that is done, the new stripe is unquiesced and used.)
.SS Examples
-1. Converting raid6_n_6 to raid6_nr with rotating data/parity.
+(Command output shown in examples may change.)
+
+Converting raid6_n_6 to raid6_nr with rotating data/parity.
This conversion naturally follows a previous conversion from striped/raid0
to raid6_n_6 (shown above). It completes the transition to a more
@@ -1318,7 +1316,8 @@ In case the RaidLV should be converted to striped:
.nf
# lvconvert --type striped vg/lv
Unable to convert LV vg/lv from raid6_nr to striped.
- Converting vg/lv from raid6_nr is directly possible to the following layouts:
+ Converting vg/lv from raid6_nr is directly possible to the \
+ following layouts:
raid6_nc
raid6_zr
raid6_la_6
6 years, 11 months
master - lvconvert: fix logic in automatic settings of possible (raid) LV types
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2bf01c2f3797d52f1ac...
Commit: 2bf01c2f3797d52f1ace72e32028912337918223
Parent: 8e99a46d09ef21e9a1741eb333e16aaa08ac50f1
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu May 18 16:11:52 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu May 18 16:20:39 2017 +0200
lvconvert: fix logic in automatic settings of possible (raid) LV types
Commit 5fe07d3574ddce3d194f0fa57af9028348a91008 failed to set raid5 types
properly on conversions from raid6. It always enforced raid6_ls_6
for types raid6/raid6_zr/raid6_nr/raid6_nc, thus requiring 3 conversions
instead of 2 when asking for raid5_{la,rs,ra,n}.
Related: rhbz1439403
---
lib/metadata/raid_manip.c | 33 +++++++++++++++++++--------------
1 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index d913301..005075c 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -5792,27 +5792,33 @@ static uint64_t _r5_to_r6[][2] = {
/* Return segment type flag for raid5 -> raid6 conversions */
-static uint64_t _get_r56_flag(const struct lv_segment *seg, unsigned idx)
+static uint64_t _get_r56_flag(const struct segment_type *segtype, unsigned idx)
{
unsigned elems = ARRAY_SIZE(_r5_to_r6);
while (elems--)
- if (seg->segtype->flags & _r5_to_r6[elems][idx])
+ if (segtype->flags & _r5_to_r6[elems][idx])
return _r5_to_r6[elems][!idx];
return 0;
}
-/* Return segment type flag for raid5 -> raid6 conversions */
+/* Return segment type flag of @seg for raid5 -> raid6 conversions */
static uint64_t _raid_seg_flag_5_to_6(const struct lv_segment *seg)
{
- return _get_r56_flag(seg, 0);
+ return _get_r56_flag(seg->segtype, 0);
}
-/* Return segment type flag for raid6 -> raid5 conversions */
+/* Return segment type flag of @seg for raid6 -> raid5 conversions */
static uint64_t _raid_seg_flag_6_to_5(const struct lv_segment *seg)
{
- return _get_r56_flag(seg, 1);
+ return _get_r56_flag(seg->segtype, 1);
+}
+
+/* Return segment type flag of @segtype for raid5 -> raid6 conversions */
+static uint64_t _raid_segtype_flag_5_to_6(const struct segment_type *segtype)
+{
+ return _get_r56_flag(segtype, 0);
}
/* Change segtype for raid* for convenience where necessary. */
@@ -5892,17 +5898,16 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
} else if (seg_is_raid4(seg_from) && !segtype_is_raid6_n_6(*segtype))
seg_flag = SEG_RAID6_N_6;
-
- else if (!(seg_flag = _raid_seg_flag_5_to_6(seg_from)))
- seg_flag = SEG_RAID5_N;
+ else
+ seg_flag = _raid_seg_flag_5_to_6(seg_from);
}
/* raid6 -> striped/raid0/raid5/raid10 */
} else if (seg_is_any_raid6(seg_from)) {
if (segtype_is_raid1(*segtype)) {
/* No result for raid6_{zr,nr,nc} */
- if (!((seg_flag = _raid_seg_flag_6_to_5(seg_from)) ||
- !(seg_flag & (*segtype)->flags)))
+ if (!(seg_flag = _raid_seg_flag_6_to_5(seg_from)) ||
+ !(seg_flag & (*segtype)->flags))
seg_flag = SEG_RAID6_LS_6;
} else if (segtype_is_any_raid10(*segtype)) {
@@ -5917,9 +5922,9 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
} else if (segtype_is_any_raid5(*segtype))
/* No result for raid6_{zr,nr,nc} */
- if (!((seg_flag = _raid_seg_flag_6_to_5(seg_from)) ||
- !(seg_flag & (*segtype)->flags)))
- seg_flag = SEG_RAID6_N_6;
+ if (!(seg_flag = _raid_seg_flag_6_to_5(seg_from)) ||
+ !(seg_flag & (*segtype)->flags))
+ seg_flag = _raid_segtype_flag_5_to_6(*segtype);
/* -> raid1 */
} else if (!seg_is_mirror(seg_from) && segtype_is_raid1(*segtype)) {
6 years, 11 months
master - lvmdbusd: Fix missed rename
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8e99a46d09ef21e9a17...
Commit: 8e99a46d09ef21e9a1741eb333e16aaa08ac50f1
Parent: 9c651b146ef7be080c5006f94c257e2c9815cd7f
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Thu May 18 12:52:46 2017 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Thu May 18 12:52:46 2017 +0200
lvmdbusd: Fix missed rename
Introduced By: e53454d6 (2.02.169)
Related: RHBZ#1348688
---
daemons/lvmdbusd/automatedproperties.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/lvmdbusd/automatedproperties.py b/daemons/lvmdbusd/automatedproperties.py
index 68cea6e..e188fa4 100644
--- a/daemons/lvmdbusd/automatedproperties.py
+++ b/daemons/lvmdbusd/automatedproperties.py
@@ -100,7 +100,7 @@ class AutomatedProperties(dbus.service.Object):
raise dbus.exceptions.DBusException(
obj._ap_interface,
'The object %s does not implement the %s interface'
- % (self.__class__, interface_name))
+ % (obj.__class__, interface_name))
@dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE,
in_signature='s', out_signature='a{sv}',
6 years, 11 months
master - lvconvert: fix indent and typo in last commit
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9c651b146ef7be080c5...
Commit: 9c651b146ef7be080c5006f94c257e2c9815cd7f
Parent: 5fe07d3574ddce3d194f0fa57af9028348a91008
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu May 18 00:43:20 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu May 18 00:43:20 2017 +0200
lvconvert: fix indent and typo in last commit
---
lib/metadata/raid_manip.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 99fe275..d913301 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -5871,8 +5871,8 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
seg_flag = SEG_RAID5_N;
else if (seg_is_any_raid5(seg_from) &&
- segtype_is_raid4(*segtype) &&
- !segtype_is_raid5_n(*segtype))
+ segtype_is_raid4(*segtype) &&
+ !segtype_is_raid5_n(*segtype))
seg_flag = SEG_RAID5_N;
else if (segtype_is_raid10(*segtype)) {
@@ -6071,7 +6071,7 @@ static int _conversion_options_allowed(const struct lv_segment *seg_from,
!is_same_level(seg_from->segtype, *segtype_to)) { /* Prompt here for takeover */
const char *basic_fmt = "Are you sure you want to convert %s LV %s";
const char *type_fmt = " to %s type";
- const char *question_fmt = " to %s type";
+ const char *question_fmt = "? [y/n]: ";
char *fmt;
size_t sz = strlen(basic_fmt) + ((seg_from->segtype == *segtype_to) ? 0 : strlen(type_fmt)) + strlen(question_fmt) + 1;
6 years, 11 months
master - lvconvert: enhance automatic settings of possible (raid) LV types
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5fe07d3574ddce3d194...
Commit: 5fe07d3574ddce3d194f0fa57af9028348a91008
Parent: 16c6d9f11ab581a79fb57fd36142af1dc57a3c61
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu May 18 00:18:15 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu May 18 00:18:15 2017 +0200
lvconvert: enhance automatic settings of possible (raid) LV types
Offer possible interim LV types and display their aliases
(e.g. raid5 and raid5_ls) for all conversions between
striped and any raid LVs in case user requests a type
not suitable to direct conversion.
E.g. running "lvconvert --type raid5 LV" on a striped
LV will replace raid5 aka raid5_ls (rotating parity)
with raid5_n (dedicated parity on last image).
User is asked to repeat the lvconvert command to get to the
requested LV type (raid5 aka raid5_ls in this example)
when such replacement occurs.
Resolves: rhbz1439403
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 312 ++++++++++++++++++++++++++++++++-------------
2 files changed, 222 insertions(+), 91 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5097c1b..07c2602 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.172 -
===============================
+ Enhance lvconvert automatic settings of possible (raid) LV types.
Allow lvchange to change properties on a thin pool data sub LV.
Fix lvcreate extent percentage calculation for mirrors.
Don't reinstate still-missing devices when correcting inconsistent metadata.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index b708442..99fe275 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -427,8 +427,10 @@ static int _raid_remove_top_layer(struct logical_volume *lv,
return 0;
}
- if (!(lvl_array = dm_pool_alloc(lv->vg->vgmem, 2 * sizeof(*lvl))))
+ if (!(lvl_array = dm_pool_alloc(lv->vg->vgmem, 2 * sizeof(*lvl)))) {
+ log_error("Memory allocation failed.");
return_0;
+ }
/* Add last metadata area to removal_lvs */
lvl_array[0].lv = seg_metalv(seg, 0);
@@ -786,8 +788,10 @@ static int _reorder_raid10_near_seg_areas(struct lv_segment *seg, enum raid0_rai
/* FIXME: once more data copies supported with raid10 */
stripes /= data_copies;
- if (!(idx = dm_pool_zalloc(seg_lv(seg, 0)->vg->vgmem, seg->area_count * sizeof(*idx))))
- return 0;
+ if (!(idx = dm_pool_zalloc(seg_lv(seg, 0)->vg->vgmem, seg->area_count * sizeof(*idx)))) {
+ log_error("Memory allocation failed.");
+ return_0;
+ }
/* Set up positional index array */
switch (conv) {
@@ -1013,8 +1017,8 @@ static struct logical_volume *_alloc_image_component(struct logical_volume *lv,
return 0;
}
- if (dm_snprintf(img_name, sizeof(img_name), "%s_%s_%%d",
- (alt_base_name) ? : lv->name, type_suffix) < 0) {
+ if (!dm_snprintf(img_name, sizeof(img_name), "%s_%s_%%d",
+ (alt_base_name) ? : lv->name, type_suffix)) {
log_error("Component name for raid %s is too long.", display_lvname(lv));
return 0;
}
@@ -1056,8 +1060,10 @@ static int _alloc_image_components(struct logical_volume *lv,
const char *raid_segtype;
if (!(lvl_array = dm_pool_alloc(lv->vg->vgmem,
- sizeof(*lvl_array) * count * 2)))
+ sizeof(*lvl_array) * count * 2))) {
+ log_error("Memory allocation failed.");
return_0;
+ }
if (!(parallel_areas = build_parallel_areas_from_lv(lv, 0, 1)))
return_0;
@@ -1250,6 +1256,10 @@ static int _cmp_level(const struct segment_type *t1, const struct segment_type *
(!segtype_is_any_raid10(t1) && segtype_is_any_raid10(t2)))
return 0;
+ if ((segtype_is_raid4(t1) && segtype_is_raid5_n(t2)) ||
+ (segtype_is_raid5_n(t1) && segtype_is_raid4(t2)))
+ return 1;
+
return !strncmp(t1->name, t2->name, 5);
}
@@ -1986,10 +1996,11 @@ static int _raid_reshape_remove_images(struct logical_volume *lv,
/*
* HM Helper:
*
- * Reshape: keep images in RAID @lv but change stripe size or data copies
+ * Reshape: keep images in RAID @lv but change layout, stripe size or data copies
*
*/
static const char *_get_segtype_alias(const struct segment_type *segtype);
+static const char *_get_segtype_alias_str(const struct logical_volume *lv, const struct segment_type *segtype);
static int _raid_reshape_keep_images(struct logical_volume *lv,
const struct segment_type *new_segtype,
int yes, int force, int *force_repair,
@@ -2001,10 +2012,13 @@ static int _raid_reshape_keep_images(struct logical_volume *lv,
struct lv_segment *seg = first_seg(lv);
if (seg->segtype != new_segtype)
- log_print_unless_silent("Converting %s LV %s to %s.",
- lvseg_name(seg), display_lvname(lv), new_segtype->name);
- if (!yes && yes_no_prompt("Are you sure you want to convert %s LV %s to %s? [y/n]: ",
- lvseg_name(seg), display_lvname(lv), new_segtype->name) == 'n') {
+ log_print_unless_silent("Converting %s%s LV %s to %s%s.",
+ lvseg_name(seg), _get_segtype_alias_str(lv, seg->segtype),
+ display_lvname(lv), new_segtype->name,
+ _get_segtype_alias_str(lv, new_segtype));
+
+ if (!yes && yes_no_prompt("Are you sure you want to convert %s LV %s? [y/n]: ",
+ lvseg_name(seg), display_lvname(lv)) == 'n') {
log_error("Logical volume %s NOT converted.", display_lvname(lv));
return 0;
}
@@ -2022,12 +2036,9 @@ static int _raid_reshape_keep_images(struct logical_volume *lv,
* The dm-raid target is able to use the space whereever it
* is found by appropriately selecting forward or backward reshape.
*/
- if (seg->segtype != new_segtype) {
- const char *alias = _get_segtype_alias(seg->segtype);
-
- if (!strcmp(alias, new_segtype->name))
- alloc_reshape_space = 0;
- }
+ if (seg->segtype != new_segtype &&
+ !strcmp(_get_segtype_alias(seg->segtype), new_segtype->name))
+ alloc_reshape_space = 0;
if (seg->stripe_size != new_stripe_size)
alloc_reshape_space = 1;
@@ -4437,6 +4448,7 @@ static int _log_possible_conversion(uint64_t *processed_segtypes, void *data)
return 1;
}
+/* Return any segment type alias name for @segtype or empty string */
static const char *_get_segtype_alias(const struct segment_type *segtype)
{
if (!strcmp(segtype->name, SEG_TYPE_NAME_RAID5))
@@ -4460,12 +4472,28 @@ static const char *_get_segtype_alias(const struct segment_type *segtype)
return "";
}
+/* Return any segment type alias string (format " (same as raid*)") for @segtype or empty string */
+static const char *_get_segtype_alias_str(const struct logical_volume *lv, const struct segment_type *segtype)
+{
+ const char *alias = _get_segtype_alias(segtype);
+
+ if (*alias) {
+ const char *msg = " (same as ";
+ size_t sz = strlen(msg) + strlen(alias) + 2;
+ char *buf = dm_pool_alloc(lv->vg->cmd->mem, sz);
+
+ if (buf)
+ alias = dm_snprintf(buf, sz, "%s%s)", msg, alias) ? buf : "";
+ }
+
+ return alias;
+}
+
static int _log_possible_conversion_types(const struct logical_volume *lv, const struct segment_type *new_segtype)
{
unsigned possible_conversions = 0;
const struct lv_segment *seg = first_seg(lv);
struct possible_type *pt = NULL;
- const char *alias;
uint64_t processed_segtypes = UINT64_C(0);
/* Count any possible segment types @seg an be directly converted to */
@@ -4476,12 +4504,10 @@ static int _log_possible_conversion_types(const struct logical_volume *lv, const
if (!possible_conversions)
log_error("Direct conversion of %s LV %s is not possible.", lvseg_name(seg), display_lvname(lv));
else {
- alias = _get_segtype_alias(seg->segtype);
-
- log_error("Converting %s from %s%s%s%s is "
+ log_error("Converting %s from %s%s is "
"directly possible to the following layout%s:",
display_lvname(lv), lvseg_name(seg),
- *alias ? " (same as " : "", alias, *alias ? ")" : "",
+ _get_segtype_alias_str(lv, seg->segtype),
possible_conversions > 1 ? "s" : "");
pt = NULL;
@@ -4526,10 +4552,16 @@ static int _takeover_noop(TAKEOVER_FN_ARGS)
static int _takeover_unsupported(TAKEOVER_FN_ARGS)
{
- log_error("Converting the segment type for %s from %s to %s is not supported.",
- display_lvname(lv), lvseg_name(first_seg(lv)),
- (segtype_is_striped_target(new_segtype) &&
- (new_stripes == 1)) ? SEG_TYPE_NAME_LINEAR : new_segtype->name);
+ struct lv_segment *seg = first_seg(lv);
+
+ if (seg->segtype == new_segtype)
+ log_error("Logical volume %s already is type %s.",
+ display_lvname(lv), lvseg_name(seg));
+ else
+ log_error("Converting the segment type for %s from %s to %s is not supported.",
+ display_lvname(lv), lvseg_name(seg),
+ (segtype_is_striped_target(new_segtype) &&
+ (new_stripes == 1)) ? SEG_TYPE_NAME_LINEAR : new_segtype->name);
if (!_log_possible_conversion_types(lv, new_segtype))
stack;
@@ -4737,7 +4769,7 @@ static int _rename_area_lvs(struct logical_volume *lv, const char *suffix)
/* Create _generate_raid_name() suffixes w/ or w/o passed in @suffix */
for (s = 0; s < SLV_COUNT; s++)
if (!(sfx[s] = dm_pool_alloc(lv->vg->cmd->mem, sz)) ||
- dm_snprintf(sfx[s], sz, suffix ? "%s%s" : "%s", s ? "rmeta" : "rimage", suffix) < 0)
+ !dm_snprintf(sfx[s], sz, suffix ? "%s%s" : "%s", s ? "rmeta" : "rimage", suffix))
return_0;
/* Change names (temporarily) to be able to shift numerical name suffixes */
@@ -4844,6 +4876,15 @@ static int _raid45_to_raid54_wrapper(TAKEOVER_FN_ARGS)
return 0;
}
+ if (!yes && yes_no_prompt("Are you sure you want to convert %s%s LV %s to %s%s type? [y/n]: ",
+ lvseg_name(seg), _get_segtype_alias_str(lv, seg->segtype),
+ display_lvname(lv), new_segtype->name,
+ _get_segtype_alias_str(lv, new_segtype)) == 'n') {
+ log_error("Logical volume %s NOT converted to \"%s\".",
+ display_lvname(lv), new_segtype->name);
+ return 0;
+ }
+
log_debug_metadata("Converting LV %s from %s to %s.", display_lvname(lv),
(seg_is_raid4(seg) ? SEG_TYPE_NAME_RAID4 : SEG_TYPE_NAME_RAID5_N),
(seg_is_raid4(seg) ? SEG_TYPE_NAME_RAID5_N : SEG_TYPE_NAME_RAID4));
@@ -4926,8 +4967,8 @@ static int _takeover_downconvert_wrapper(TAKEOVER_FN_ARGS)
}
if (seg->area_count > 2) {
- if (dm_snprintf(res_str, sizeof(res_str), " losing %s resilience",
- segtype_is_striped(new_segtype) ? "all" : "some") < 0)
+ if (!dm_snprintf(res_str, sizeof(res_str), " losing %s resilience",
+ segtype_is_striped(new_segtype) ? "all" : "some"))
return_0;
} else
*res_str = '\0';
@@ -5018,7 +5059,7 @@ static int _takeover_downconvert_wrapper(TAKEOVER_FN_ARGS)
}
if (segtype_is_raid4(new_segtype))
- return _raid45_to_raid54_wrapper(lv, new_segtype, yes, force, first_seg(lv)->area_count,
+ return _raid45_to_raid54_wrapper(lv, new_segtype, 1 /* yes */, force, first_seg(lv)->area_count,
1 /* data_copies */, 0, 0, 0, allocate_pvs);
return 1;
@@ -5200,7 +5241,7 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS)
if (!(raid5_n_segtype = get_segtype_from_flag(lv->vg->cmd, SEG_RAID5_N)))
return_0;
- /* raid6 upconvert: vonvert to raid5_n preserving already allocated new image component pair */
+ /* raid6 upconvert: convert to raid5_n preserving already allocated new image component pair */
if (segtype_is_any_raid6(new_segtype)) {
struct logical_volume *meta_lv, *data_lv;
@@ -5217,7 +5258,7 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS)
extents_copied, seg_len);
seg->area_count--;
- if (!_raid45_to_raid54_wrapper(lv, raid5_n_segtype, yes, force, seg->area_count,
+ if (!_raid45_to_raid54_wrapper(lv, raid5_n_segtype, 1 /* yes */, force, seg->area_count,
1 /* data_copies */, 0, 0, 0, allocate_pvs))
return 0;
@@ -5774,71 +5815,144 @@ 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 where necessary. */
-static int _set_convenient_raid1456_segtype_to(const struct lv_segment *seg_from,
- const struct segment_type **segtype,
- int yes)
+/* Change segtype for raid* for convenience where necessary. */
+/* FIXME: do this like _conversion_options_allowed()? */
+static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_from,
+ const struct segment_type **segtype,
+ int yes)
{
- size_t len = min(strlen((*segtype)->name), strlen(lvseg_name(seg_from)));
- uint64_t seg_flag;
+ uint64_t seg_flag = 0;
struct cmd_context *cmd = seg_from->lv->vg->cmd;
const struct segment_type *segtype_sav = *segtype;
/* Bail out if same RAID level is requested. */
- if (!strncmp((*segtype)->name, lvseg_name(seg_from), len))
+ if (is_same_level(seg_from->segtype, *segtype))
return 1;
- /* Striped/raid0 -> raid5/6 */
+ log_debug("Checking LV %s requested %s segment type for convenience",
+ display_lvname(seg_from->lv), (*segtype)->name);
+
+ /* striped/raid0 -> raid5/6 */
if (seg_is_striped(seg_from) || seg_is_any_raid0(seg_from)) {
/* If this is any raid5 conversion request -> enforce raid5_n, because we convert from striped */
- if (segtype_is_any_raid5(*segtype) && !segtype_is_raid5_n(*segtype)) {
+ if (segtype_is_any_raid5(*segtype) && !segtype_is_raid5_n(*segtype))
seg_flag = SEG_RAID5_N;
- goto replaced;
/* If this is any raid6 conversion request -> enforce raid6_n_6, because we convert from striped */
- } else if (segtype_is_any_raid6(*segtype) && !segtype_is_raid6_n_6(*segtype)) {
+ else if (segtype_is_any_raid6(*segtype) && !segtype_is_raid6_n_6(*segtype))
seg_flag = SEG_RAID6_N_6;
- goto replaced;
+
+ /* raid1 -> */
+ } else if (seg_is_raid1(seg_from) && !segtype_is_mirror(*segtype)) {
+ if (seg_from->area_count != 2) {
+ log_warn("Convert %s LV %s to 2 images first.",
+ lvseg_name(seg_from), display_lvname(seg_from->lv));
+ return 0;
+
+ } else if (segtype_is_striped(*segtype) ||
+ segtype_is_any_raid0(*segtype) ||
+ segtype_is_raid10(*segtype))
+ seg_flag = SEG_RAID5_N;
+
+ else if (!segtype_is_raid4(*segtype) && !segtype_is_any_raid5(*segtype))
+ seg_flag = SEG_RAID5_LS;
+
+ /* raid4/raid5 -> striped/raid0/raid1/raid6/raid10 */
+ } else if (seg_is_raid4(seg_from) || seg_is_any_raid5(seg_from)) {
+ if (segtype_is_raid1(*segtype) &&
+ seg_from->area_count != 2) {
+ log_warn("Convert %s LV %s to 2 stripes first (i.e. --stripes 1).",
+ lvseg_name(seg_from), display_lvname(seg_from->lv));
+ return 0;
+
+ } else if (seg_is_raid4(seg_from) &&
+ segtype_is_any_raid5(*segtype) &&
+ !segtype_is_raid5_n(*segtype))
+ seg_flag = SEG_RAID5_N;
+
+ else if (seg_is_any_raid5(seg_from) &&
+ segtype_is_raid4(*segtype) &&
+ !segtype_is_raid5_n(*segtype))
+ seg_flag = SEG_RAID5_N;
+
+ else if (segtype_is_raid10(*segtype)) {
+ if (seg_from->area_count < 3) {
+ log_warn("Convert %s LV %s to minimum 3 stripes first (i.e. --stripes 2).",
+ lvseg_name(seg_from), display_lvname(seg_from->lv));
+ return 0;
+ }
+
+ seg_flag = seg_is_raid5_n(seg_from) ? SEG_RAID0_META : SEG_RAID5_N;
+
+ } else if (segtype_is_any_raid6(*segtype)) {
+ if (seg_from->area_count < 4) {
+ log_warn("Convert %s LV %s to minimum 4 stripes first (i.e. --stripes 3).",
+ lvseg_name(seg_from), display_lvname(seg_from->lv));
+ return 0;
+
+ } else if (seg_is_raid4(seg_from) && !segtype_is_raid6_n_6(*segtype))
+ seg_flag = SEG_RAID6_N_6;
+
+ else if (!(seg_flag = _raid_seg_flag_5_to_6(seg_from)))
+ seg_flag = SEG_RAID5_N;
}
- /* raid4 -> raid5_n */
- } else if (seg_is_raid4(seg_from) && segtype_is_any_raid5(*segtype)) {
- seg_flag = SEG_RAID5_N;
- goto replaced;
+ /* raid6 -> striped/raid0/raid5/raid10 */
+ } else if (seg_is_any_raid6(seg_from)) {
+ if (segtype_is_raid1(*segtype)) {
+ /* No result for raid6_{zr,nr,nc} */
+ if (!((seg_flag = _raid_seg_flag_6_to_5(seg_from)) ||
+ !(seg_flag & (*segtype)->flags)))
+ seg_flag = SEG_RAID6_LS_6;
- /* raid4/raid5_n -> striped/raid0/raid6 */
- } else if ((seg_is_raid4(seg_from) || seg_is_raid5_n(seg_from)) &&
- !segtype_is_striped(*segtype) &&
- !segtype_is_any_raid0(*segtype) &&
- !segtype_is_raid1(*segtype) &&
- !segtype_is_raid4(*segtype) &&
- !segtype_is_raid5_n(*segtype) &&
- !segtype_is_raid6_n_6(*segtype)) {
- seg_flag = SEG_RAID6_N_6;
- goto replaced;
-
- /* Got to do check for raid5 -> raid6 ... */
- } else if (seg_is_any_raid5(seg_from) && segtype_is_any_raid6(*segtype)) {
- if (!(seg_flag = _raid_seg_flag_5_to_6(seg_from)))
- return_0;
- goto replaced;
+ } else if (segtype_is_any_raid10(*segtype)) {
+ seg_flag = seg_is_raid6_n_6(seg_from) ? SEG_RAID0_META : SEG_RAID6_N_6;
- /* ... and raid6 -> raid5 */
- } else if (seg_is_any_raid6(seg_from) && segtype_is_any_raid5(*segtype)) {
- /* No result for raid6_{zr,nr,nc} */
- if (!(seg_flag = _raid_seg_flag_6_to_5(seg_from)))
+ } else if ((segtype_is_striped(*segtype) || segtype_is_any_raid0(*segtype)) &&
+ !seg_is_raid6_n_6(seg_from)) {
+ seg_flag = SEG_RAID6_N_6;
+
+ } else if (segtype_is_raid4(*segtype) && !seg_is_raid6_n_6(seg_from)) {
+ seg_flag = SEG_RAID6_N_6;
+
+ } else if (segtype_is_any_raid5(*segtype))
+ /* No result for raid6_{zr,nr,nc} */
+ if (!((seg_flag = _raid_seg_flag_6_to_5(seg_from)) ||
+ !(seg_flag & (*segtype)->flags)))
+ seg_flag = SEG_RAID6_N_6;
+
+ /* -> raid1 */
+ } else if (!seg_is_mirror(seg_from) && segtype_is_raid1(*segtype)) {
+ if (!seg_is_raid4(seg_from) && !seg_is_any_raid5(seg_from)) {
+ log_warn("Convert %s LV %s to raid4/raid5 first.",
+ lvseg_name(seg_from), display_lvname(seg_from->lv));
return 0;
- goto replaced;
- }
- return 1;
+ } else if (seg_from->area_count != 2) {
+ log_warn("Convert %s LV %s to 2 stripes first (i.e. --stripes 1).",
+ lvseg_name(seg_from), display_lvname(seg_from->lv));
+ return 0;
+
+ }
+
+ /* raid10 -> ... */
+ } else if (seg_is_raid10(seg_from) &&
+ !segtype_is_striped(*segtype) &&
+ !segtype_is_any_raid0(*segtype))
+ seg_flag = SEG_RAID0_META;
+
+ if (seg_flag) {
+ if (!(*segtype = get_segtype_from_flag(cmd, seg_flag)))
+ return_0;
+ if (segtype_sav != *segtype) {
+ log_warn("Replaced LV type %s%s with possible type %s.",
+ segtype_sav->name, _get_segtype_alias_str(seg_from->lv, segtype_sav),
+ (*segtype)->name);
+ log_warn("Repeat this command to convert to %s after an interim conversion has finished.",
+ segtype_sav->name);
+ }
+ }
-replaced:
- if (!(*segtype = get_segtype_from_flag(cmd, seg_flag)))
- return_0;
- if (segtype_sav != *segtype)
- log_warn("Replaced LV type %s with possible type %s.",
- segtype_sav->name, (*segtype)->name);
return 1;
}
@@ -5924,7 +6038,7 @@ static int _conversion_options_allowed(const struct lv_segment *seg_from,
int r = 1;
uint32_t opts;
- if (!new_image_count && !_set_convenient_raid1456_segtype_to(seg_from, segtype_to, yes))
+ if (!new_image_count && !_set_convenient_raid145610_segtype_to(seg_from, segtype_to, yes))
return_0;
if (!_get_allowed_conversion_options(seg_from, *segtype_to, new_image_count, &opts)) {
@@ -5952,12 +6066,28 @@ static int _conversion_options_allowed(const struct lv_segment *seg_from,
}
if (r &&
+ !yes &&
strcmp((*segtype_to)->name, SEG_TYPE_NAME_MIRROR) && /* "mirror" is prompted for later */
- !yes && yes_no_prompt("Are you sure you want to convert %s LV %s to %s type? [y/n]: ",
- lvseg_name(seg_from), display_lvname(seg_from->lv),
+ !is_same_level(seg_from->segtype, *segtype_to)) { /* Prompt here for takeover */
+ const char *basic_fmt = "Are you sure you want to convert %s LV %s";
+ const char *type_fmt = " to %s type";
+ const char *question_fmt = " to %s type";
+ char *fmt;
+ size_t sz = strlen(basic_fmt) + ((seg_from->segtype == *segtype_to) ? 0 : strlen(type_fmt)) + strlen(question_fmt) + 1;
+
+ if (!(fmt = dm_pool_alloc(seg_from->lv->vg->cmd->mem, sz)))
+ return_0;
+
+ if (!dm_snprintf(fmt, sz, "%s%s%s", basic_fmt, (seg_from->segtype == *segtype_to) ? "" : type_fmt, question_fmt)) {
+ log_error(INTERNAL_ERROR "dm_snprintf failed.");
+ return_0;
+ }
+
+ if (yes_no_prompt(fmt, lvseg_name(seg_from), display_lvname(seg_from->lv),
(*segtype_to)->name) == 'n') {
- log_error("Logical volume %s NOT converted.", display_lvname(seg_from->lv));
- r = 0;
+ log_error("Logical volume %s NOT converted.", display_lvname(seg_from->lv));
+ r = 0;
+ }
}
return r;
@@ -6040,6 +6170,15 @@ int lv_raid_convert(struct logical_volume *lv,
region_size = region_size ? : get_default_region_size(lv->vg->cmd);
/*
+ * Check acceptible options mirrors, region_size,
+ * stripes and/or stripe_size have been provided.
+ */
+ if (!_conversion_options_allowed(seg, &new_segtype, yes,
+ 0 /* Takeover */, 0 /*new_data_copies*/, new_region_size,
+ new_stripes, new_stripe_size_supplied))
+ return _log_possible_conversion_types(lv, new_segtype);
+
+ /*
* reshape of capable raid type requested
*/
switch (_reshape_requested(lv, new_segtype, data_copies, region_size, stripes, stripe_size)) {
@@ -6074,15 +6213,6 @@ int lv_raid_convert(struct logical_volume *lv,
return 0;
}
- /*
- * Check acceptible options mirrors, region_size,
- * stripes and/or stripe_size have been provided.
- */
- if (!_conversion_options_allowed(seg, &new_segtype, yes,
- 0 /* Takeover */, 0 /*new_data_copies*/, new_region_size,
- new_stripes, new_stripe_size_supplied))
- return _log_possible_conversion_types(lv, new_segtype);
-
takeover_fn = _get_takeover_fn(first_seg(lv), new_segtype, new_image_count);
/* Exit without doing activation checks if the combination isn't possible */
6 years, 11 months
master - lvmdbusd: Fix notify_dbus mangling config option
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=16c6d9f11ab581a79fb...
Commit: 16c6d9f11ab581a79fb57fd36142af1dc57a3c61
Parent: 9291fb7bf5d5f6265f3fd2f5ec6eff6542d2afb9
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Wed May 17 15:26:05 2017 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Wed May 17 15:35:20 2017 +0200
lvmdbusd: Fix notify_dbus mangling config option
If config option is passed by caller, dbusd appends to the option not to
the value, and also without using delimiter.
Bug: RHBZ#1451612
---
daemons/lvmdbusd/utils.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index af9e10a..170824d 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -519,7 +519,9 @@ def add_no_notify(cmdline):
if '--config' in cmdline:
for i, arg in enumerate(cmdline):
if arg == '--config':
- cmdline[i] += "global/notify_dbus=0"
+ if len(cmdline) <= i+1:
+ raise dbus.exceptions.DBusException("Missing value for --config option.")
+ cmdline[i+1] += " global/notify_dbus=0"
break
else:
cmdline.extend(['--config', 'global/notify_dbus=0'])
6 years, 11 months
master - test: Fix condition
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9291fb7bf5d5f6265f3...
Commit: 9291fb7bf5d5f6265f3fd2f5ec6eff6542d2afb9
Parent: 1fb13e8660340492e3d2f249caa78bacc5b8410a
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Wed May 17 11:43:49 2017 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Wed May 17 11:43:49 2017 +0200
test: Fix condition
---
test/shell/lvconvert-raid-regionsize.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-raid-regionsize.sh b/test/shell/lvconvert-raid-regionsize.sh
index 2a9ef62..762dada 100644
--- a/test/shell/lvconvert-raid-regionsize.sh
+++ b/test/shell/lvconvert-raid-regionsize.sh
@@ -64,7 +64,7 @@ _test_regionsizes raid1
# Clean up
lvremove --yes $vg
-if aux have_raid 1 11 0; then
+if aux have_raid 1 10 0; then
# Create 5-way raid6
lvcreate --yes -aey --type raid6 -i 3 --stripesize 128K -R 256K -L8M -n $lv1 $vg
check lv_field $vg/$lv1 segtype "raid6"
6 years, 11 months
master - test: Fix skipped cleanup
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1fb13e8660340492e3d...
Commit: 1fb13e8660340492e3d2f249caa78bacc5b8410a
Parent: 48408ece6ddd730c394e3081f9a2d78d1771f129
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Wed May 17 11:37:29 2017 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Wed May 17 11:37:29 2017 +0200
test: Fix skipped cleanup
---
test/shell/lvconvert-raid-regionsize.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-raid-regionsize.sh b/test/shell/lvconvert-raid-regionsize.sh
index 2884037..2a9ef62 100644
--- a/test/shell/lvconvert-raid-regionsize.sh
+++ b/test/shell/lvconvert-raid-regionsize.sh
@@ -61,10 +61,10 @@ fsck -fn "$DM_DEV_DIR/$vg/$lv1"
_test_regionsizes raid1
-if aux have_raid 1 11 0; then
# Clean up
lvremove --yes $vg
+if aux have_raid 1 11 0; then
# Create 5-way raid6
lvcreate --yes -aey --type raid6 -i 3 --stripesize 128K -R 256K -L8M -n $lv1 $vg
check lv_field $vg/$lv1 segtype "raid6"
6 years, 11 months
master - test: add missing yes option to lvconvert stripe removal
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=48408ece6ddd730c394...
Commit: 48408ece6ddd730c394e3081f9a2d78d1771f129
Parent: f4f408610c6801a50395f95b8116e2037a58761e
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Tue May 16 17:51:58 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Tue May 16 17:52:54 2017 +0200
test: add missing yes option to lvconvert stripe removal
---
.../lvconvert-raid-reshape-striped_to_linear.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-raid-reshape-striped_to_linear.sh b/test/shell/lvconvert-raid-reshape-striped_to_linear.sh
index 4051862..d926827 100644
--- a/test/shell/lvconvert-raid-reshape-striped_to_linear.sh
+++ b/test/shell/lvconvert-raid-reshape-striped_to_linear.sh
@@ -79,7 +79,7 @@ aux wait_for_sync $vg $lv1 1
fsck -fn $DM_DEV_DIR/$vg/$lv1
# Remove the now freed legs
-lvconvert --stripes 1 $vg/$lv1
+lvconvert -y --stripes 1 $vg/$lv1
check lv_first_seg_field $vg/$lv1 segtype "raid5_n"
check lv_first_seg_field $vg/$lv1 data_stripes 1
check lv_first_seg_field $vg/$lv1 stripes 2
6 years, 11 months