]> sourceware.org Git - lvm2.git/commitdiff
Replicator: add read and release VGs for rsites
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 21 May 2010 14:07:16 +0000 (14:07 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 21 May 2010 14:07:16 +0000 (14:07 +0000)
Add functions to read and release remote VGs for replicator sites
in activation context.

WHATS_NEW
lib/metadata/metadata-exported.h
lib/metadata/replicator_manip.c

index 0b8d7fb440053aa02426c1776b63b0c78b74a89f..bcd2099da88e3aaba1380c603bfc227a8d1b6102 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.67 -
 ===============================
+  Add functions for read and release VGs list.
   Add find_replicator_vgs() to discover all needed VGs for replicator-dev LV.
   Add functions for handling cmd_vg structure.
   Extend _lv_each_dependency() with Replicator dependencies.
index 5fde3835abbe7d66312d9ec1da2be26f636e5fdc..258f221d57eafe74e4118cbd72febd322cf37db1 100644 (file)
@@ -817,6 +817,9 @@ void cmd_vg_release(struct dm_list *cmd_vgs);
 
 int find_replicator_vgs(struct logical_volume *lv);
 
+int lv_read_replicator_vgs(struct logical_volume *lv);
+void lv_release_replicator_vgs(struct logical_volume *lv);
+
 struct logical_volume *find_pvmove_lv(struct volume_group *vg,
                                      struct device *dev, uint32_t lv_type);
 struct logical_volume *find_pvmove_lv_from_pvname(struct cmd_context *cmd,
index 18fe6c76014d3ab8478c66ccabb5512224aac97c..b3a2fff66e9d2334493822f98c9a322597b2d0c7 100644 (file)
@@ -635,3 +635,59 @@ int find_replicator_vgs(struct logical_volume *lv)
 
        return ret;
 }
+
+/**
+ * Read all remote VGs from lv's replicator sites.
+ * Function is used in activation context and needs all VGs already locked.
+ */
+int lv_read_replicator_vgs(struct logical_volume *lv)
+{
+       struct replicator_device *rdev;
+       struct replicator_site *rsite;
+       struct volume_group *vg;
+
+       if (!lv_is_replicator_dev(lv))
+               return 1;
+
+       dm_list_iterate_items(rsite, &first_seg(lv)->replicator->rsites) {
+               if (!rsite->vg_name)
+                       continue;
+               vg = vg_read(lv->vg->cmd, rsite->vg_name, 0, 0); // READ_WITHOUT_LOCK
+               if (vg_read_error(vg)) {
+                       log_error("Unable to read volume group %s",
+                                 rsite->vg_name);
+                       goto bad;
+               }
+               rsite->vg = vg;
+               /* FIXME: handling missing LVs needs to be better */
+               dm_list_iterate_items(rdev, &rsite->rdevices)
+                       if (!(rdev->lv = find_lv(vg, rdev->name))) {
+                               log_error("Unable to find %s in volume group %s",
+                                         rdev->name, rsite->vg_name);
+                               goto bad;
+                       }
+       }
+
+       return 1;
+bad:
+       lv_release_replicator_vgs(lv);
+       return 0;
+}
+
+/**
+ * Release all VG resources taken by lv's replicator sites.
+ * Function is used in activation context and needs all VGs already locked.
+ */
+void lv_release_replicator_vgs(struct logical_volume *lv)
+{
+       struct replicator_site *rsite;
+
+       if (!lv_is_replicator_dev(lv))
+               return;
+
+       dm_list_iterate_back_items(rsite, &first_seg(lv)->replicator->rsites)
+               if (rsite->vg_name && rsite->vg) {
+                       vg_release(rsite->vg);
+                       rsite->vg = NULL;
+               }
+}
This page took 0.050834 seconds and 5 git commands to generate.