Skip to contentSkip to conversation

master - lvdisplay: dispaly correct status when underlying devs missing

PATCH David Teigland 1 participant 1 message Aug 24, 2020 MD RAID

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1d0dc74f9147e3c1f3681efa4166cbe2edcb6571
Commit:        1d0dc74f9147e3c1f3681efa4166cbe2edcb6571
Parent:        46d15b5e4d2830fce313d7a58a1498d61b7a8f86
Author:        Zhao Heming <[email protected]>
AuthorDate:    Mon Aug 24 09:47:04 2020 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Mon Aug 24 09:47:04 2020 -0500

lvdisplay: dispaly correct status when underlying devs missing

reproducible steps:
1. vgcreate vg1 /dev/sda /dev/sdb
2. lvcreate --type raid0 -l 100%FREE -n raid0lv vg1
3. do remove the /dev/sdb action
4. lvdisplay show wrong 'LV Status'

After removing raid0 type LV underlying dev, lvdisplay still display 'available'. This is wrong status for raid0.

This patch add a new function raid_is_available(), which will handle all raid case.

With this patch, lvdisplay will show
from:
LV Status available
to:
LV Status NOT available (partial)

---
 lib/display/display.c  | 13 +++++++++---
 lib/metadata/segtype.h |  1 +
 lib/raid/raid.c        | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+), 3 deletions(-)
lib/display/display.c +10 -3
index 36c9879b3..3bb570f03 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;
@@ -553,11 +553,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);
lib/metadata/segtype.h +1 -0
index 08ddc3565..1a840707d 100644
@@ -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)
lib/raid/raid.c +54 -0

60 lines not on this page · raw message