public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 include/.symlinks.in lib/Makefile.in lib/ ...
@ 2010-09-30 13:05 wysochanski
  0 siblings, 0 replies; 4+ messages in thread
From: wysochanski @ 2010-09-30 13:05 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-09-30 13:05:20

Modified files:
	include        : .symlinks.in 
	lib            : Makefile.in 
	lib/metadata   : metadata-exported.h metadata.c 

Log message:
	Refactor metadata.[ch] into pv.[ch] for pv functions.
	
	The metadata.[ch] files are very large.  This patch makes a first
	attempt at separating out pv functions and data, particularly
	related to the reporting fields calculations.
	
	More code could be moved here but for now I'm stopping at reporting
	functions 'get' / 'set' functions.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/include/.symlinks.in.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/Makefile.in.diff?cvsroot=lvm2&r1=1.106&r2=1.107
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.166&r2=1.167
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.398&r2=1.399

--- LVM2/include/.symlinks.in	2010/09/30 13:04:55	1.4
+++ LVM2/include/.symlinks.in	2010/09/30 13:05:20	1.5
@@ -33,6 +33,7 @@
 @top_srcdir@/lib/metadata/lv_alloc.h
 @top_srcdir@/lib/metadata/metadata.h
 @top_srcdir@/lib/metadata/metadata-exported.h
+@top_srcdir@/lib/metadata/pv.h
 @top_srcdir@/lib/metadata/pv_alloc.h
 @top_srcdir@/lib/metadata/segtype.h
 @top_srcdir@/lib/metadata/vg.h
--- LVM2/lib/Makefile.in	2010/09/30 13:04:55	1.106
+++ LVM2/lib/Makefile.in	2010/09/30 13:05:20	1.107
@@ -77,6 +77,7 @@
 	metadata/merge.c \
 	metadata/metadata.c \
 	metadata/mirror.c \
+	metadata/pv.c \
 	metadata/pv_manip.c \
 	metadata/pv_map.c \
 	metadata/replicator_manip.c \
--- LVM2/lib/metadata/metadata-exported.h	2010/09/30 13:04:56	1.166
+++ LVM2/lib/metadata/metadata-exported.h	2010/09/30 13:05:20	1.167
@@ -22,6 +22,7 @@
 #define _LVM_METADATA_EXPORTED_H
 
 #include "uuid.h"
+#include "pv.h"
 #include "vg.h"
 
 #define MAX_STRIPES 128U
@@ -175,39 +176,6 @@
 
 #define pvseg_is_allocated(pvseg) ((pvseg)->lvseg)
 
-struct physical_volume {
-	struct id id;
-	struct device *dev;
-	const struct format_type *fmt;
-
-	/*
-	 * vg_name and vgid are used before the parent VG struct exists.
-	 * FIXME: Investigate removal/substitution with 'vg' fields.
-	 */
-	const char *vg_name;
-	struct id vgid;
-
-	/*
-	 * 'vg' is set and maintained when the PV belongs to a 'pvs'
-	 * list in a parent VG struct.
-	 */
-	struct volume_group *vg;
-
-	uint64_t status;
-	uint64_t size;
-
-	/* physical extents */
-	uint32_t pe_size;
-	uint64_t pe_start;
-	uint32_t pe_count;
-	uint32_t pe_alloc_count;
-	unsigned long pe_align;
-	unsigned long pe_align_offset;
-
-	struct dm_list segments;	/* Ordered pv_segments covering complete PV */
-	struct dm_list tags;
-};
-
 struct format_instance {
 	const struct format_type *fmt;
 	/*
@@ -419,7 +387,6 @@
 
 int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
 	     struct dm_list *mdas, int64_t label_sector);
-int is_pv(struct physical_volume *pv);
 int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
 	    const char *pv_name);
 int move_pvs_used_by_lv(struct volume_group *vg_from,
@@ -427,8 +394,6 @@
 			const char *lv_name);
 int is_global_vg(const char *vg_name);
 int is_orphan_vg(const char *vg_name);
-int is_orphan(const struct physical_volume *pv);
-int is_missing_pv(const struct physical_volume *pv);
 int vg_missing_pv_count(const struct volume_group *vg);
 int vgs_are_compatible(struct cmd_context *cmd,
 		       struct volume_group *vg_from,
@@ -777,21 +742,6 @@
 /*
 * Begin skeleton for external LVM library
 */
-struct device *pv_dev(const struct physical_volume *pv);
-const char *pv_vg_name(const struct physical_volume *pv);
-const char *pv_dev_name(const struct physical_volume *pv);
-uint64_t pv_size(const struct physical_volume *pv);
-uint64_t pv_size_field(const struct physical_volume *pv);
-uint64_t pv_dev_size(const struct physical_volume *pv);
-uint64_t pv_free(const struct physical_volume *pv);
-uint64_t pv_status(const struct physical_volume *pv);
-uint32_t pv_pe_size(const struct physical_volume *pv);
-uint64_t pv_pe_start(const struct physical_volume *pv);
-uint32_t pv_pe_count(const struct physical_volume *pv);
-uint32_t pv_pe_alloc_count(const struct physical_volume *pv);
-uint32_t pv_mda_count(const struct physical_volume *pv);
-uint32_t pv_mda_used_count(const struct physical_volume *pv);
-unsigned pv_mda_set_ignored(const struct physical_volume *pv, unsigned ignored);
 int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignore);
 
 uint64_t lv_size(const struct logical_volume *lv);
--- LVM2/lib/metadata/metadata.c	2010/09/30 13:04:56	1.398
+++ LVM2/lib/metadata/metadata.c	2010/09/30 13:05:20	1.399
@@ -34,12 +34,6 @@
 #include <math.h>
 #include <sys/param.h>
 
-/*
- * FIXME: Check for valid handle before dereferencing field or log error?
- */
-#define pv_field(handle, field)				\
-	(((const struct physical_volume *)(handle))->field)
-
 static struct physical_volume *_pv_read(struct cmd_context *cmd,
 					struct dm_pool *pvmem,
 					const char *pv_name,
@@ -3425,29 +3419,6 @@
 	return (vg_name && !strncmp(vg_name, ORPHAN_PREFIX, sizeof(ORPHAN_PREFIX) - 1)) ? 1 : 0;
 }
 
-/**
- * is_orphan - Determine whether a pv is an orphan based on its vg_name
- * @pv: handle to the physical volume
- */
-int is_orphan(const struct physical_volume *pv)
-{
-	return is_orphan_vg(pv_field(pv, vg_name));
-}
-
-/**
- * is_pv - Determine whether a pv is a real pv or dummy one
- * @pv: handle to device
- */
-int is_pv(struct physical_volume *pv)
-{
-	return (pv_field(pv, vg_name) ? 1 : 0);
-}
- 
-int is_missing_pv(const struct physical_volume *pv)
-{
-	return pv_field(pv, status) & MISSING_PV ? 1 : 0;
-}
-
 /*
  * Returns:
  *  0 - fail
@@ -3791,101 +3762,6 @@
 	return FAILED_EXIST;
 }
 
-/*
- * Gets/Sets for external LVM library
- */
-struct id pv_id(const struct physical_volume *pv)
-{
-	return pv_field(pv, id);
-}
-
-const struct format_type *pv_format_type(const struct physical_volume *pv)
-{
-	return pv_field(pv, fmt);
-}
-
-struct id pv_vgid(const struct physical_volume *pv)
-{
-	return pv_field(pv, vgid);
-}
-
-struct device *pv_dev(const struct physical_volume *pv)
-{
-	return pv_field(pv, dev);
-}
-
-const char *pv_vg_name(const struct physical_volume *pv)
-{
-	return pv_field(pv, vg_name);
-}
-
-const char *pv_dev_name(const struct physical_volume *pv)
-{
-	return dev_name(pv_dev(pv));
-}
-
-uint64_t pv_size(const struct physical_volume *pv)
-{
-	return pv_field(pv, size);
-}
-
-uint64_t pv_dev_size(const struct physical_volume *pv)
-{
-	uint64_t size;
-
-	if (!dev_get_size(pv->dev, &size))
-		size = 0;
-	return size;
-}
-
-uint64_t pv_size_field(const struct physical_volume *pv)
-{
-	uint64_t size;
-
-	if (!pv->pe_count)
-		size = pv->size;
-	else
-		size = (uint64_t) pv->pe_count * pv->pe_size;
-	return size;
-}
-
-uint64_t pv_free(const struct physical_volume *pv)
-{
-	uint64_t freespace;
-
-	if (!pv->pe_count)
-		freespace = pv->size;
-	else
-		freespace = (uint64_t)
-			(pv->pe_count - pv->pe_alloc_count) * pv->pe_size;
-	return freespace;
-}
-
-uint64_t pv_status(const struct physical_volume *pv)
-{
-	return pv_field(pv, status);
-}
-
-uint32_t pv_pe_size(const struct physical_volume *pv)
-{
-	return pv_field(pv, pe_size);
-}
-
-uint64_t pv_pe_start(const struct physical_volume *pv)
-{
-	return pv_field(pv, pe_start);
-}
-
-uint32_t pv_pe_count(const struct physical_volume *pv)
-{
-	return pv_field(pv, pe_count);
-}
-
-uint32_t pv_pe_alloc_count(const struct physical_volume *pv)
-{
-	return pv_field(pv, pe_alloc_count);
-}
-
 void fid_add_mda(struct format_instance *fid, struct metadata_area *mda)
 {
 	dm_list_add(mda_is_ignored(mda) ? &fid->metadata_areas_ignored :
@@ -3984,88 +3860,6 @@
 		  mda->ops->mda_metadata_locn_offset ? mda->ops->mda_metadata_locn_offset(locn) : UINT64_C(0));
 }
 
-uint32_t pv_mda_count(const struct physical_volume *pv)
-{
-	struct lvmcache_info *info;
-
-	info = info_from_pvid((const char *)&pv->id.uuid, 0);
-	return info ? dm_list_size(&info->mdas) : UINT64_C(0);
-}
-
-uint32_t pv_mda_used_count(const struct physical_volume *pv)
-{
-	struct lvmcache_info *info;
-	struct metadata_area *mda;
-	uint32_t used_count=0;
-
-	info = info_from_pvid((const char *)&pv->id.uuid, 0);
-	if (!info)
-		return 0;
-	dm_list_iterate_items(mda, &info->mdas) {
-		if (!mda_is_ignored(mda))
-			used_count++;
-	}
-	return used_count;
-}
-
-unsigned pv_mda_set_ignored(const struct physical_volume *pv, unsigned mda_ignored)
-{
-	struct lvmcache_info *info;
-	struct metadata_area *mda, *vg_mda, *tmda;
-	struct dm_list *vg_mdas_in_use, *vg_mdas_ignored;
-
-	if (!(info = info_from_pvid((const char *)&pv->id.uuid, 0)))
-		return_0;
-
-	if (is_orphan(pv)) {
-		dm_list_iterate_items(mda, &info->mdas)
-			mda_set_ignored(mda, mda_ignored);
-		return 1;
-	}
-
-	/*
-	 * Do not allow disabling of the the last PV in a VG.
-	 */
-	if (pv_mda_used_count(pv) == vg_mda_used_count(pv->vg)) {
-		log_error("Cannot disable all metadata areas in volume group %s.",
-			  pv->vg->name);
-		return 0;
-	}
-
-	/*
-	 * Non-orphan case is more complex.
-	 * If the PV's mdas are ignored, and we wish to un-ignore,
-	 * we clear the bit and move them from the ignored mda list to the
-	 * in_use list, ensuring the new state will get written to disk
-	 * in the vg_write() path.
-	 * If the PV's mdas are not ignored, and we are setting
-	 * them to ignored, we set the bit but leave them on the in_use
-	 * list, ensuring the new state will get written to disk in the
-	 * vg_write() path.
-	 */
-	vg_mdas_in_use = &pv->vg->fid->metadata_areas_in_use;
-	vg_mdas_ignored = &pv->vg->fid->metadata_areas_ignored;
-
-	dm_list_iterate_items(mda, &info->mdas) {
-		if (mda_is_ignored(mda) && !mda_ignored)
-			/* Changing an ignored mda to one in_use requires moving it */
-			dm_list_iterate_items_safe(vg_mda, tmda, vg_mdas_ignored)
-				if (mda_locns_match(mda, vg_mda)) {
-					mda_set_ignored(vg_mda, mda_ignored);
-					dm_list_move(vg_mdas_in_use, &vg_mda->list);
-				}
-
-		dm_list_iterate_items_safe(vg_mda, tmda, vg_mdas_in_use)
-			if (mda_locns_match(mda, vg_mda))
-				/* Don't move mda: needs writing to disk. */
-				mda_set_ignored(vg_mda, mda_ignored);
-
-		mda_set_ignored(mda, mda_ignored);
-	}
-
-	return 1;
-}
-
 int mdas_empty_or_ignored(struct dm_list *mdas)
 {
 	struct metadata_area *mda;


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

* LVM2 include/.symlinks.in lib/Makefile.in lib/ ...
@ 2010-11-30 11:53 mornfall
  0 siblings, 0 replies; 4+ messages in thread
From: mornfall @ 2010-11-30 11:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-11-30 11:53:33

Modified files:
	include        : .symlinks.in 
	lib            : Makefile.in 
	lib/activate   : activate.c activate.h dev_manager.c 
	                 dev_manager.h 
	lib/display    : display.c 
	lib/metadata   : lv.c metadata-exported.h mirror.c segtype.h 
	lib/mirror     : mirrored.c 
	lib/replicator : replicator.c 
	lib/report     : report.c 
	lib/snapshot   : snapshot.c 
	tools          : lvconvert.c lvcreate.c lvmcmdline.c lvresize.c 
	                 lvscan.c polldaemon.c tools.h 
Added files:
	lib/misc       : lvm-percent.c lvm-percent.h 

Log message:
	Refactor the percent (mirror sync, snapshot usage) handling code to use
	fixed-point values instead of a combination of a float value and an enum.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/include/.symlinks.in.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/Makefile.in.diff?cvsroot=lvm2&r1=1.108&r2=1.109
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.180&r2=1.181
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.71&r2=1.72
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.205&r2=1.206
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.h.diff?cvsroot=lvm2&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.114&r2=1.115
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.171&r2=1.172
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.137&r2=1.138
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/segtype.h.diff?cvsroot=lvm2&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-percent.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-percent.h.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replicator/replicator.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.140&r2=1.141
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.150&r2=1.151
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.225&r2=1.226
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.133&r2=1.134
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvscan.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/tools.h.diff?cvsroot=lvm2&r1=1.73&r2=1.74

--- LVM2/include/.symlinks.in	2010/09/30 13:05:45	1.6
+++ LVM2/include/.symlinks.in	2010/11/30 11:53:31	1.7
@@ -52,6 +52,7 @@
 @top_srcdir@/lib/misc/lvm-string.h
 @top_builddir@/lib/misc/lvm-version.h
 @top_srcdir@/lib/misc/lvm-wrappers.h
+@top_srcdir@/lib/misc/lvm-percent.h
 @top_srcdir@/lib/misc/sharedlib.h
 @top_srcdir@/lib/report/properties.h
 @top_srcdir@/lib/report/report.h
--- LVM2/lib/Makefile.in	2010/09/30 13:05:45	1.108
+++ LVM2/lib/Makefile.in	2010/11/30 11:53:31	1.109
@@ -91,6 +91,7 @@
 	misc/lvm-globals.c \
 	misc/lvm-string.c \
 	misc/lvm-wrappers.c \
+	misc/lvm-percent.c \
 	misc/util.c \
 	mm/memlock.c \
 	report/properties.c \
--- LVM2/lib/activate/activate.c	2010/11/09 12:34:41	1.180
+++ LVM2/lib/activate/activate.c	2010/11/30 11:53:31	1.181
@@ -158,14 +158,12 @@
 {
 	return 0;
 }
-int lv_snapshot_percent(const struct logical_volume *lv, float *percent,
-			percent_range_t *percent_range)
+int lv_snapshot_percent(const struct logical_volume *lv, percent_t *percent)
 {
 	return 0;
 }
 int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv,
-		      int wait, float *percent, percent_range_t *percent_range,
-		      uint32_t *event_nr)
+		      int wait, percent_t *percent, uint32_t *event_nr)
 {
 	return 0;
 }
@@ -523,8 +521,7 @@
 /*
  * Returns 1 if percent set, else 0 on failure.
  */
-int lv_snapshot_percent(const struct logical_volume *lv, float *percent,
-			percent_range_t *percent_range)
+int lv_snapshot_percent(const struct logical_volume *lv, percent_t *percent)
 {
 	int r;
 	struct dev_manager *dm;
@@ -535,7 +532,7 @@
 	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name)))
 		return_0;
 
-	if (!(r = dev_manager_snapshot_percent(dm, lv, percent, percent_range)))
+	if (!(r = dev_manager_snapshot_percent(dm, lv, percent)))
 		stack;
 
 	dev_manager_destroy(dm);
@@ -545,8 +542,7 @@
 
 /* FIXME Merge with snapshot_percent */
 int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv,
-		      int wait, float *percent, percent_range_t *percent_range,
-		      uint32_t *event_nr)
+		      int wait, percent_t *percent, uint32_t *event_nr)
 {
 	int r;
 	struct dev_manager *dm;
@@ -555,7 +551,7 @@
 	/* If mirrored LV is temporarily shrinked to 1 area (= linear),
 	 * it should be considered in-sync. */
 	if (dm_list_size(&lv->segments) == 1 && first_seg(lv)->area_count == 1) {
-		*percent = 100.0;
+		*percent = PERCENT_100;
 		return 1;
 	}
 
@@ -571,8 +567,7 @@
 	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name)))
 		return_0;
 
-	if (!(r = dev_manager_mirror_percent(dm, lv, wait, percent,
-					     percent_range, event_nr)))
+	if (!(r = dev_manager_mirror_percent(dm, lv, wait, percent, event_nr)))
 		stack;
 
 	dev_manager_destroy(dm);
--- LVM2/lib/activate/activate.h	2010/08/17 16:25:32	1.71
+++ LVM2/lib/activate/activate.h	2010/11/30 11:53:31	1.72
@@ -83,11 +83,9 @@
 /*
  * Returns 1 if percent has been set, else 0.
  */
-int lv_snapshot_percent(const struct logical_volume *lv, float *percent,
-			percent_range_t *percent_range);
+int lv_snapshot_percent(const struct logical_volume *lv, percent_t *percent);
 int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv,
-		      int wait, float *percent, percent_range_t *percent_range,
-		      uint32_t *event_nr);
+		      int wait, percent_t *percent, uint32_t *event_nr);
 
 /*
  * Return number of LVs in the VG that are active.
--- LVM2/lib/activate/dev_manager.c	2010/10/25 10:37:35	1.205
+++ LVM2/lib/activate/dev_manager.c	2010/11/30 11:53:31	1.206
@@ -428,8 +428,8 @@
 	return r;
 }
 
-static percent_range_t _combine_percent_ranges(percent_range_t a,
-					       percent_range_t b)
+static percent_range_t _combine_percent(percent_t a, percent_t b,
+                                        uint32_t numerator, uint32_t denominator)
 {
 	if (a == PERCENT_INVALID || b == PERCENT_INVALID)
 		return PERCENT_INVALID;
@@ -440,14 +440,13 @@
 	if (a == PERCENT_0 && b == PERCENT_0)
 		return PERCENT_0;
 
-	return PERCENT_0_TO_100;
+	return make_percent(numerator, denominator);
 }
 
 static int _percent_run(struct dev_manager *dm, const char *name,
 			const char *dlid,
 			const char *target_type, int wait,
-			const struct logical_volume *lv, float *percent,
-			percent_range_t *overall_percent_range,
+			const struct logical_volume *lv, percent_t *overall_percent,
 			uint32_t *event_nr, int fail_if_percent_unsupported)
 {
 	int r = 0;
@@ -460,13 +459,12 @@
 	const struct dm_list *segh = &lv->segments;
 	struct lv_segment *seg = NULL;
 	struct segment_type *segtype;
-	percent_range_t percent_range = 0, combined_percent_range = 0;
 	int first_time = 1;
+	percent_t percent;
 
 	uint64_t total_numerator = 0, total_denominator = 0;
 
-	*percent = -1;
-	*overall_percent_range = PERCENT_INVALID;
+	*overall_percent = PERCENT_INVALID;
 
 	if (!(dmt = _setup_task(name, dlid, event_nr,
 				wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS, 0, 0)))
@@ -511,19 +509,19 @@
 
 		if (segtype->ops->target_percent &&
 		    !segtype->ops->target_percent(&dm->target_state,
-						  &percent_range, dm->mem,
+						  &percent, dm->mem,
 						  dm->cmd, seg, params,
 						  &total_numerator,
 						  &total_denominator))
 			goto_out;
 
 		if (first_time) {
-			combined_percent_range = percent_range;
+			*overall_percent = percent;
 			first_time = 0;
 		} else
-			combined_percent_range =
-			    _combine_percent_ranges(combined_percent_range,
-						    percent_range);
+			*overall_percent =
+				_combine_percent(*overall_percent, percent,
+						 total_numerator, total_denominator);
 	} while (next);
 
 	if (lv && (segh = dm_list_next(&lv->segments, segh))) {
@@ -532,22 +530,15 @@
 		goto out;
 	}
 
-	if (total_denominator) {
-		*percent = (float) total_numerator *100 / total_denominator;
-		*overall_percent_range = combined_percent_range;
-	} else {
-		*percent = 100;
-		if (first_time) {
-			/* above ->target_percent() was not executed! */
-			/* FIXME why return PERCENT_100 et. al. in this case? */
-			*overall_percent_range = PERCENT_100;
-			if (fail_if_percent_unsupported)
-				goto_out;
-		} else
-			*overall_percent_range = combined_percent_range;
+	if (first_time) {
+		/* above ->target_percent() was not executed! */
+		/* FIXME why return PERCENT_100 et. al. in this case? */
+		*overall_percent = PERCENT_100;
+		if (fail_if_percent_unsupported)
+			goto_out;
 	}
 
-	log_debug("LV percent: %f", *percent);
+	log_debug("LV percent: %f", percent_to_float(*overall_percent));
 	r = 1;
 
       out:
@@ -557,25 +548,21 @@
 
 static int _percent(struct dev_manager *dm, const char *name, const char *dlid,
 		    const char *target_type, int wait,
-		    const struct logical_volume *lv, float *percent,
-		    percent_range_t *overall_percent_range, uint32_t *event_nr,
-		    int fail_if_percent_unsupported)
+		    const struct logical_volume *lv, percent_t *percent,
+		    uint32_t *event_nr, int fail_if_percent_unsupported)
 {
 	if (dlid && *dlid) {
 		if (_percent_run(dm, NULL, dlid, target_type, wait, lv, percent,
-				 overall_percent_range, event_nr,
-				 fail_if_percent_unsupported))
+				 event_nr, fail_if_percent_unsupported))
 			return 1;
 		else if (_percent_run(dm, NULL, dlid + sizeof(UUID_PREFIX) - 1,
 				      target_type, wait, lv, percent,
-				      overall_percent_range, event_nr,
-				      fail_if_percent_unsupported))
+				      event_nr, fail_if_percent_unsupported))
 			return 1;
 	}
 
 	if (name && _percent_run(dm, name, NULL, target_type, wait, lv, percent,
-				 overall_percent_range, event_nr,
-				 fail_if_percent_unsupported))
+				 event_nr, fail_if_percent_unsupported))
 		return 1;
 
 	return 0;
@@ -694,7 +681,7 @@
 
 int dev_manager_snapshot_percent(struct dev_manager *dm,
 				 const struct logical_volume *lv,
-				 float *percent, percent_range_t *percent_range)
+				 percent_t *percent)
 {
 	char *name;
 	const char *dlid;
@@ -729,7 +716,7 @@
 	 */
 	log_debug("Getting device status percentage for %s", name);
 	if (!(_percent(dm, name, dlid, "snapshot", 0, NULL, percent,
-		       percent_range, NULL, fail_if_percent_unsupported)))
+		       NULL, fail_if_percent_unsupported)))
 		return_0;
 
 	/* FIXME dm_pool_free ? */
@@ -742,8 +729,7 @@
 /* FIXME Cope with more than one target */
 int dev_manager_mirror_percent(struct dev_manager *dm,
 			       const struct logical_volume *lv, int wait,
-			       float *percent, percent_range_t *percent_range,
-			       uint32_t *event_nr)
+			       percent_t *percent, uint32_t *event_nr)
 {
 	char *name;
 	const char *dlid;
@@ -764,7 +750,7 @@
 
 	log_debug("Getting device mirror status percentage for %s", name);
 	if (!(_percent(dm, name, dlid, "mirror", wait, lv, percent,
-		       percent_range, event_nr, 0)))
+		       event_nr, 0)))
 		return_0;
 
 	return 1;
--- LVM2/lib/activate/dev_manager.h	2010/08/17 16:25:33	1.34
+++ LVM2/lib/activate/dev_manager.h	2010/11/30 11:53:31	1.35
@@ -46,12 +46,10 @@
 		     struct dm_info *info, uint32_t *read_ahead);
 int dev_manager_snapshot_percent(struct dev_manager *dm,
 				 const struct logical_volume *lv,
-				 float *percent,
-				 percent_range_t *percent_range);
+				 percent_t *percent);
 int dev_manager_mirror_percent(struct dev_manager *dm,
 			       const struct logical_volume *lv, int wait,
-			       float *percent, percent_range_t *percent_range,
-			       uint32_t *event_nr);
+			       percent_t *percent, uint32_t *event_nr);
 int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv,
 			unsigned origin_only, int lockfs, int flush_required);
 int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv, unsigned origin_only);
--- LVM2/lib/display/display.c	2010/11/09 12:34:42	1.114
+++ LVM2/lib/display/display.c	2010/11/30 11:53:31	1.115
@@ -492,8 +492,7 @@
 	int inkernel, snap_active = 0;
 	char uuid[64] __attribute__((aligned(8)));
 	struct lv_segment *snap_seg = NULL, *mirror_seg = NULL;
-	float snap_percent;	/* fused, fsize; */
-	percent_range_t percent_range;
+	percent_t snap_percent;
 
 	if (!id_write_format(&lv->lvid.id[1], uuid, sizeof(uuid)))
 		return_0;
@@ -518,9 +517,8 @@
 				       origin_list) {
 			if (inkernel &&
 			    (snap_active = lv_snapshot_percent(snap_seg->cow,
-							       &snap_percent,
-							       &percent_range)))
-				if (percent_range == PERCENT_INVALID)
+							       &snap_percent)))
+				if (snap_percent == PERCENT_INVALID)
 					snap_active = 0;
 			log_print("                       %s%s/%s [%s]",
 				  lv->vg->cmd->dev_dir, lv->vg->name,
@@ -531,9 +529,8 @@
 	} else if ((snap_seg = find_cow(lv))) {
 		if (inkernel &&
 		    (snap_active = lv_snapshot_percent(snap_seg->cow,
-						       &snap_percent,
-						       &percent_range)))
-			if (percent_range == PERCENT_INVALID)
+						       &snap_percent)))
+			if (snap_percent == PERCENT_INVALID)
 				snap_active = 0;
 
 		log_print("LV snapshot status     %s destination for %s%s/%s",
@@ -568,7 +565,8 @@
 		log_print("COW-table LE           %u", lv->le_count);
 
 		if (snap_active)
-			log_print("Allocated to snapshot  %.2f%% ", snap_percent);	
+			log_print("Allocated to snapshot  %.2f%% ",
+				  percent_to_float(snap_percent));
 
 		log_print("Snapshot chunk size    %s",
 			  display_size(cmd, (uint64_t) snap_seg->chunk_size));
--- LVM2/lib/metadata/lv.c	2010/11/17 20:08:14	1.19
+++ LVM2/lib/metadata/lv.c	2010/11/30 11:53:32	1.20
@@ -193,24 +193,22 @@
 
 static int _lv_mimage_in_sync(const struct logical_volume *lv)
 {
-	float percent;
-	percent_range_t percent_range;
+	percent_t percent;
 	struct lv_segment *mirror_seg = find_mirror_seg(first_seg(lv));
 
 	if (!(lv->status & MIRROR_IMAGE) || !mirror_seg)
 		return_0;
 
 	if (!lv_mirror_percent(lv->vg->cmd, mirror_seg->lv, 0, &percent,
-			       &percent_range, NULL))
+			       NULL))
 		return_0;
 
-	return (percent_range == PERCENT_100) ? 1 : 0;
+	return (percent == PERCENT_100) ? 1 : 0;
 }
 
 char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
 {
-	float snap_percent;
-	percent_range_t percent_range;
+	percent_t snap_percent;
 	struct lvinfo info;
 	char *repstr;
 
@@ -272,8 +270,8 @@
 
 		/* Snapshot dropped? */
 		if (info.live_table && lv_is_cow(lv) &&
-		    (!lv_snapshot_percent(lv, &snap_percent, &percent_range) ||
-		     percent_range == PERCENT_INVALID)) {
+		    (!lv_snapshot_percent(lv, &snap_percent) ||
+		     snap_percent == PERCENT_INVALID)) {
 			repstr[0] = toupper(repstr[0]);
 			if (info.suspended)
 				repstr[4] = 'S'; /* Susp Inv snapshot */
--- LVM2/lib/metadata/metadata-exported.h	2010/11/23 01:55:59	1.171
+++ LVM2/lib/metadata/metadata-exported.h	2010/11/30 11:53:32	1.172
@@ -25,6 +25,7 @@
 #include "pv.h"
 #include "vg.h"
 #include "lv.h"
+#include "lvm-percent.h"
 
 #define MAX_STRIPES 128U
 #define SECTOR_SHIFT 9L
@@ -139,13 +140,6 @@
 	DONT_PROMPT_OVERRIDE = 2 /* Skip prompt + override a second condition */
 } force_t;
 
-typedef enum {
-	PERCENT_0 = 0,
-	PERCENT_0_TO_100 = 1,
-	PERCENT_100 = 2,
-	PERCENT_INVALID = 3
-} percent_range_t;
-
 struct cmd_context;
 struct format_handler;
 struct labeller;
@@ -704,8 +698,7 @@
 						  uint32_t lv_type);
 const char *get_pvmove_pvname_from_lv(struct logical_volume *lv);
 const char *get_pvmove_pvname_from_lv_mirr(struct logical_volume *lv_mirr);
-float copy_percent(struct logical_volume *lv_mirr,
-		   percent_range_t *percent_range);
+percent_t copy_percent(struct logical_volume *lv_mirr);
 struct dm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
 			  struct logical_volume *lv);
 
--- LVM2/lib/metadata/mirror.c	2010/11/09 12:34:43	1.137
+++ LVM2/lib/metadata/mirror.c	2010/11/30 11:53:32	1.138
@@ -547,17 +547,16 @@
 
 static int _mirrored_lv_in_sync(struct logical_volume *lv)
 {
-	float sync_percent;
-	percent_range_t percent_range;
+	percent_t sync_percent;
 
 	if (!lv_mirror_percent(lv->vg->cmd, lv, 0, &sync_percent,
-			       &percent_range, NULL)) {
+			       NULL)) {
 		log_error("Unable to determine mirror sync status of %s/%s.",
 			  lv->vg->name, lv->name);
 		return 0;
 	}
 
-	return (percent_range == PERCENT_100) ? 1 : 0;
+	return (sync_percent == PERCENT_100) ? 1 : 0;
 }
 
 /*
@@ -1508,8 +1507,7 @@
 	return lvs;
 }
 
-float copy_percent(struct logical_volume *lv_mirr,
-		   percent_range_t *percent_range)
+percent_t copy_percent(struct logical_volume *lv_mirr)
 {
 	uint32_t numerator = 0u, denominator = 0u;
 	struct lv_segment *seg;
@@ -1523,14 +1521,7 @@
 			numerator += seg->area_len;
 	}
 
-	if (!denominator || (numerator == denominator))
-		*percent_range = PERCENT_100;
-	else if (numerator == 0)
-		*percent_range = PERCENT_0;
-	else
-		*percent_range = PERCENT_0_TO_100;
-		
-	return denominator ? (float) numerator *100 / denominator : 100.0;
+	return denominator ? make_percent( numerator, denominator ) : 100.0;
 }
 
 /*
@@ -1604,8 +1595,7 @@
 		      struct dm_list *removable_pvs,
 		      int force)
 {
-	float sync_percent;
-	percent_range_t percent_range = PERCENT_0;
+	percent_t sync_percent;
 	struct lvinfo info;
 	struct volume_group *vg = lv->vg;
 
@@ -1618,7 +1608,7 @@
 	/* Had disk log, switch to core. */
 	if (lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) {
 		if (!lv_mirror_percent(cmd, lv, 0, &sync_percent,
-				       &percent_range, NULL)) {
+				       NULL)) {
 			log_error("Unable to determine mirror sync status.");
 			return 0;
 		}
@@ -1633,7 +1623,7 @@
 	else
 		return 0;
 
-	if (percent_range == PERCENT_100)
+	if (sync_percent == PERCENT_100)
 		init_mirror_in_sync(1);
 	else {
 		/* A full resync will take place */
@@ -1798,8 +1788,7 @@
 	struct alloc_handle *ah;
 	const struct segment_type *segtype;
 	struct dm_list *parallel_areas;
-	float sync_percent;
-	percent_range_t percent_range;
+	percent_t sync_percent;
 	int in_sync;
 	struct logical_volume *log_lv;
 	struct lvinfo info;
@@ -1845,9 +1834,8 @@
 	}
 
 	/* check sync status */
-	if (lv_mirror_percent(cmd, lv, 0, &sync_percent, &percent_range,
-			      NULL) &&
-	    (percent_range == PERCENT_100))
+	if (lv_mirror_percent(cmd, lv, 0, &sync_percent, NULL) &&
+	    (sync_percent == PERCENT_100))
 		in_sync = 1;
 	else
 		in_sync = 0;
--- LVM2/lib/metadata/segtype.h	2010/10/13 21:26:37	1.31
+++ LVM2/lib/metadata/segtype.h	2010/11/30 11:53:32	1.32
@@ -85,7 +85,7 @@
 	int (*target_status_compatible) (const char *type);
 	int (*check_transient_status) (struct lv_segment *seg, char *params);
 	int (*target_percent) (void **target_state,
-			       percent_range_t *percent_range,
+			       percent_t *percent,
 			       struct dm_pool * mem,
 			       struct cmd_context *cmd,
 			       struct lv_segment *seg, char *params,
--- LVM2/lib/mirror/mirrored.c	2010/08/17 16:25:35	1.78
+++ LVM2/lib/mirror/mirrored.c	2010/11/30 11:53:32	1.79
@@ -177,7 +177,7 @@
 }
 
 static int _mirrored_target_percent(void **target_state,
-				    percent_range_t *percent_range,
+				    percent_t *percent,
 				    struct dm_pool *mem,
 				    struct cmd_context *cmd,
 				    struct lv_segment *seg, char *params,
@@ -227,12 +227,7 @@
 	if (seg)
 		seg->extents_copied = seg->area_len * numerator / denominator;
 
-	if (numerator == denominator)
-		*percent_range = PERCENT_100;
-	else if (numerator == 0)
-		*percent_range = PERCENT_0;
-	else
-		*percent_range = PERCENT_0_TO_100;
+        *percent = make_percent(numerator, denominator);
 
 	return 1;
 }
/cvs/lvm2/LVM2/lib/misc/lvm-percent.c,v  -->  standard output
revision 1.1
--- LVM2/lib/misc/lvm-percent.c
+++ -	2010-11-30 11:53:35.265706000 +0000
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "lvm-percent.h"
+
+float percent_to_float(percent_t v)
+{
+    return (float)v / PERCENT_1;
+}
+
+percent_t make_percent(uint64_t numerator, uint64_t denominator)
+{
+    percent_t percent;
+    if (!denominator)
+        return PERCENT_100; /* FIXME? */
+    if (!numerator)
+        return PERCENT_0;
+    if (numerator == denominator)
+        return PERCENT_100;
+    switch (percent = PERCENT_100 * ((double) numerator / (double) denominator)) {
+    case PERCENT_100:
+        return PERCENT_100 - 1;
+    case PERCENT_0:
+        return PERCENT_0 + 1;
+    default:
+        return percent;
+    }
+}
+
/cvs/lvm2/LVM2/lib/misc/lvm-percent.h,v  -->  standard output
revision 1.1
--- LVM2/lib/misc/lvm-percent.h
+++ -	2010-11-30 11:53:35.390476000 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _LVM_PERCENT_H
+#define _LVM_PERCENT_H
+#include <stdint.h>
+
+/*
+ * A fixed-point representation of percent values. One percent equals to
+ * PERCENT_1 as defined below. Values that are not multiples of PERCENT_1
+ * represent fractions, with precision of 1/1000000 of a percent. See
+ * percent_to_float for a conversion to a floating-point representation.
+ *
+ * You should always use make_percent when building percent_t values. The
+ * implementation of make_percent is biased towards the middle: it ensures that
+ * the result is PERCENT_0 or PERCENT_100 if and only if this is the actual
+ * value -- it never rounds any intermediate value (> 0 or < 100) to either 0
+ * or 100.
+ */
+typedef int32_t percent_t;
+
+typedef enum {
+	PERCENT_0 = 0,
+	PERCENT_1 = 1000000,
+	PERCENT_100 = 100 * PERCENT_1,
+	PERCENT_INVALID = -1
+} percent_range_t;
+
+float percent_to_float(percent_t v);
+percent_t make_percent(uint64_t numerator, uint64_t denominator);
+
+#endif
--- LVM2/lib/replicator/replicator.c	2010/07/09 15:34:45	1.2
+++ LVM2/lib/replicator/replicator.c	2010/11/30 11:53:32	1.3
@@ -365,7 +365,7 @@
 
 /* FIXME: write something useful for replicator here */
 static int _replicator_target_percent(void **target_state,
-				      percent_range_t *percent_range,
+				      percent_t *percent,
 				      struct dm_pool *mem,
 				      struct cmd_context *cmd,
 				      struct lv_segment *seg,
@@ -708,7 +708,7 @@
 
 /* FIXME: write something useful for replicator-dev here */
 static int _replicator_dev_target_percent(void **target_state,
-					  percent_range_t *percent_range,
+					  percent_t *percent,
 					  struct dm_pool *mem,
 					  struct cmd_context *cmd,
 					  struct lv_segment *seg,
--- LVM2/lib/report/report.c	2010/11/17 20:08:14	1.140
+++ LVM2/lib/report/report.c	2010/11/30 11:53:32	1.141
@@ -795,8 +795,7 @@
 {
 	const struct logical_volume *lv = (const struct logical_volume *) data;
 	struct lvinfo info;
-	float snap_percent;
-	percent_range_t percent_range;
+	percent_t snap_percent;
 	uint64_t *sortval;
 	char *repstr;
 
@@ -818,8 +817,8 @@
 		return 1;
 	}
 
-	if (!lv_snapshot_percent(lv, &snap_percent, &percent_range) ||
-				 (percent_range == PERCENT_INVALID)) {
+	if (!lv_snapshot_percent(lv, &snap_percent) ||
+				 (snap_percent == PERCENT_INVALID)) {
 		if (!lv_is_merging_origin(lv)) {
 			*sortval = UINT64_C(100);
 			dm_report_field_set_value(field, "100.00", sortval);
@@ -838,7 +837,7 @@
 		return 0;
 	}
 
-	if (dm_snprintf(repstr, 7, "%.2f", snap_percent) < 0) {
+	if (dm_snprintf(repstr, 7, "%.2f", percent_to_float(snap_percent)) < 0) {
 		log_error("snapshot percentage too large");
 		return 0;
 	}
@@ -855,8 +854,7 @@
 			     const void *data, void *private __attribute__((unused)))
 {
 	struct logical_volume *lv = (struct logical_volume *) data;
-	float percent;
-	percent_range_t percent_range;
+	percent_t percent;
 	uint64_t *sortval;
 	char *repstr;
 
@@ -866,21 +864,21 @@
 	}
 
 	if ((!(lv->status & PVMOVE) && !(lv->status & MIRRORED)) ||
-	    !lv_mirror_percent(lv->vg->cmd, lv, 0, &percent, &percent_range,
-			       NULL) || (percent_range == PERCENT_INVALID)) {
+	    !lv_mirror_percent(lv->vg->cmd, lv, 0, &percent,
+			       NULL) || (percent == PERCENT_INVALID)) {
 		*sortval = UINT64_C(0);
 		dm_report_field_set_value(field, "", sortval);
 		return 1;
 	}
 
-	percent = copy_percent(lv, &percent_range);
+	percent = copy_percent(lv);
 
 	if (!(repstr = dm_pool_zalloc(mem, 8))) {
 		log_error("dm_pool_alloc failed");
 		return 0;
 	}
 
-	if (dm_snprintf(repstr, 7, "%.2f", percent) < 0) {
+	if (dm_snprintf(repstr, 7, "%.2f", percent_to_float(percent)) < 0) {
 		log_error("copy percentage too large");
 		return 0;
 	}
--- LVM2/lib/snapshot/snapshot.c	2010/10/13 21:26:37	1.50
+++ LVM2/lib/snapshot/snapshot.c	2010/11/30 11:53:32	1.51
@@ -109,7 +109,7 @@
 
 #ifdef DEVMAPPER_SUPPORT
 static int _snap_target_percent(void **target_state __attribute__((unused)),
-				percent_range_t *percent_range,
+				percent_t *percent,
 				struct dm_pool *mem __attribute__((unused)),
 				struct cmd_context *cmd __attribute__((unused)),
 				struct lv_segment *seg __attribute__((unused)),
@@ -130,14 +130,14 @@
 		*total_numerator += sectors_allocated;
 		*total_denominator += total_sectors;
 		if (r == 3 && sectors_allocated == metadata_sectors)
-			*percent_range = PERCENT_0;
+			*percent = PERCENT_0;
 		else if (sectors_allocated == total_sectors)
-			*percent_range = PERCENT_100;
+			*percent = PERCENT_100;
 		else
-			*percent_range = PERCENT_0_TO_100;
+			*percent = make_percent(*total_numerator, *total_denominator);
 	} else if (!strcmp(params, "Invalid") ||
 		   !strcmp(params, "Merge failed"))
-		*percent_range = PERCENT_INVALID;
+		*percent = PERCENT_INVALID;
 	else
 		return 0;
 
--- LVM2/tools/lvconvert.c	2010/11/28 18:37:33	1.150
+++ LVM2/tools/lvconvert.c	2010/11/30 11:53:33	1.151
@@ -425,23 +425,24 @@
 				       const char *name __attribute__((unused)),
 				       struct daemon_parms *parms)
 {
-	float percent = 0.0;
-	percent_range_t percent_range;
+	percent_t percent = PERCENT_0;
 
-	if (!lv_snapshot_percent(lv, &percent, &percent_range)) {
+	if (!lv_snapshot_percent(lv, &percent)) {
 		log_error("%s: Failed query for merging percentage. Aborting merge.", lv->name);
 		return PROGRESS_CHECK_FAILED;
-	} else if (percent_range == PERCENT_INVALID) {
+	} else if (percent == PERCENT_INVALID) {
 		log_error("%s: Merging snapshot invalidated. Aborting merge.", lv->name);
 		return PROGRESS_CHECK_FAILED;
 	}
 
 	if (parms->progress_display)
-		log_print("%s: %s: %.1f%%", lv->name, parms->progress_title, percent);
+		log_print("%s: %s: %.1f%%", lv->name, parms->progress_title,
+			  percent_to_float(percent));
 	else
-		log_verbose("%s: %s: %.1f%%", lv->name, parms->progress_title, percent);
+		log_verbose("%s: %s: %.1f%%", lv->name, parms->progress_title,
+			    percent_to_float(percent));
 
-	if (percent_range == PERCENT_0)
+	if (percent == PERCENT_0)
 		return PROGRESS_FINISHED_ALL;
 
 	return PROGRESS_UNFINISHED;
--- LVM2/tools/lvcreate.c	2010/11/11 17:29:06	1.225
+++ LVM2/tools/lvcreate.c	2010/11/30 11:53:33	1.226
@@ -19,7 +19,7 @@
 #include <fcntl.h>
 
 struct lvcreate_cmdline_params {
-	percent_t percent;
+	percent_type_t percent;
 	uint64_t size;
 	char **pvs;
 	int pv_count;
--- LVM2/tools/lvmcmdline.c	2010/11/29 11:14:33	1.133
+++ LVM2/tools/lvmcmdline.c	2010/11/30 11:53:33	1.134
@@ -126,7 +126,7 @@
 	return arg_count(cmd, a) ? cmd->arg_values[a].sign : def;
 }
 
-percent_t arg_percent_value(struct cmd_context *cmd, int a, const percent_t def)
+percent_type_t arg_percent_value(struct cmd_context *cmd, int a, const percent_type_t def)
 {
 	return arg_count(cmd, a) ? cmd->arg_values[a].percent : def;
 }
--- LVM2/tools/lvresize.c	2010/11/01 14:17:36	1.125
+++ LVM2/tools/lvresize.c	2010/11/30 11:53:33	1.126
@@ -31,7 +31,7 @@
 	uint32_t extents;
 	uint64_t size;
 	sign_t sign;
-	percent_t percent;
+	percent_type_t percent;
 
 	enum {
 		LV_ANY = 0,
@@ -282,24 +282,23 @@
 static int _adjust_policy_params(struct cmd_context *cmd,
 				 struct logical_volume *lv, struct lvresize_params *lp)
 {
-	float percent;
-	percent_range_t range;
+	percent_t percent;
 	int policy_threshold, policy_amount;
 
 	policy_threshold =
 		find_config_tree_int(cmd, "activation/snapshot_autoextend_threshold",
-				     DEFAULT_SNAPSHOT_AUTOEXTEND_THRESHOLD);
+				     DEFAULT_SNAPSHOT_AUTOEXTEND_THRESHOLD) * PERCENT_1;
 	policy_amount =
 		find_config_tree_int(cmd, "activation/snapshot_autoextend_percent",
 				     DEFAULT_SNAPSHOT_AUTOEXTEND_PERCENT);
 
-	if (policy_threshold >= 100)
+	if (policy_threshold >= PERCENT_100)
 		return 1; /* nothing to do */
 
-	if (!lv_snapshot_percent(lv, &percent, &range))
+	if (!lv_snapshot_percent(lv, &percent))
 		return_0;
 
-	if (range != PERCENT_0_TO_100 || percent <= policy_threshold)
+	if (!(PERCENT_0 < percent && percent < PERCENT_100) || percent <= policy_threshold)
 		return 1; /* nothing to do */
 
 	lp->extents = policy_amount;
--- LVM2/tools/lvscan.c	2010/08/17 16:25:35	1.42
+++ LVM2/tools/lvscan.c	2010/11/30 11:53:33	1.43
@@ -23,8 +23,7 @@
 	uint64_t lv_capacity_total = 0;
 	int inkernel, snap_active = 1;
 	struct lv_segment *snap_seg = NULL;
-	float snap_percent;     /* fused, fsize; */
-	percent_range_t percent_range;
+	percent_t snap_percent;     /* fused, fsize; */
 
 	const char *active_str, *snapshot_str;
 
@@ -37,17 +36,15 @@
 				       origin_list) {
 			if (inkernel &&
 			    (snap_active = lv_snapshot_percent(snap_seg->cow,
-							       &snap_percent,
-							       &percent_range)))
-				if (percent_range == PERCENT_INVALID)
+							       &snap_percent)))
+				if (snap_percent == PERCENT_INVALID)
 					snap_active = 0;
 		}
 		snap_seg = NULL;
 	} else if (lv_is_cow(lv)) {
 		if (inkernel &&
-		    (snap_active = lv_snapshot_percent(lv, &snap_percent,
-						       &percent_range)))
-			if (percent_range == PERCENT_INVALID)
+		    (snap_active = lv_snapshot_percent(lv, &snap_percent)))
+			if (snap_percent == PERCENT_INVALID)
 				snap_active = 0;
 	}
 
--- LVM2/tools/polldaemon.c	2010/08/26 16:29:12	1.37
+++ LVM2/tools/polldaemon.c	2010/11/30 11:53:33	1.38
@@ -74,30 +74,29 @@
 				struct logical_volume *lv, const char *name,
 				struct daemon_parms *parms)
 {
-	float segment_percent = 0.0, overall_percent = 0.0;
-	percent_range_t percent_range, overall_percent_range;
+	percent_t segment_percent = PERCENT_0, overall_percent = PERCENT_0;
 	uint32_t event_nr = 0;
 
 	if (!lv_is_mirrored(lv) ||
 	    !lv_mirror_percent(cmd, lv, !parms->interval, &segment_percent,
-			       &percent_range, &event_nr) ||
-	    (percent_range == PERCENT_INVALID)) {
+			       &event_nr) ||
+	    (segment_percent == PERCENT_INVALID)) {
 		log_error("ABORTING: Mirror percentage check failed.");
 		return PROGRESS_CHECK_FAILED;
 	}
 
-	overall_percent = copy_percent(lv, &overall_percent_range);
+	overall_percent = copy_percent(lv);
 	if (parms->progress_display)
 		log_print("%s: %s: %.1f%%", name, parms->progress_title,
-			  overall_percent);
+			  percent_to_float(overall_percent));
 	else
 		log_verbose("%s: %s: %.1f%%", name, parms->progress_title,
-			    overall_percent);
+			    percent_to_float(overall_percent));
 
-	if (percent_range != PERCENT_100)
+	if (segment_percent != PERCENT_100)
 		return PROGRESS_UNFINISHED;
 
-	if (overall_percent_range == PERCENT_100)
+	if (overall_percent == PERCENT_100)
 		return PROGRESS_FINISHED_ALL;
 
 	return PROGRESS_FINISHED_SEGMENT;
--- LVM2/tools/tools.h	2010/11/11 17:29:06	1.73
+++ LVM2/tools/tools.h	2010/11/30 11:53:33	1.74
@@ -85,7 +85,7 @@
 	PERCENT_LV,
 	PERCENT_PVS,
 	PERCENT_ORIGIN
-} percent_t;
+} percent_type_t;
 
 enum {
 	CHANGE_AY = 0,
@@ -106,7 +106,7 @@
 	int64_t i64_value;
 	uint64_t ui64_value;
 	sign_t sign;
-	percent_t percent;
+	percent_type_t percent;
 /*	void *ptr; // Currently not used. */
 };
 
@@ -174,7 +174,7 @@
 uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def);
 const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def);
 sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def);
-percent_t arg_percent_value(struct cmd_context *cmd, int a, const percent_t def);
+percent_type_t arg_percent_value(struct cmd_context *cmd, int a, const percent_type_t def);
 int arg_count_increment(struct cmd_context *cmd, int a);
 
 unsigned grouped_arg_count(const struct arg_values *av, int a);


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

* LVM2 include/.symlinks.in lib/Makefile.in lib/ ...
@ 2010-09-30 13:05 wysochanski
  0 siblings, 0 replies; 4+ messages in thread
From: wysochanski @ 2010-09-30 13:05 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-09-30 13:05:45

Modified files:
	include        : .symlinks.in 
	lib            : Makefile.in 
	lib/metadata   : metadata-exported.h metadata.c 

Log message:
	Refactor metadata.[ch] into lv.[ch] for lv functions.
	
	This patch is similar to the other patches for pv and vg
	functionality, and separates lv functionality into separate
	files, concentrating on reporting fields and simple functions.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/include/.symlinks.in.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/Makefile.in.diff?cvsroot=lvm2&r1=1.107&r2=1.108
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.167&r2=1.168
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.399&r2=1.400

--- LVM2/include/.symlinks.in	2010/09/30 13:05:20	1.5
+++ LVM2/include/.symlinks.in	2010/09/30 13:05:45	1.6
@@ -30,6 +30,7 @@
 @top_srcdir@/lib/locking/locking.h
 @top_srcdir@/lib/log/log.h
 @top_srcdir@/lib/log/lvm-logging.h
+@top_srcdir@/lib/metadata/lv.h
 @top_srcdir@/lib/metadata/lv_alloc.h
 @top_srcdir@/lib/metadata/metadata.h
 @top_srcdir@/lib/metadata/metadata-exported.h
--- LVM2/lib/Makefile.in	2010/09/30 13:05:20	1.107
+++ LVM2/lib/Makefile.in	2010/09/30 13:05:45	1.108
@@ -73,6 +73,7 @@
 	locking/locking.c \
 	locking/no_locking.c \
 	log/log.c \
+	metadata/lv.c \
 	metadata/lv_manip.c \
 	metadata/merge.c \
 	metadata/metadata.c \
--- LVM2/lib/metadata/metadata-exported.h	2010/09/30 13:05:20	1.167
+++ LVM2/lib/metadata/metadata-exported.h	2010/09/30 13:05:45	1.168
@@ -24,6 +24,7 @@
 #include "uuid.h"
 #include "pv.h"
 #include "vg.h"
+#include "lv.h"
 
 #define MAX_STRIPES 128U
 #define SECTOR_SHIFT 9L
@@ -291,33 +292,6 @@
 #define seg_pv(seg, s)		(seg)->areas[(s)].u.pv.pvseg->pv
 #define seg_lv(seg, s)		(seg)->areas[(s)].u.lv.lv
 
-struct logical_volume {
-	union lvid lvid;
-	char *name;
-
-	struct volume_group *vg;
-
-	uint64_t status;
-	alloc_policy_t alloc;
-	uint32_t read_ahead;
-	int32_t major;
-	int32_t minor;
-
-	uint64_t size;		/* Sectors */
-	uint32_t le_count;
-
-	uint32_t origin_count;
-	struct dm_list snapshot_segs;
-	struct lv_segment *snapshot;
-
-	struct replicator_device *rdevice;/* For replicator-devs, rimages, slogs - reference to rdevice */
-	struct dm_list rsites;	/* For replicators - all sites */
-
-	struct dm_list segments;
-	struct dm_list tags;
-	struct dm_list segs_using_this_lv;
-};
-
 struct pe_range {
 	struct dm_list list;
 	uint32_t start;		/* PEs */
@@ -744,7 +718,6 @@
 */
 int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignore);
 
-uint64_t lv_size(const struct logical_volume *lv);
 
 int vg_check_write_mode(struct volume_group *vg);
 #define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
--- LVM2/lib/metadata/metadata.c	2010/09/30 13:05:20	1.399
+++ LVM2/lib/metadata/metadata.c	2010/09/30 13:05:45	1.400
@@ -3921,11 +3921,6 @@
 	return 1;
 }
 
-uint64_t lv_size(const struct logical_volume *lv)
-{
-	return lv->size;
-}
-
 /**
  * pv_by_path - Given a device path return a PV handle if it is a PV
  * @cmd - handle to the LVM command instance


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

* LVM2 include/.symlinks.in lib/Makefile.in lib/ ...
@ 2010-09-30 13:04 wysochanski
  0 siblings, 0 replies; 4+ messages in thread
From: wysochanski @ 2010-09-30 13:04 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-09-30 13:04:56

Modified files:
	include        : .symlinks.in 
	lib            : Makefile.in 
	lib/metadata   : metadata-exported.h metadata.c metadata.h 

Log message:
	Refactor metadata.[ch] into vg.[ch] for vg functions.
	
	The metadata.[ch] files are very large.  This patch makes a first
	attempt at separating out vg functions and data, particularly
	related to the reporting fields calculations.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/include/.symlinks.in.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/Makefile.in.diff?cvsroot=lvm2&r1=1.105&r2=1.106
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.165&r2=1.166
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.397&r2=1.398
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.218&r2=1.219

--- LVM2/include/.symlinks.in	2010/08/20 12:44:47	1.3
+++ LVM2/include/.symlinks.in	2010/09/30 13:04:55	1.4
@@ -35,6 +35,7 @@
 @top_srcdir@/lib/metadata/metadata-exported.h
 @top_srcdir@/lib/metadata/pv_alloc.h
 @top_srcdir@/lib/metadata/segtype.h
+@top_srcdir@/lib/metadata/vg.h
 @top_srcdir@/lib/mm/memlock.h
 @top_srcdir@/lib/mm/xlate.h
 @top_builddir@/lib/misc/configure.h
--- LVM2/lib/Makefile.in	2010/08/20 12:44:47	1.105
+++ LVM2/lib/Makefile.in	2010/09/30 13:04:55	1.106
@@ -82,6 +82,7 @@
 	metadata/replicator_manip.c \
 	metadata/segtype.c \
 	metadata/snapshot_manip.c \
+	metadata/vg.c \
 	misc/crc.c \
 	misc/lvm-exec.c \
 	misc/lvm-file.c \
--- LVM2/lib/metadata/metadata-exported.h	2010/07/08 18:24:30	1.165
+++ LVM2/lib/metadata/metadata-exported.h	2010/09/30 13:04:56	1.166
@@ -22,6 +22,7 @@
 #define _LVM_METADATA_EXPORTED_H
 
 #include "uuid.h"
+#include "vg.h"
 
 #define MAX_STRIPES 128U
 #define SECTOR_SHIFT 9L
@@ -122,15 +123,6 @@
 
 /* Ordered list - see lv_manip.c */
 typedef enum {
-	ALLOC_INVALID,
-	ALLOC_CONTIGUOUS,
-	ALLOC_CLING,
-	ALLOC_NORMAL,
-	ALLOC_ANYWHERE,
-	ALLOC_INHERIT
-} alloc_policy_t;
-
-typedef enum {
 	AREA_UNASSIGNED,
 	AREA_PV,
 	AREA_LV
@@ -229,70 +221,6 @@
 	void *private;
 };
 
-struct volume_group {
-	struct cmd_context *cmd;
-	struct dm_pool *vgmem;
-	struct format_instance *fid;
-	struct dm_list *cmd_vgs;/* List of wanted/locked and opened VGs */
-	uint32_t cmd_missing_vgs;/* Flag marks missing VG */
-	uint32_t seqno;		/* Metadata sequence number */
-
-	alloc_policy_t alloc;
-	uint64_t status;
-
-	struct id id;
-	char *name;
-	char *old_name;		/* Set during vgrename and vgcfgrestore */
-	char *system_id;
-
-	uint32_t extent_size;
-	uint32_t extent_count;
-	uint32_t free_count;
-
-	uint32_t max_lv;
-	uint32_t max_pv;
-
-	/* physical volumes */
-	uint32_t pv_count;
-	struct dm_list pvs;
-
-	/*
-	 * logical volumes
-	 * The following relationship should always hold:
-	 * dm_list_size(lvs) = user visible lv_count + snapshot_count + other invisible LVs
-	 *
-	 * Snapshots consist of 2 instances of "struct logical_volume":
-	 * - cow (lv_name is visible to the user)
-	 * - snapshot (lv_name is 'snapshotN')
-	 *
-	 * Mirrors consist of multiple instances of "struct logical_volume":
-	 * - one for the mirror log
-	 * - one for each mirror leg
-	 * - one for the user-visible mirror LV
-	 */
-	struct dm_list lvs;
-
-	struct dm_list tags;
-
-	/*
-	 * FIXME: Move the next fields into a different struct?
-	 */
-
-	/*
-	 * List of removed physical volumes by pvreduce.
-	 * They have to get cleared on vg_commit.
-	 */
-	struct dm_list removed_pvs;
-	uint32_t open_mode; /* FIXME: read or write - check lock type? */
-
-	/*
-	 * Store result of the last vg_read().
-	 * 0 for success else appropriate FAILURE_* bits set.
-	 */
-	uint32_t read_status;
-	uint32_t mda_copies; /* target number of mdas for this VG */
-};
-
 /* There will be one area for each stripe */
 struct lv_segment_area {
 	area_type_t type;
@@ -501,6 +429,7 @@
 int is_orphan_vg(const char *vg_name);
 int is_orphan(const struct physical_volume *pv);
 int is_missing_pv(const struct physical_volume *pv);
+int vg_missing_pv_count(const struct volume_group *vg);
 int vgs_are_compatible(struct cmd_context *cmd,
 		       struct volume_group *vg_from,
 		       struct volume_group *vg_to);
@@ -552,11 +481,6 @@
 	      struct pvcreate_params *pp);
 int vg_reduce(struct volume_group *vg, char *pv_name);
 int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag);
-int vg_set_extent_size(struct volume_group *vg, uint32_t new_extent_size);
-int vg_set_max_lv(struct volume_group *vg, uint32_t max_lv);
-int vg_set_max_pv(struct volume_group *vg, uint32_t max_pv);
-int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc);
-int vg_set_clustered(struct volume_group *vg, int clustered);
 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
 		  struct volume_group *vg_to);
 /* FIXME: Investigate refactoring these functions to take a pv ISO pv_list */
@@ -746,10 +670,6 @@
 
 int vg_check_status(const struct volume_group *vg, uint64_t status);
 
-/*
- * Returns visible LV count - number of LVs from user perspective
- */
-unsigned vg_visible_lvs(const struct volume_group *vg);
 
 /*
  * Check if the VG reached maximal LVs count (if set)
@@ -876,21 +796,6 @@
 
 uint64_t lv_size(const struct logical_volume *lv);
 
-int vg_missing_pv_count(const struct volume_group *vg);
-uint32_t vg_seqno(const struct volume_group *vg);
-uint64_t vg_status(const struct volume_group *vg);
-uint64_t vg_size(const struct volume_group *vg);
-uint64_t vg_free(const struct volume_group *vg);
-uint64_t vg_extent_size(const struct volume_group *vg);
-uint64_t vg_extent_count(const struct volume_group *vg);
-uint64_t vg_free_count(const struct volume_group *vg);
-uint64_t vg_pv_count(const struct volume_group *vg);
-uint64_t vg_max_pv(const struct volume_group *vg);
-uint64_t vg_max_lv(const struct volume_group *vg);
-uint32_t vg_mda_count(const struct volume_group *vg);
-uint32_t vg_mda_used_count(const struct volume_group *vg);
-uint32_t vg_mda_copies(const struct volume_group *vg);
-int vg_set_mda_copies(struct volume_group *vg, uint32_t mda_copies);
 int vg_check_write_mode(struct volume_group *vg);
 #define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
 #define vg_is_exported(vg) (vg_status((vg)) & EXPORTED_VG)
--- LVM2/lib/metadata/metadata.c	2010/09/23 12:02:34	1.397
+++ LVM2/lib/metadata/metadata.c	2010/09/30 13:04:56	1.398
@@ -1021,31 +1021,6 @@
 	return (uint64_t) size / extent_size;
 }
 
-static int _recalc_extents(uint32_t *extents, const char *desc1,
-			   const char *desc2, uint32_t old_size,
-			   uint32_t new_size)
-{
-	uint64_t size = (uint64_t) old_size * (*extents);
-
-	if (size % new_size) {
-		log_error("New size %" PRIu64 " for %s%s not an exact number "
-			  "of new extents.", size, desc1, desc2);
-		return 0;
-	}
-
-	size /= new_size;
-
-	if (size > UINT32_MAX) {
-		log_error("New extent count %" PRIu64 " for %s%s exceeds "
-			  "32 bits.", size, desc1, desc2);
-		return 0;
-	}
-
-	*extents = (uint32_t) size;
-
-	return 1;
-}
-
 static dm_bitset_t _bitset_with_random_bits(struct dm_pool *mem, uint32_t num_bits,
 					    uint32_t num_set_bits, unsigned *seed)
 {
@@ -1220,22 +1195,6 @@
 	return 1;
 }
 
-uint32_t vg_mda_copies(const struct volume_group *vg)
-{
-	return vg->mda_copies;
-}
-
-int vg_set_mda_copies(struct volume_group *vg, uint32_t mda_copies)
-{
-	vg->mda_copies = mda_copies;
-
-	/* FIXME Use log_verbose when this is due to specific cmdline request. */
-	log_debug("Setting mda_copies to %"PRIu32" for VG %s",
-		    mda_copies, vg->name);
-
-	return 1;
-}
-
 uint64_t find_min_mda_size(struct dm_list *mdas)
 {
 	uint64_t min_mda_size = UINT64_MAX, mda_size;
@@ -1255,285 +1214,6 @@
 	return min_mda_size;
 }
 
-uint64_t vg_mda_size(const struct volume_group *vg)
-{
-	return find_min_mda_size(&vg->fid->metadata_areas_in_use);
-}
-
-uint64_t vg_mda_free(const struct volume_group *vg)
-{
-	uint64_t freespace = UINT64_MAX, mda_free;
-	struct metadata_area *mda;
-
-	dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
-		if (!mda->ops->mda_free_sectors)
-			continue;
-		mda_free = mda->ops->mda_free_sectors(mda);
-		if (mda_free < freespace)
-			freespace = mda_free;
-	}
-
-	if (freespace == UINT64_MAX)
-		freespace = UINT64_C(0);
-	return freespace;
-}
-
-int vg_set_extent_size(struct volume_group *vg, uint32_t new_size)
-{
-	uint32_t old_size = vg->extent_size;
-	struct pv_list *pvl;
-	struct lv_list *lvl;
-	struct physical_volume *pv;
-	struct logical_volume *lv;
-	struct lv_segment *seg;
-	struct pv_segment *pvseg;
-	uint32_t s;
-
-	if (!vg_is_resizeable(vg)) {
-		log_error("Volume group \"%s\" must be resizeable "
-			  "to change PE size", vg->name);
-		return 0;
-	}
-
-	if (!new_size) {
-		log_error("Physical extent size may not be zero");
-		return 0;
-	}
-
-	if (new_size == vg->extent_size)
-		return 1;
-
-	if (new_size & (new_size - 1)) {
-		log_error("Physical extent size must be a power of 2.");
-		return 0;
-	}
-
-	if (new_size > vg->extent_size) {
-		if ((uint64_t) vg_size(vg) % new_size) {
-			/* FIXME Adjust used PV sizes instead */
-			log_error("New extent size is not a perfect fit");
-			return 0;
-		}
-	}
-
-	vg->extent_size = new_size;
-
-	if (vg->fid->fmt->ops->vg_setup &&
-	    !vg->fid->fmt->ops->vg_setup(vg->fid, vg))
-		return_0;
-
-	if (!_recalc_extents(&vg->extent_count, vg->name, "", old_size,
-			     new_size))
-		return_0;
-
-	if (!_recalc_extents(&vg->free_count, vg->name, " free space",
-			     old_size, new_size))
-		return_0;
-
-	/* foreach PV */
-	dm_list_iterate_items(pvl, &vg->pvs) {
-		pv = pvl->pv;
-
-		pv->pe_size = new_size;
-		if (!_recalc_extents(&pv->pe_count, pv_dev_name(pv), "",
-				     old_size, new_size))
-			return_0;
-
-		if (!_recalc_extents(&pv->pe_alloc_count, pv_dev_name(pv),
-				     " allocated space", old_size, new_size))
-			return_0;
-
-		/* foreach free PV Segment */
-		dm_list_iterate_items(pvseg, &pv->segments) {
-			if (pvseg_is_allocated(pvseg))
-				continue;
-
-			if (!_recalc_extents(&pvseg->pe, pv_dev_name(pv),
-					     " PV segment start", old_size,
-					     new_size))
-				return_0;
-			if (!_recalc_extents(&pvseg->len, pv_dev_name(pv),
-					     " PV segment length", old_size,
-					     new_size))
-				return_0;
-		}
-	}
-
-	/* foreach LV */
-	dm_list_iterate_items(lvl, &vg->lvs) {
-		lv = lvl->lv;
-
-		if (!_recalc_extents(&lv->le_count, lv->name, "", old_size,
-				     new_size))
-			return_0;
-
-		dm_list_iterate_items(seg, &lv->segments) {
-			if (!_recalc_extents(&seg->le, lv->name,
-					     " segment start", old_size,
-					     new_size))
-				return_0;
-
-			if (!_recalc_extents(&seg->len, lv->name,
-					     " segment length", old_size,
-					     new_size))
-				return_0;
-
-			if (!_recalc_extents(&seg->area_len, lv->name,
-					     " area length", old_size,
-					     new_size))
-				return_0;
-
-			if (!_recalc_extents(&seg->extents_copied, lv->name,
-					     " extents moved", old_size,
-					     new_size))
-				return_0;
-
-			/* foreach area */
-			for (s = 0; s < seg->area_count; s++) {
-				switch (seg_type(seg, s)) {
-				case AREA_PV:
-					if (!_recalc_extents
-					    (&seg_pe(seg, s),
-					     lv->name,
-					     " pvseg start", old_size,
-					     new_size))
-						return_0;
-					if (!_recalc_extents
-					    (&seg_pvseg(seg, s)->len,
-					     lv->name,
-					     " pvseg length", old_size,
-					     new_size))
-						return_0;
-					break;
-				case AREA_LV:
-					if (!_recalc_extents
-					    (&seg_le(seg, s), lv->name,
-					     " area start", old_size,
-					     new_size))
-						return_0;
-					break;
-				case AREA_UNASSIGNED:
-					log_error("Unassigned area %u found in "
-						  "segment", s);
-					return 0;
-				}
-			}
-		}
-
-	}
-
-	return 1;
-}
-
-int vg_set_max_lv(struct volume_group *vg, uint32_t max_lv)
-{
-	if (!vg_is_resizeable(vg)) {
-		log_error("Volume group \"%s\" must be resizeable "
-			  "to change MaxLogicalVolume", vg->name);
-		return 0;
-	}
-
-	if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS)) {
-		if (!max_lv)
-			max_lv = 255;
-		else if (max_lv > 255) {
-			log_error("MaxLogicalVolume limit is 255");
-			return 0;
-		}
-	}
-
-	if (max_lv && max_lv < vg_visible_lvs(vg)) {
-		log_error("MaxLogicalVolume is less than the current number "
-			  "%d of LVs for %s", vg_visible_lvs(vg),
-			  vg->name);
-		return 0;
-	}
-	vg->max_lv = max_lv;
-
-	return 1;
-}
-
-int vg_set_max_pv(struct volume_group *vg, uint32_t max_pv)
-{
-	if (!vg_is_resizeable(vg)) {
-		log_error("Volume group \"%s\" must be resizeable "
-			  "to change MaxPhysicalVolumes", vg->name);
-		return 0;
-	}
-
-	if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS)) {
-		if (!max_pv)
-			max_pv = 255;
-		else if (max_pv > 255) {
-			log_error("MaxPhysicalVolume limit is 255");
-			return 0;
-		}
-	}
-
-	if (max_pv && max_pv < vg->pv_count) {
-		log_error("MaxPhysicalVolumes is less than the current number "
-			  "%d of PVs for \"%s\"", vg->pv_count,
-			  vg->name);
-		return 0;
-	}
-	vg->max_pv = max_pv;
-	return 1;
-}
-
-int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc)
-{
-	if (alloc == ALLOC_INHERIT) {
-		log_error("Volume Group allocation policy cannot inherit "
-			  "from anything");
-		return 0;
-	}
-
-	if (alloc == vg->alloc)
-		return 1;
-
-	vg->alloc = alloc;
-	return 1;
-}
-
-int vg_set_clustered(struct volume_group *vg, int clustered)
-{
-	struct lv_list *lvl;
-
-	/*
-	 * We do not currently support switching the cluster attribute
-	 * on active mirrors or snapshots.
-	 */
-	dm_list_iterate_items(lvl, &vg->lvs) {
-		if (lv_is_mirrored(lvl->lv) && lv_is_active(lvl->lv)) {
-			log_error("Mirror logical volumes must be inactive "
-				  "when changing the cluster attribute.");
-			return 0;
-		}
-
-		if (clustered) {
-			if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) {
-				log_error("Volume group %s contains snapshots "
-					  "that are not yet supported.",
-					  vg->name);
-				return 0;
-			}
-		}
-
-		if ((lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) &&
-		    lv_is_active(lvl->lv)) {
-			log_error("Snapshot logical volumes must be inactive "
-				  "when changing the cluster attribute.");
-			return 0;
-		}
-	}
-
-	if (clustered)
-		vg->status |= CLUSTERED;
-	else
-		vg->status &= ~CLUSTERED;
-	return 1;
-}
-
 static int _move_mdas(struct volume_group *vg_from, struct volume_group *vg_to,
 		      struct dm_list *mdas_from, struct dm_list *mdas_to)
 {
@@ -2168,31 +1848,6 @@
 	return 1;
 }
 
-unsigned snapshot_count(const struct volume_group *vg)
-{
-	struct lv_list *lvl;
-	unsigned num_snapshots = 0;
-
-	dm_list_iterate_items(lvl, &vg->lvs)
-		if (lv_is_cow(lvl->lv))
-			num_snapshots++;
-
-	return num_snapshots;
-}
-
-unsigned vg_visible_lvs(const struct volume_group *vg)
-{
-	struct lv_list *lvl;
-	unsigned lv_count = 0;
-
-	dm_list_iterate_items(lvl, &vg->lvs) {
-		if (lv_is_visible(lvl->lv))
-			lv_count++;
-	}
-
-	return lv_count;
-}
-
 /*
  * Determine whether two vgs are compatible for merging.
  */
@@ -4472,79 +4127,6 @@
 	return 1;
 }
 
-uint32_t vg_seqno(const struct volume_group *vg)
-{
-	return vg->seqno;
-}
-
-uint64_t vg_status(const struct volume_group *vg)
-{
-	return vg->status;
-}
-
-uint64_t vg_size(const struct volume_group *vg)
-{
-	return (uint64_t) vg->extent_count * vg->extent_size;
-}
-
-uint64_t vg_free(const struct volume_group *vg)
-{
-	return (uint64_t) vg->free_count * vg->extent_size;
-}
-
-uint64_t vg_extent_size(const struct volume_group *vg)
-{
-	return (uint64_t) vg->extent_size;
-}
-
-uint64_t vg_extent_count(const struct volume_group *vg)
-{
-	return (uint64_t) vg->extent_count;
-}
-
-uint64_t vg_free_count(const struct volume_group *vg)
-{
-	return (uint64_t) vg->free_count;
-}
-
-uint64_t vg_pv_count(const struct volume_group *vg)
-{
-	return (uint64_t) vg->pv_count;
-}
-
-uint64_t vg_max_pv(const struct volume_group *vg)
-{
-	return (uint64_t) vg->max_pv;
-}
-
-uint64_t vg_max_lv(const struct volume_group *vg)
-{
-	return (uint64_t) vg->max_lv;
-}
-
-uint32_t vg_mda_count(const struct volume_group *vg)
-{
-	return dm_list_size(&vg->fid->metadata_areas_in_use) +
-		dm_list_size(&vg->fid->metadata_areas_ignored);
-}
-
-uint32_t vg_mda_used_count(const struct volume_group *vg)
-{
-       uint32_t used_count = 0;
-       struct metadata_area *mda;
-
-	/*
-	 * Ignored mdas could be on either list - the reason being the state
-	 * may have changed from ignored to un-ignored and we need to write
-	 * the state to disk.
-	 */
-       dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use)
-	       if (!mda_is_ignored(mda))
-		       used_count++;
-
-       return used_count;
-}
-
 uint64_t lv_size(const struct logical_volume *lv)
 {
 	return lv->size;
--- LVM2/lib/metadata/metadata.h	2010/08/26 12:08:19	1.218
+++ LVM2/lib/metadata/metadata.h	2010/09/30 13:04:56	1.219
@@ -378,11 +378,6 @@
 struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv);
 
 /*
- * Count snapshot LVs.
- */
-unsigned snapshot_count(const struct volume_group *vg);
-
-/*
  * Calculate readahead from underlying PV devices
  */
 void lv_calculate_readahead(const struct logical_volume *lv, uint32_t *read_ahead);
@@ -417,7 +412,5 @@
 int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton);
 
 uint64_t find_min_mda_size(struct dm_list *mdas);
-uint64_t vg_mda_size(const struct volume_group *vg);
-uint64_t vg_mda_free(const struct volume_group *vg);
 
 #endif


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

end of thread, other threads:[~2010-11-30 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-30 13:05 LVM2 include/.symlinks.in lib/Makefile.in lib/ wysochanski
  -- strict thread matches above, loose matches on Subject: below --
2010-11-30 11:53 mornfall
2010-09-30 13:05 wysochanski
2010-09-30 13:04 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).