public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 lib/metadata/metadata.c lib/metadata/meta ...
@ 2007-06-12 21:20 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2007-06-12 21:20 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-06-12 21:20:20
Modified files:
lib/metadata : metadata.c metadata.h
. : WHATS_NEW
Log message:
Add get_pv_* functions to return PV fields in prep for external LVM library
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.157&r2=1.158
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.626&r2=1.627
--- LVM2/lib/metadata/metadata.c 2007/06/11 18:29:30 1.110
+++ LVM2/lib/metadata/metadata.c 2007/06/12 21:20:20 1.111
@@ -28,6 +28,12 @@
#include <sys/param.h>
+/*
+ * FIXME: Check for valid handle before dereferencing member or log error?
+ */
+#define PV_HANDLE_DEREF(H, M) \
+ (((struct physical_volume *)H)->M)
+
static struct physical_volume *_pv_read(struct cmd_context *cmd,
const char *pv_name,
struct list *mdas,
@@ -1452,7 +1458,21 @@
return lvl->lv;
}
-/* FIXME: liblvm todo - make into function that returns handle */
+/**
+ * pv_read - read and return a handle to a physical volume
+ * @cmd: LVM command initiating the pv_read
+ * @pv_name: full device name of the PV, including the path
+ * @mdas: list of metadata areas of the PV
+ * @label_sector: sector number where the PV label is stored on @pv_name
+ * @warnings:
+ *
+ * Returns:
+ * PV handle - valid pv_name and successful read of the PV, or
+ * NULL - invalid parameter or error in reading the PV
+ *
+ * Note:
+ * FIXME - liblvm todo - make into function that returns handle
+ */
struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
struct list *mdas, uint64_t *label_sector,
int warnings)
@@ -1684,7 +1704,6 @@
/**
* vg_check_status - check volume group status flags and log error
- *
* @vg - volume group to check status flags
* @status_flags - specific status flags to check (e.g. EXPORTED_VG)
*
@@ -1720,3 +1739,62 @@
return 1;
}
+
+
+/*
+ * Gets/Sets for external LVM library
+ */
+struct id get_pv_id (void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, id);
+}
+
+const struct format_type *get_pv_format_type (void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, fmt);
+}
+
+struct id get_pv_vgid (void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, vgid);
+}
+
+struct device *get_pv_dev (void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, dev);
+}
+
+const char *get_pv_vg_name (void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, vg_name);
+}
+
+uint64_t get_pv_size(void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, size);
+}
+
+uint32_t get_pv_status (void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, status);
+}
+
+uint32_t get_pv_pe_size (void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, pe_size);
+}
+
+uint64_t get_pv_pe_start (void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, pe_start);
+}
+
+uint32_t get_pv_pe_count (void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, pe_count);
+}
+
+uint32_t get_pv_pe_alloc_count (void *pv_handle)
+{
+ return PV_HANDLE_DEREF(pv_handle, pe_alloc_count);
+}
--- LVM2/lib/metadata/metadata.h 2007/06/06 19:40:27 1.157
+++ LVM2/lib/metadata/metadata.h 2007/06/12 21:20:20 1.158
@@ -635,4 +635,19 @@
char *generate_lv_name(struct volume_group *vg, const char *format,
char *buffer, size_t len);
+/*
+ * Gets/Sets for external LVM library
+ */
+struct id get_pv_id (void *pv_handle);
+const struct format_type *get_pv_format_type (void *pv_handle);
+struct id get_pv_vgid (void *pv_handle);
+struct device *get_pv_dev (void *pv_handle);
+const char *get_pv_vg_name (void *pv_handle);
+uint64_t get_pv_size(void *pv_handle);
+uint32_t get_pv_status (void *pv_handle);
+uint32_t get_pv_pe_size (void *pv_handle);
+uint64_t get_pv_pe_start (void *pv_handle);
+uint32_t get_pv_pe_count (void *pv_handle);
+uint32_t get_pv_pe_alloc_count (void *pv_handle);
+
#endif
--- LVM2/WHATS_NEW 2007/06/11 18:29:30 1.626
+++ LVM2/WHATS_NEW 2007/06/12 21:20:20 1.627
@@ -1,5 +1,6 @@
Version 2.02.26 -
=================================
+ Add get_pv_* functions to return PV members (external LVM library).
Add wrappers to some functions in preparation for external LVM library.
Allow vgcfgrestore to list metadata backup files using -f
Add vg_check_status to consolidate vg status checks and error messages.
^ permalink raw reply [flat|nested] 6+ messages in thread
* LVM2 lib/metadata/metadata.c lib/metadata/meta ...
@ 2007-06-19 4:36 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2007-06-19 4:36 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-06-19 04:36:12
Modified files:
lib/metadata : metadata.c metadata.h
tools : lvremove.c polldaemon.c toollib.c vgck.c
vgconvert.c vgdisplay.c vgexport.c vgreduce.c
vgremove.c
Log message:
Convert vg->status checks to use vg_check_status function.\nRename status_flags to status in vg_check_status.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.165&r2=1.166
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvremove.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.100&r2=1.101
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgck.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgconvert.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgdisplay.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgexport.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgremove.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
--- LVM2/lib/metadata/metadata.c 2007/06/19 04:23:32 1.120
+++ LVM2/lib/metadata/metadata.c 2007/06/19 04:36:12 1.121
@@ -1744,33 +1744,33 @@
/**
* vg_check_status - check volume group status flags and log error
* @vg - volume group to check status flags
- * @status_flags - specific status flags to check (e.g. EXPORTED_VG)
+ * @status - specific status flags to check (e.g. EXPORTED_VG)
*
* Returns:
* 0 - fail
* 1 - success
*/
-int vg_check_status(struct volume_group *vg, uint32_t status_flags)
+int vg_check_status(struct volume_group *vg, uint32_t status)
{
- if ((status_flags & CLUSTERED) &&
+ if ((status & CLUSTERED) &&
(vg->status & CLUSTERED) && !locking_is_clustered() &&
!lockingfailed()) {
log_error("Skipping clustered volume group %s", vg->name);
return 0;
}
- if ((status_flags & EXPORTED_VG) &&
+ if ((status & EXPORTED_VG) &&
(vg->status & EXPORTED_VG)) {
log_error("Volume group %s is exported", vg->name);
return 0;
}
- if ((status_flags & LVM_WRITE) &&
+ if ((status & LVM_WRITE) &&
!(vg->status & LVM_WRITE)) {
log_error("Volume group %s is read-only", vg->name);
return 0;
}
- if ((status_flags & RESIZEABLE_VG) &&
+ if ((status & RESIZEABLE_VG) &&
!(vg->status & RESIZEABLE_VG)) {
log_error("Volume group %s is not resizeable.", vg->name);
return 0;
--- LVM2/lib/metadata/metadata.h 2007/06/19 04:23:32 1.165
+++ LVM2/lib/metadata/metadata.h 2007/06/19 04:36:12 1.166
@@ -580,7 +580,7 @@
int vg_remove_snapshot(struct logical_volume *cow);
-int vg_check_status(struct volume_group *vg, uint32_t status_flags);
+int vg_check_status(struct volume_group *vg, uint32_t status);
/*
* Mirroring functions
--- LVM2/tools/lvremove.c 2006/10/23 11:46:16 1.49
+++ LVM2/tools/lvremove.c 2007/06/19 04:36:12 1.50
@@ -24,10 +24,8 @@
vg = lv->vg;
- if (!(vg->status & LVM_WRITE)) {
- log_error("Volume group \"%s\" is read-only", vg->name);
+ if (!vg_check_status(vg, LVM_WRITE))
return ECMD_FAILED;
- }
if (lv_is_origin(lv)) {
log_error("Can't remove logical volume \"%s\" under snapshot",
@@ -77,7 +75,7 @@
/* If the VG is clustered then make sure no-one else is using the LV
we are about to remove */
- if (vg->status & CLUSTERED) {
+ if (vg_status(vg) & CLUSTERED) {
if (!activate_lv_excl(cmd, lv)) {
log_error("Can't get exclusive access to volume \"%s\"",
lv->name);
--- LVM2/tools/polldaemon.c 2006/05/09 21:23:51 1.6
+++ LVM2/tools/polldaemon.c 2007/06/19 04:36:12 1.7
@@ -191,10 +191,8 @@
return ECMD_FAILED;
}
- if (vg->status & EXPORTED_VG) {
- log_error("Volume group \"%s\" is exported", vg->name);
+ if (!vg_check_status(vg, EXPORTED_VG))
return ECMD_FAILED;
- }
list_iterate_items(lvl, &vg->lvs) {
lv_mirr = lvl->lv;
--- LVM2/tools/toollib.c 2007/06/15 10:11:14 1.100
+++ LVM2/tools/toollib.c 2007/06/19 04:36:12 1.101
@@ -159,10 +159,8 @@
struct lv_list *lvl;
- if (vg->status & EXPORTED_VG) {
- log_error("Volume group \"%s\" is exported", vg->name);
+ if (!vg_check_status(vg, EXPORTED_VG))
return ECMD_FAILED;
- }
if (tags && !list_empty(tags))
tags_supplied = 1;
--- LVM2/tools/vgck.c 2006/05/09 21:23:51 1.15
+++ LVM2/tools/vgck.c 2007/06/19 04:36:12 1.16
@@ -30,10 +30,8 @@
return ECMD_FAILED;
}
- if (vg->status & EXPORTED_VG) {
- log_error("Volume group \"%s\" is exported", vg_name);
+ if (!vg_check_status(vg, EXPORTED_VG))
return ECMD_FAILED;
- }
return ECMD_PROCESSED;
}
--- LVM2/tools/vgconvert.c 2007/06/15 22:16:55 1.22
+++ LVM2/tools/vgconvert.c 2007/06/19 04:36:12 1.23
@@ -45,15 +45,8 @@
return ECMD_FAILED;
}
- if (!(vg->status & LVM_WRITE)) {
- log_error("Volume group \"%s\" is read-only", vg->name);
+ if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG))
return ECMD_FAILED;
- }
-
- if (vg->status & EXPORTED_VG) {
- log_error("Volume group \"%s\" is exported", vg_name);
- return ECMD_FAILED;
- }
if (vg->fid->fmt == cmd->fmt) {
log_error("Volume group \"%s\" already uses format %s",
--- LVM2/tools/vgdisplay.c 2006/05/09 21:23:51 1.16
+++ LVM2/tools/vgdisplay.c 2007/06/19 04:36:12 1.17
@@ -28,8 +28,7 @@
if (!consistent)
log_error("WARNING: Volume group \"%s\" inconsistent", vg_name);
- if (vg->status & EXPORTED_VG)
- log_print("WARNING: volume group \"%s\" is exported", vg_name);
+ vg_check_status(vg, EXPORTED_VG);
if (arg_count(cmd, colon_ARG)) {
vgdisplay_colons(vg);
--- LVM2/tools/vgexport.c 2006/05/09 21:23:51 1.15
+++ LVM2/tools/vgexport.c 2007/06/19 04:36:12 1.16
@@ -33,13 +33,7 @@
goto error;
}
- if (vg->status & EXPORTED_VG) {
- log_error("Volume group \"%s\" is already exported", vg_name);
- goto error;
- }
-
- if (!(vg->status & LVM_WRITE)) {
- log_error("Volume group \"%s\" is read-only", vg_name);
+ if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE)) {
goto error;
}
--- LVM2/tools/vgreduce.c 2007/06/15 22:16:55 1.64
+++ LVM2/tools/vgreduce.c 2007/06/19 04:36:12 1.65
@@ -532,21 +532,7 @@
log_print("Wrote out consistent volume group %s", vg_name);
} else {
- if (vg->status & EXPORTED_VG) {
- log_error("Volume group \"%s\" is exported", vg->name);
- unlock_vg(cmd, vg_name);
- return ECMD_FAILED;
- }
-
- if (!(vg->status & LVM_WRITE)) {
- log_error("Volume group \"%s\" is read-only", vg_name);
- unlock_vg(cmd, vg_name);
- return ECMD_FAILED;
- }
-
- if (!(vg->status & RESIZEABLE_VG)) {
- log_error("Volume group \"%s\" is not reducible",
- vg_name);
+ if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE | RESIZEABLE_VG)) {
unlock_vg(cmd, vg_name);
return ECMD_FAILED;
}
--- LVM2/tools/vgremove.c 2007/06/15 22:16:55 1.40
+++ LVM2/tools/vgremove.c 2007/06/19 04:36:12 1.41
@@ -23,7 +23,7 @@
struct pv_list *pvl;
int ret = ECMD_PROCESSED;
- if (!vg || !consistent || (vg->status & PARTIAL_VG)) {
+ if (!vg || !consistent || (vg_status(vg) & PARTIAL_VG)) {
log_error("Volume group \"%s\" not found or inconsistent.",
vg_name);
log_error("Consider vgreduce --removemissing if metadata "
@@ -31,10 +31,8 @@
return ECMD_FAILED;
}
- if (vg->status & EXPORTED_VG) {
- log_error("Volume group \"%s\" is exported", vg->name);
+ if (!vg_check_status(vg, EXPORTED_VG))
return ECMD_FAILED;
- }
if (vg->lv_count) {
log_error("Volume group \"%s\" still contains %d "
^ permalink raw reply [flat|nested] 6+ messages in thread
* LVM2 lib/metadata/metadata.c lib/metadata/meta ...
@ 2007-06-19 0:33 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2007-06-19 0:33 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-06-19 00:33:43
Modified files:
lib/metadata : metadata.c metadata.h
tools : vgextend.c
Log message:
Make vg_extend() format_instance * parameter internal to vg_extend()
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.163&r2=1.164
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgextend.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
--- LVM2/lib/metadata/metadata.c 2007/06/15 22:16:55 1.118
+++ LVM2/lib/metadata/metadata.c 2007/06/19 00:33:43 1.119
@@ -245,14 +245,13 @@
return 1;
}
-int vg_extend(struct format_instance *fid,
- struct volume_group *vg, int pv_count, char **pv_names)
+int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)
{
int i;
/* attach each pv */
for (i = 0; i < pv_count; i++)
- if (!_add_pv_to_vg(fid, vg, pv_names[i])) {
+ if (!_add_pv_to_vg(vg->fid, vg, pv_names[i])) {
log_error("Unable to add physical volume '%s' to "
"volume group '%s'.", pv_names[i], vg->name);
return 0;
@@ -352,7 +351,7 @@
}
/* attach the pv's */
- if (!vg_extend(vg->fid, vg, pv_count, pv_names))
+ if (!vg_extend(vg, pv_count, pv_names))
goto_bad;
return vg;
--- LVM2/lib/metadata/metadata.h 2007/06/15 22:16:55 1.163
+++ LVM2/lib/metadata/metadata.h 2007/06/19 00:33:43 1.164
@@ -461,8 +461,7 @@
int vg_remove(struct volume_group *vg);
int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
const char *new_name);
-int vg_extend(struct format_instance *fi, struct volume_group *vg,
- int pv_count, char **pv_names);
+int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
int vg_change_pesize(struct cmd_context *cmd, struct volume_group *vg,
uint32_t new_extent_size);
int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
--- LVM2/tools/vgextend.c 2007/06/06 19:40:28 1.30
+++ LVM2/tools/vgextend.c 2007/06/19 00:33:43 1.31
@@ -74,7 +74,7 @@
goto error;
/* extend vg */
- if (!vg_extend(vg->fid, vg, argc, argv))
+ if (!vg_extend(vg, argc, argv))
goto error;
/* ret > 0 */
^ permalink raw reply [flat|nested] 6+ messages in thread
* LVM2 lib/metadata/metadata.c lib/metadata/meta ...
@ 2007-06-15 22:16 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2007-06-15 22:16 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-06-15 22:16:55
Modified files:
lib/metadata : metadata.c metadata.h
tools : pvchange.c pvcreate.c pvdisplay.c pvmove.c
pvremove.c pvresize.c pvscan.c reporter.c
vgconvert.c vgreduce.c vgremove.c vgsplit.c
Log message:
Remove get_ prefix from get_pv_* functions
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.162&r2=1.163
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvdisplay.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvremove.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvscan.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgconvert.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgremove.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30
--- LVM2/lib/metadata/metadata.c 2007/06/14 15:48:05 1.117
+++ LVM2/lib/metadata/metadata.c 2007/06/15 22:16:55 1.118
@@ -1784,57 +1784,57 @@
/*
* Gets/Sets for external LVM library
*/
-struct id get_pv_id(pv_t *pv)
+struct id pv_id(pv_t *pv)
{
return pv_field(pv, id);
}
-const struct format_type *get_pv_format_type(pv_t *pv)
+const struct format_type *pv_format_type(pv_t *pv)
{
return pv_field(pv, fmt);
}
-struct id get_pv_vgid(pv_t *pv)
+struct id pv_vgid(pv_t *pv)
{
return pv_field(pv, vgid);
}
-struct device *get_pv_dev(pv_t *pv)
+struct device *pv_dev(pv_t *pv)
{
return pv_field(pv, dev);
}
-const char *get_pv_vg_name(pv_t *pv)
+const char *pv_vg_name(pv_t *pv)
{
return pv_field(pv, vg_name);
}
-uint64_t get_pv_size(pv_t *pv)
+uint64_t pv_size(pv_t *pv)
{
return pv_field(pv, size);
}
-uint32_t get_pv_status(pv_t *pv)
+uint32_t pv_status(pv_t *pv)
{
return pv_field(pv, status);
}
-uint32_t get_pv_pe_size(pv_t *pv)
+uint32_t pv_pe_size(pv_t *pv)
{
return pv_field(pv, pe_size);
}
-uint64_t get_pv_pe_start(pv_t *pv)
+uint64_t pv_pe_start(pv_t *pv)
{
return pv_field(pv, pe_start);
}
-uint32_t get_pv_pe_count(pv_t *pv)
+uint32_t pv_pe_count(pv_t *pv)
{
return pv_field(pv, pe_count);
}
-uint32_t get_pv_pe_alloc_count(pv_t *pv)
+uint32_t pv_pe_alloc_count(pv_t *pv)
{
return pv_field(pv, pe_alloc_count);
}
--- LVM2/lib/metadata/metadata.h 2007/06/14 15:48:05 1.162
+++ LVM2/lib/metadata/metadata.h 2007/06/15 22:16:55 1.163
@@ -639,16 +639,16 @@
/*
* Gets/Sets for external LVM library
*/
-struct id get_pv_id(pv_t *pv);
-const struct format_type *get_pv_format_type(pv_t *pv);
-struct id get_pv_vgid(pv_t *pv);
-struct device *get_pv_dev(pv_t *pv);
-const char *get_pv_vg_name(pv_t *pv);
-uint64_t get_pv_size(pv_t *pv);
-uint32_t get_pv_status(pv_t *pv);
-uint32_t get_pv_pe_size(pv_t *pv);
-uint64_t get_pv_pe_start(pv_t *pv);
-uint32_t get_pv_pe_count(pv_t *pv);
-uint32_t get_pv_pe_alloc_count(pv_t *pv);
+struct id pv_id(pv_t *pv);
+const struct format_type *pv_format_type(pv_t *pv);
+struct id pv_vgid(pv_t *pv);
+struct device *pv_dev(pv_t *pv);
+const char *pv_vg_name(pv_t *pv);
+uint64_t pv_size(pv_t *pv);
+uint32_t pv_status(pv_t *pv);
+uint32_t pv_pe_size(pv_t *pv);
+uint64_t pv_pe_start(pv_t *pv);
+uint32_t pv_pe_count(pv_t *pv);
+uint32_t pv_pe_alloc_count(pv_t *pv);
#endif
--- LVM2/tools/pvchange.c 2007/06/14 15:25:35 1.50
+++ LVM2/tools/pvchange.c 2007/06/15 22:16:55 1.51
@@ -26,7 +26,7 @@
uint64_t sector;
uint32_t orig_pe_alloc_count;
- const char *pv_name = dev_name(get_pv_dev(pv));
+ const char *pv_name = dev_name(pv_dev(pv));
const char *tag = NULL;
const char *orig_vg_name;
char uuid[64] __attribute((aligned(8)));
@@ -51,17 +51,17 @@
}
/* If in a VG, must change using volume group. */
- if (*get_pv_vg_name(pv)) {
+ if (*pv_vg_name(pv)) {
log_verbose("Finding volume group of physical volume \"%s\"",
pv_name);
- if (!lock_vol(cmd, get_pv_vg_name(pv), LCK_VG_WRITE)) {
- log_error("Can't get lock for %s", get_pv_vg_name(pv));
+ if (!lock_vol(cmd, pv_vg_name(pv), LCK_VG_WRITE)) {
+ log_error("Can't get lock for %s", pv_vg_name(pv));
return 0;
}
- if (!(vg = vg_read(cmd, get_pv_vg_name(pv), NULL, &consistent))) {
- unlock_vg(cmd, get_pv_vg_name(pv));
+ if (!(vg = vg_read(cmd, pv_vg_name(pv), NULL, &consistent))) {
+ unlock_vg(cmd, pv_vg_name(pv));
log_error("Unable to find volume group of \"%s\"",
pv_name);
return 0;
@@ -69,25 +69,25 @@
if (!vg_check_status(vg,
CLUSTERED | EXPORTED_VG | LVM_WRITE)) {
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
return 0;
}
if (!(pvl = find_pv_in_vg(vg, pv_name))) {
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
log_error
("Unable to find \"%s\" in volume group \"%s\"",
pv_name, vg->name);
return 0;
}
if (tagarg && !(vg->fid->fmt->features & FMT_TAGS)) {
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
log_error("Volume group containing %s does not "
"support tags", pv_name);
return 0;
}
if (arg_count(cmd, uuid_ARG) && lvs_in_vg_activated(vg)) {
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
log_error("Volume group containing %s has active "
"logical volumes", pv_name);
return 0;
@@ -115,7 +115,7 @@
}
if (arg_count(cmd, allocatable_ARG)) {
- if (!*get_pv_vg_name(pv) &&
+ if (!*pv_vg_name(pv) &&
!(pv->fmt->features & FMT_ORPHAN_ALLOCATABLE)) {
log_error("Allocatability not supported by orphan "
"%s format PV %s", pv->fmt->name, pv_name);
@@ -124,21 +124,21 @@
}
/* change allocatability for a PV */
- if (allocatable && (get_pv_status(pv) & ALLOCATABLE_PV)) {
+ if (allocatable && (pv_status(pv) & ALLOCATABLE_PV)) {
log_error("Physical volume \"%s\" is already "
"allocatable", pv_name);
- if (*get_pv_vg_name(pv))
- unlock_vg(cmd, get_pv_vg_name(pv));
+ if (*pv_vg_name(pv))
+ unlock_vg(cmd, pv_vg_name(pv));
else
unlock_vg(cmd, ORPHAN);
return 1;
}
- if (!allocatable && !(get_pv_status(pv) & ALLOCATABLE_PV)) {
+ if (!allocatable && !(pv_status(pv) & ALLOCATABLE_PV)) {
log_error("Physical volume \"%s\" is already "
"unallocatable", pv_name);
- if (*get_pv_vg_name(pv))
- unlock_vg(cmd, get_pv_vg_name(pv));
+ if (*pv_vg_name(pv))
+ unlock_vg(cmd, pv_vg_name(pv));
else
unlock_vg(cmd, ORPHAN);
return 1;
@@ -180,9 +180,9 @@
return 0;
}
log_verbose("Changing uuid of %s to %s.", pv_name, uuid);
- if (*get_pv_vg_name(pv)) {
- orig_vg_name = get_pv_vg_name(pv);
- orig_pe_alloc_count = get_pv_pe_alloc_count(pv);
+ if (*pv_vg_name(pv)) {
+ orig_vg_name = pv_vg_name(pv);
+ orig_pe_alloc_count = pv_pe_alloc_count(pv);
pv->vg_name = ORPHAN;
pv->pe_alloc_count = 0;
if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
@@ -196,15 +196,15 @@
}
log_verbose("Updating physical volume \"%s\"", pv_name);
- if (*get_pv_vg_name(pv)) {
+ if (*pv_vg_name(pv)) {
if (!vg_write(vg) || !vg_commit(vg)) {
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
log_error("Failed to store physical volume \"%s\" in "
"volume group \"%s\"", pv_name, vg->name);
return 0;
}
backup(vg);
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
} else {
if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
unlock_vg(cmd, ORPHAN);
--- LVM2/tools/pvcreate.c 2007/06/15 10:11:14 1.52
+++ LVM2/tools/pvcreate.c 2007/06/15 22:16:55 1.53
@@ -47,13 +47,13 @@
/* We must have -ff to overwrite a non orphan */
if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG) != 2) {
log_error("Can't initialize physical volume \"%s\" of "
- "volume group \"%s\" without -ff", name, get_pv_vg_name(pv));
+ "volume group \"%s\" without -ff", name, pv_vg_name(pv));
return 0;
}
/* prompt */
if (pv && !is_orphan(pv) && !arg_count(cmd, yes_ARG) &&
- yes_no_prompt(_really_init, name, get_pv_vg_name(pv)) == 'n') {
+ yes_no_prompt(_really_init, name, pv_vg_name(pv)) == 'n') {
log_print("%s: physical volume not initialized", name);
return 0;
}
@@ -113,7 +113,7 @@
log_print("WARNING: Forcing physical volume creation on "
"%s%s%s%s", name,
!is_orphan(pv) ? " of volume group \"" : "",
- !is_orphan(pv) ? get_pv_vg_name(pv) : "",
+ !is_orphan(pv) ? pv_vg_name(pv) : "",
!is_orphan(pv) ? "\"" : "");
}
@@ -166,9 +166,9 @@
uuid, restorefile);
return ECMD_FAILED;
}
- pe_start = get_pv_pe_start(existing_pv);
- extent_size = get_pv_pe_size(existing_pv);
- extent_count = get_pv_pe_count(existing_pv);
+ pe_start = pv_pe_start(existing_pv);
+ extent_size = pv_pe_size(existing_pv);
+ extent_count = pv_pe_count(existing_pv);
}
if (!lock_vol(cmd, ORPHAN, LCK_VG_WRITE)) {
@@ -220,10 +220,10 @@
}
log_verbose("Set up physical volume for \"%s\" with %" PRIu64
- " available sectors", pv_name, get_pv_size(pv));
+ " available sectors", pv_name, pv_size(pv));
/* Wipe existing label first */
- if (!label_remove(get_pv_dev(pv))) {
+ if (!label_remove(pv_dev(pv))) {
log_error("Failed to wipe existing label on %s", pv_name);
goto error;
}
--- LVM2/tools/pvdisplay.c 2007/06/14 15:25:36 1.36
+++ LVM2/tools/pvdisplay.c 2007/06/15 22:16:55 1.37
@@ -24,16 +24,16 @@
int ret = ECMD_PROCESSED;
uint64_t size;
- const char *pv_name = dev_name(get_pv_dev(pv));
+ const char *pv_name = dev_name(pv_dev(pv));
- if (get_pv_vg_name(pv)) {
- if (!lock_vol(cmd, get_pv_vg_name(pv), LCK_VG_READ)) {
- log_error("Can't lock %s: skipping", get_pv_vg_name(pv));
+ if (pv_vg_name(pv)) {
+ if (!lock_vol(cmd, pv_vg_name(pv), LCK_VG_READ)) {
+ log_error("Can't lock %s: skipping", pv_vg_name(pv));
return ECMD_FAILED;
}
- if (!(vg = vg_read(cmd, get_pv_vg_name(pv), (char *)&pv->vgid, &consistent))) {
- log_error("Can't read %s: skipping", get_pv_vg_name(pv));
+ if (!(vg = vg_read(cmd, pv_vg_name(pv), (char *)&pv->vgid, &consistent))) {
+ log_error("Can't read %s: skipping", pv_vg_name(pv));
goto out;
}
@@ -56,11 +56,11 @@
pv = pvl->pv;
}
- if (!*get_pv_vg_name(pv))
- size = get_pv_size(pv);
+ if (!*pv_vg_name(pv))
+ size = pv_size(pv);
else
- size = (get_pv_pe_count(pv) - get_pv_pe_alloc_count(pv)) *
- get_pv_pe_size(pv);
+ size = (pv_pe_count(pv) - pv_pe_alloc_count(pv)) *
+ pv_pe_size(pv);
if (arg_count(cmd, short_ARG)) {
log_print("Device \"%s\" has a capacity of %s", pv_name,
@@ -68,11 +68,11 @@
goto out;
}
- if (get_pv_status(pv) & EXPORTED_VG)
+ if (pv_status(pv) & EXPORTED_VG)
log_print("Physical volume \"%s\" of volume group \"%s\" "
- "is exported", pv_name, get_pv_vg_name(pv));
+ "is exported", pv_name, pv_vg_name(pv));
- if (!get_pv_vg_name(pv))
+ if (!pv_vg_name(pv))
log_print("\"%s\" is a new physical volume of \"%s\"",
pv_name, display_size(cmd, size));
@@ -87,8 +87,8 @@
pvdisplay_segments(pv);
out:
- if (get_pv_vg_name(pv))
- unlock_vg(cmd, get_pv_vg_name(pv));
+ if (pv_vg_name(pv))
+ unlock_vg(cmd, pv_vg_name(pv));
return ret;
}
--- LVM2/tools/pvmove.c 2007/06/14 15:25:36 1.37
+++ LVM2/tools/pvmove.c 2007/06/15 22:16:55 1.38
@@ -100,7 +100,7 @@
pvl = list_item(pvh, struct pv_list);
/* Don't allocate onto the PV we're clearing! */
- if ((alloc != ALLOC_ANYWHERE) && (pvl->pv->dev == get_pv_dev(pv))) {
+ if ((alloc != ALLOC_ANYWHERE) && (pvl->pv->dev == pv_dev(pv))) {
list_del(&pvl->list);
continue;
}
@@ -281,7 +281,7 @@
}
if (arg_count(cmd, name_ARG)) {
- if (!(lv_name = _extract_lvname(cmd, get_pv_vg_name(pv),
+ if (!(lv_name = _extract_lvname(cmd, pv_vg_name(pv),
arg_value(cmd, name_ARG)))) {
stack;
return EINVALID_CMD_LINE;
@@ -289,14 +289,14 @@
}
/* Read VG */
- log_verbose("Finding volume group \"%s\"", get_pv_vg_name(pv));
+ log_verbose("Finding volume group \"%s\"", pv_vg_name(pv));
- if (!(vg = _get_vg(cmd, get_pv_vg_name(pv)))) {
+ if (!(vg = _get_vg(cmd, pv_vg_name(pv)))) {
stack;
return ECMD_FAILED;
}
- if ((lv_mirr = find_pvmove_lv(vg, get_pv_dev(pv), PVMOVE))) {
+ if ((lv_mirr = find_pvmove_lv(vg, pv_dev(pv), PVMOVE))) {
log_print("Detected pvmove in progress for %s", pv_name);
if (argc || lv_name)
log_error("Ignoring remaining command line arguments");
@@ -304,7 +304,7 @@
if (!(lvs_changed = lvs_using_lv(cmd, vg, lv_mirr))) {
log_error
("ABORTING: Failed to generate list of moving LVs");
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
return ECMD_FAILED;
}
@@ -312,7 +312,7 @@
if (!activate_lv_excl(cmd, lv_mirr)) {
log_error
("ABORTING: Temporary mirror activation failed.");
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
return ECMD_FAILED;
}
@@ -322,7 +322,7 @@
if (!(source_pvl = create_pv_list(cmd->mem, vg, 1,
&pv_name_arg, 0))) {
stack;
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
return ECMD_FAILED;
}
@@ -334,12 +334,12 @@
if (!(allocatable_pvs = _get_allocatable_pvs(cmd, argc, argv,
vg, pv, alloc))) {
stack;
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
return ECMD_FAILED;
}
if (!archive(vg)) {
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
stack;
return ECMD_FAILED;
}
@@ -348,7 +348,7 @@
allocatable_pvs, alloc,
&lvs_changed))) {
stack;
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
return ECMD_FAILED;
}
}
@@ -356,7 +356,7 @@
/* Lock lvs_changed for exclusive use and activate (with old metadata) */
if (!activate_lvs_excl(cmd, lvs_changed)) {
stack;
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
return ECMD_FAILED;
}
@@ -368,13 +368,13 @@
if (!_update_metadata
(cmd, vg, lv_mirr, lvs_changed, first_time)) {
stack;
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
return ECMD_FAILED;
}
}
/* LVs are all in status LOCKED */
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
return ECMD_PROCESSED;
}
@@ -469,7 +469,7 @@
return NULL;
}
- return _get_vg(cmd, get_pv_vg_name(pv));
+ return _get_vg(cmd, pv_vg_name(pv));
}
static struct poll_functions _pvmove_fns = {
--- LVM2/tools/pvremove.c 2007/06/14 15:51:36 1.16
+++ LVM2/tools/pvremove.c 2007/06/15 22:16:55 1.17
@@ -50,13 +50,13 @@
/* we must have -ff to overwrite a non orphan */
if (arg_count(cmd, force_ARG) < 2) {
log_error("Can't pvremove physical volume \"%s\" of "
- "volume group \"%s\" without -ff", name, get_pv_vg_name(pv));
+ "volume group \"%s\" without -ff", name, pv_vg_name(pv));
return 0;
}
/* prompt */
if (!arg_count(cmd, yes_ARG) &&
- yes_no_prompt(_really_wipe, name, get_pv_vg_name(pv)) == 'n') {
+ yes_no_prompt(_really_wipe, name, pv_vg_name(pv)) == 'n') {
log_print("%s: physical volume label not removed", name);
return 0;
}
@@ -65,7 +65,7 @@
log_print("WARNING: Wiping physical volume label from "
"%s%s%s%s", name,
!is_orphan(pv) ? " of volume group \"" : "",
- !is_orphan(pv) ? get_pv_vg_name(pv) : "",
+ !is_orphan(pv) ? pv_vg_name(pv) : "",
!is_orphan(pv) ? "\"" : "");
}
--- LVM2/tools/pvresize.c 2007/06/14 15:25:36 1.10
+++ LVM2/tools/pvresize.c 2007/06/15 22:16:55 1.11
@@ -33,7 +33,7 @@
uint64_t size = 0;
uint32_t new_pe_count = 0;
struct list mdas;
- const char *pv_name = dev_name(get_pv_dev(pv));
+ const char *pv_name = dev_name(pv_dev(pv));
struct pvresize_params *params = (struct pvresize_params *) handle;
const char *vg_name;
@@ -41,7 +41,7 @@
params->total++;
- if (!*get_pv_vg_name(pv)) {
+ if (!*pv_vg_name(pv)) {
vg_name = ORPHAN;
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
@@ -63,10 +63,10 @@
return ECMD_FAILED;
}
} else {
- vg_name = get_pv_vg_name(pv);
+ vg_name = pv_vg_name(pv);
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
- log_error("Can't get lock for %s", get_pv_vg_name(pv));
+ log_error("Can't get lock for %s", pv_vg_name(pv));
return ECMD_FAILED;
}
@@ -103,7 +103,7 @@
}
/* Get new size */
- if (!dev_get_size(get_pv_dev(pv), &size)) {
+ if (!dev_get_size(pv_dev(pv), &size)) {
log_error("%s: Couldn't get size.", pv_name);
unlock_vg(cmd, vg_name);
return ECMD_FAILED;
@@ -114,7 +114,7 @@
log_print("WARNING: %s: Overriding real size. "
"You could lose data.", pv_name);
log_verbose("%s: Pretending size is %" PRIu64 " not %" PRIu64
- " sectors.", pv_name, params->new_size, get_pv_size(pv));
+ " sectors.", pv_name, params->new_size, pv_size(pv));
size = params->new_size;
}
@@ -125,9 +125,9 @@
return ECMD_FAILED;
}
- if (size < get_pv_pe_start(pv)) {
+ if (size < pv_pe_start(pv)) {
log_error("%s: Size must exceed physical extent start of "
- "%" PRIu64 " sectors.", pv_name, get_pv_pe_start(pv));
+ "%" PRIu64 " sectors.", pv_name, pv_pe_start(pv));
unlock_vg(cmd, vg_name);
return ECMD_FAILED;
}
@@ -135,14 +135,14 @@
pv->size = size;
if (vg) {
- pv->size -= get_pv_pe_start(pv);
- new_pe_count = get_pv_size(pv) / vg->extent_size;
+ pv->size -= pv_pe_start(pv);
+ new_pe_count = pv_size(pv) / vg->extent_size;
if (!new_pe_count) {
log_error("%s: Size must leave space for at "
"least one physical extent of "
"%" PRIu32 " sectors.", pv_name,
- get_pv_pe_size(pv));
+ pv_pe_size(pv));
unlock_vg(cmd, vg_name);
return ECMD_FAILED;
}
@@ -155,12 +155,12 @@
}
log_verbose("Resizing volume \"%s\" to %" PRIu64 " sectors.",
- pv_name, get_pv_size(pv));
+ pv_name, pv_size(pv));
log_verbose("Updating physical volume \"%s\"", pv_name);
- if (*get_pv_vg_name(pv)) {
+ if (*pv_vg_name(pv)) {
if (!vg_write(vg) || !vg_commit(vg)) {
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
log_error("Failed to store physical volume \"%s\" in "
"volume group \"%s\"", pv_name, vg->name);
return ECMD_FAILED;
--- LVM2/tools/pvscan.c 2007/06/14 15:25:36 1.38
+++ LVM2/tools/pvscan.c 2007/06/15 22:16:55 1.39
@@ -31,7 +31,7 @@
/* short listing? */
if (arg_count(cmd, short_ARG) > 0) {
- log_print("%s", dev_name(get_pv_dev(pv)));
+ log_print("%s", dev_name(pv_dev(pv)));
return;
}
@@ -48,7 +48,7 @@
memset(pv_tmp_name, 0, sizeof(pv_tmp_name));
- vg_name_len = strlen(get_pv_vg_name(pv)) + 1;
+ vg_name_len = strlen(pv_vg_name(pv)) + 1;
if (arg_count(cmd, uuid_ARG)) {
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
@@ -57,43 +57,43 @@
}
sprintf(pv_tmp_name, "%-*s with UUID %s",
- pv_max_name_len - 2, dev_name(get_pv_dev(pv)), uuid);
+ pv_max_name_len - 2, dev_name(pv_dev(pv)), uuid);
} else {
- sprintf(pv_tmp_name, "%s", dev_name(get_pv_dev(pv)));
+ sprintf(pv_tmp_name, "%s", dev_name(pv_dev(pv)));
}
- if (!*get_pv_vg_name(pv)) {
+ if (!*pv_vg_name(pv)) {
log_print("PV %-*s %-*s %s [%s]",
pv_max_name_len, pv_tmp_name,
vg_max_name_len, " ",
pv->fmt ? pv->fmt->name : " ",
- display_size(cmd, get_pv_size(pv)));
+ display_size(cmd, pv_size(pv)));
return;
}
- if (get_pv_status(pv) & EXPORTED_VG) {
- strncpy(vg_name_this, get_pv_vg_name(pv), vg_name_len);
+ if (pv_status(pv) & EXPORTED_VG) {
+ strncpy(vg_name_this, pv_vg_name(pv), vg_name_len);
log_print("PV %-*s is in exported VG %s "
"[%s / %s free]",
pv_max_name_len, pv_tmp_name,
vg_name_this,
- display_size(cmd, (uint64_t) get_pv_pe_count(pv) *
- get_pv_pe_size(pv)),
- display_size(cmd, (uint64_t) (get_pv_pe_count(pv) -
- get_pv_pe_alloc_count(pv))
- * get_pv_pe_size(pv)));
+ display_size(cmd, (uint64_t) pv_pe_count(pv) *
+ pv_pe_size(pv)),
+ display_size(cmd, (uint64_t) (pv_pe_count(pv) -
+ pv_pe_alloc_count(pv))
+ * pv_pe_size(pv)));
return;
}
- sprintf(vg_tmp_name, "%s", get_pv_vg_name(pv));
+ sprintf(vg_tmp_name, "%s", pv_vg_name(pv));
log_print("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len,
pv_tmp_name, vg_max_name_len, vg_tmp_name,
pv->fmt ? pv->fmt->name : " ",
- display_size(cmd, (uint64_t) get_pv_pe_count(pv) *
- get_pv_pe_size(pv)),
- display_size(cmd, (uint64_t) (get_pv_pe_count(pv) -
- get_pv_pe_alloc_count(pv)) *
- get_pv_pe_size(pv)));
+ display_size(cmd, (uint64_t) pv_pe_count(pv) *
+ pv_pe_size(pv)),
+ display_size(cmd, (uint64_t) (pv_pe_count(pv) -
+ pv_pe_alloc_count(pv)) *
+ pv_pe_size(pv)));
return;
}
@@ -136,8 +136,8 @@
pv = pvl->pv;
if ((arg_count(cmd, exported_ARG)
- && !(get_pv_status(pv) & EXPORTED_VG))
- || (arg_count(cmd, novolumegroup_ARG) && (*get_pv_vg_name(pv)))) {
+ && !(pv_status(pv) & EXPORTED_VG))
+ || (arg_count(cmd, novolumegroup_ARG) && (*pv_vg_name(pv)))) {
list_del(&pvl->list);
continue;
}
@@ -154,22 +154,22 @@
********/
pvs_found++;
- if (!*get_pv_vg_name(pv)) {
+ if (!*pv_vg_name(pv)) {
new_pvs_found++;
- size_new += get_pv_size(pv);
- size_total += get_pv_size(pv);
+ size_new += pv_size(pv);
+ size_total += pv_size(pv);
} else
- size_total += get_pv_pe_count(pv) * get_pv_pe_size(pv);
+ size_total += pv_pe_count(pv) * pv_pe_size(pv);
}
/* find maximum pv name length */
pv_max_name_len = vg_max_name_len = 0;
list_iterate_items(pvl, pvslist) {
pv = pvl->pv;
- len = strlen(dev_name(get_pv_dev(pv)));
+ len = strlen(dev_name(pv_dev(pv)));
if (pv_max_name_len < len)
pv_max_name_len = len;
- len = strlen(get_pv_vg_name(pv));
+ len = strlen(pv_vg_name(pv));
if (vg_max_name_len < len)
vg_max_name_len = len;
}
--- LVM2/tools/reporter.c 2007/06/14 15:25:36 1.24
+++ LVM2/tools/reporter.c 2007/06/15 22:16:55 1.25
@@ -61,13 +61,13 @@
struct physical_volume *pv = pvseg->pv;
int ret = ECMD_PROCESSED;
- if (!lock_vol(cmd, get_pv_vg_name(pv), LCK_VG_READ)) {
- log_error("Can't lock %s: skipping", get_pv_vg_name(pv));
+ if (!lock_vol(cmd, pv_vg_name(pv), LCK_VG_READ)) {
+ log_error("Can't lock %s: skipping", pv_vg_name(pv));
return ECMD_FAILED;
}
- if (!(vg = vg_read(cmd, get_pv_vg_name(pv), NULL, &consistent))) {
- log_error("Can't read %s: skipping", get_pv_vg_name(pv));
+ if (!(vg = vg_read(cmd, pv_vg_name(pv), NULL, &consistent))) {
+ log_error("Can't read %s: skipping", pv_vg_name(pv));
goto out;
}
@@ -80,7 +80,7 @@
ret = ECMD_FAILED;
out:
- unlock_vg(cmd, get_pv_vg_name(pv));
+ unlock_vg(cmd, pv_vg_name(pv));
return ret;
}
@@ -106,14 +106,14 @@
int consistent = 0;
int ret = ECMD_PROCESSED;
- if (get_pv_vg_name(pv)) {
- if (!lock_vol(cmd, get_pv_vg_name(pv), LCK_VG_READ)) {
- log_error("Can't lock %s: skipping", get_pv_vg_name(pv));
+ if (pv_vg_name(pv)) {
+ if (!lock_vol(cmd, pv_vg_name(pv), LCK_VG_READ)) {
+ log_error("Can't lock %s: skipping", pv_vg_name(pv));
return ECMD_FAILED;
}
- if (!(vg = vg_read(cmd, get_pv_vg_name(pv), (char *)&pv->vgid, &consistent))) {
- log_error("Can't read %s: skipping", get_pv_vg_name(pv));
+ if (!(vg = vg_read(cmd, pv_vg_name(pv), (char *)&pv->vgid, &consistent))) {
+ log_error("Can't read %s: skipping", pv_vg_name(pv));
goto out;
}
@@ -127,8 +127,8 @@
ret = ECMD_FAILED;
out:
- if (get_pv_vg_name(pv))
- unlock_vg(cmd, get_pv_vg_name(pv));
+ if (pv_vg_name(pv))
+ unlock_vg(cmd, pv_vg_name(pv));
return ret;
}
--- LVM2/tools/vgconvert.c 2007/06/13 23:29:33 1.21
+++ LVM2/tools/vgconvert.c 2007/06/15 22:16:55 1.22
@@ -114,18 +114,18 @@
list_iterate_items(pvl, &vg->pvs) {
existing_pv = pvl->pv;
- pe_start = get_pv_pe_start(existing_pv);
- pe_end = get_pv_pe_count(existing_pv) * get_pv_pe_size(existing_pv)
+ pe_start = pv_pe_start(existing_pv);
+ pe_end = pv_pe_count(existing_pv) * pv_pe_size(existing_pv)
+ pe_start - 1;
list_init(&mdas);
- if (!(pv = pv_create(cmd->fmt, get_pv_dev(existing_pv),
+ if (!(pv = pv_create(cmd->fmt, pv_dev(existing_pv),
&existing_pv->id, size,
- pe_start, get_pv_pe_count(existing_pv),
- get_pv_pe_size(existing_pv), pvmetadatacopies,
+ pe_start, pv_pe_count(existing_pv),
+ pv_pe_size(existing_pv), pvmetadatacopies,
pvmetadatasize, &mdas))) {
log_error("Failed to setup physical volume \"%s\"",
- dev_name(get_pv_dev(existing_pv)));
+ dev_name(pv_dev(existing_pv)));
if (change_made)
log_error("Use pvcreate and vgcfgrestore to "
"repair from archived metadata.");
@@ -136,30 +136,30 @@
change_made = 1;
log_verbose("Set up physical volume for \"%s\" with %" PRIu64
- " available sectors", dev_name(get_pv_dev(pv)), get_pv_size(pv));
+ " available sectors", dev_name(pv_dev(pv)), pv_size(pv));
/* Wipe existing label first */
- if (!label_remove(get_pv_dev(pv))) {
+ if (!label_remove(pv_dev(pv))) {
log_error("Failed to wipe existing label on %s",
- dev_name(get_pv_dev(pv)));
+ dev_name(pv_dev(pv)));
log_error("Use pvcreate and vgcfgrestore to repair "
"from archived metadata.");
return ECMD_FAILED;
}
log_very_verbose("Writing physical volume data to disk \"%s\"",
- dev_name(get_pv_dev(pv)));
+ dev_name(pv_dev(pv)));
if (!(pv_write(cmd, pv, &mdas,
arg_int64_value(cmd, labelsector_ARG,
DEFAULT_LABELSECTOR)))) {
log_error("Failed to write physical volume \"%s\"",
- dev_name(get_pv_dev(pv)));
+ dev_name(pv_dev(pv)));
log_error("Use pvcreate and vgcfgrestore to repair "
"from archived metadata.");
return ECMD_FAILED;
}
log_verbose("Physical volume \"%s\" successfully created",
- dev_name(get_pv_dev(pv)));
+ dev_name(pv_dev(pv)));
}
--- LVM2/tools/vgreduce.c 2007/06/13 23:29:33 1.63
+++ LVM2/tools/vgreduce.c 2007/06/15 22:16:55 1.64
@@ -185,7 +185,7 @@
/* FIXME Also check for segs on deleted LVs */
pv = seg_pv(seg, s);
- if (!pv || !get_pv_dev(pv)) {
+ if (!pv || !pv_dev(pv)) {
if (arg_count(cmd, mirrorsonly_ARG) &&
!(lv->status & MIRROR_IMAGE)) {
log_error("Non-mirror-image LV %s found: can't remove.", lv->name);
@@ -365,9 +365,9 @@
void *handle __attribute((unused)))
{
struct pv_list *pvl;
- const char *name = dev_name(get_pv_dev(pv));
+ const char *name = dev_name(pv_dev(pv));
- if (get_pv_pe_alloc_count(pv)) {
+ if (pv_pe_alloc_count(pv)) {
log_error("Physical volume \"%s\" still in use", name);
return ECMD_FAILED;
}
@@ -391,14 +391,14 @@
pv->vg_name = ORPHAN;
pv->status = ALLOCATABLE_PV;
- if (!dev_get_size(get_pv_dev(pv), &pv->size)) {
- log_error("%s: Couldn't get size.", dev_name(get_pv_dev(pv)));
+ if (!dev_get_size(pv_dev(pv), &pv->size)) {
+ log_error("%s: Couldn't get size.", dev_name(pv_dev(pv)));
return ECMD_FAILED;
}
vg->pv_count--;
- vg->free_count -= get_pv_pe_count(pv) - get_pv_pe_alloc_count(pv);
- vg->extent_count -= get_pv_pe_count(pv);
+ vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
+ vg->extent_count -= pv_pe_count(pv);
if (!vg_write(vg) || !vg_commit(vg)) {
log_error("Removal of physical volume \"%s\" from "
--- LVM2/tools/vgremove.c 2007/06/13 23:29:33 1.39
+++ LVM2/tools/vgremove.c 2007/06/15 22:16:55 1.40
@@ -54,12 +54,12 @@
list_iterate_items(pvl, &vg->pvs) {
pv = pvl->pv;
log_verbose("Removing physical volume \"%s\" from "
- "volume group \"%s\"", dev_name(get_pv_dev(pv)), vg_name);
+ "volume group \"%s\"", dev_name(pv_dev(pv)), vg_name);
pv->vg_name = ORPHAN;
pv->status = ALLOCATABLE_PV;
- if (!dev_get_size(get_pv_dev(pv), &pv->size)) {
- log_error("%s: Couldn't get size.", dev_name(get_pv_dev(pv)));
+ if (!dev_get_size(pv_dev(pv), &pv->size)) {
+ log_error("%s: Couldn't get size.", dev_name(pv_dev(pv)));
ret = ECMD_FAILED;
continue;
}
@@ -68,7 +68,7 @@
if (!pv_write(cmd, pv, NULL, INT64_C(-1))) {
log_error("Failed to remove physical volume \"%s\""
" from volume group \"%s\"",
- dev_name(get_pv_dev(pv)), vg_name);
+ dev_name(pv_dev(pv)), vg_name);
ret = ECMD_FAILED;
}
}
--- LVM2/tools/vgsplit.c 2007/06/13 23:29:33 1.29
+++ LVM2/tools/vgsplit.c 2007/06/15 22:16:55 1.30
@@ -35,11 +35,11 @@
pv = list_item(pvl, struct pv_list)->pv;
- vg_from->extent_count -= get_pv_pe_count(pv);
- vg_to->extent_count += get_pv_pe_count(pv);
+ vg_from->extent_count -= pv_pe_count(pv);
+ vg_to->extent_count += pv_pe_count(pv);
- vg_from->free_count -= get_pv_pe_count(pv) - get_pv_pe_alloc_count(pv);
- vg_to->free_count += get_pv_pe_count(pv) - get_pv_pe_alloc_count(pv);
+ vg_from->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
+ vg_to->free_count += pv_pe_count(pv) - pv_pe_alloc_count(pv);
return 1;
}
@@ -105,7 +105,7 @@
continue;
}
log_error("Physical Volume %s not found",
- dev_name(get_pv_dev(pv)));
+ dev_name(pv_dev(pv)));
return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* LVM2 lib/metadata/metadata.c lib/metadata/meta ...
@ 2007-06-13 19:52 wysochanski
0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2007-06-13 19:52 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-06-13 19:52:48
Modified files:
lib/metadata : metadata.c metadata.h
. : WHATS_NEW
Log message:
Add typedef pv_handle_t
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.113&r2=1.114
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.159&r2=1.160
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.629&r2=1.630
--- LVM2/lib/metadata/metadata.c 2007/06/12 22:41:27 1.113
+++ LVM2/lib/metadata/metadata.c 2007/06/13 19:52:48 1.114
@@ -586,7 +586,7 @@
* Note:
* FIXME - liblvm todo - tidy up arguments for external use (fmt, mdas, etc)
*/
-void *pv_create(const struct format_type *fmt,
+pv_handle_t pv_create(const struct format_type *fmt,
struct device *dev,
struct id *id, uint64_t size,
uint64_t pe_start,
@@ -595,11 +595,11 @@
int pvmetadatacopies,
uint64_t pvmetadatasize, struct list *mdas)
{
- return _pv_create(fmt, dev, id, size, pe_start,
- existing_extent_count,
- existing_extent_size,
- pvmetadatacopies,
- pvmetadatasize, mdas);
+ return (pv_handle_t) _pv_create(fmt, dev, id, size, pe_start,
+ existing_extent_count,
+ existing_extent_size,
+ pvmetadatacopies,
+ pvmetadatasize, mdas);
}
/* Sizes in sectors */
@@ -719,9 +719,9 @@
* Note
* FIXME - liblvm todo - make into function that takes VG handle
*/
-void *find_pv_in_vg_by_uuid(struct volume_group *vg, struct id *id)
+pv_handle_t find_pv_in_vg_by_uuid(struct volume_group *vg, struct id *id)
{
- return _find_pv_in_vg_by_uuid(vg, id);
+ return (pv_handle_t) _find_pv_in_vg_by_uuid(vg, id);
}
@@ -1773,57 +1773,57 @@
/*
* Gets/Sets for external LVM library
*/
-struct id get_pv_id (void *pv_handle)
+struct id get_pv_id (pv_handle_t pv_handle)
{
return pv_field(pv_handle, id);
}
-const struct format_type *get_pv_format_type (void *pv_handle)
+const struct format_type *get_pv_format_type (pv_handle_t pv_handle)
{
return pv_field(pv_handle, fmt);
}
-struct id get_pv_vgid (void *pv_handle)
+struct id get_pv_vgid (pv_handle_t pv_handle)
{
return pv_field(pv_handle, vgid);
}
-struct device *get_pv_dev (void *pv_handle)
+struct device *get_pv_dev (pv_handle_t pv_handle)
{
return pv_field(pv_handle, dev);
}
-const char *get_pv_vg_name (void *pv_handle)
+const char *get_pv_vg_name (pv_handle_t pv_handle)
{
return pv_field(pv_handle, vg_name);
}
-uint64_t get_pv_size(void *pv_handle)
+uint64_t get_pv_size(pv_handle_t pv_handle)
{
return pv_field(pv_handle, size);
}
-uint32_t get_pv_status (void *pv_handle)
+uint32_t get_pv_status (pv_handle_t pv_handle)
{
return pv_field(pv_handle, status);
}
-uint32_t get_pv_pe_size (void *pv_handle)
+uint32_t get_pv_pe_size (pv_handle_t pv_handle)
{
return pv_field(pv_handle, pe_size);
}
-uint64_t get_pv_pe_start (void *pv_handle)
+uint64_t get_pv_pe_start (pv_handle_t pv_handle)
{
return pv_field(pv_handle, pe_start);
}
-uint32_t get_pv_pe_count (void *pv_handle)
+uint32_t get_pv_pe_count (pv_handle_t pv_handle)
{
return pv_field(pv_handle, pe_count);
}
-uint32_t get_pv_pe_alloc_count (void *pv_handle)
+uint32_t get_pv_pe_alloc_count (pv_handle_t pv_handle)
{
return pv_field(pv_handle, pe_alloc_count);
}
--- LVM2/lib/metadata/metadata.h 2007/06/12 22:41:27 1.159
+++ LVM2/lib/metadata/metadata.h 2007/06/13 19:52:48 1.160
@@ -142,6 +142,7 @@
struct list tags;
};
+typedef struct physical_volume * pv_handle_t;
struct metadata_area;
struct format_instance;
@@ -438,15 +439,15 @@
/* pe_start and pe_end relate to any existing data so that new metadata
* areas can avoid overlap */
-void *pv_create(const struct format_type *fmt,
- struct device *dev,
- struct id *id,
- uint64_t size,
- uint64_t pe_start,
- uint32_t existing_extent_count,
- uint32_t existing_extent_size,
- int pvmetadatacopies,
- uint64_t pvmetadatasize, struct list *mdas);
+pv_handle_t pv_create(const struct format_type *fmt,
+ struct device *dev,
+ struct id *id,
+ uint64_t size,
+ uint64_t pe_start,
+ uint32_t existing_extent_count,
+ uint32_t existing_extent_size,
+ int pvmetadatacopies,
+ uint64_t pvmetadatasize, struct list *mdas);
int pv_resize(struct physical_volume *pv, struct volume_group *vg,
uint32_t new_pe_count);
int pv_analyze(struct cmd_context *cmd, const char *pv_name,
@@ -500,7 +501,7 @@
/* Find a PV within a given VG */
struct pv_list *find_pv_in_vg(struct volume_group *vg, const char *pv_name);
-void *find_pv_in_vg_by_uuid(struct volume_group *vg, struct id *id);
+pv_handle_t find_pv_in_vg_by_uuid(struct volume_group *vg, struct id *id);
int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
const char *vgid, const char *pvid,
struct physical_volume *pv);
@@ -637,16 +638,16 @@
/*
* Gets/Sets for external LVM library
*/
-struct id get_pv_id (void *pv_handle);
-const struct format_type *get_pv_format_type (void *pv_handle);
-struct id get_pv_vgid (void *pv_handle);
-struct device *get_pv_dev (void *pv_handle);
-const char *get_pv_vg_name (void *pv_handle);
-uint64_t get_pv_size(void *pv_handle);
-uint32_t get_pv_status (void *pv_handle);
-uint32_t get_pv_pe_size (void *pv_handle);
-uint64_t get_pv_pe_start (void *pv_handle);
-uint32_t get_pv_pe_count (void *pv_handle);
-uint32_t get_pv_pe_alloc_count (void *pv_handle);
+struct id get_pv_id (pv_handle_t pv_handle);
+const struct format_type *get_pv_format_type (pv_handle_t pv_handle);
+struct id get_pv_vgid (pv_handle_t pv_handle);
+struct device *get_pv_dev (pv_handle_t pv_handle);
+const char *get_pv_vg_name (pv_handle_t pv_handle);
+uint64_t get_pv_size(pv_handle_t pv_handle);
+uint32_t get_pv_status (pv_handle_t pv_handle);
+uint32_t get_pv_pe_size (pv_handle_t pv_handle);
+uint64_t get_pv_pe_start (pv_handle_t pv_handle);
+uint32_t get_pv_pe_count (pv_handle_t pv_handle);
+uint32_t get_pv_pe_alloc_count (pv_handle_t pv_handle);
#endif
--- LVM2/WHATS_NEW 2007/06/13 15:11:19 1.629
+++ LVM2/WHATS_NEW 2007/06/13 19:52:48 1.630
@@ -1,6 +1,6 @@
Version 2.02.26 -
=================================
- Fix a couple benign warnings by adding variable initializations.
+ Suppress a couple benign warnings by adding variable initializations.
Convert find_pv_in_vg_by_uuid and pv_create to use PV handles.
Add get_pv_* functions to return PV members (external LVM library).
Add wrappers to some functions in preparation for external LVM library.
^ permalink raw reply [flat|nested] 6+ messages in thread
* LVM2 lib/metadata/metadata.c lib/metadata/meta ...
@ 2004-05-05 11:04 agk
0 siblings, 0 replies; 6+ messages in thread
From: agk @ 2004-05-05 11:04 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2004-05-05 11:04:28
Modified files:
lib/metadata : metadata.c metadata.h
tools : pvmove.c
Log message:
move find_pv_by_name to lib
Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.99&r2=1.100
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-06-19 4:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-12 21:20 LVM2 lib/metadata/metadata.c lib/metadata/meta wysochanski
-- strict thread matches above, loose matches on Subject: below --
2007-06-19 4:36 wysochanski
2007-06-19 0:33 wysochanski
2007-06-15 22:16 wysochanski
2007-06-13 19:52 wysochanski
2004-05-05 11:04 agk
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).