public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/liblvm lvm.h lvm_vg.c
@ 2009-07-26 1:54 wysochanski
0 siblings, 0 replies; 2+ messages in thread
From: wysochanski @ 2009-07-26 1:54 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2009-07-26 01:54:40
Modified files:
liblvm : lvm.h lvm_vg.c
Log message:
Update lvm_vg_extend to do an implicit pvcreate on the device.
Although the tools do not currently do this, we update lvm_vg_extend
to do an implicit pvcreate on an uninitialized device. The tools will
soon be refactored to do this as well, but more work is needed in the
tools. For now we update lvm_vg_extend since this is the behavior
required by liblvm.
With this change, the simple liblvm unit test, test/api/vgtest.c
should pass whether or not the device is initialized.
Author: Dave Wysochanski <dwysocha@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10
--- LVM2/liblvm/lvm.h 2009/07/24 12:48:21 1.12
+++ LVM2/liblvm/lvm.h 2009/07/26 01:54:40 1.13
@@ -146,6 +146,10 @@
* After successfully adding 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.
+ * If the device is not initialized for LVM use, it will be initialized
+ * before adding to the VG. Although some internal checks are done,
+ * the caller should be sure the device is not in use by other subsystems
+ * before calling lvm_vg_extend.
*
* \param vg
* VG handle obtained from lvm_vg_create.
--- LVM2/liblvm/lvm_vg.c 2009/07/24 15:12:50 1.9
+++ LVM2/liblvm/lvm_vg.c 2009/07/26 01:54:40 1.10
@@ -12,9 +12,6 @@
* 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"
@@ -23,6 +20,10 @@
#include "locking.h"
#include "lvm-string.h"
#include "lvmcache.h"
+#include "metadata.h"
+
+#include <errno.h>
+#include <string.h>
vg_t *lvm_vg_create(lvm_t libh, const char *vg_name)
{
@@ -47,6 +48,14 @@
return 0;
}
+ /* If device not initialized, pvcreate it */
+ if (!pv_by_path(vg->cmd, device) &&
+ (!pvcreate_single(vg->cmd, device, NULL))) {
+ log_error("Unable to initialize device for LVM use\n");
+ unlock_vg(vg->cmd, VG_ORPHANS);
+ return 0;
+ }
+
if (!vg_extend(vg, 1, (char **) &device)) {
unlock_vg(vg->cmd, VG_ORPHANS);
return 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
* LVM2/liblvm lvm.h lvm_vg.c
@ 2009-07-23 1:20 wysochanski
0 siblings, 0 replies; 2+ messages in thread
From: wysochanski @ 2009-07-23 1:20 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2009-07-23 01:20:23
Modified files:
liblvm : lvm.h lvm_vg.c
Log message:
Update lvm_vg_create to use NULL / non-NULL return for the time being.
Some of the error interface is still TBD. Rather than exporting a lot
of codes, etc, just use a simple pass / fail. The allows our unit test
to not segfault if trying to create a VG that already exists.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4
--- LVM2/liblvm/lvm.h 2009/07/22 22:24:16 1.5
+++ LVM2/liblvm/lvm.h 2009/07/23 01:20:22 1.6
@@ -110,8 +110,7 @@
* \param libh
* Handle obtained from lvm_create.
*
- * \return A VG handle with error code set appropriately.
- * FIXME: Update error handling description after errno and logging patches
+ * \return non-NULL vg handle (success) or NULL (failure)
*/
vg_t *lvm_vg_create(lvm_t libh, const char *vg_name);
--- LVM2/liblvm/lvm_vg.c 2009/07/22 22:24:16 1.3
+++ LVM2/liblvm/lvm_vg.c 2009/07/23 01:20:22 1.4
@@ -24,7 +24,15 @@
vg_t *lvm_vg_create(lvm_t libh, const char *vg_name)
{
- return vg_create((struct cmd_context *)libh, vg_name);
+ vg_t *vg;
+
+ vg = vg_create((struct cmd_context *)libh, vg_name);
+ /* FIXME: error handling is still TBD */
+ if (vg_read_error(vg)) {
+ vg_release(vg);
+ return NULL;
+ }
+ return vg;
}
int lvm_vg_extend(vg_t *vg, const char *device)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-07-26 1:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-26 1:54 LVM2/liblvm lvm.h lvm_vg.c wysochanski
-- strict thread matches above, loose matches on Subject: below --
2009-07-23 1:20 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).