Skip to contentSkip to conversation

lvdisplay: dispaly correct status on linear type

PATCH In review Zhao Heming 2 participants 4 messages Aug 26, 2020 – Aug 27, 2020 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lvdisplay: dispaly correct status on linear type

It commit is enhancement for 1d0dc74f9147e3c1f3681efa4166cbe2edcb6571 1d0dc74f9147 only supports all raid type, this commit adds linear type.

With this patch, for linear type LV, one of two disks missing, lvdisplay will show
from:
LV Status available (partial)
to:
LV Status NOT available (partial)

---
 lib/display/display.c            |  7 ++-
 lib/metadata/lv_manip.c          | 76 ++++++++++++++++++++++++++++++++
 lib/metadata/metadata-exported.h |  1 +
 lib/metadata/segtype.h           |  1 -
 lib/raid/raid.c                  | 54 -----------------------
 5 files changed, 80 insertions(+), 59 deletions(-)
lib/display/display.c +3 -4
index 3bb570f03..7c4ec9bb3 100644
@@ -399,7 +399,7 @@ int lvdisplay_full(struct cmd_context *cmd,
 		   void *handle __attribute__((unused)))
 {
 	struct lvinfo info;
-	int inkernel, snap_active = 0, partial = 0, raid_is_avail = 1;
+	int inkernel, snap_active = 0, partial = 0, lv_is_avail = 1;
 	char uuid[64] __attribute__((aligned(8)));
 	const char *access_str;
 	struct lv_segment *snap_seg = NULL, *mirror_seg = NULL;
@@ -555,15 +555,14 @@ int lvdisplay_full(struct cmd_context *cmd,
 
 	if (lv_is_partial(lv)) {
 		partial = 1;
-		if (lv_is_raid(lv))
-			raid_is_avail = raid_is_available(lv) ? 1 : 0;
+		lv_is_avail = lv_is_available(lv) ? 1 : 0;
 	}
 
 	if (inkernel && info.suspended)
 		log_print("LV Status              suspended");
 	else if (activation())
 		log_print("LV Status              %savailable %s",
-			  (inkernel && raid_is_avail) ? "" : "NOT ",
+			  (inkernel && lv_is_avail) ? "" : "NOT ",
 			  partial ? "(partial)" : "");
 
 /********* FIXME lv_number
lib/metadata/lv_manip.c +76 -0

82 lines not on this page · raw message

lib/metadata/metadata-exported.h +1 -0
index 06ea757b8..2c1e23195 100644
@@ -291,6 +291,7 @@
 
 int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
 		       struct dm_list **layout, struct dm_list **role);
+bool lv_is_available(const struct logical_volume *lv);
 
 /* Ordered list - see lv_manip.c */
 typedef enum {
lib/metadata/segtype.h +0 -1
index 1a840707d..08ddc3565 100644
@@ -326,7 +326,6 @@ 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 +0 -54

60 lines not on this page · raw message

Signature · 1 line
2.27.0
#1 lore raw

Same as the commit writing, this commit is code enhancement not bugfix.

Last commit 1d0dc74f9147e3c1f3681efa4166cbe2edcb6571 had been verified by one of suse customer. They did test for types: mirror, raid0, raid1, raid5, linear.

For this commit, I only verified linear & raid cases. I have little experience with type: snapshot, thin, vdo, cache etc. So I am not sure whether this commit contains any bug when LV type is not linear & raid.

Quoted 18 lines · Zhao Heming

It commit is enhancement for 1d0dc74f9147e3c1f3681efa4166cbe2edcb6571 1d0dc74f9147 only supports all raid type, this commit adds linear type.

With this patch, for linear type LV, one of two disks missing, lvdisplay will show
from:
LV Status available (partial)
to:
LV Status NOT available (partial)

---
  lib/display/display.c            |  7 ++-
  lib/metadata/lv_manip.c          | 76 ++++++++++++++++++++++++++++++++
  lib/metadata/metadata-exported.h |  1 +
  lib/metadata/segtype.h           |  1 -
  lib/raid/raid.c                  | 54 -----------------------
  5 files changed, 80 insertions(+), 59 deletions(-)
#2 lore raw
In reply to Zhao Heming
Quoted 9 lines · Zhao Heming

It commit is enhancement for 1d0dc74f9147e3c1f3681efa4166cbe2edcb6571 1d0dc74f9147 only supports all raid type, this commit adds linear type.

With this patch, for linear type LV, one of two disks missing, lvdisplay will show
from:
LV Status available (partial)
to:
LV Status NOT available (partial)

It would be nice if you could come up with a more formal definition for what you're calling "lv_is_available", and also in the same terms define the existing "lv_is_partial", explaining how they differ. Both properties may be useful to show in lvs reporting fields (and possibly lv_attr). Reporting this state only via the lvdisplay line above seems strange.

lib/metadata/lv_manip.c bad: · line 737

Quoted 2 lines
lib/metadata/lv_manip.c +2 -0
+			} else if (seg_type(seg, s) == AREA_PV) {
+				if (seg_pv(seg, s)->status & MISSING_PV)

Using only MISSING_PV is probably insufficient, because that flag is used only when the metadata is written while the device is missing. i.e. pv->dev can be NULL when the flag is not set.

Dave

#3 lore raw

thank you for your kindly review.

Quoted 11 lines · David Teigland
Quoted 9 lines · Zhao Heming

It commit is enhancement for 1d0dc74f9147e3c1f3681efa4166cbe2edcb6571 1d0dc74f9147 only supports all raid type, this commit adds linear type.

With this patch, for linear type LV, one of two disks missing, lvdisplay will show
from:
LV Status available (partial)
to:
LV Status NOT available (partial)

Quoted 5 lines

It would be nice if you could come up with a more formal definition for what you're calling "lv_is_available", and also in the same terms define the existing "lv_is_partial", explaining how they differ. Both properties may be useful to show in lvs reporting fields (and possibly lv_attr). Reporting this state only via the lvdisplay line above seems strange.

I will send the v2 patch very soon.
the v2 patch only for lvdisplay cmd. if my code acceptable, I plan update lvs cmd in v3, add a new letter (N)ot_available in bit 9 (Volume Health).

Quoted 8 lines

lib/metadata/lv_manip.c bad: · line 737

Quoted 3 lines
lib/metadata/lv_manip.c +2 -0
+			} else if (seg_type(seg, s) == AREA_PV) {
+				if (seg_pv(seg, s)->status & MISSING_PV)

Using only MISSING_PV is probably insufficient, because that flag is used only when the metadata is written while the device is missing. i.e. pv->dev can be NULL when the flag is not set.

I have a little confused with your comments.
These 2 lines are same as _lv_mark_if_partial_single() code:

```
            if (seg_type(lvseg, s) == AREA_PV) {
                if (is_missing_pv(seg_pv(lvseg, s))) {
```

why _lv_mark_if_partial_single can use these 2 lines?
please wait for the v2 patch, I changed some code logic, set the NOT_AVAIL_LV in _lv_mark_if_partial_single().

Quoted 2 lines

Dave