public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/liblvm .exported_symbols lvm.h lvm_lv.c
@ 2009-07-26 14:36 wysochanski
  0 siblings, 0 replies; 4+ messages in thread
From: wysochanski @ 2009-07-26 14:36 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 14:36:52

Modified files:
	liblvm         : .exported_symbols lvm.h lvm_lv.c 

Log message:
	Add lvm_vg_remove_lv liblvm function.
	
	Add a very simple version of lvm_vg_remove_lv.
	Since we currently can only create linear LVs, this simple remove function
	is adequate.  We must refactor lvremove_single a bit.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4

--- LVM2/liblvm/.exported_symbols	2009/07/26 13:06:59	1.10
+++ LVM2/liblvm/.exported_symbols	2009/07/26 14:36:52	1.11
@@ -30,3 +30,4 @@
 lvm_list_vg_names
 lvm_list_vg_ids
 lvm_vg_create_lv_linear
+lvm_vg_remove_lv
--- LVM2/liblvm/lvm.h	2009/07/26 13:06:59	1.15
+++ LVM2/liblvm/lvm.h	2009/07/26 14:36:52	1.16
@@ -117,6 +117,17 @@
 lv_t *lvm_vg_create_lv_linear(vg_t *vg, const char *name, uint64_t size);
 
 /**
+ * Remove a logical volume from a volume group.
+ * This API commits the change to disk and does _not_ require calling
+ * lvm_vg_write.
+ * Currently only removing linear LVs are possible.
+ *
+ * FIXME: This API should probably not commit to disk but require calling
+ * lvm_vg_write.
+ */
+int lvm_vg_remove_lv(lv_t *lv);
+
+/**
  * Return stored error no describing last LVM API error.
  *
  * Users of liblvm should use lvm_errno to determine success or failure
--- LVM2/liblvm/lvm_lv.c	2009/07/26 13:06:59	1.3
+++ LVM2/liblvm/lvm_lv.c	2009/07/26 14:36:52	1.4
@@ -96,3 +96,9 @@
 	return lvl->lv;
 }
 
+int lvm_vg_remove_lv(lv_t *lv)
+{
+	if (!lv || !lv->vg || vg_read_error(lv->vg))
+		return 0;
+	return lv_remove_single(lv->vg->cmd, lv, DONT_PROMPT);
+}


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

* LVM2/liblvm .exported_symbols lvm.h lvm_lv.c
@ 2009-07-26 20:58 wysochanski
  0 siblings, 0 replies; 4+ messages in thread
From: wysochanski @ 2009-07-26 20:58 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 20:58:11

Modified files:
	liblvm         : .exported_symbols lvm.h lvm_lv.c 

Log message:
	Add lvm_lv_is_active and lvm_lv_is_suspended.
	
	Return whether an LV is active in the kernel (live table) or suspended
	(table suspend).
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7

--- LVM2/liblvm/.exported_symbols	2009/07/26 20:57:37	1.16
+++ LVM2/liblvm/.exported_symbols	2009/07/26 20:58:11	1.17
@@ -17,6 +17,8 @@
 lvm_lv_get_uuid
 lvm_lv_get_name
 lvm_lv_get_size
+lvm_lv_is_active
+lvm_lv_is_suspended
 lvm_vg_create
 lvm_vg_extend
 lvm_vg_set_extent_size
--- LVM2/liblvm/lvm.h	2009/07/26 20:57:37	1.25
+++ LVM2/liblvm/lvm.h	2009/07/26 20:58:11	1.26
@@ -516,6 +516,24 @@
  */
 uint64_t lvm_lv_get_size(const lv_t *lv);
 
+/**
+ * Get the current activation state of a logical volume.
+ *
+ * \param   lv
+ *          Logical volume handle.
+ * \return  1 if the LV is active in the kernel, 0 if not
+ */
+uint64_t lvm_lv_is_active(const lv_t *lv);
+
+/**
+ * Get the current suspended state of a logical volume.
+ *
+ * \param   lv
+ *          Logical volume handle.
+ * \return  1 if the LV is suspended in the kernel, 0 if not
+ */
+uint64_t lvm_lv_is_suspended(const lv_t *lv);
+
 /************************** physical volume handling ************************/
 
 /**
--- LVM2/liblvm/lvm_lv.c	2009/07/26 20:57:37	1.6
+++ LVM2/liblvm/lvm_lv.c	2009/07/26 20:58:11	1.7
@@ -19,6 +19,7 @@
 #include "defaults.h"
 #include "segtype.h"
 #include "locking.h"
+#include "activate.h"
 
 #include <string.h>
 
@@ -49,6 +50,24 @@
 	return name;
 }
 
+uint64_t lvm_lv_is_active(const lv_t *lv)
+{
+	struct lvinfo info;
+	if (lv_info(lv->vg->cmd, lv, &info, 1, 0) &&
+	    info.exists && info.live_table)
+		return 1;
+	return 0;
+}
+
+uint64_t lvm_lv_is_suspended(const lv_t *lv)
+{
+	struct lvinfo info;
+	if (lv_info(lv->vg->cmd, lv, &info, 1, 0) &&
+	    info.exists && info.suspended)
+		return 1;
+	return 0;
+}
+
 /* Set defaults for non-segment specific LV parameters */
 static void _lv_set_default_params(struct lvcreate_params *lp,
 				   vg_t *vg, const char *lvname,


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

* LVM2/liblvm .exported_symbols lvm.h lvm_lv.c
@ 2009-07-26 20:57 wysochanski
  0 siblings, 0 replies; 4+ messages in thread
From: wysochanski @ 2009-07-26 20:57 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 20:57:38

Modified files:
	liblvm         : .exported_symbols lvm.h lvm_lv.c 

Log message:
	Implement lvm_lv_activate and lvm_lv_deactivate liblvm calls.
	
	Limited implementation but other types of activation should probably have
	separate calls.  We also currently do not handle pvmoves or lvconverts.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6

--- LVM2/liblvm/.exported_symbols	2009/07/26 16:44:05	1.15
+++ LVM2/liblvm/.exported_symbols	2009/07/26 20:57:37	1.16
@@ -12,6 +12,8 @@
 lvm_vg_get_extent_count
 lvm_vg_get_free_extent_count
 lvm_vg_get_pv_count
+lvm_lv_activate
+lvm_lv_deactivate
 lvm_lv_get_uuid
 lvm_lv_get_name
 lvm_lv_get_size
--- LVM2/liblvm/lvm.h	2009/07/26 20:28:59	1.24
+++ LVM2/liblvm/lvm.h	2009/07/26 20:57:37	1.25
@@ -443,6 +443,31 @@
 lv_t *lvm_vg_create_lv_linear(vg_t *vg, const char *name, uint64_t size);
 
 /**
+ * Activate a logical volume.
+ *
+ * This API is the equivalent of the lvm command "lvchange -ay".
+ *
+ * NOTE: This API cannot currently handle LVs with an in-progress pvmove or
+ * lvconvert.
+ *
+ * \param   lv
+ *          Logical volume handle.
+ * \return  0 (success) or -1 (failure).
+ */
+int lvm_lv_activate(lv_t *lv);
+
+/**
+ * Deactivate a logical volume.
+ *
+ * This API is the equivalent of the lvm command "lvchange -an".
+ *
+ * \param   lv
+ *          Logical volume handle.
+ * \return  0 (success) or -1 (failure).
+ */
+int lvm_lv_deactivate(lv_t *lv);
+
+/**
  * Remove a logical volume from a volume group.
  *
  * This function commits the change to disk and does _not_ require calling
--- LVM2/liblvm/lvm_lv.c	2009/07/26 20:28:59	1.5
+++ LVM2/liblvm/lvm_lv.c	2009/07/26 20:57:37	1.6
@@ -18,6 +18,8 @@
 #include "lvm-string.h"
 #include "defaults.h"
 #include "segtype.h"
+#include "locking.h"
+
 #include <string.h>
 
 /* FIXME: have lib/report/report.c _disp function call lv_size()? */
@@ -104,3 +106,51 @@
 		return -1;
 	return 0;
 }
+
+int lvm_lv_activate(lv_t *lv)
+{
+	if (!lv || !lv->vg || vg_read_error(lv->vg) || !lv->vg->cmd)
+		return -1;
+
+	/* FIXME: handle pvmove stuff later */
+	if (lv->status & LOCKED) {
+		log_error("Unable to activate locked LV\n");
+		return -1;
+	}
+
+	/* FIXME: handle lvconvert stuff later */
+	if (lv->status & CONVERTING) {
+		log_error("Unable to activate LV with in-progress lvconvert\n");
+		return -1;
+	}
+
+	if (lv_is_origin(lv)) {
+		log_verbose("Activating logical volume \"%s\" "
+			    "exclusively", lv->name);
+		if (!activate_lv_excl(lv->vg->cmd, lv)) {
+			log_error("Activate exclusive failed.\n");
+			return -1;
+		}
+	} else {
+		log_verbose("Activating logical volume \"%s\"",
+			    lv->name);
+		if (!activate_lv(lv->vg->cmd, lv)) {
+			log_error("Activate failed.\n");
+			return -1;
+		}
+	}
+	return 0;
+}
+
+int lvm_lv_deactivate(lv_t *lv)
+{
+	if (!lv || !lv->vg || vg_read_error(lv->vg) || !lv->vg->cmd)
+		return -1;
+
+	log_verbose("Deactivating logical volume \"%s\"", lv->name);
+	if (!deactivate_lv(lv->vg->cmd, lv)) {
+		log_error("Deactivate failed.\n");
+		return -1;
+	}
+	return 0;
+}


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

* LVM2/liblvm .exported_symbols lvm.h lvm_lv.c
@ 2009-07-26  2:34 wysochanski
  0 siblings, 0 replies; 4+ messages in thread
From: wysochanski @ 2009-07-26  2:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 02:34:36

Modified files:
	liblvm         : .exported_symbols lvm.h lvm_lv.c 

Log message:
	Add lvm_vg_create_lv_linear liblvm function.
	
	Create a default linear logical volume from a volume group.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2

--- LVM2/liblvm/.exported_symbols	2009/07/24 12:48:21	1.8
+++ LVM2/liblvm/.exported_symbols	2009/07/26 02:34:36	1.9
@@ -21,3 +21,4 @@
 lvm_vg_list_lvs
 lvm_list_vg_names
 lvm_list_vg_ids
+lvm_vg_create_lv_linear
--- LVM2/liblvm/lvm.h	2009/07/26 01:54:40	1.13
+++ LVM2/liblvm/lvm.h	2009/07/26 02:34:36	1.14
@@ -97,6 +97,26 @@
 int lvm_reload_config(lvm_t libh);
 
 /**
+ * Create a linear logical volume.
+ * This API commits the change to disk and does _not_ require calling
+ * lvm_vg_write.
+ * FIXME: This API should probably not commit to disk but require calling
+ * lvm_vg_write.  However, this appears to be non-trivial change until
+ * lv_create_single is refactored by segtype.
+ *
+ * \param   vg
+ *          VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \param   name
+ *          Name of logical volume to create.
+ *
+ * \param   size
+ *          Size of logical volume in extents.
+ *
+ */
+lv_t *lvm_vg_create_lv_linear(vg_t *vg, const char *name, uint64_t size);
+
+/**
  * Return stored error no describing last LVM API error.
  *
  * Users of liblvm should use lvm_errno to determine success or failure
--- LVM2/liblvm/lvm_lv.c	2009/07/23 23:40:05	1.1
+++ LVM2/liblvm/lvm_lv.c	2009/07/26 02:34:36	1.2
@@ -16,6 +16,9 @@
 #include "lvm.h"
 #include "metadata-exported.h"
 #include "lvm-string.h"
+#include "defaults.h"
+#include "segtype.h"
+#include <string.h>
 
 char *lvm_lv_get_uuid(const lv_t *lv)
 {
@@ -38,3 +41,52 @@
 	return name;
 }
 
+/* Set defaults for non-segment specific LV parameters */
+static void _lv_set_default_params(struct lvcreate_params *lp,
+				   vg_t *vg, const char *lvname,
+				   uint64_t extents)
+{
+	lp->zero = 1;
+	lp->major = -1;
+	lp->minor = -1;
+	lp->vg_name = vg->name;
+	lp->lv_name = lvname; /* FIXME: check this for safety */
+	lp->pvh = &vg->pvs;
+
+	lp->extents = extents;
+	lp->permission = LVM_READ | LVM_WRITE;
+	lp->read_ahead = DM_READ_AHEAD_NONE;
+	lp->alloc = ALLOC_INHERIT;
+	lp->tag = NULL;
+}
+
+/* Set default for linear segment specific LV parameters */
+static void _lv_set_default_linear_params(struct cmd_context *cmd,
+					  struct lvcreate_params *lp)
+{
+	lp->segtype = get_segtype_from_string(cmd, "striped");
+	lp->stripes = 1;
+	lp->stripe_size = DEFAULT_STRIPESIZE * 2;
+}
+
+lv_t *lvm_vg_create_lv_linear(vg_t *vg, const char *name, uint64_t size)
+{
+	struct lvcreate_params lp;
+	uint64_t extents;
+	struct lv_list *lvl;
+
+	/* FIXME: check for proper VG access */
+	if (vg_read_error(vg))
+		return NULL;
+	memset(&lp, 0, sizeof(lp));
+	extents = extents_from_size(vg->cmd, size, vg->extent_size);
+	_lv_set_default_params(&lp, vg, name, extents);
+	_lv_set_default_linear_params(vg->cmd, &lp);
+	if (!lv_create_single(vg, &lp))
+		return NULL;
+	lvl = find_lv_in_vg(vg, name);
+	if (!lvl)
+		return NULL;
+	return lvl->lv;
+}
+


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

end of thread, other threads:[~2009-07-26 20:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-26 14:36 LVM2/liblvm .exported_symbols lvm.h lvm_lv.c wysochanski
  -- strict thread matches above, loose matches on Subject: below --
2009-07-26 20:58 wysochanski
2009-07-26 20:57 wysochanski
2009-07-26  2:34 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).