]> sourceware.org Git - lvm2.git/commitdiff
Replicator: add replicator to dtree
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 24 May 2010 09:01:05 +0000 (09:01 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 24 May 2010 09:01:05 +0000 (09:01 +0000)
Adding all replicator related LVs to dtree.
Start of one replicator_dev initiate start of all other related.

WHATS_NEW
lib/activate/dev_manager.c

index c09de9e40b5f72968fc66819ec2b816283c4af52..9f4ce4e02ecba0f91bf6867bf0dbefff0d9af5d3 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.67 -
 ===============================
+  Add Replicators' LVs to dtree for activation.
   Avoid print activation message if there is a missing VG (Replicator).
   Fixed scripts/relpath.awk to work in mawk
   Add _add_partial_replicator_to_dtree().
index 9d21d5f2322a9aaced9663689115c9519445c5ea..15f58192b9102b57a99645a9ed5c090ad55ef6b0 100644 (file)
@@ -1200,6 +1200,61 @@ static int _add_target_to_dtree(struct dev_manager *dm,
 static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
                                  struct logical_volume *lv, const char *layer);
 
+/* Add all replicators' LVs */
+static int _add_replicator_dev_target_to_dtree(struct dev_manager *dm,
+                                              struct dm_tree *dtree,
+                                              struct lv_segment *seg)
+{
+       struct replicator_device *rdev;
+       struct replicator_site *rsite;
+
+       /* For inactive replicator add linear mapping */
+       if (!lv_is_active_replicator_dev(seg->lv)) {
+               if (!_add_new_lv_to_dtree(dm, dtree, seg->lv->rdevice->lv, NULL))
+                       return_0;
+               return 1;
+       }
+
+       /* Add rlog and replicator nodes */
+       if (!seg->replicator ||
+            !first_seg(seg->replicator)->rlog_lv ||
+           !_add_new_lv_to_dtree(dm, dtree,
+                                 first_seg(seg->replicator)->rlog_lv, NULL) ||
+           !_add_new_lv_to_dtree(dm, dtree, seg->replicator, NULL))
+           return_0;
+
+       /* Activation of one replicator_dev node activates all other nodes */
+       dm_list_iterate_items(rsite, &seg->replicator->rsites) {
+               dm_list_iterate_items(rdev, &rsite->rdevices) {
+                       if (rdev->lv &&
+                           !_add_new_lv_to_dtree(dm, dtree, rdev->lv, NULL))
+                               return_0;
+
+                       if (rdev->slog &&
+                           !_add_new_lv_to_dtree(dm, dtree,
+                                                 rdev->slog, NULL))
+                               return_0;
+               }
+       }
+       /* Add remaining replicator-dev nodes in the second loop
+        * to avoid multiple retries for inserting all elements */
+       dm_list_iterate_items(rsite, &seg->replicator->rsites) {
+               if (rsite->state != REPLICATOR_STATE_ACTIVE)
+                       continue;
+               dm_list_iterate_items(rdev, &rsite->rdevices) {
+                       if (rdev->replicator_dev->lv == seg->lv)
+                               continue;
+                       if (!rdev->replicator_dev->lv ||
+                           !_add_new_lv_to_dtree(dm, dtree,
+                                                 rdev->replicator_dev->lv,
+                                                 NULL))
+                               return_0;
+               }
+       }
+
+       return 1;
+}
+
 static int _add_segment_to_dtree(struct dev_manager *dm,
                                   struct dm_tree *dtree,
                                   struct dm_tree_node *dnode,
@@ -1230,9 +1285,12 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
            !_add_new_lv_to_dtree(dm, dtree, seg->log_lv, NULL))
                return_0;
 
+       if (seg_is_replicator_dev(seg)) {
+               if (!_add_replicator_dev_target_to_dtree(dm, dtree, seg))
+                       return_0;
        /* If this is a snapshot origin, add real LV */
        /* If this is a snapshot origin + merging snapshot, add cow + real LV */
-       if (lv_is_origin(seg->lv) && !layer) {
+       } else if (lv_is_origin(seg->lv) && !layer) {
                if (vg_is_clustered(seg->lv->vg)) {
                        log_error("Clustered snapshots are not yet supported");
                        return 0;
This page took 0.049776 seconds and 5 git commands to generate.