Skip to contentSkip to conversation

stable-2.02 - lvdisplay: enhance LV status output for raid(0)

PATCH Heinz Mauelshagen 1 participant 1 message Jan 26, 2021 MD RAID

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2c3f4c2501e0dd3668cee543886badcc78be1066
Commit:        2c3f4c2501e0dd3668cee543886badcc78be1066
Parent:        1d94748601056442b160df8802817404e0a5c7c4
Author:        Heinz Mauelshagen <[email protected]>
AuthorDate:    Tue Jan 26 19:32:24 2021 +0100
Committer:     Heinz Mauelshagen <[email protected]>
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(-)
WHATS_NEW +1 -0
index 2a745dbdd..311923204 100644
@@ -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.
lib/display/display.c +10 -3
index e9cfaa985..cd911feea 100644
@@ -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);
lib/metadata/segtype.h +1 -0
index 9c05836bf..009ec16cf 100644
@@ -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)
lib/raid/raid.c +57 -0

63 lines not on this page · raw message

test/shell/lvdisplay-raid.sh new file +79 -0

79 lines not on this page · raw message