Skip to contentSkip to conversation

LVM2/lib/metadata metadata.c

PATCH [email protected] 3 participants 3 messages Feb 14, 2011 – Feb 15, 2011

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall at sourceware.org 2011-02-14 19:27:05

Modified files:
lib/metadata : metadata.c

Log message:
Fix an lv_postorder bug where it failed to clear temporary flags, making it impossible to use twice with the same LV(s). Discovered by Milan.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.420&r2=1.421

lib/metadata/metadata.c +13 -12
@@ -1969,18 +1969,6 @@
 			       int (*fn)(struct logical_volume *lv, void *data),
 			       void *data);
 
-static int _lv_postorder_level(struct logical_volume *lv, void *data)
-{
-	struct _lv_postorder_baton *baton = data;
-	if (lv->status & POSTORDER_OPEN_FLAG)
-		return 1; // a data structure loop has closed...
-	lv->status |= POSTORDER_OPEN_FLAG;
-	int r =_lv_postorder_visit(lv, baton->fn, baton->data);
-	lv->status &= ~POSTORDER_OPEN_FLAG;
-	lv->status |= POSTORDER_FLAG;
-	return r;
-};
-
 static int _lv_each_dependency(struct logical_volume *lv,
 			       int (*fn)(struct logical_volume *lv, void *data),
 			       void *data)
@@ -2022,6 +2010,12 @@
 	return 1;
 }
 
+static int _lv_postorder_level(struct logical_volume *lv, void *data)
+{
+	struct _lv_postorder_baton *baton = data;
+	return _lv_postorder_visit(lv, baton->fn, baton->data);
+};
+
 static int _lv_postorder_visit(struct logical_volume *lv,
 			       int (*fn)(struct logical_volume *lv, void *data),
 			       void *data)
@@ -2031,13 +2025,20 @@
 
 	if (lv->status & POSTORDER_FLAG)
 		return 1;
+	if (lv->status & POSTORDER_OPEN_FLAG)
+		return 1; // a data structure loop has closed...
+	lv->status |= POSTORDER_OPEN_FLAG;
 
 	baton.fn = fn;
 	baton.data = data;
 	r = _lv_each_dependency(lv, _lv_postorder_level, &baton);
+
 	if (r)
 		r = fn(lv, data);
 
+	lv->status &= ~POSTORDER_OPEN_FLAG;
+	lv->status |= POSTORDER_FLAG;
+
 	return r;
 }
 
#1 lore raw
Quoted 2 lines · mornfall at sourceware.org

Fix an lv_postorder bug where it failed to clear temporary flags, making it impossible to use twice with the same LV(s). Discovered by Milan.

Is this bug triggered by any existing code paths and if so which?

Alasdair

#2 lore raw
Quoted 5 lines · Alasdair G Kergon
Quoted 2 lines · mornfall at sourceware.org

Fix an lv_postorder bug where it failed to clear temporary flags, making it impossible to use twice with the same LV(s). Discovered by Milan.

Is this bug triggered by any existing code paths and if so which?

Yes, second readahead checkon the same LV == NOOP.

Milan