public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/liblvm .exported_symbols lvm.h lvm_vg.c
@ 2009-07-24 12:48 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-07-24 12:48 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2009-07-24 12:48:21
Modified files:
liblvm : .exported_symbols lvm.h lvm_vg.c
Log message:
Add lvm_scan_vgs liblvm fn to scan the system for LVM metadata.
The lvm_list_vg_{names|ids} functions do not do a scan so we provide
a liblvm function that does a scan.
Author: Dave Wysochanski <dwysocha@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8
--- LVM2/liblvm/.exported_symbols 2009/07/24 12:47:15 1.7
+++ LVM2/liblvm/.exported_symbols 2009/07/24 12:48:21 1.8
@@ -14,6 +14,7 @@
lvm_vg_open
lvm_vg_close
lvm_vg_remove
+lvm_scan_vgs
lvm_errno
lvm_errmsg
lvm_vg_list_pvs
--- LVM2/liblvm/lvm.h 2009/07/24 12:47:15 1.11
+++ LVM2/liblvm/lvm.h 2009/07/24 12:48:21 1.12
@@ -265,6 +265,8 @@
* Return a list of VG names or VG uuids in the system.
*
* NOTE: This function will _NOT_ scan devices in the system for LVM metadata.
+ * To scan the system, use lvm_scan_vgs.
+ *
* To process the list, use the dm_list iterator functions. For example:
* vg_t *vg;
* struct dm_list *vgnames;
@@ -286,5 +288,11 @@
struct dm_list *lvm_list_vg_names(lvm_t libh);
struct dm_list *lvm_list_vg_ids(lvm_t libh);
+/**
+ * Scan all devices on the system for VGs and LVM metadata.
+ *
+ * \return Status code of 1 (success) or 0 (failure).
+ */
+int lvm_scan_vgs(lvm_t libh);
#endif /* _LIB_LVM_H */
--- LVM2/liblvm/lvm_vg.c 2009/07/24 12:47:15 1.7
+++ LVM2/liblvm/lvm_vg.c 2009/07/24 12:48:21 1.8
@@ -22,6 +22,7 @@
#include "archiver.h"
#include "locking.h"
#include "lvm-string.h"
+#include "lvmcache.h"
vg_t *lvm_vg_create(lvm_t libh, const char *vg_name)
{
@@ -198,3 +199,8 @@
{
return get_vgids((struct cmd_context *)libh, 0);
}
+
+int lvm_scan_vgs(lvm_t libh)
+{
+ return lvmcache_label_scan((struct cmd_context *)libh, 2);
+}
^ permalink raw reply [flat|nested] 6+ messages in thread
* LVM2/liblvm .exported_symbols lvm.h lvm_vg.c
@ 2009-07-27 17:44 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-07-27 17:44 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2009-07-27 17:44:29
Modified files:
liblvm : .exported_symbols lvm.h lvm_vg.c
Log message:
Add lvm_vg_reduce to liblvm2app
Extend lvm_vg_write to remove pvs removed in lvm_vg_reduce. The lvm
volume_group internal structure removed_pvs is used for that. The list is
empty afterwards.
Add new test for vg->pvs emptyness to lvm_vg_write to prevent to write empty
vgs. This is needed because of lvm_vg_reduce and lv_vg_create, which creates
empty vgs.
Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>
Author: Dave Wysochanski <dwysocha@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.18&r2=1.19
--- LVM2/liblvm/.exported_symbols 2009/07/26 20:58:11 1.17
+++ LVM2/liblvm/.exported_symbols 2009/07/27 17:44:29 1.18
@@ -21,6 +21,7 @@
lvm_lv_is_suspended
lvm_vg_create
lvm_vg_extend
+lvm_vg_reduce
lvm_vg_set_extent_size
lvm_vg_write
lvm_vg_open
--- LVM2/liblvm/lvm.h 2009/07/27 11:00:18 1.29
+++ LVM2/liblvm/lvm.h 2009/07/27 17:44:29 1.30
@@ -331,6 +331,24 @@
int lvm_vg_extend(vg_t *vg, const char *device);
/**
+ * Reduce a VG by removing an unused device.
+ *
+ * This API requires calling lvm_vg_write to commit the change to disk.
+ * After successfully removing a device, use lvm_vg_write to commit the new VG
+ * to disk. Upon failure, retry the operation or release the VG handle with
+ * lvm_vg_close.
+ *
+ * \param vg
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \param device
+ * Name of device to remove from VG.
+ *
+ * \return 0 (success) or -1 (failure).
+ */
+int lvm_vg_reduce(vg_t *vg, const char *device);
+
+/**
* Set the extent size of a VG.
*
* This API requires calling lvm_vg_write to commit the change to disk.
--- LVM2/liblvm/lvm_vg.c 2009/07/27 11:00:18 1.18
+++ LVM2/liblvm/lvm_vg.c 2009/07/27 17:44:29 1.19
@@ -68,6 +68,16 @@
return 0;
}
+int lvm_vg_reduce(vg_t *vg, const char *device)
+{
+ if (vg_read_error(vg))
+ return -1;
+
+ if (!vg_reduce(vg, (char *)device))
+ return -1;
+ return 0;
+}
+
int lvm_vg_set_extent_size(vg_t *vg, uint32_t new_size)
{
if (vg_read_error(vg))
@@ -80,15 +90,40 @@
int lvm_vg_write(vg_t *vg)
{
+ struct pv_list *pvl;
+
if (vg_read_error(vg))
return -1;
+ if (dm_list_empty(&vg->pvs)) {
+ log_error("Volume group %s does not contain any "
+ "physical volumes.\n", vg->name);
+ return -1;
+ }
+
+ if (! dm_list_empty(&vg->removed_pvs)) {
+ if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+ log_error("Can't get lock for orphan PVs");
+ return 0;
+ }
+ }
+
if (!archive(vg))
return -1;
/* Store VG on disk(s) */
if (!vg_write(vg) || !vg_commit(vg))
return -1;
+
+ if (! dm_list_empty(&vg->removed_pvs)) {
+ dm_list_iterate_items(pvl, &vg->removed_pvs) {
+ pv_write_orphan(vg->cmd, pvl->pv);
+ /* FIXME: do pvremove / label_remove()? */
+ }
+ dm_list_init(&vg->removed_pvs);
+ unlock_vg(vg->cmd, VG_ORPHANS);
+ }
+
return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* LVM2/liblvm .exported_symbols lvm.h lvm_vg.c
@ 2009-07-26 16:05 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-07-26 16:05 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2009-07-26 16:05:50
Modified files:
liblvm : .exported_symbols lvm.h lvm_vg.c
Log message:
Rename lvm_vg_get_free_count to lvm_vg_get_free_extent_count.
Author: Dave Wysochanski <dwysocha@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12
--- LVM2/liblvm/.exported_symbols 2009/07/26 14:36:52 1.11
+++ LVM2/liblvm/.exported_symbols 2009/07/26 16:05:49 1.12
@@ -10,7 +10,7 @@
lvm_vg_get_free
lvm_vg_get_extent_size
lvm_vg_get_extent_count
-lvm_vg_get_free_count
+lvm_vg_get_free_extent_count
lvm_vg_get_pv_count
lvm_lv_get_uuid
lvm_lv_get_name
--- LVM2/liblvm/lvm.h 2009/07/26 14:36:52 1.16
+++ LVM2/liblvm/lvm.h 2009/07/26 16:05:49 1.17
@@ -264,7 +264,7 @@
uint64_t lvm_vg_get_free(const vg_t *vg);
uint64_t lvm_vg_get_extent_size(const vg_t *vg);
uint64_t lvm_vg_get_extent_count(const vg_t *vg);
-uint64_t lvm_vg_get_free_count(const vg_t *vg);
+uint64_t lvm_vg_get_free_extent_count(const vg_t *vg);
uint64_t lvm_vg_get_pv_count(const vg_t *vg);
uint64_t lvm_lv_get_size(const lv_t *lv);
--- LVM2/liblvm/lvm_vg.c 2009/07/26 13:06:59 1.11
+++ LVM2/liblvm/lvm_vg.c 2009/07/26 16:05:49 1.12
@@ -211,7 +211,7 @@
return vg_extent_count(vg);
}
-uint64_t lvm_vg_get_free_count(const vg_t *vg)
+uint64_t lvm_vg_get_free_extent_count(const vg_t *vg)
{
return vg_free_count(vg);
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* LVM2/liblvm .exported_symbols lvm.h lvm_vg.c
@ 2009-07-24 12:47 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-07-24 12:47 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2009-07-24 12:47:15
Modified files:
liblvm : .exported_symbols lvm.h lvm_vg.c
Log message:
Add lvm_list_vg_names and lvm_list_vg_ids liblvm functions.
These functions provide the capability of enumerating all vgnames and
vgids in the system. They do not do a scan of the system.
Author: Dave Wysochanski <dwysocha@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
--- LVM2/liblvm/.exported_symbols 2009/07/23 23:40:05 1.6
+++ LVM2/liblvm/.exported_symbols 2009/07/24 12:47:15 1.7
@@ -18,3 +18,5 @@
lvm_errmsg
lvm_vg_list_pvs
lvm_vg_list_lvs
+lvm_list_vg_names
+lvm_list_vg_ids
--- LVM2/liblvm/lvm.h 2009/07/23 23:40:05 1.10
+++ LVM2/liblvm/lvm.h 2009/07/24 12:47:15 1.11
@@ -44,6 +44,11 @@
lv_t *lv;
} lv_list_t;
+struct lvm_str_list {
+ struct dm_list list;
+ const char *str;
+};
+
/**
* Return a list of LV handles for a given VG handle.
*
@@ -256,4 +261,30 @@
*/
struct dm_list *lvm_vg_list_pvs(vg_t *vg);
+/**
+ * Return a list of VG names or VG uuids in the system.
+ *
+ * NOTE: This function will _NOT_ scan devices in the system for LVM metadata.
+ * To process the list, use the dm_list iterator functions. For example:
+ * vg_t *vg;
+ * struct dm_list *vgnames;
+ * struct lvm_str_list *strl;
+ *
+ * vgnames = lvm_list_vg_names(libh);
+ * dm_list_iterate_items(strl, vgnames) {
+ * vgname = strl->str;
+ * vg = lvm_vg_open(libh, vgname, "r");
+ * // do something with vg
+ * lvm_vg_close(vg);
+ * }
+ *
+ *
+ * \return A list of struct lvm_str_list
+ * If no VGs exist on the system, NULL is returned.
+ * FIXME: handle list memory cleanup
+ */
+struct dm_list *lvm_list_vg_names(lvm_t libh);
+struct dm_list *lvm_list_vg_ids(lvm_t libh);
+
+
#endif /* _LIB_LVM_H */
--- LVM2/liblvm/lvm_vg.c 2009/07/23 23:40:05 1.6
+++ LVM2/liblvm/lvm_vg.c 2009/07/24 12:47:15 1.7
@@ -188,3 +188,13 @@
name[NAME_LEN] = '\0';
return name;
}
+
+struct dm_list *lvm_list_vg_names(lvm_t libh)
+{
+ return get_vgnames((struct cmd_context *)libh, 0);
+}
+
+struct dm_list *lvm_list_vg_ids(lvm_t libh)
+{
+ return get_vgids((struct cmd_context *)libh, 0);
+}
^ permalink raw reply [flat|nested] 6+ messages in thread
* LVM2/liblvm .exported_symbols lvm.h lvm_vg.c
@ 2009-07-23 23:39 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-07-23 23:39 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2009-07-23 23:39:02
Modified files:
liblvm : .exported_symbols lvm.h lvm_vg.c
Log message:
Add lvm_vg_list_{pvs|lvs} - return lists of pv/lv handles for a vg.
- Use vgmem pool to allocate a list of lvm_*_list structs
- Allocate a new list each call (list may have changed since last call)
- Add to liblvm's exported symbols
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Thomas Woerner <twoerner@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
--- LVM2/liblvm/.exported_symbols 2009/07/22 22:24:16 1.4
+++ LVM2/liblvm/.exported_symbols 2009/07/23 23:39:02 1.5
@@ -10,3 +10,5 @@
lvm_vg_remove
lvm_errno
lvm_errmsg
+lvm_vg_list_pvs
+lvm_vg_list_lvs
--- LVM2/liblvm/lvm.h 2009/07/23 23:37:24 1.8
+++ LVM2/liblvm/lvm.h 2009/07/23 23:39:02 1.9
@@ -44,6 +44,13 @@
lv_t *lv;
} lv_list_t;
+/**
+ * Return a list of LV handles for a given VG handle.
+ *
+ * \return A list of lv_list_t structures containing lv handles for this vg.
+ * If no LVs exist on the given VG, NULL is returned.
+ */
+struct dm_list *lvm_vg_list_lvs(vg_t *vg);
struct lvm; /* internal data */
@@ -225,4 +232,12 @@
vg_t *lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
uint32_t flags);
+/**
+ * Return a list of PV handles for a given VG handle.
+ *
+ * \return A list of pv_list_t structures containing pv handles for this vg.
+ * If no PVs exist on the given VG, NULL is returned.
+ */
+struct dm_list *lvm_vg_list_pvs(vg_t *vg);
+
#endif /* _LIB_LVM_H */
--- LVM2/liblvm/lvm_vg.c 2009/07/23 01:20:22 1.4
+++ LVM2/liblvm/lvm_vg.c 2009/07/23 23:39:02 1.5
@@ -114,3 +114,55 @@
return vg;
}
+
+struct dm_list *lvm_vg_list_pvs(vg_t *vg)
+{
+ struct dm_list *list;
+ pv_list_t *pvs;
+ struct pv_list *pvl;
+
+ if (dm_list_empty(&vg->pvs))
+ return NULL;
+
+ if (!(list = dm_pool_zalloc(vg->vgmem, sizeof(*list)))) {
+ log_error("Memory allocation fail for dm_list.\n");
+ return NULL;
+ }
+ dm_list_init(list);
+
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ if (!(pvs = dm_pool_zalloc(vg->vgmem, sizeof(*pvs)))) {
+ log_error("Memory allocation fail for lvm_pv_list.\n");
+ return NULL;
+ }
+ pvs->pv = pvl->pv;
+ dm_list_add(list, &pvs->list);
+ }
+ return list;
+}
+
+struct dm_list *lvm_vg_list_lvs(vg_t *vg)
+{
+ struct dm_list *list;
+ lv_list_t *lvs;
+ struct lv_list *lvl;
+
+ if (dm_list_empty(&vg->lvs))
+ return NULL;
+
+ if (!(list = dm_pool_zalloc(vg->vgmem, sizeof(*list)))) {
+ log_error("Memory allocation fail for dm_list.\n");
+ return NULL;
+ }
+ dm_list_init(list);
+
+ dm_list_iterate_items(lvl, &vg->lvs) {
+ if (!(lvs = dm_pool_zalloc(vg->vgmem, sizeof(*lvs)))) {
+ log_error("Memory allocation fail for lvm_lv_list.\n");
+ return NULL;
+ }
+ lvs->lv = lvl->lv;
+ dm_list_add(list, &lvs->list);
+ }
+ return list;
+}
^ permalink raw reply [flat|nested] 6+ messages in thread
* LVM2/liblvm .exported_symbols lvm.h lvm_vg.c
@ 2009-07-22 22:24 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2009-07-22 22:24 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2009-07-22 22:24:17
Modified files:
liblvm : .exported_symbols lvm.h lvm_vg.c
Log message:
Add lvm_vg_open() to open an existing VG for reading or writing.
lvm_vg_open() calls internal vg_read() function which is the entry point
for reading an existing VG. In addition to the mode, we include a 'flags'
parameter for future extensions.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
--- LVM2/liblvm/.exported_symbols 2009/07/22 03:13:13 1.3
+++ LVM2/liblvm/.exported_symbols 2009/07/22 22:24:16 1.4
@@ -5,6 +5,7 @@
lvm_vg_extend
lvm_vg_set_extent_size
lvm_vg_write
+lvm_vg_open
lvm_vg_close
lvm_vg_remove
lvm_errno
--- LVM2/liblvm/lvm.h 2009/07/16 03:07:46 1.4
+++ LVM2/liblvm/lvm.h 2009/07/22 22:24:16 1.5
@@ -190,4 +190,27 @@
*/
int lvm_vg_close(vg_t *vg);
+/**
+ * Open an existing VG.
+ *
+ * Open a VG for reading or writing.
+ *
+ * \param libh
+ * Handle obtained from lvm_create.
+ *
+ * \param vgname
+ * Name of the VG to open.
+ *
+ * \param mode
+ * Open mode - either "r" (read) or "w" (read/write).
+ * Any other character results in an error with EINVAL set.
+ *
+ * \param flags
+ * Open flags - currently ignored.
+ *
+ * \return non-NULL VG handle (success) or NULL (failure).
+ */
+vg_t *lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
+ uint32_t flags);
+
#endif /* _LIB_LVM_H */
--- LVM2/liblvm/lvm_vg.c 2009/07/22 03:13:35 1.2
+++ LVM2/liblvm/lvm_vg.c 2009/07/22 22:24:16 1.3
@@ -12,6 +12,9 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <errno.h>
+#include <string.h>
+
#include "lib.h"
#include "lvm.h"
#include "toolcontext.h"
@@ -80,3 +83,26 @@
bad:
return 0;
}
+
+vg_t *lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
+ uint32_t flags)
+{
+ uint32_t internal_flags = 0;
+ vg_t *vg;
+
+ if (!strncmp(mode, "w", 1))
+ internal_flags |= READ_FOR_UPDATE;
+ else if (strncmp(mode, "r", 1)) {
+ log_errno(EINVAL, "Invalid VG open mode");
+ return NULL;
+ }
+
+ vg = vg_read((struct cmd_context *)libh, vgname, NULL, internal_flags);
+ if (vg_read_error(vg)) {
+ /* FIXME: use log_errno either here in inside vg_read */
+ vg_release(vg);
+ return NULL;
+ }
+
+ return vg;
+}
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-07-27 17:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-24 12:48 LVM2/liblvm .exported_symbols lvm.h lvm_vg.c wysochanski
-- strict thread matches above, loose matches on Subject: below --
2009-07-27 17:44 wysochanski
2009-07-26 16:05 wysochanski
2009-07-24 12:47 wysochanski
2009-07-23 23:39 wysochanski
2009-07-22 22:24 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).