public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/lib metadata/metadata-exported.h metadata ...
@ 2012-02-12 23:01 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2012-02-12 23:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2012-02-12 23:01:20

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	lib/cache      : lvmcache.c 
	lib/format1    : format1.c 
	lib/format_pool: format_pool.c 
	lib/format_text: archive.c archiver.c format-text.c 

Log message:
	FMT_INSTANCE_VG is redundant now

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.229&r2=1.230
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.479&r2=1.480
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archive.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.189&r2=1.190

--- LVM2/lib/metadata/metadata-exported.h	2012/02/12 22:37:24	1.229
+++ LVM2/lib/metadata/metadata-exported.h	2012/02/12 23:01:19	1.230
@@ -199,20 +199,15 @@
 #define pvseg_is_allocated(pvseg) ((pvseg)->lvseg)
 
 /*
- * These flags define the type of the format instance to be created.
- * There used to be a PV-based type, but all are now VG-based.
- * We can further control the format_instance initialisation and functionality
- * by using the other flags. Today, the primary role of the format_instance
- * is to temporarily store metadata area information we are working with. More
- * flags can be defined to cover even more functionality in the future...
+ * Properties of each format instance type.
+ * The primary role of the format_instance is to temporarily store metadata
+ * area information we are working with.
  */
 
-/* VG-based format instance */
-#define FMT_INSTANCE_VG			0x00000001U
-
 /* Include any existing PV mdas during format_instance initialisation */
 #define FMT_INSTANCE_MDAS		0x00000002U
 
+/* FIXME Define auxiliary here! */
 /* Include any auxiliary mdas during format_instance intialisation */
 #define FMT_INSTANCE_AUX_MDAS		0x00000004U
 
--- LVM2/lib/metadata/metadata.c	2012/02/12 20:19:39	1.479
+++ LVM2/lib/metadata/metadata.c	2012/02/12 23:01:19	1.480
@@ -956,7 +956,7 @@
 
 	vg->pv_count = 0;
 
-	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+	fic.type = FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = vg_name;
 	fic.context.vg_ref.vg_id = NULL;
 	if (!(fid = cmd->fmt->ops->create_instance(cmd->fmt, &fic))) {
@@ -2940,7 +2940,7 @@
 		use_precommitted = 0;
 
 	/* create format instance with appropriate metadata area */
-	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+	fic.type = FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = vgname;
 	fic.context.vg_ref.vg_id = vgid;
 	if (!(fid = fmt->ops->create_instance(fmt, &fic))) {
@@ -3120,7 +3120,7 @@
 			use_precommitted = 0;
 
 		/* create format instance with appropriate metadata area */
-		fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+		fic.type = FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
 		fic.context.vg_ref.vg_name = vgname;
 		fic.context.vg_ref.vg_id = vgid;
 		if (!(fid = fmt->ops->create_instance(fmt, &fic))) {
@@ -4207,14 +4207,12 @@
 		return 1;
 
 	/* Add metadata area to index. */
-	if (fid->type & FMT_INSTANCE_VG) {
-		if (!_convert_key_to_string(key, key_len, sub_key,
-					    full_key, sizeof(full_key)))
-		return_0;
+	if (!_convert_key_to_string(key, key_len, sub_key,
+				    full_key, sizeof(full_key)))
+	return_0;
 
-		dm_hash_insert(fid->metadata_areas_index,
-			       full_key, mda);
-	}
+	dm_hash_insert(fid->metadata_areas_index,
+		       full_key, mda);
 
 	return 1;
 }
@@ -4245,13 +4243,11 @@
 	struct metadata_area *mda = NULL;
 
 
-	if (fid->type & FMT_INSTANCE_VG) {
-		if (!_convert_key_to_string(key, key_len, sub_key,
-					    full_key, sizeof(full_key)))
-			return_NULL;
-		mda = (struct metadata_area *) dm_hash_lookup(fid->metadata_areas_index,
-							      full_key);
-	}
+	if (!_convert_key_to_string(key, key_len, sub_key,
+				    full_key, sizeof(full_key)))
+		return_NULL;
+	mda = (struct metadata_area *) dm_hash_lookup(fid->metadata_areas_index,
+						      full_key);
 
 	return mda;
 }
@@ -4278,13 +4274,11 @@
 
 		mda = mda_indexed;
 
-		if (fid->type & FMT_INSTANCE_VG) {
-			if (!_convert_key_to_string(key, key_len, sub_key,
-					    full_key, sizeof(full_key)))
-				return_0;
+		if (!_convert_key_to_string(key, key_len, sub_key,
+				    full_key, sizeof(full_key)))
+			return_0;
 
-			dm_hash_remove(fid->metadata_areas_index, full_key);
-		}
+		dm_hash_remove(fid->metadata_areas_index, full_key);
 	}
 
 	dm_list_del(&mda->list);
--- LVM2/lib/cache/lvmcache.c	2012/02/10 02:53:03	1.124
+++ LVM2/lib/cache/lvmcache.c	2012/02/12 23:01:19	1.125
@@ -707,7 +707,7 @@
 	if ((vg = vginfo->cached_vg))
 		goto out;
 
-	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+	fic.type = FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = vginfo->vgname;
 	fic.context.vg_ref.vg_id = vgid;
 	if (!(fid = vginfo->fmt->ops->create_instance(vginfo->fmt, &fic)))
--- LVM2/lib/format1/format1.c	2012/02/10 02:53:04	1.142
+++ LVM2/lib/format1/format1.c	2012/02/12 23:01:19	1.143
@@ -609,7 +609,7 @@
 		log_error("Couldn't create lvm1 orphan VG.");
 		return NULL;
 	}
-	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
+	fic.type = FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = fmt->orphan_vg_name;
 	fic.context.vg_ref.vg_id = NULL;
 	if (!(fid = _format1_create_instance(fmt, &fic))) {
--- LVM2/lib/format_pool/format_pool.c	2012/02/10 02:53:04	1.47
+++ LVM2/lib/format_pool/format_pool.c	2012/02/12 23:01:19	1.48
@@ -322,7 +322,7 @@
 		log_error("Couldn't create lvm1 orphan VG.");
 		return NULL;
 	}
-	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
+	fic.type = FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = fmt->orphan_vg_name;
 	fic.context.vg_ref.vg_id = NULL;
 	if (!(fid = _pool_create_instance(fmt, &fic))) {
--- LVM2/lib/format_text/archive.c	2011/08/10 20:25:30	1.44
+++ LVM2/lib/format_text/archive.c	2012/02/12 23:01:19	1.45
@@ -310,7 +310,7 @@
 	log_print(" ");
 	log_print("File:\t\t%s", af->path);
 
-	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
+	fic.type = FMT_INSTANCE_PRIVATE_MDAS;
 	fic.context.private = &tc;
 	if (!(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, &fic))) {
 		log_error("Couldn't create text instance object.");
--- LVM2/lib/format_text/archiver.c	2012/02/08 12:50:10	1.49
+++ LVM2/lib/format_text/archiver.c	2012/02/12 23:01:19	1.50
@@ -279,7 +279,7 @@
 				  .desc = cmd->cmd_line};
 	struct metadata_area *mda;
 
-	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
+	fic.type = FMT_INSTANCE_PRIVATE_MDAS;
 	fic.context.private = &tc;
 	if (!(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, &fic))) {
 		log_error("Couldn't create text format object.");
@@ -312,7 +312,7 @@
 	 */
 
 	/* Attempt to write out using currently active format */
-	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
+	fic.type = FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = vg->name;
 	fic.context.vg_ref.vg_id = NULL;
 	if (!(fid = cmd->fmt->ops->create_instance(cmd->fmt, &fic))) {
@@ -409,7 +409,7 @@
 
 	log_verbose("Creating volume group backup \"%s\" (seqno %u).", file, vg->seqno);
 
-	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
+	fic.type = FMT_INSTANCE_PRIVATE_MDAS;
 	fic.context.private = &tc;
 	if (!(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, &fic))) {
 		log_error("Couldn't create backup object.");
--- LVM2/lib/format_text/format-text.c	2012/02/10 02:53:05	1.189
+++ LVM2/lib/format_text/format-text.c	2012/02/12 23:01:19	1.190
@@ -1084,7 +1084,7 @@
 
 				/* FIXME stat file to see if it's changed */
 				/* FIXME: Check this fid is OK! */
-				fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
+				fic.type = FMT_INSTANCE_PRIVATE_MDAS;
 				fic.context.private = NULL;
 				fid = _text_create_text_instance(fmt, &fic);
 				if ((vg = _vg_read_file_name(fid, scanned_vgname,
@@ -1513,7 +1513,7 @@
 static void _text_destroy_instance(struct format_instance *fid)
 {
 	if (--fid->ref_count <= 1) {
-		if (fid->type & FMT_INSTANCE_VG && fid->metadata_areas_index)
+		if (fid->metadata_areas_index)
 			dm_hash_destroy(fid->metadata_areas_index);
 		dm_pool_destroy(fid->mem);
 	}
@@ -1671,12 +1671,6 @@
 	return 1;
 }
 
-static int _create_pv_text_instance(struct format_instance *fid,
-                                    const struct format_instance_ctx *fic)
-{
-	return 0; /* just fail */
-}
-
 static void *_create_text_context(struct dm_pool *mem, struct text_context *tc)
 {
 	struct text_context *new_tc;
@@ -2173,8 +2167,7 @@
 	if (!(fid = alloc_fid(fmt, fic)))
 		return_NULL;
 
-	if (fid->type & FMT_INSTANCE_VG ? _create_vg_text_instance(fid, fic) :
-					  _create_pv_text_instance(fid, fic))
+	if (_create_vg_text_instance(fid, fic))
 		return fid;
 
 	dm_pool_destroy(fid->mem);
@@ -2342,7 +2335,7 @@
 		return NULL;
 	}
 
-	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
+	fic.type = FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = fmt->orphan_vg_name;
 	fic.context.vg_ref.vg_id = NULL;
 	if (!(fid = _text_create_text_instance(fmt, &fic))) {


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

* LVM2/lib metadata/metadata-exported.h metadata ...
@ 2011-05-07 13:32 mornfall
  0 siblings, 0 replies; 5+ messages in thread
From: mornfall @ 2011-05-07 13:32 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2011-05-07 13:32:06

Modified files:
	lib/metadata   : metadata-exported.h metadata.c metadata.h 
	lib/mirror     : mirrored.c 

Log message:
	Make vg_mark_partial_lvs also clear existing PARTIAL_LV flags, so it can be
	issued repeatedly on the same VG, keeping the PARTIAL_LV flags up to date.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.190&r2=1.191
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.455&r2=1.456
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.242&r2=1.243
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87

--- LVM2/lib/metadata/metadata-exported.h	2011/04/28 20:30:00	1.190
+++ LVM2/lib/metadata/metadata-exported.h	2011/05/07 13:32:05	1.191
@@ -763,6 +763,8 @@
 int lv_has_unknown_segments(const struct logical_volume *lv);
 int vg_has_unknown_segments(const struct volume_group *vg);
 
+int vg_mark_partial_lvs(struct volume_group *vg, int clear);
+
 struct vgcreate_params {
 	const char *vg_name;
 	uint32_t extent_size;
--- LVM2/lib/metadata/metadata.c	2011/04/21 13:13:40	1.455
+++ LVM2/lib/metadata/metadata.c	2011/05/07 13:32:05	1.456
@@ -2138,11 +2138,16 @@
  * propagated transitively, so LVs referencing other LVs are marked
  * partial as well, if any of their referenced LVs are marked partial.
  */
-int vg_mark_partial_lvs(struct volume_group *vg)
+int vg_mark_partial_lvs(struct volume_group *vg, int clear)
 {
+	struct lv_list *lvl;
+
+	if (clear)
+		dm_list_iterate_items(lvl, &vg->lvs)
+			lvl->lv->status &= ~PARTIAL_LV;
+
 	if (!_lv_postorder_vg(vg, _lv_mark_if_partial_single, NULL))
 		return_0;
-
 	return 1;
 }
 
@@ -2825,7 +2830,7 @@
 		if (vg_missing_pv_count(correct_vg)) {
 			log_verbose("There are %d physical volumes missing.",
 				    vg_missing_pv_count(correct_vg));
-			vg_mark_partial_lvs(correct_vg);
+			vg_mark_partial_lvs(correct_vg, 1);
 		}
 		return correct_vg;
 	} else {
@@ -3179,7 +3184,7 @@
 	if (vg_missing_pv_count(correct_vg)) {
 		log_verbose("There are %d physical volumes missing.",
 			    vg_missing_pv_count(correct_vg));
-		vg_mark_partial_lvs(correct_vg);
+		vg_mark_partial_lvs(correct_vg, 1);
 	}
 
 	if ((correct_vg->status & PVMOVE) && !pvmove_mode()) {
--- LVM2/lib/metadata/metadata.h	2011/03/11 14:50:15	1.242
+++ LVM2/lib/metadata/metadata.h	2011/05/07 13:32:05	1.243
@@ -471,7 +471,6 @@
 struct physical_volume *pv_by_path(struct cmd_context *cmd, const char *pv_name);
 int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
 		 struct physical_volume *pv);
-int vg_mark_partial_lvs(struct volume_group *vg);
 int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton);
 
 uint64_t find_min_mda_size(struct dm_list *mdas);
--- LVM2/lib/mirror/mirrored.c	2011/04/29 00:21:14	1.86
+++ LVM2/lib/mirror/mirrored.c	2011/05/07 13:32:06	1.87
@@ -343,7 +343,7 @@
 
 	/* update PARTIAL_LV flags across the VG */
 	if (failed)
-		vg_mark_partial_lvs(lv->vg);
+		vg_mark_partial_lvs(lv->vg, 0);
 
 	return 1;
 }


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

* LVM2/lib metadata/metadata-exported.h metadata ...
@ 2010-06-28 20:33 wysochanski
  0 siblings, 0 replies; 5+ messages in thread
From: wysochanski @ 2010-06-28 20:33 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-28 20:33:44

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	lib/report     : columns.h report.c 

Log message:
	Define new functions and vgs/pvs fields related to mda ignore.
	
	Define a new pvs field, pv_mda_used_count, and a new vgs field,
	vg_mda_used_count to match the existing pv_mda_count and vg_mda_count.
	These new fields count the number of mdas that have the 'ignored' bit
	clear (they are in use on the PV / VG).  Also define various supporting
	functions to implement the counting as well as setting the ignored
	flag and determining if an mda is ignored.  These high level functions
	call into the lower level location independent mda ignore functions
	defined by earlier patches.
	
	Note that counting ignored mdas in a vg requires traversing both lists
	and checking for the ignored bit on the mda.  The count of 'ignored'
	mdas then is defined by having the bit set, not by which list the mda
	is on.  The list does determine whether LVM actually does read/write to
	the mda, though we must count the bits in order to return accurate numbers
	for the various counts.  Also, pv_mda_set_ignored must search both vg
	lists for ignored mda.  If the state changes and needs to be committed
	to disk, the ignored mda will be on the non-ignored list.
	
	Note also in pv_mda_set_ignored(), we must properly manage the mda lists.
	If we change the ignored state of an mda, we must change any mdas on
	vg->fid->metadata_areas that correspond to this pv.  Also, we may
	need to allocate a copy of the mda, as is done when fid->metadata_areas
	is populated from _vg_read(), if we are un-ignoring an ignored mda.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.154&r2=1.155
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.351&r2=1.352
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/columns.h.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120

--- LVM2/lib/metadata/metadata-exported.h	2010/06/28 20:33:23	1.154
+++ LVM2/lib/metadata/metadata-exported.h	2010/06/28 20:33:44	1.155
@@ -863,6 +863,8 @@
 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);
 
 uint64_t lv_size(const struct logical_volume *lv);
 
@@ -878,6 +880,7 @@
 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);
 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/06/28 20:33:23	1.351
+++ LVM2/lib/metadata/metadata.c	2010/06/28 20:33:44	1.352
@@ -3955,6 +3955,83 @@
 	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 ignored)
+{
+	struct lvmcache_info *info;
+	struct metadata_area *mda, *vg_mda, *tmda;
+	struct dm_list *vg_mdas_in_use, *vg_mdas_ignored;
+
+	info = info_from_pvid((const char *)&pv->id.uuid, 0);
+	if (!info)
+		return_0;
+
+	if (is_orphan(pv)) {
+		dm_list_iterate_items(mda, &info->mdas) {
+			mda_set_ignored(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 metadata - volume group "
+			  "needs at least one physical volume with "
+			  "metadata areas in use.\n");
+		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) && !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, 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)) {
+				mda_set_ignored(vg_mda, ignored);
+				/* don't move mda - needs written to disk */
+			}
+		}
+		mda_set_ignored(mda, ignored);
+	}
+	return 1;
+}
+
 uint32_t vg_seqno(const struct volume_group *vg)
 {
 	return vg->seqno;
@@ -4007,7 +4084,30 @@
 
 uint32_t vg_mda_count(const struct volume_group *vg)
 {
-	return dm_list_size(&vg->fid->metadata_areas_in_use);
+	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++;
+       }
+       dm_list_iterate_items(mda, &vg->fid->metadata_areas_ignored) {
+	       if (!mda_is_ignored(mda))
+		       used_count++;
+       }
+
+       return used_count;
 }
 
 uint64_t lv_size(const struct logical_volume *lv)
--- LVM2/lib/report/columns.h	2010/06/23 12:32:08	1.39
+++ LVM2/lib/report/columns.h	2010/06/28 20:33:44	1.40
@@ -93,6 +93,7 @@
 FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count", "Total number of allocated Physical Extents.")
 FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, "pv_tags", "Tags, if any.")
 FIELD(PVS, pv, NUM, "#PMda", id, 5, pvmdas, "pv_mda_count", "Number of metadata areas on this device.")
+FIELD(PVS, pv, NUM, "#PMdaUse", id, 8, pvmdasused, "pv_mda_used_count", "Number of metadata areas in use on this device.")
 
 FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt", "Type of metadata.")
 FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid", "Unique identifier.")
@@ -112,6 +113,7 @@
 FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno", "Revision number of internal metadata.  Incremented whenever it changes.")
 FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, "vg_tags", "Tags, if any.")
 FIELD(VGS, vg, NUM, "#VMda", cmd, 5, vgmdas, "vg_mda_count", "Number of metadata areas in use by this VG.")
+FIELD(VGS, vg, NUM, "#VMdaUse", cmd, 8, vgmdasused, "vg_mda_used_count", "Number of metadata areas in use on this VG.")
 FIELD(VGS, vg, NUM, "VMdaFree", cmd, 9, vgmdafree, "vg_mda_free", "Free metadata area space for this VG in current units.")
 FIELD(VGS, vg, NUM, "VMdaSize", cmd, 9, vgmdasize, "vg_mda_size", "Size of smallest metadata area for this VG in current units.")
 
--- LVM2/lib/report/report.c	2010/06/28 20:33:23	1.119
+++ LVM2/lib/report/report.c	2010/06/28 20:33:44	1.120
@@ -880,6 +880,19 @@
 	return _uint32_disp(rh, mem, field, &count, private);
 }
 
+static int _pvmdasused_disp(struct dm_report *rh, struct dm_pool *mem,
+			     struct dm_report_field *field,
+			     const void *data, void *private)
+{
+	uint32_t count;
+	const struct physical_volume *pv =
+	    (const struct physical_volume *) data;
+
+	count = pv_mda_used_count(pv);
+
+	return _uint32_disp(rh, mem, field, &count, private);
+}
+
 static int _vgmdas_disp(struct dm_report *rh, struct dm_pool *mem,
 			struct dm_report_field *field,
 			const void *data, void *private)
@@ -892,6 +905,18 @@
 	return _uint32_disp(rh, mem, field, &count, private);
 }
 
+static int _vgmdasused_disp(struct dm_report *rh, struct dm_pool *mem,
+			     struct dm_report_field *field,
+			     const void *data, void *private)
+{
+	const struct volume_group *vg = (const struct volume_group *) data;
+	uint32_t count;
+
+	count = vg_mda_used_count(vg);
+
+	return _uint32_disp(rh, mem, field, &count, private);
+}
+
 static int _pvmdafree_disp(struct dm_report *rh, struct dm_pool *mem,
 			   struct dm_report_field *field,
 			   const void *data, void *private)


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

* LVM2/lib metadata/metadata-exported.h metadata ...
@ 2009-10-31 17:26 wysochanski
  0 siblings, 0 replies; 5+ messages in thread
From: wysochanski @ 2009-10-31 17:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-10-31 17:26:14

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	lib/report     : report.c 

Log message:
	Add vg_mda_count library function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.117&r2=1.118
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.291&r2=1.292
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.105&r2=1.106

--- LVM2/lib/metadata/metadata-exported.h	2009/10/16 17:41:52	1.117
+++ LVM2/lib/metadata/metadata-exported.h	2009/10/31 17:26:13	1.118
@@ -730,6 +730,7 @@
 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);
 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	2009/10/16 17:41:52	1.291
+++ LVM2/lib/metadata/metadata.c	2009/10/31 17:26:13	1.292
@@ -3611,6 +3611,11 @@
 	return (uint64_t) vg->max_lv;
 }
 
+uint32_t vg_mda_count(const struct volume_group *vg)
+{
+	return dm_list_size(&vg->fid->metadata_areas);
+}
+
 uint64_t lv_size(const struct logical_volume *lv)
 {
 	return lv->size;
--- LVM2/lib/report/report.c	2009/10/26 10:01:57	1.105
+++ LVM2/lib/report/report.c	2009/10/31 17:26:14	1.106
@@ -870,7 +870,7 @@
 	const struct volume_group *vg = (const struct volume_group *) data;
 	uint32_t count;
 
-	count = dm_list_size(&vg->fid->metadata_areas);
+	count = vg_mda_count(vg);
 
 	return _uint32_disp(rh, mem, field, &count, private);
 }


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

* LVM2/lib metadata/metadata-exported.h metadata ...
@ 2009-07-26 12:41 wysochanski
  0 siblings, 0 replies; 5+ messages in thread
From: wysochanski @ 2009-07-26 12:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 12:41:09

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	lib/report     : report.c 

Log message:
	Refactor a few report field calculations into separate functions.
	
	For liblvm 'get' functions, we should share code with the reporting functions.
	This means we need common code to return the values for the fields.
	In this patch we refactor a few of the fields needed in liblvm.
	Unfortunately, for the simple fields that do derefernces of structure
	members (for example, vg_extent_count), we cannot call the common function
	from the reporting infrastructure without more refactoring.  The reason is
	that the dereference of the simple fields is done deep inside the reporting
	code (to get the generic "data" pointer), and the display function is a
	generic 'size32' function.  We can fix these issues later with more
	refactoring.
	
	Should be no functional change and the testsuite should cover any possible
	regressions.  The only fields in the report affected by this patch are:
	vg_size, vg_free, and pv_mda_count.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.101&r2=1.102
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.267&r2=1.268
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100

--- LVM2/lib/metadata/metadata-exported.h	2009/07/26 02:34:09	1.101
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/26 12:41:09	1.102
@@ -693,9 +693,18 @@
 uint64_t pv_pe_start(const pv_t *pv);
 uint32_t pv_pe_count(const pv_t *pv);
 uint32_t pv_pe_alloc_count(const pv_t *pv);
+uint32_t pv_mda_count(const pv_t *pv);
+
+uint64_t lv_size(const lv_t *lv);
 
 int vg_missing_pv_count(const vg_t *vg);
 uint32_t vg_status(const vg_t *vg);
+uint64_t vg_size(const vg_t *vg);
+uint64_t vg_free(const vg_t *vg);
+uint64_t vg_extent_size(const vg_t *vg);
+uint64_t vg_extent_count(const vg_t *vg);
+uint64_t vg_free_count(const vg_t *vg);
+uint64_t vg_pv_count(const vg_t *vg);
 #define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
 
 struct vgcreate_params {
--- LVM2/lib/metadata/metadata.c	2009/07/26 02:34:09	1.267
+++ LVM2/lib/metadata/metadata.c	2009/07/26 12:41:09	1.268
@@ -3364,11 +3364,54 @@
 	return pv_field(pv, pe_alloc_count);
 }
 
+uint32_t pv_mda_count(const pv_t *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 vg_status(const vg_t *vg)
 {
 	return vg->status;
 }
 
+uint64_t vg_size(const vg_t *vg)
+{
+	return (uint64_t) vg->extent_count * vg->extent_size;
+}
+
+uint64_t vg_free(const vg_t *vg)
+{
+	return (uint64_t) vg->free_count * vg->extent_size;
+}
+
+uint64_t vg_extent_size(const vg_t *vg)
+{
+	return (uint64_t) vg->extent_size;
+}
+
+uint64_t vg_extent_count(const vg_t *vg)
+{
+	return (uint64_t) vg->extent_count;
+}
+
+uint64_t vg_free_count(const vg_t *vg)
+{
+	return (uint64_t) vg->free_count;
+}
+
+uint64_t vg_pv_count(const vg_t *vg)
+{
+	return (uint64_t) vg->pv_count;
+}
+
+uint64_t lv_size(const lv_t *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
--- LVM2/lib/report/report.c	2009/05/13 21:27:44	1.99
+++ LVM2/lib/report/report.c	2009/07/26 12:41:09	1.100
@@ -672,7 +672,7 @@
 	const struct volume_group *vg = (const struct volume_group *) data;
 	uint64_t size;
 
-	size = (uint64_t) vg->extent_count * vg->extent_size;
+	size = (uint64_t) vg_size(vg);
 
 	return _size64_disp(rh, mem, field, &size, private);
 }
@@ -812,7 +812,7 @@
 	const struct volume_group *vg = (const struct volume_group *) data;
 	uint64_t freespace;
 
-	freespace = (uint64_t) vg->free_count * vg->extent_size;
+	freespace = (uint64_t) vg_free(vg);
 
 	return _size64_disp(rh, mem, field, &freespace, private);
 }
@@ -853,12 +853,11 @@
 			struct dm_report_field *field,
 			const void *data, void *private)
 {
-	struct lvmcache_info *info;
 	uint32_t count;
-	const char *pvid = (const char *)(&((struct id *) data)->uuid);
+	const struct physical_volume *pv =
+	    (const struct physical_volume *) data;
 
-	info = info_from_pvid(pvid, 0);
-	count = info ? dm_list_size(&info->mdas) : 0;
+	count = pv_mda_count(pv);
 
 	return _uint32_disp(rh, mem, field, &count, private);
 }


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

end of thread, other threads:[~2012-02-12 23:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-12 23:01 LVM2/lib metadata/metadata-exported.h metadata agk
  -- strict thread matches above, loose matches on Subject: below --
2011-05-07 13:32 mornfall
2010-06-28 20:33 wysochanski
2009-10-31 17:26 wysochanski
2009-07-26 12:41 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).