]> sourceware.org Git - lvm2.git/commitdiff
Fix an lv_postorder bug where it failed to clear temporary flags, making it
authorPetr Rockai <prockai@redhat.com>
Mon, 14 Feb 2011 19:27:05 +0000 (19:27 +0000)
committerPetr Rockai <prockai@redhat.com>
Mon, 14 Feb 2011 19:27:05 +0000 (19:27 +0000)
impossible to use twice with the same LV(s). Discovered by Milan.

lib/metadata/metadata.c

index 771cdb08affde8d35d58aeec1bf6036fb78f6aa8..6a6773317f4c0a4b2367e3e00922122c3495face 100644 (file)
@@ -1969,18 +1969,6 @@ static int _lv_postorder_visit(struct logical_volume *,
                               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 @@ static int _lv_postorder_cleanup(struct logical_volume *lv, void *data)
        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 @@ static int _lv_postorder_visit(struct logical_volume *lv,
 
        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;
 }
 
This page took 0.06579 seconds and 5 git commands to generate.