public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/liblvm lvm2app.h lvm_pv.c
@ 2010-10-25 14:08 wysochanski
  0 siblings, 0 replies; 3+ messages in thread
From: wysochanski @ 2010-10-25 14:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-10-25 14:08:55

Modified files:
	liblvm         : lvm2app.h lvm_pv.c 

Log message:
	Add lvm_pv_get_property() generic function to obtain value of any pv property.
	
	Add a generic PV property function to lvm2app, similar to VG function.
	Return lvm_property_value and require caller to check 'is_valid' flag
	before using the value.  If 'is_valid' is not set, then lvm_errno()
	should be used to obtain the specific error.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm2app.h.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_pv.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14

--- LVM2/liblvm/lvm2app.h	2010/10/25 14:08:43	1.21
+++ LVM2/liblvm/lvm2app.h	2010/10/25 14:08:55	1.22
@@ -1243,6 +1243,44 @@
 uint64_t lvm_pv_get_free(const pv_t pv);
 
 /**
+ * Get the value of a PV property
+ *
+ * \memberof pv_t
+ *
+ * \param   pv
+ * Physical volume handle.
+ *
+ * \param   name
+ * Name of property to query.  See pvs man page for full list of properties
+ * that may be queried.
+ *
+ * The memory allocated for a string property value is tied to the vg_t
+ * handle and will be released when lvm_vg_close() is called.
+ *
+ * Example:
+ *      lvm_property_value value;
+ *      char *prop_name = "pv_mda_count";
+ *
+ *      v = lvm_pv_get_property(pv, prop_name);
+ *      if (!v.is_valid) {
+ *           printf("Invalid property name or unable to query"
+ *                  "'%s', errno = %d.\n", prop_name, lvm_errno(libh));
+ *           return;
+ *      }
+ *      if (v.is_string)
+ *           printf(", value = %s\n", v.value.string);
+ *	if (v.is_integer)
+ *           printf(", value = %"PRIu64"\n", v.value.integer);
+ *
+ * \return
+ * lvm_property_value structure that will contain the current
+ * value of the property.  Caller should check 'is_valid' flag before using
+ * the value.  If 'is_valid' is not set, caller should check lvm_errno()
+ * for specific error.
+ */
+struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name);
+
+/**
  * Resize physical volume to new_size bytes.
  *
  * \memberof pv_t
--- LVM2/liblvm/lvm_pv.c	2010/09/30 14:07:48	1.13
+++ LVM2/liblvm/lvm_pv.c	2010/10/25 14:08:55	1.14
@@ -16,6 +16,7 @@
 #include "lvm2app.h"
 #include "metadata.h"
 #include "lvm-string.h"
+#include "lvm_misc.h"
 
 const char *lvm_pv_get_uuid(const pv_t pv)
 {
@@ -48,6 +49,11 @@
 	return (uint64_t) SECTOR_SIZE * pv_free(pv);
 }
 
+struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name)
+{
+	return get_property(pv, NULL, NULL, name);
+}
+
 int lvm_pv_resize(const pv_t pv, uint64_t new_size)
 {
 	/* FIXME: add pv resize code here */


^ permalink raw reply	[flat|nested] 3+ messages in thread

* LVM2/liblvm lvm2app.h lvm_pv.c
@ 2010-11-17 20:10 mornfall
  0 siblings, 0 replies; 3+ messages in thread
From: mornfall @ 2010-11-17 20:10 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-11-17 20:10:42

Modified files:
	liblvm         : lvm2app.h lvm_pv.c 

Log message:
	Add a new type and function to lvm2app to enumerate pvsegs.
	
	Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
	Reviewed-by: Petr Rockai <prockai@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm2app.h.diff?cvsroot=lvm2&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_pv.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16

--- LVM2/liblvm/lvm2app.h	2010/11/17 20:09:42	1.26
+++ LVM2/liblvm/lvm2app.h	2010/11/17 20:10:42	1.27
@@ -96,6 +96,7 @@
 struct volume_group;
 struct logical_volume;
 struct lv_segment;
+struct pv_segment;
 
 /**
  * \class lvm_t
@@ -145,6 +146,13 @@
 typedef struct lv_segment *lvseg_t;
 
 /**
+ * \class pvseg_t
+ *
+ * This pv segment object is bound to a pv_t.
+ */
+typedef struct pv_segment *pvseg_t;
+
+/**
  * Logical Volume object list.
  *
  * Lists of these structures are returned by lvm_vg_list_lvs().
@@ -175,6 +183,16 @@
 } pv_list_t;
 
 /**
+ * Physical Volume Segment object list.
+ *
+ * Lists of these structures are returned by lvm_pv_list_pvsegs().
+ */
+typedef struct lvm_pvseg_list {
+	struct dm_list list;
+	pvseg_t pvseg;
+} pvseg_list_t;
+
+/**
  * String list.
  *
  * This string list contains read-only strings.
@@ -1419,6 +1437,19 @@
 struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name);
 
 /**
+ * Return a list of pvseg handles for a given PV handle.
+ *
+ * \memberof pv_t
+ *
+ * \param   pv
+ * Physical volume handle.
+ *
+ * \return
+ * A list of lvm_pvseg_list structures containing pvseg handles for this pv.
+ */
+struct dm_list *lvm_pv_list_pvsegs(pv_t pv);
+
+/**
  * Resize physical volume to new_size bytes.
  *
  * \memberof pv_t
--- LVM2/liblvm/lvm_pv.c	2010/11/17 20:09:42	1.15
+++ LVM2/liblvm/lvm_pv.c	2010/11/17 20:10:42	1.16
@@ -54,6 +54,33 @@
 	return get_property(pv, NULL, NULL, NULL, name);
 }
 
+struct dm_list *lvm_pv_list_pvsegs(pv_t pv)
+{
+	struct dm_list *list;
+	pvseg_list_t *pvseg;
+	struct pv_segment *pvl;
+
+	if (dm_list_empty(&pv->segments))
+		return NULL;
+
+	if (!(list = dm_pool_zalloc(pv->vg->vgmem, sizeof(*list)))) {
+		log_errno(ENOMEM, "Memory allocation fail for dm_list.");
+		return NULL;
+	}
+	dm_list_init(list);
+
+	dm_list_iterate_items(pvl, &pv->segments) {
+		if (!(pvseg = dm_pool_zalloc(pv->vg->vgmem, sizeof(*pvseg)))) {
+			log_errno(ENOMEM,
+				"Memory allocation fail for lvm_pvseg_list.");
+			return NULL;
+		}
+		pvseg->pvseg = pvl;
+		dm_list_add(list, &pvseg->list);
+	}
+	return list;
+}
+
 int lvm_pv_resize(const pv_t pv, uint64_t new_size)
 {
 	/* FIXME: add pv resize code here */


^ permalink raw reply	[flat|nested] 3+ messages in thread

* LVM2/liblvm lvm2app.h lvm_pv.c
@ 2009-08-13 12:18 wysochanski
  0 siblings, 0 replies; 3+ messages in thread
From: wysochanski @ 2009-08-13 12:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-08-13 12:18:15

Modified files:
	liblvm         : lvm2app.h lvm_pv.c 

Log message:
	Make lvm2app pv_t handle definition consistent with lvm_t.
	
	This patch update pv_t handle to be consistent with lvm_t - define as a pointer
	to internal struct physical_volume.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm2app.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_pv.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7

--- LVM2/liblvm/lvm2app.h	2009/08/13 12:17:32	1.5
+++ LVM2/liblvm/lvm2app.h	2009/08/13 12:18:15	1.6
@@ -130,7 +130,7 @@
  * group.  Changes will be written to disk when the volume group gets
  * committed to disk.
  */
-typedef struct physical_volume pv_t;
+typedef struct physical_volume *pv_t;
 
 /**
  * Logical Volume object list.
@@ -149,7 +149,7 @@
  */
 typedef struct lvm_pv_list {
 	struct dm_list list;
-	pv_t *pv;
+	pv_t pv;
 } pv_list_t;
 
 /**
@@ -781,7 +781,7 @@
  * \return
  * Copy of the uuid string.
  */
-char *lvm_pv_get_uuid(const pv_t *pv);
+char *lvm_pv_get_uuid(const pv_t pv);
 
 /**
  * Get the current name of a logical volume.
@@ -795,7 +795,7 @@
  * \return
  * Copy of the name.
  */
-char *lvm_pv_get_name(const pv_t *pv);
+char *lvm_pv_get_name(const pv_t pv);
 
 /**
  * Get the current number of metadata areas in the physical volume.
@@ -806,7 +806,7 @@
  * \return
  * Number of metadata areas in the PV.
  */
-uint64_t lvm_pv_get_mda_count(const pv_t *pv);
+uint64_t lvm_pv_get_mda_count(const pv_t pv);
 
 /**
  * Resize physical volume to new_size bytes.
@@ -822,6 +822,6 @@
  * \return
  * 0 (success) or -1 (failure).
  */
-int lvm_pv_resize(const pv_t *pv, uint64_t new_size);
+int lvm_pv_resize(const pv_t pv, uint64_t new_size);
 
 #endif /* _LIB_LVM2APP_H */
--- LVM2/liblvm/lvm_pv.c	2009/07/29 13:26:01	1.6
+++ LVM2/liblvm/lvm_pv.c	2009/08/13 12:18:15	1.7
@@ -17,7 +17,7 @@
 #include "metadata-exported.h"
 #include "lvm-string.h"
 
-char *lvm_pv_get_uuid(const pv_t *pv)
+char *lvm_pv_get_uuid(const pv_t pv)
 {
 	char uuid[64] __attribute((aligned(8)));
 
@@ -28,7 +28,7 @@
 	return strndup((const char *)uuid, 64);
 }
 
-char *lvm_pv_get_name(const pv_t *pv)
+char *lvm_pv_get_name(const pv_t pv)
 {
 	char *name;
 
@@ -38,12 +38,12 @@
 	return name;
 }
 
-uint64_t lvm_pv_get_mda_count(const pv_t *pv)
+uint64_t lvm_pv_get_mda_count(const pv_t pv)
 {
 	return (uint64_t) pv_mda_count(pv);
 }
 
-int lvm_pv_resize(const pv_t *pv, uint64_t new_size)
+int lvm_pv_resize(const pv_t pv, uint64_t new_size)
 {
 	/* FIXME: add pv resize code here */
 	log_error("NOT IMPLEMENTED YET");


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-17 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-25 14:08 LVM2/liblvm lvm2app.h lvm_pv.c wysochanski
  -- strict thread matches above, loose matches on Subject: below --
2010-11-17 20:10 mornfall
2009-08-13 12:18 wysochanski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).