Skip to contentSkip to conversation

LVM2/lib cache/lvmcache.c format1/format1.c fo ...

PATCH [email protected] 1 participant 1 message Feb 10, 2012

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall at sourceware.org 2012-02-10 02:53:05

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

Log message:
Keep a global (per-format) orphan_vg and keep any and all orphan PVs linked to it. Avoids the need for FMT_INSTANCE_PV and enables further simplifications. No functional change, internal refactor only.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.123&r2=1.124
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.141&r2=1.142
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.188&r2=1.189
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.227&r2=1.228
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.477&r2=1.478
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16

lib/cache/lvmcache.c +0 -2
@@ -1322,8 +1322,6 @@
 				  const char *vgname, const char *vgid,
 				  uint32_t vgstatus, const char *creation_host)
 {
-        log_error("lvmcache_update_vgname_and_id: %s -> %s", dev_name(info->dev), vgname);
-
 	if (!vgname && !info->vginfo) {
 		log_error(INTERNAL_ERROR "NULL vgname handed to cache");
 		/* FIXME Remove this */
lib/format1/format1.c +22 -0
@@ -546,6 +546,13 @@
 
 static void _format1_destroy(struct format_type *fmt)
 {
+	/* FIXME out of place, but the main (cmd) pool has been already
+	 * destroyed and touching the fid (also via release_vg) will crash the
+	 * program */
+	dm_hash_destroy(fmt->orphan_vg->hostnames);
+	dm_pool_destroy(fmt->orphan_vg->fid->mem);
+	dm_pool_destroy(fmt->orphan_vg->vgmem);
+
 	dm_free(fmt);
 }
 
@@ -570,6 +577,8 @@
 #endif
 {
 	struct format_type *fmt = dm_malloc(sizeof(*fmt));
+	struct format_instance_ctx fic;
+	struct format_instance *fid;
 
 	if (!fmt)
 		return_NULL;
@@ -596,6 +605,19 @@
 		return NULL;
 	}
 
+	if (!(fmt->orphan_vg = alloc_vg("text_orphan", cmd, fmt->orphan_vg_name))) {
+		log_error("Couldn't create lvm1 orphan VG.");
+		return NULL;
+	}
+	fic.type = FMT_INSTANCE_VG | 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))) {
+		log_error("Couldn't create lvm1 orphan VG format instance.");
+		return NULL;
+	}
+	vg_set_fid(fmt->orphan_vg, fid);
+
 	log_very_verbose("Initialised format: %s", fmt->name);
 
 	return fmt;
lib/format_pool/format_pool.c +22 -0
@@ -259,6 +259,13 @@
 
 static void _pool_destroy(struct format_type *fmt)
 {
+	/* FIXME out of place, but the main (cmd) pool has been already
+	 * destroyed and touching the fid (also via release_vg) will crash the
+	 * program */
+	dm_hash_destroy(fmt->orphan_vg->hostnames);
+	dm_pool_destroy(fmt->orphan_vg->fid->mem);
+	dm_pool_destroy(fmt->orphan_vg->vgmem);
+
 	dm_free(fmt);
 }
 
@@ -281,6 +288,8 @@
 #endif
 {
 	struct format_type *fmt = dm_malloc(sizeof(*fmt));
+	struct format_instance_ctx fic;
+	struct format_instance *fid;
 
 	if (!fmt) {
 		log_error("Unable to allocate format type structure for pool "
@@ -309,6 +318,19 @@
 		return NULL;
 	}
 
+	if (!(fmt->orphan_vg = alloc_vg("text_orphan", cmd, fmt->orphan_vg_name))) {
+		log_error("Couldn't create lvm1 orphan VG.");
+		return NULL;
+	}
+	fic.type = FMT_INSTANCE_VG | 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))) {
+		log_error("Couldn't create lvm1 orphan VG format instance.");
+		return NULL;
+	}
+	vg_set_fid(fmt->orphan_vg, fid);
+
 	log_very_verbose("Initialised format: %s", fmt->name);
 
 	return fmt;
lib/format_text/format-text.c +40 -23

116 lines not on this page · raw message

lib/metadata/metadata-exported.h +2 -4
@@ -178,6 +178,7 @@
 	const char *name;
 	const char *alias;
 	const char *orphan_vg_name;
+	struct volume_group *orphan_vg; /* Only one ever exists. */
 	uint32_t features;
 	void *library;
 	void *private;
@@ -237,10 +238,7 @@
 	/* FIXME: Try to use the index only. Remove these lists. */
 	struct dm_list metadata_areas_in_use;
 	struct dm_list metadata_areas_ignored;
-	union {
-		struct metadata_area **array;
-		struct dm_hash_table *hash;
-	} metadata_areas_index;
+	struct dm_hash_table *metadata_areas_index;
 
 	void *private;
 };
lib/metadata/metadata.c +23 -45

140 lines not on this page · raw message

lib/metadata/vg.c +1 -1
@@ -79,7 +79,7 @@
 
 void release_vg(struct volume_group *vg)
 {
-	if (!vg)
+	if (!vg || (vg->fid && vg == vg->fid->fmt->orphan_vg))
 		return;
 
 	/* Check if there are any vginfo holders */