[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [patch 1/3] Add lv_is_active() to determine whether an lv is active.



Handles non-clustered as well as clustered.

Signed-off-by: Dave Wysochanski <dwysocha redhat com>
---
 lib/activate/activate.c |   19 +++++++++++++++++++
 lib/activate/activate.h |    1 +
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 7b959cd..75d31a8 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -674,6 +674,25 @@ int lvs_in_vg_opened(const struct volume_group *vg)
 }
 
 /*
+ * Determine whether an LV is active locally or in a cluster.
+ * Assumes vg lock held.
+ * Returns:
+ * 0 - not active locally or on any node in cluster
+ * 1 - active either locally or some node in the cluster
+ */
+int lv_is_active(struct logical_volume *lv)
+{
+	if (_lv_active(lv->vg->cmd, lv, 0))
+		return 1;
+
+	if (activate_lv_excl(lv->vg->cmd, lv)) {
+		deactivate_lv(lv->vg->cmd, lv);
+		return 0;
+	}
+	return 1;
+}
+
+/*
  * Returns 0 if an attempt to (un)monitor the device failed.
  * Returns 1 otherwise.
  */
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index ec68251..656ea15 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -91,6 +91,7 @@ int lvs_in_vg_activated(struct volume_group *vg);
 int lvs_in_vg_activated_by_uuid_only(struct volume_group *vg);
 int lvs_in_vg_opened(const struct volume_group *vg);
 
+int lv_is_active(struct logical_volume *lv);
 
 int monitor_dev_for_events(struct cmd_context *cmd,
 			    struct logical_volume *lv, int do_reg);
-- 
1.5.3.4

-- 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]