Skip to contentSkip to conversation

main - vg_validate: fix validation of merging thin origin

PATCH Zdenek Kabelac 1 participant 1 message Mar 15, 2021

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a18409b6d1d6a90e432b0b0079ce702d0055fa5a
Commit:        a18409b6d1d6a90e432b0b0079ce702d0055fa5a
Parent:        ff712987a5792cfc3fba03889ec4485294386a03
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Sun Mar 14 11:44:54 2021 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Mar 15 10:59:09 2021 +0100

vg_validate: fix validation of merging thin origin

Compat code and handle unusual case, where
thin snapshot is also a 'thick snapshot origin' and such snapshot gets merged into a thin origin.

However since now lv_is_visible() (which is complex function) replaced &VISIBLE_LV check, the whole this check seems to be no longer useful as sum of all 3 will always match??

---
 lib/metadata/metadata.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
lib/metadata/metadata.c +6 -19
index ed1c05f75..cee236e3e 100644
@@ -2397,12 +2397,6 @@ int vg_validate(struct volume_group *vg)
 			}
 		}
 
-		if (lv_is_cow(lvl->lv))
-			num_snapshots++;
-
-		if (lv_is_visible(lvl->lv))
-			lv_visible_count++;
-
 		if (!check_lv_segments(lvl->lv, 0)) {
 			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
 				  lvl->lv->name);
@@ -2427,19 +2421,12 @@ int vg_validate(struct volume_group *vg)
 				r = 0;
 			}
 
-		if (lvl->lv->status & VISIBLE_LV)
-			continue;
-
-		/* snapshots */
-		if (lv_is_cow(lvl->lv))
-			continue;
-
-		/* virtual origins are always hidden */
-		if (lv_is_origin(lvl->lv) && !lv_is_virtual_origin(lvl->lv))
-			continue;
-
-		/* count other non-snapshot invisible volumes */
-		hidden_lv_count++;
+		if (lv_is_visible(lvl->lv))
+			lv_visible_count++;
+		else if (lv_is_cow(lvl->lv))
+			num_snapshots++;
+		else		/* count other non-snapshot invisible volumes */
+			hidden_lv_count++;
 
 		/*
 		 *  FIXME: add check for unreferenced invisible LVs