Skip to contentSkip to conversation

master - lvm2app: Add function to retrieve list of PVs V3

PATCH tasleson 1 participant 1 message Jul 2, 2013

lore
Share & tools
lore

tasleson

author
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ef3ab801e8604d8f629badc1cac1d9190467033f
Commit:        ef3ab801e8604d8f629badc1cac1d9190467033f
Parent:        49d7596581be013ec71a1da7897f861b721eaa19
Author:        Tony Asleson <[email protected]>
AuthorDate:    Tue Mar 19 17:37:04 2013 -0400
Committer:     Tony Asleson <[email protected]>
CommitterDate: Tue Jul 2 14:24:33 2013 -0500

lvm2app: Add function to retrieve list of PVs V3

As locks are held, you need to call the included function to release the memory and locks when done transversing the list of physical volumes.

V2: Rebase fix
V3: Prevent VGs from getting cached and then write protected.

---
 lib/metadata/metadata-exported.h |   12 +++-
 lib/metadata/metadata.c          |   91 +++++++++++++++++------
 liblvm/lvm2app.h                 |   28 +++++++
 liblvm/lvm_pv.c                  |   79 ++++++++++++++++++++
 python/liblvm.c                  |  152 ++++++++++++++++++++++++++++++++++++--
 5 files changed, 331 insertions(+), 31 deletions(-)
lib/metadata/metadata-exported.h +11 -1
index ee8f0c1..7743c47 100644
@@ -403,6 +403,11 @@ struct lv_list {
 	struct logical_volume *lv;
 };
 
+struct vg_list {
+	struct dm_list list;
+	struct volume_group *vg;
+};
+
 #define PV_PE_START_CALC ((uint64_t) -1) /* Calculate pe_start value */
 
 struct pvcreate_restorable_params {
@@ -493,7 +498,12 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_na
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
 				int warnings,
 				int scan_label_only);
-struct dm_list *get_pvs(struct cmd_context *cmd);
+
+#define get_pvs( cmd ) get_pvs_internal((cmd), NULL, NULL)
+#define get_pvs_perserve_vg( cmd, pv_list, vg_list ) get_pvs_internal((cmd), (pv_list), (vg_list))
+
+struct dm_list *get_pvs_internal(struct cmd_context *cmd,
+		struct dm_list *pvslist, struct dm_list *vgslist);
 
 /*
  * Add/remove LV to/from volume group
lib/metadata/metadata.c +69 -22

134 lines not on this page · raw message

liblvm/lvm2app.h +28 -0
index 25778d1..f70e72c 100644
@@ -543,6 +543,34 @@ vg_t lvm_vg_create(lvm_t libh, const char *vg_name);
 struct dm_list *lvm_vg_list_lvs(vg_t vg);
 
 /**
+ * Return a list of PV handles for all.
+ *
+ * \memberof lvm_t
+ *
+ * \param   libh
+ * Library handle retrieved from lvm_init
+ *
+ * \return
+ * A list of lvm_pv_list structures containing pv handles for all physical
+ * volumes. If no PVs exist or a global lock was unable to be obtained a
+ * NULL is returned.
+ */
+struct dm_list *lvm_list_pvs(lvm_t libh);
+
+/**
+ * Free the resources used by acquiring the pvlist.  This should be called as
+ * soon as possible after processing the needed information from the pv list as
+ * a global locks are held.
+ *
+ * \param	pvlist
+ * PV list to be freed
+ *
+ * \return
+ * 0 on success, else -1 with library errno and text set.
+ */
+int lvm_list_pvs_free(struct dm_list *pvlist);
+
+/**
  * Return a list of PV handles for a given VG handle.
  *
  * \memberof vg_t
liblvm/lvm_pv.c +79 -0

96 lines not on this page · raw message

python/liblvm.c +144 -8

224 lines not on this page · raw message