main - writecache: use cleaner message instead of table reload
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a690d16d29ff7d5e0cc...
Commit: a690d16d29ff7d5e0cc1adb1fed2621efd5fafa4
Parent: f08ef238564a547477f18c3668c616d497d7f3f8
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jan 27 16:23:00 2021 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jan 28 15:14:25 2021 -0600
writecache: use cleaner message instead of table reload
When detaching writecache, make the first stage send a message
to dm-writecache to set the cleaner option. This is instead of
reloading the dm table with the cleaner option set. Reloading
the table causes udev to process/probe the dm dev, which gets
stalled because of the writeback activity, and the stalled udev
in turn stalls the lvconvert command when it tries to sync with
udev events.
When getting writecache status we do not need to get
open_count or read_head info, which can cause extra steps.
---
lib/metadata/writecache_manip.c | 10 +++++++---
tools/lvconvert.c | 2 ++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/writecache_manip.c b/lib/metadata/writecache_manip.c
index 5004aa989..8150d0781 100644
--- a/lib/metadata/writecache_manip.c
+++ b/lib/metadata/writecache_manip.c
@@ -75,7 +75,7 @@ static int _get_writecache_kernel_status(struct cmd_context *cmd,
return 0;
}
- if (!lv_info_with_seg_status(cmd, first_seg(lv), &status, 1, 1)) {
+ if (!lv_info_with_seg_status(cmd, first_seg(lv), &status, 0, 0)) {
log_error("Failed to get device mapper status for %s", display_lvname(lv));
goto fail;
}
@@ -434,8 +434,12 @@ int lv_writecache_set_cleaner(struct logical_volume *lv)
seg->writecache_settings.cleaner_set = 1;
if (lv_is_active(lv)) {
- if (!lv_update_and_reload(lv)) {
- log_error("Failed to update VG and reload LV.");
+ if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
+ log_error("Failed to update VG.");
+ return 0;
+ }
+ if (!lv_writecache_message(lv, "cleaner")) {
+ log_error("Failed to set writecache cleaner for %s.", display_lvname(lv));
return 0;
}
} else {
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 432396567..7b74afbe2 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5720,6 +5720,8 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
return 0;
}
+ log_debug("detach writecache check clean reading vg %s", id->vg_name);
+
vg = vg_read(cmd, id->vg_name, NULL, READ_FOR_UPDATE, lockd_state, &error_flags, NULL);
if (!vg) {
2 years, 8 months
stable-2.02 - lvdisplay: enhance LV status output for raid(0)
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c56b3fa4e2042230054...
Commit: c56b3fa4e2042230054786697cd0781f44d56f93
Parent: 1d94748601056442b160df8802817404e0a5c7c4
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Tue Jan 26 19:32:24 2021 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Wed Jan 27 16:59:02 2021 +0100
lvdisplay: enhance LV status output for raid(0)
In case legs of a raid0 LV are removed, the lvdisplay command still
reports 'available' though raid0 is not providing any resilience
compared to the other raid levels.
Also lvdisplay does not display '(partial)' in case of missing raid0
legs as oposed to the lvs command.
Enhance lvdisplay to report "NOT available" for any RaidLV type in case
too many legs are inaccessible hence causing data loss. I.e. any leg
for raid0, all for raid1, more than 1 for raid4/5, more than 2 for raid6
and in case of completely lost mirror groups for raid10.
Add test/shell/lvdisplay-raid.sh.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1872678
---
WHATS_NEW | 1 +
lib/display/display.c | 13 +++++--
lib/metadata/metadata-exported.h | 1 +
lib/metadata/segtype.h | 1 +
lib/raid/raid.c | 57 +++++++++++++++++++++++++++++
test/shell/lvdisplay-raid.sh | 79 ++++++++++++++++++++++++++++++++++++++++
6 files changed, 149 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2a745dbdd..311923204 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.188 -
==================================
+ Enhance lvdisplay to report raid availiable/partial.
Enhance error handling for fsadm and hanled correct fsck result.
Stop logging rename errors from persintent filter.
Dmeventd lvm plugin ignores higher reserved_stack lvm.conf values.
diff --git a/lib/display/display.c b/lib/display/display.c
index e9cfaa985..cd911feea 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -399,7 +399,7 @@ int lvdisplay_full(struct cmd_context *cmd,
void *handle __attribute__((unused)))
{
struct lvinfo info;
- int inkernel, snap_active = 0;
+ int inkernel, snap_active = 0, partial = 0, raid_is_avail = 1;
char uuid[64] __attribute__((aligned(8)));
const char *access_str;
struct lv_segment *snap_seg = NULL, *mirror_seg = NULL;
@@ -536,11 +536,18 @@ int lvdisplay_full(struct cmd_context *cmd,
log_print("LV Pool data %s", seg_lv(seg, 0)->name);
}
+ if (lv_is_partial(lv))
+ partial = 1;
+
+ if (lv_is_raid(lv))
+ raid_is_avail = raid_is_available(lv) ? 1 : 0;
+
if (inkernel && info.suspended)
log_print("LV Status suspended");
else if (activation())
- log_print("LV Status %savailable",
- inkernel ? "" : "NOT ");
+ log_print("LV Status %savailable%s",
+ (inkernel && raid_is_avail) ? "" : "NOT ",
+ partial ? " (partial)" : "");
/********* FIXME lv_number
log_print("LV # %u", lv->lv_number + 1);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 8f173059b..30ab47576 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -26,6 +26,7 @@
#include "vg.h"
#include "lv.h"
#include "lvm-percent.h"
+#include <stdbool.h>
#define MAX_STRIPES 128U
#define SECTOR_SHIFT 9L
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 9c05836bf..009ec16cf 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -310,6 +310,7 @@ struct segment_type *init_unknown_segtype(struct cmd_context *cmd,
#ifdef RAID_INTERNAL
int init_raid_segtypes(struct cmd_context *cmd, struct segtype_library *seglib);
+bool raid_is_available(const struct logical_volume *lv);
#endif
#define THIN_FEATURE_DISCARDS (1U << 0)
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 28340a0ca..f75c676e8 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -468,6 +468,63 @@ static int _check_feature(const struct raid_feature *feature, uint32_t maj, uint
(maj == feature->maj && min == feature->min && patchlevel >= feature->patchlevel);
}
+/* Check availability of raid10 taking data copies into consideration. */
+static bool _raid10_is_available(const struct logical_volume *lv)
+{
+ uint32_t i, rebuilds_per_group, s;
+ const uint32_t copies = 2; /* FIXME: we only support 2-way mirrors (i.e. 2 data copies) in RAID10 for now. */
+ struct lv_segment *seg = first_seg(lv); /* We only have one segment in RaidLVs for now. */
+
+ for (i = 0; i < seg->area_count * copies; ++i) {
+ s = i % seg->area_count;
+
+ if (!(i % copies))
+ rebuilds_per_group = 0;
+
+ if (seg_type(seg, s) == AREA_LV &&
+ (lv_is_partial(seg_lv(seg, s)) ||
+ lv_is_virtual(seg_lv(seg, s))))
+ rebuilds_per_group++;
+
+ if (rebuilds_per_group >= copies)
+ return false;
+ }
+
+ return true;
+}
+
+/*
+ * Return true in case RaidLV with specific RAID level is available.
+ *
+ * - raid0: all legs have to be live
+ * - raid1 : minimum of 1 leg live
+ * - raid4/5: maximum of 1 leg unavailable
+ * - raid6: maximum of 2 legs unavailable
+ * - raid10: minimum of 1 leg per mirror group available
+ *
+ */
+bool raid_is_available(const struct logical_volume *lv)
+{
+ uint32_t s, missing_legs = 0;
+ struct lv_segment *seg = first_seg(lv); /* We only have one segment in RaidLVs for now. */
+
+ /* Be cautious about bogus calls. */
+ if (!seg || !seg_is_raid(seg))
+ return false;
+
+ if (seg_is_any_raid10(seg))
+ return _raid10_is_available(lv);
+
+ /* Count missing RAID legs */
+ for (s = 0; s < seg->area_count; ++s)
+ if (seg_type(seg, s) == AREA_LV &&
+ lv_is_partial(seg_lv(seg, s)))
+ missing_legs++;
+
+ /* Degradation: segtype raid1 may miss legs-1, raid0/4/5/6 may loose parity devices. */
+ return missing_legs <= (seg_is_raid1(seg) ? seg->area_count - 1 : seg->segtype->parity_devs);
+}
+
static int _raid_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute__((unused)),
unsigned *attributes)
diff --git a/test/shell/lvdisplay-raid.sh b/test/shell/lvdisplay-raid.sh
new file mode 100644
index 000000000..18ea9ae1e
--- /dev/null
+++ b/test/shell/lvdisplay-raid.sh
@@ -0,0 +1,79 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+#
+# tests functionality lvdisplay tool for RAID
+#
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_vg 6
+get_devs
+
+# raid0 loosing a leg
+lvcreate -aey --type raid0 -i5 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1
+lvremove -y $vg/$lv
+
+# raid1 loosing a leg/all legs
+lvcreate -aey --type raid1 -m1 -l5 -n $lv $vg $dev1 $dev2
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+lvremove -y $vg/$lv
+
+# raid5 loosing a leg/2 legs
+lvcreate -aey --type raid5 -i3 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+lvremove -y $vg/$lv
+
+# raid6 loosing a leg/2 legs/3 legs
+lvcreate -aey --type raid6 -i3 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev3
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2 $dev3
+lvremove -y $vg/$lv
+
+# raid10 loosing a leg per mirror group / a complete mirror group
+lvcreate -aey --type raid10 -i3 -l3 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev3
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev6
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux enable_dev $dev1 $dev3 $dev6
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1 $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+
+vgremove -y -f $vg
2 years, 8 months
master - lvdisplay: enhance LV status output for raid(0)
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f08ef238564a547477f...
Commit: f08ef238564a547477f18c3668c616d497d7f3f8
Parent: 665d265349596d1d4e67b1db5cb33f78338f4c7c
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Tue Jan 26 19:32:24 2021 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Wed Jan 27 16:56:22 2021 +0100
lvdisplay: enhance LV status output for raid(0)
In case legs of a raid0 LV are removed, the lvdisplay command still
reports 'available' though raid0 is not providing any resilience
compared to the other raid levels.
Also lvdisplay does not display '(partial)' in case of missing raid0
legs as oposed to the lvs command.
Enhance lvdisplay to report "NOT available" for any RaidLV type in case
too many legs are inaccessible hence causing data loss. I.e. any leg
for raid0, all for raid1, more than 1 for raid4/5, more than 2 for raid6
and in case of completely lost mirror groups for raid10.
Add test/shell/lvdisplay-raid.sh.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1872678
---
WHATS_NEW | 1 +
lib/display/display.c | 13 +++++--
lib/metadata/metadata-exported.h | 1 +
lib/metadata/segtype.h | 1 +
lib/raid/raid.c | 57 +++++++++++++++++++++++++++++
test/shell/lvdisplay-raid.sh | 79 ++++++++++++++++++++++++++++++++++++++++
6 files changed, 149 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9fda1de87..ef1afaabd 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.12 -
===================================
+ Enhance lvdisplay to report raid availiable/partial.
Support online rename of VDO pools.
Imporove removal of pmspare when last pool is removed.
Fix problem with wiping of converted LVs.
diff --git a/lib/display/display.c b/lib/display/display.c
index c0224edfb..a84695393 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -399,7 +399,7 @@ int lvdisplay_full(struct cmd_context *cmd,
void *handle __attribute__((unused)))
{
struct lvinfo info;
- int inkernel, snap_active = 0;
+ int inkernel, snap_active = 0, partial = 0, raid_is_avail = 1;
char uuid[64] __attribute__((aligned(8)));
const char *access_str;
struct lv_segment *snap_seg = NULL, *mirror_seg = NULL;
@@ -558,11 +558,18 @@ int lvdisplay_full(struct cmd_context *cmd,
log_print("LV VDO Pool name %s", seg_lv(seg, 0)->name);
}
+ if (lv_is_partial(lv))
+ partial = 1;
+
+ if (lv_is_raid(lv))
+ raid_is_avail = raid_is_available(lv) ? 1 : 0;
+
if (inkernel && info.suspended)
log_print("LV Status suspended");
else if (activation())
- log_print("LV Status %savailable",
- inkernel ? "" : "NOT ");
+ log_print("LV Status %savailable%s",
+ (inkernel && raid_is_avail) ? "" : "NOT ",
+ partial ? " (partial)" : "");
/********* FIXME lv_number
log_print("LV # %u", lv->lv_number + 1);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 54dc29ffe..bf58b9fb2 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -26,6 +26,7 @@
#include "lib/metadata/vg.h"
#include "lib/metadata/lv.h"
#include "lib/misc/lvm-percent.h"
+#include <stdbool.h>
#define MAX_STRIPES 128U
#define SECTOR_SHIFT 9L
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 2714a6b45..676f37e3c 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -326,6 +326,7 @@ struct segment_type *init_unknown_segtype(struct cmd_context *cmd,
#ifdef RAID_INTERNAL
int init_raid_segtypes(struct cmd_context *cmd, struct segtype_library *seglib);
+bool raid_is_available(const struct logical_volume *lv);
#endif
#define THIN_FEATURE_DISCARDS (1U << 0)
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index a72e486e9..126b22d43 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -469,6 +469,63 @@ static int _check_feature(const struct raid_feature *feature, uint32_t maj, uint
(maj == feature->maj && min == feature->min && patchlevel >= feature->patchlevel);
}
+/* Check availability of raid10 taking data copies into consideration. */
+static bool _raid10_is_available(const struct logical_volume *lv)
+{
+ uint32_t i, rebuilds_per_group, s;
+ const uint32_t copies = 2; /* FIXME: we only support 2-way mirrors (i.e. 2 data copies) in RAID10 for now. */
+ struct lv_segment *seg = first_seg(lv); /* We only have one segment in RaidLVs for now. */
+
+ for (i = 0; i < seg->area_count * copies; ++i) {
+ s = i % seg->area_count;
+
+ if (!(i % copies))
+ rebuilds_per_group = 0;
+
+ if (seg_type(seg, s) == AREA_LV &&
+ (lv_is_partial(seg_lv(seg, s)) ||
+ lv_is_virtual(seg_lv(seg, s))))
+ rebuilds_per_group++;
+
+ if (rebuilds_per_group >= copies)
+ return false;
+ }
+
+ return true;
+}
+
+/*
+ * Return true in case RaidLV with specific RAID level is available.
+ *
+ * - raid0: all legs have to be live
+ * - raid1 : minimum of 1 leg live
+ * - raid4/5: maximum of 1 leg unavailable
+ * - raid6: maximum of 2 legs unavailable
+ * - raid10: minimum of 1 leg per mirror group available
+ *
+ */
+bool raid_is_available(const struct logical_volume *lv)
+{
+ uint32_t s, missing_legs = 0;
+ struct lv_segment *seg = first_seg(lv); /* We only have one segment in RaidLVs for now. */
+
+ /* Be cautious about bogus calls. */
+ if (!seg || !seg_is_raid(seg))
+ return false;
+
+ if (seg_is_any_raid10(seg))
+ return _raid10_is_available(lv);
+
+ /* Count missing RAID legs */
+ for (s = 0; s < seg->area_count; ++s)
+ if (seg_type(seg, s) == AREA_LV &&
+ lv_is_partial(seg_lv(seg, s)))
+ missing_legs++;
+
+ /* Degradation: segtype raid1 may miss legs-1, raid0/4/5/6 may loose parity devices. */
+ return missing_legs <= (seg_is_raid1(seg) ? seg->area_count - 1 : seg->segtype->parity_devs);
+}
+
static int _raid_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute__((unused)),
unsigned *attributes)
diff --git a/test/shell/lvdisplay-raid.sh b/test/shell/lvdisplay-raid.sh
new file mode 100644
index 000000000..18ea9ae1e
--- /dev/null
+++ b/test/shell/lvdisplay-raid.sh
@@ -0,0 +1,79 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+#
+# tests functionality lvdisplay tool for RAID
+#
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_vg 6
+get_devs
+
+# raid0 loosing a leg
+lvcreate -aey --type raid0 -i5 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1
+lvremove -y $vg/$lv
+
+# raid1 loosing a leg/all legs
+lvcreate -aey --type raid1 -m1 -l5 -n $lv $vg $dev1 $dev2
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+lvremove -y $vg/$lv
+
+# raid5 loosing a leg/2 legs
+lvcreate -aey --type raid5 -i3 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+lvremove -y $vg/$lv
+
+# raid6 loosing a leg/2 legs/3 legs
+lvcreate -aey --type raid6 -i3 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev3
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2 $dev3
+lvremove -y $vg/$lv
+
+# raid10 loosing a leg per mirror group / a complete mirror group
+lvcreate -aey --type raid10 -i3 -l3 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev3
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev6
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux enable_dev $dev1 $dev3 $dev6
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1 $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+
+vgremove -y -f $vg
2 years, 8 months
stable-2.02 - lvdisplay: enhance LV status output for raid(0)
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2c3f4c2501e0dd3668c...
Commit: 2c3f4c2501e0dd3668cee543886badcc78be1066
Parent: 1d94748601056442b160df8802817404e0a5c7c4
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Tue Jan 26 19:32:24 2021 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Tue Jan 26 19:36:39 2021 +0100
lvdisplay: enhance LV status output for raid(0)
In case legs of a raid0 LV are removed, the lvdisplay command still
reports 'available' though raid0 is not providing any resilience
compared to the other raid levels.
Also lvdisplay does not display '(partial)' in case of missing raid0
legs as oposed to the lvs command.
Enhance lvdisplay to report "NOT available" for any RaidLV type in case
too many legs are inaccessible hence causing data loss. I.e. any leg
for raid0, all for raid1, more than 1 for raid4/5, more than 2 for raid6
and in case of completely lost mirror groups for raid10.
Add test/shell/lvdisplay-raid.sh.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1872678
---
WHATS_NEW | 1 +
lib/display/display.c | 13 ++++++--
lib/metadata/segtype.h | 1 +
lib/raid/raid.c | 57 ++++++++++++++++++++++++++++++++
test/shell/lvdisplay-raid.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 148 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2a745dbdd..311923204 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.188 -
==================================
+ Enhance lvdisplay to report raid availiable/partial.
Enhance error handling for fsadm and hanled correct fsck result.
Stop logging rename errors from persintent filter.
Dmeventd lvm plugin ignores higher reserved_stack lvm.conf values.
diff --git a/lib/display/display.c b/lib/display/display.c
index e9cfaa985..cd911feea 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -399,7 +399,7 @@ int lvdisplay_full(struct cmd_context *cmd,
void *handle __attribute__((unused)))
{
struct lvinfo info;
- int inkernel, snap_active = 0;
+ int inkernel, snap_active = 0, partial = 0, raid_is_avail = 1;
char uuid[64] __attribute__((aligned(8)));
const char *access_str;
struct lv_segment *snap_seg = NULL, *mirror_seg = NULL;
@@ -536,11 +536,18 @@ int lvdisplay_full(struct cmd_context *cmd,
log_print("LV Pool data %s", seg_lv(seg, 0)->name);
}
+ if (lv_is_partial(lv))
+ partial = 1;
+
+ if (lv_is_raid(lv))
+ raid_is_avail = raid_is_available(lv) ? 1 : 0;
+
if (inkernel && info.suspended)
log_print("LV Status suspended");
else if (activation())
- log_print("LV Status %savailable",
- inkernel ? "" : "NOT ");
+ log_print("LV Status %savailable%s",
+ (inkernel && raid_is_avail) ? "" : "NOT ",
+ partial ? " (partial)" : "");
/********* FIXME lv_number
log_print("LV # %u", lv->lv_number + 1);
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 9c05836bf..009ec16cf 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -310,6 +310,7 @@ struct segment_type *init_unknown_segtype(struct cmd_context *cmd,
#ifdef RAID_INTERNAL
int init_raid_segtypes(struct cmd_context *cmd, struct segtype_library *seglib);
+bool raid_is_available(const struct logical_volume *lv);
#endif
#define THIN_FEATURE_DISCARDS (1U << 0)
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 28340a0ca..f75c676e8 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -468,6 +468,63 @@ static int _check_feature(const struct raid_feature *feature, uint32_t maj, uint
(maj == feature->maj && min == feature->min && patchlevel >= feature->patchlevel);
}
+/* Check availability of raid10 taking data copies into consideration. */
+static bool _raid10_is_available(const struct logical_volume *lv)
+{
+ uint32_t i, rebuilds_per_group, s;
+ const uint32_t copies = 2; /* FIXME: we only support 2-way mirrors (i.e. 2 data copies) in RAID10 for now. */
+ struct lv_segment *seg = first_seg(lv); /* We only have one segment in RaidLVs for now. */
+
+ for (i = 0; i < seg->area_count * copies; ++i) {
+ s = i % seg->area_count;
+
+ if (!(i % copies))
+ rebuilds_per_group = 0;
+
+ if (seg_type(seg, s) == AREA_LV &&
+ (lv_is_partial(seg_lv(seg, s)) ||
+ lv_is_virtual(seg_lv(seg, s))))
+ rebuilds_per_group++;
+
+ if (rebuilds_per_group >= copies)
+ return false;
+ }
+
+ return true;
+}
+
+/*
+ * Return true in case RaidLV with specific RAID level is available.
+ *
+ * - raid0: all legs have to be live
+ * - raid1 : minimum of 1 leg live
+ * - raid4/5: maximum of 1 leg unavailable
+ * - raid6: maximum of 2 legs unavailable
+ * - raid10: minimum of 1 leg per mirror group available
+ *
+ */
+bool raid_is_available(const struct logical_volume *lv)
+{
+ uint32_t s, missing_legs = 0;
+ struct lv_segment *seg = first_seg(lv); /* We only have one segment in RaidLVs for now. */
+
+ /* Be cautious about bogus calls. */
+ if (!seg || !seg_is_raid(seg))
+ return false;
+
+ if (seg_is_any_raid10(seg))
+ return _raid10_is_available(lv);
+
+ /* Count missing RAID legs */
+ for (s = 0; s < seg->area_count; ++s)
+ if (seg_type(seg, s) == AREA_LV &&
+ lv_is_partial(seg_lv(seg, s)))
+ missing_legs++;
+
+ /* Degradation: segtype raid1 may miss legs-1, raid0/4/5/6 may loose parity devices. */
+ return missing_legs <= (seg_is_raid1(seg) ? seg->area_count - 1 : seg->segtype->parity_devs);
+}
+
static int _raid_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute__((unused)),
unsigned *attributes)
diff --git a/test/shell/lvdisplay-raid.sh b/test/shell/lvdisplay-raid.sh
new file mode 100644
index 000000000..18ea9ae1e
--- /dev/null
+++ b/test/shell/lvdisplay-raid.sh
@@ -0,0 +1,79 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+#
+# tests functionality lvdisplay tool for RAID
+#
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_vg 6
+get_devs
+
+# raid0 loosing a leg
+lvcreate -aey --type raid0 -i5 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1
+lvremove -y $vg/$lv
+
+# raid1 loosing a leg/all legs
+lvcreate -aey --type raid1 -m1 -l5 -n $lv $vg $dev1 $dev2
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+lvremove -y $vg/$lv
+
+# raid5 loosing a leg/2 legs
+lvcreate -aey --type raid5 -i3 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+lvremove -y $vg/$lv
+
+# raid6 loosing a leg/2 legs/3 legs
+lvcreate -aey --type raid6 -i3 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev3
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2 $dev3
+lvremove -y $vg/$lv
+
+# raid10 loosing a leg per mirror group / a complete mirror group
+lvcreate -aey --type raid10 -i3 -l3 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev3
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev6
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux enable_dev $dev1 $dev3 $dev6
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1 $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+
+vgremove -y -f $vg
2 years, 8 months
master - lvdisplay: enhance LV status output for raid(0)
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fb55f15fa6e79fa9b6c...
Commit: fb55f15fa6e79fa9b6ce5af99e857aa4bb3f3c2f
Parent: 665d265349596d1d4e67b1db5cb33f78338f4c7c
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Tue Jan 26 19:32:24 2021 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Tue Jan 26 19:34:00 2021 +0100
lvdisplay: enhance LV status output for raid(0)
In case legs of a raid0 LV are removed, the lvdisplay command still
reports 'available' though raid0 is not providing any resilience
compared to the other raid levels.
Also lvdisplay does not display '(partial)' in case of missing raid0
legs as oposed to the lvs command.
Enhance lvdisplay to report "NOT available" for any RaidLV type in case
too many legs are inaccessible hence causing data loss. I.e. any leg
for raid0, all for raid1, more than 1 for raid4/5, more than 2 for raid6
and in case of completely lost mirror groups for raid10.
Add test/shell/lvdisplay-raid.sh.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1872678
---
WHATS_NEW | 1 +
lib/display/display.c | 13 ++++++--
lib/metadata/segtype.h | 1 +
lib/raid/raid.c | 57 ++++++++++++++++++++++++++++++++
test/shell/lvdisplay-raid.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 148 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9fda1de87..ef1afaabd 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.12 -
===================================
+ Enhance lvdisplay to report raid availiable/partial.
Support online rename of VDO pools.
Imporove removal of pmspare when last pool is removed.
Fix problem with wiping of converted LVs.
diff --git a/lib/display/display.c b/lib/display/display.c
index c0224edfb..a84695393 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -399,7 +399,7 @@ int lvdisplay_full(struct cmd_context *cmd,
void *handle __attribute__((unused)))
{
struct lvinfo info;
- int inkernel, snap_active = 0;
+ int inkernel, snap_active = 0, partial = 0, raid_is_avail = 1;
char uuid[64] __attribute__((aligned(8)));
const char *access_str;
struct lv_segment *snap_seg = NULL, *mirror_seg = NULL;
@@ -558,11 +558,18 @@ int lvdisplay_full(struct cmd_context *cmd,
log_print("LV VDO Pool name %s", seg_lv(seg, 0)->name);
}
+ if (lv_is_partial(lv))
+ partial = 1;
+
+ if (lv_is_raid(lv))
+ raid_is_avail = raid_is_available(lv) ? 1 : 0;
+
if (inkernel && info.suspended)
log_print("LV Status suspended");
else if (activation())
- log_print("LV Status %savailable",
- inkernel ? "" : "NOT ");
+ log_print("LV Status %savailable%s",
+ (inkernel && raid_is_avail) ? "" : "NOT ",
+ partial ? " (partial)" : "");
/********* FIXME lv_number
log_print("LV # %u", lv->lv_number + 1);
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 2714a6b45..676f37e3c 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -326,6 +326,7 @@ struct segment_type *init_unknown_segtype(struct cmd_context *cmd,
#ifdef RAID_INTERNAL
int init_raid_segtypes(struct cmd_context *cmd, struct segtype_library *seglib);
+bool raid_is_available(const struct logical_volume *lv);
#endif
#define THIN_FEATURE_DISCARDS (1U << 0)
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index a72e486e9..126b22d43 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -469,6 +469,63 @@ static int _check_feature(const struct raid_feature *feature, uint32_t maj, uint
(maj == feature->maj && min == feature->min && patchlevel >= feature->patchlevel);
}
+/* Check availability of raid10 taking data copies into consideration. */
+static bool _raid10_is_available(const struct logical_volume *lv)
+{
+ uint32_t i, rebuilds_per_group, s;
+ const uint32_t copies = 2; /* FIXME: we only support 2-way mirrors (i.e. 2 data copies) in RAID10 for now. */
+ struct lv_segment *seg = first_seg(lv); /* We only have one segment in RaidLVs for now. */
+
+ for (i = 0; i < seg->area_count * copies; ++i) {
+ s = i % seg->area_count;
+
+ if (!(i % copies))
+ rebuilds_per_group = 0;
+
+ if (seg_type(seg, s) == AREA_LV &&
+ (lv_is_partial(seg_lv(seg, s)) ||
+ lv_is_virtual(seg_lv(seg, s))))
+ rebuilds_per_group++;
+
+ if (rebuilds_per_group >= copies)
+ return false;
+ }
+
+ return true;
+}
+
+/*
+ * Return true in case RaidLV with specific RAID level is available.
+ *
+ * - raid0: all legs have to be live
+ * - raid1 : minimum of 1 leg live
+ * - raid4/5: maximum of 1 leg unavailable
+ * - raid6: maximum of 2 legs unavailable
+ * - raid10: minimum of 1 leg per mirror group available
+ *
+ */
+bool raid_is_available(const struct logical_volume *lv)
+{
+ uint32_t s, missing_legs = 0;
+ struct lv_segment *seg = first_seg(lv); /* We only have one segment in RaidLVs for now. */
+
+ /* Be cautious about bogus calls. */
+ if (!seg || !seg_is_raid(seg))
+ return false;
+
+ if (seg_is_any_raid10(seg))
+ return _raid10_is_available(lv);
+
+ /* Count missing RAID legs */
+ for (s = 0; s < seg->area_count; ++s)
+ if (seg_type(seg, s) == AREA_LV &&
+ lv_is_partial(seg_lv(seg, s)))
+ missing_legs++;
+
+ /* Degradation: segtype raid1 may miss legs-1, raid0/4/5/6 may loose parity devices. */
+ return missing_legs <= (seg_is_raid1(seg) ? seg->area_count - 1 : seg->segtype->parity_devs);
+}
+
static int _raid_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute__((unused)),
unsigned *attributes)
diff --git a/test/shell/lvdisplay-raid.sh b/test/shell/lvdisplay-raid.sh
new file mode 100644
index 000000000..18ea9ae1e
--- /dev/null
+++ b/test/shell/lvdisplay-raid.sh
@@ -0,0 +1,79 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+#
+# tests functionality lvdisplay tool for RAID
+#
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_vg 6
+get_devs
+
+# raid0 loosing a leg
+lvcreate -aey --type raid0 -i5 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1
+lvremove -y $vg/$lv
+
+# raid1 loosing a leg/all legs
+lvcreate -aey --type raid1 -m1 -l5 -n $lv $vg $dev1 $dev2
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+lvremove -y $vg/$lv
+
+# raid5 loosing a leg/2 legs
+lvcreate -aey --type raid5 -i3 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+lvremove -y $vg/$lv
+
+# raid6 loosing a leg/2 legs/3 legs
+lvcreate -aey --type raid6 -i3 -l5 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev2
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev3
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2 $dev3
+lvremove -y $vg/$lv
+
+# raid10 loosing a leg per mirror group / a complete mirror group
+lvcreate -aey --type raid10 -i3 -l3 -n $lv $vg
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev3
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux disable_dev $dev6
+lvdisplay $vg/$lv|grep "LV Status *available (partial)"
+aux enable_dev $dev1 $dev3 $dev6
+lvdisplay $vg/$lv|grep "LV Status *available"
+aux disable_dev $dev1 $dev2
+lvdisplay $vg/$lv|grep "LV Status *NOT available (partial)"
+aux enable_dev $dev1 $dev2
+
+vgremove -y -f $vg
2 years, 8 months
main - WHATS_NEW: update
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=665d265349596d1d4e6...
Commit: 665d265349596d1d4e67b1db5cb33f78338f4c7c
Parent: fa2fa9f36da74d228db22a7765aa4df28107f71a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 22 16:09:38 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jan 22 16:09:38 2021 +0100
WHATS_NEW: update
---
WHATS_NEW | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index ffefc9d2d..9fda1de87 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,9 @@
Version 2.03.12 -
===================================
+ Support online rename of VDO pools.
+ Imporove removal of pmspare when last pool is removed.
+ Fix problem with wiping of converted LVs.
+ Fix memleak in scanning (2.03.11).
Fix corner case allocation for thin-pools.
Version 2.03.11 - 08th January 2021
2 years, 8 months
main - pvscan: ensure read buffer ends with 0
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fa2fa9f36da74d228db...
Commit: fa2fa9f36da74d228db22a7765aa4df28107f71a
Parent: ce6e74f485cb1fb36a4c1c35d1bd3262b77954de
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 21 21:15:33 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jan 22 15:30:37 2021 +0100
pvscan: ensure read buffer ends with 0
Read buffersize - 1 so the last byte is always 0.
Simplify init of 0 buffers.
Check snprintf result for error and report internal error as it could
happen only via bad compile parameters.
---
tools/pvscan.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 0ad901c13..021ec691e 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -206,7 +206,7 @@ static char *_vgname_in_pvid_file_buf(char *buf)
static int _online_pvid_file_read(char *path, int *major, int *minor, char *vgname)
{
- char buf[MAX_PVID_FILE_SIZE];
+ char buf[MAX_PVID_FILE_SIZE] = { 0 };
char *name;
int fd, rv;
@@ -216,9 +216,7 @@ static int _online_pvid_file_read(char *path, int *major, int *minor, char *vgna
return 0;
}
- memset(buf, 0, sizeof(buf));
-
- rv = read(fd, buf, sizeof(buf));
+ rv = read(fd, buf, sizeof(buf) - 1);
if (close(fd))
log_sys_debug("close", path);
if (!rv || rv < 0) {
@@ -350,7 +348,7 @@ static void _online_files_remove(const char *dirpath)
static int _online_pvid_file_create(struct device *dev, const char *vgname)
{
char path[PATH_MAX];
- char buf[MAX_PVID_FILE_SIZE];
+ char buf[MAX_PVID_FILE_SIZE] = { 0 };
char file_vgname[NAME_LEN];
int file_major = 0, file_minor = 0;
int major, minor;
@@ -360,8 +358,6 @@ static int _online_pvid_file_create(struct device *dev, const char *vgname)
int len1 = 0;
int len2 = 0;
- memset(buf, 0, sizeof(buf));
-
major = (int)MAJOR(dev->dev);
minor = (int)MINOR(dev->dev);
@@ -451,13 +447,14 @@ check_duplicate:
static int _online_pvid_file_exists(const char *pvid)
{
- char path[PATH_MAX];
+ char path[PATH_MAX] = { 0 };
struct stat buf;
int rv;
- memset(path, 0, sizeof(path));
-
- snprintf(path, sizeof(path), "%s/%s", _pvs_online_dir, pvid);
+ if (dm_snprintf(path, sizeof(path), "%s/%s", _pvs_online_dir, pvid) < 0) {
+ log_debug(INTERNAL_ERROR "Path %s/%s is too long.", _pvs_online_dir, pvid);
+ return 0;
+ }
log_debug("Check pv online: %s", path);
2 years, 8 months
main - filters: avoid duplicated //
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ce6e74f485cb1fb36a4...
Commit: ce6e74f485cb1fb36a4c1c35d1bd3262b77954de
Parent: 5485ec10e2b592f48f5208d8b5e3cf5e0f0eb70d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 20 00:41:23 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jan 22 15:30:37 2021 +0100
filters: avoid duplicated //
sysfs_dir already goes with '/sys/'.
---
lib/filters/filter-mpath.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/filters/filter-mpath.c b/lib/filters/filter-mpath.c
index 85d1625f6..889a2dd96 100644
--- a/lib/filters/filter-mpath.c
+++ b/lib/filters/filter-mpath.c
@@ -60,7 +60,7 @@ static const char *_get_sysfs_name_by_devt(const char *sysfs_dir, dev_t devno,
char path[PATH_MAX];
int size;
- if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d", sysfs_dir,
+ if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d", sysfs_dir,
(int) MAJOR(devno), (int) MINOR(devno)) < 0) {
log_error("Sysfs path string is too long.");
return NULL;
@@ -106,7 +106,7 @@ static int _get_sysfs_get_major_minor(const char *sysfs_dir, const char *kname,
{
char path[PATH_MAX], buffer[64];
- if (dm_snprintf(path, sizeof(path), "%s/block/%s/dev", sysfs_dir, kname) < 0) {
+ if (dm_snprintf(path, sizeof(path), "%sblock/%s/dev", sysfs_dir, kname) < 0) {
log_error("Sysfs path string is too long.");
return 0;
}
@@ -215,7 +215,7 @@ static int _native_dev_is_mpath(struct dev_filter *f, struct device *dev)
return 0;
}
- if (dm_snprintf(path, sizeof(path), "%s/block/%s/holders", sysfs_dir, name) < 0) {
+ if (dm_snprintf(path, sizeof(path), "%sblock/%s/holders", sysfs_dir, name) < 0) {
log_warn("Sysfs path to check mpath is too long.");
return 0;
}
2 years, 8 months
main - pvscan: make ret value defined
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5485ec10e2b592f48f5...
Commit: 5485ec10e2b592f48f5208d8b5e3cf5e0f0eb70d
Parent: cddeaed6e956b181faf665f8af789cb517259bc2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jan 19 22:38:17 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jan 22 15:30:37 2021 +0100
pvscan: make ret value defined
---
tools/pvscan.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 55c708682..0ad901c13 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -1020,11 +1020,10 @@ static int _pvscan_aa(struct cmd_context *cmd, struct pvscan_aa_params *pp,
struct processing_handle *handle = NULL;
struct dm_str_list *sl, *sl2;
int no_quick = 0;
- int ret;
+ int ret = ECMD_FAILED;
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
- ret = ECMD_FAILED;
goto out;
}
2 years, 8 months
main - tests: check support for online vdo rename
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cddeaed6e956b181faf...
Commit: cddeaed6e956b181faf665f8af789cb517259bc2
Parent: 8532b1ca97e8b9b4a9250140b5d629169f36df28
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 22 15:07:43 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jan 22 15:30:37 2021 +0100
tests: check support for online vdo rename
kvdo 6.2.3 module version supports online rename.
Add cache and raid stacked renames.
---
test/shell/lvcreate-vdo-cache.sh | 17 +-------
test/shell/lvrename-vdo.sh | 88 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+), 15 deletions(-)
diff --git a/test/shell/lvcreate-vdo-cache.sh b/test/shell/lvcreate-vdo-cache.sh
index c31ccccda..6cf84373c 100644
--- a/test/shell/lvcreate-vdo-cache.sh
+++ b/test/shell/lvcreate-vdo-cache.sh
@@ -32,22 +32,9 @@ export MKE2FS_CONFIG="$TESTDIR/lib/mke2fs.conf"
aux prepare_vg 1 9000
-lvcreate --vdo -L4G -V2G --name $lv1 $vg/vpool1
-
+lvcreate --vdo -L4G -V2G --name $lv1 $vg/vpool
# Test caching VDOPoolLV
-lvcreate -H -L10 $vg/vpool1
-
-# Current VDO target driver cannot handle online rename
-# once this will be supported - update this test
-not lvrename $vg/vpool1 $vg/vpool 2>&1 | tee out
-grep "Cannot rename" out
-
-lvchange -an $vg
-
-# Ofline should work
-lvrename $vg/vpool1 $vg/vpool
-
-lvchange -ay $vg
+lvcreate -H -L10 $vg/vpool
mkfs.ext4 -E nodiscard "$DM_DEV_DIR/$vg/$lv1"
diff --git a/test/shell/lvrename-vdo.sh b/test/shell/lvrename-vdo.sh
new file mode 100644
index 000000000..1417d9fe3
--- /dev/null
+++ b/test/shell/lvrename-vdo.sh
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Check online renaming of VDO devices works
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+#
+# Main
+#
+
+aux have_vdo 6 2 1 || skip
+aux have_cache 1 3 0 || skip
+aux have_raid 1 3 0 || skip
+
+aux prepare_vg 2 5000
+
+lvcreate --vdo -L4G -V2G --name $lv1 $vg/vpool1
+lvrename $vg/vpool1 vpool2
+check lv_exists $vg $lv1 vpool2 vpool2_vdata
+
+lvremove -ff $vg
+
+# With version >= 6.2.3 online rename should work
+if aux have_vdo 6 2 3 ; then
+
+### CACHE ####
+lvcreate --vdo -L4G -V2G --name $lv1 $vg/vpool1
+lvcreate -H -L10 $vg/vpool1
+lvrename $vg/vpool1 $vg/vpool2
+check lv_exists $vg vpool2 vpool2_vdata
+lvremove -ff $vg
+
+### RAID ####
+lvcreate --type raid1 -L4G --nosync --name vpool1 $vg
+lvconvert --yes --type vdo-pool $vg/vpool1
+lvrename $vg/vpool1 $vg/vpool2
+check lv_exists $vg vpool2 vpool2_vdata vpool2_vdata_rimage_0
+lvremove -ff $vg
+
+fi # >= 6.2.3
+
+# Check when VDO target does not support online resize
+aux lvmconf "global/vdo_disabled_features = [ \"online_rename\" ]"
+
+
+### CACHE ####
+lvcreate --vdo -L4G -V2G --name $lv1 $vg/vpool1
+lvcreate -H -L10 $vg/vpool1
+
+# VDO target driver cannot handle online rename
+not lvrename $vg/vpool1 $vg/vpool2 2>&1 | tee out
+grep "Cannot rename" out
+
+# Ofline should work
+lvchange -an $vg
+lvrename $vg/vpool1 $vg/vpool2
+lvchange -ay $vg
+check lv_exists $vg $lv1 vpool2 vpool2_vdata
+lvremove -ff $vg
+
+
+### RAID ####
+lvcreate --type raid1 -L4G --nosync --name vpool1 $vg
+lvconvert --yes --type vdo-pool $vg/vpool1
+not lvrename $vg/vpool1 $vg/vpool2 2>&1 | tee out
+grep "Cannot rename" out
+
+# Ofline should work
+lvchange -an $vg
+lvrename $vg/vpool1 $vg/vpool2
+lvchange -ay $vg
+check lv_exists $vg vpool2 vpool2_vdata vpool2_vdata_rimage_0
+lvremove -ff $vg
+
+vgremove -ff $vg
2 years, 8 months