public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/format_text/export.c lib/ ...
@ 2012-01-19 15:31 zkabelac
  0 siblings, 0 replies; 8+ messages in thread
From: zkabelac @ 2012-01-19 15:31 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-01-19 15:31:46

Modified files:
	.              : WHATS_NEW 
	lib/format_text: export.c import_vsn1.c 
	lib/metadata   : lv.c lv.h lv_manip.c vg.c vg.h 

Log message:
	Add support to keep info about creation time and host for each LV
	
	Basic support to keep info when the LV was created.
	Host and time is stored into LV mda section.
	
	FIXME: Current version doesn't support configurable string via lvm.conf
	and used fixed version strftime "%Y-%m-%d %T %z".

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2222&r2=1.2223
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.84&r2=1.85
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.h.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.341&r2=1.342
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.h.diff?cvsroot=lvm2&r1=1.16&r2=1.17

--- LVM2/WHATS_NEW	2012/01/12 18:29:07	1.2222
+++ LVM2/WHATS_NEW	2012/01/19 15:31:45	1.2223
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Keep into about creation host and time for each logical volume.
   Make error message hit when preallocated memlock memory exceeded clearer.
   Use R lv_attr to indicate read-only activation of non-read-only device in lvs.
   Show read-only activation override in lvdisplay & add 4 to perms in -c.
--- LVM2/lib/format_text/export.c	2011/09/01 10:25:22	1.84
+++ LVM2/lib/format_text/export.c	2012/01/19 15:31:45	1.85
@@ -579,6 +579,8 @@
 	struct lv_segment *seg;
 	char buffer[4096];
 	int seg_count;
+	struct tm *local_tm;
+	time_t ts;
 
 	outnl(f);
 	outf(f, "%s {", lv->name);
@@ -596,6 +598,19 @@
 	if (!_out_tags(f, &lv->tags))
 		return_0;
 
+	if (lv->timestamp) {
+		ts = (time_t)lv->timestamp;
+		strncpy(buffer, "# ", sizeof(buffer));
+		if (!(local_tm = localtime(&ts)) ||
+		    !strftime(buffer + 2, sizeof(buffer) - 2,
+			      "%Y-%m-%d %T %z", local_tm))
+			buffer[0] = 0;
+
+		outf(f, "creation_host = \"%s\"", lv->hostname);
+		outfc(f, buffer, "creation_time = %" PRIu64,
+		      lv->timestamp);
+	}
+
 	if (lv->alloc != ALLOC_INHERIT)
 		outf(f, "allocation_policy = \"%s\"",
 		     get_alloc_string(lv->alloc));
--- LVM2/lib/format_text/import_vsn1.c	2012/01/19 15:17:46	1.97
+++ LVM2/lib/format_text/import_vsn1.c	2012/01/19 15:31:45	1.98
@@ -494,6 +494,8 @@
 	struct logical_volume *lv;
 	const char *lv_alloc;
 	const struct dm_config_value *cv;
+	const char *hostname;
+	uint64_t timestamp = 0;
 
 	if (!(lv = alloc_lv(mem)))
 		return_0;
@@ -512,6 +514,23 @@
 		return 0;
 	}
 
+	if (dm_config_has_node(lvn, "creation_time")) {
+		if (!_read_uint64(lvn, "creation_time", &timestamp)) {
+			log_error("Invalid creation_time for logical volume %s.",
+				  lv->name);
+			return 0;
+		}
+		if (!dm_config_get_str(lvn, "creation_host", &hostname)) {
+			log_error("Couldn't read creation_host for logical volume %s.",
+				  lv->name);
+			return 0;
+		}
+	} else if (dm_config_has_node(lvn, "creation_host")) {
+		log_error("Missing creation_time for logical volume %s.",
+			  lv->name);
+		return 0;
+	}
+
 	lv->alloc = ALLOC_INHERIT;
 	if (dm_config_get_str(lvn, "allocation_policy", &lv_alloc)) {
 		lv->alloc = get_alloc_from_string(lv_alloc);
@@ -548,7 +567,13 @@
 	if (!dm_hash_insert(lv_hash, lv->name, lv))
 		return_0;
 
-	return link_lv_to_vg(vg, lv);
+	if (!link_lv_to_vg(vg, lv))
+		return_0;
+
+	if (timestamp && !lv_set_creation(lv, hostname, timestamp))
+		return_0;
+
+	return 1;
 }
 
 static int _read_lvsegs(struct format_instance *fid __attribute__((unused)),
--- LVM2/lib/metadata/lv.c	2012/01/12 16:58:44	1.30
+++ LVM2/lib/metadata/lv.c	2012/01/19 15:31:45	1.31
@@ -21,6 +21,12 @@
 #include "segtype.h"
 #include "str_list.h"
 
+#include <time.h>
+#include <sys/utsname.h>
+
+static struct utsname _utsname;
+static int _utsinit = 0;
+
 static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
 			     int range_format)
 {
@@ -469,3 +475,58 @@
 out:
 	return repstr;
 }
+
+int lv_set_creation(struct logical_volume *lv,
+		    const char *hostname, uint64_t timestamp)
+{
+	const char *hn;
+
+	if (!hostname) {
+		if (!_utsinit) {
+			if (uname(&_utsname)) {
+				log_error("uname failed: %s", strerror(errno));
+				memset(&_utsname, 0, sizeof(_utsname));
+			}
+
+			_utsinit = 1;
+		}
+
+		hostname = _utsname.nodename;
+	}
+
+	if (!(hn = dm_hash_lookup(lv->vg->hostnames, hostname))) {
+		if (!(hn = dm_pool_strdup(lv->vg->vgmem, hostname))) {
+			log_error("Failed to duplicate hostname");
+			return 0;
+		}
+
+		if (!dm_hash_insert(lv->vg->hostnames, hostname, (void*)hn))
+			return_0;
+	}
+
+	lv->hostname = hn;
+	lv->timestamp = timestamp ? : time(NULL);
+
+	return 1;
+}
+
+char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv)
+{
+	char buffer[50];
+	struct tm *local_tm;
+	time_t ts = (time_t)lv->timestamp;
+
+	if (!ts ||
+	    !(local_tm = localtime(&ts)) ||
+	    /* FIXME: make this lvm.conf configurable */
+	    !strftime(buffer, sizeof(buffer),
+		      "%Y-%m-%d %T %z", local_tm))
+		buffer[0] = 0;
+
+	return dm_pool_strdup(mem, buffer);
+}
+
+char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv)
+{
+	return dm_pool_strdup(mem, lv->hostname ? : "");
+}
--- LVM2/lib/metadata/lv.h	2011/09/09 00:54:49	1.21
+++ LVM2/lib/metadata/lv.h	2012/01/19 15:31:45	1.22
@@ -46,6 +46,9 @@
 	struct dm_list segments;
 	struct dm_list tags;
 	struct dm_list segs_using_this_lv;
+
+	uint64_t timestamp;
+	const char *hostname;
 };
 
 uint64_t lv_size(const struct logical_volume *lv);
@@ -71,5 +74,8 @@
 char *lvseg_tags_dup(const struct lv_segment *seg);
 char *lvseg_devices(struct dm_pool *mem, const struct lv_segment *seg);
 char *lvseg_seg_pe_ranges(struct dm_pool *mem, const struct lv_segment *seg);
-
+char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv);
+char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv);
+int lv_set_creation(struct logical_volume *lv,
+		    const char *hostname, uint64_t timestamp);
 #endif /* _LVM_LV_H */
--- LVM2/lib/metadata/lv_manip.c	2012/01/19 15:23:50	1.341
+++ LVM2/lib/metadata/lv_manip.c	2012/01/19 15:31:45	1.342
@@ -2993,6 +2993,9 @@
 
 	if (!link_lv_to_vg(vg, lv))
 		goto_bad;
+
+	if (!lv_set_creation(lv, NULL, 0))
+		goto_bad;
  
 	if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv))
 		goto_bad;
--- LVM2/lib/metadata/vg.c	2011/11/04 22:49:53	1.13
+++ LVM2/lib/metadata/vg.c	2012/01/19 15:31:45	1.14
@@ -44,6 +44,12 @@
 	vg->vgmem = vgmem;
 	vg->alloc = ALLOC_NORMAL;
 
+	if (!(vg->hostnames = dm_hash_create(16))) {
+		log_error("Failed to allocate VG hostname hashtable.");
+		dm_pool_destroy(vgmem);
+		return NULL;
+	}
+
 	dm_list_init(&vg->pvs);
 	dm_list_init(&vg->pvs_to_create);
 	dm_list_init(&vg->lvs);
@@ -67,6 +73,7 @@
 
 	log_debug("Freeing VG %s at %p.", vg->name, vg);
 
+	dm_hash_destroy(vg->hostnames);
 	dm_pool_destroy(vg->vgmem);
 }
 
--- LVM2/lib/metadata/vg.h	2011/11/04 22:49:53	1.16
+++ LVM2/lib/metadata/vg.h	2012/01/19 15:31:45	1.17
@@ -109,6 +109,8 @@
 	 */
 	uint32_t read_status;
 	uint32_t mda_copies; /* target number of mdas for this VG */
+
+	struct dm_hash_table *hostnames; /* map of creation hostnames */
 };
 
 struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,


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

* LVM2 ./WHATS_NEW lib/format_text/export.c lib/ ...
@ 2010-09-20 14:23 prajnoha
  0 siblings, 0 replies; 8+ messages in thread
From: prajnoha @ 2010-09-20 14:23 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2010-09-20 14:23:20

Modified files:
	.              : WHATS_NEW 
	lib/format_text: export.c import-export.h tags.c 

Log message:
	Use dynamic allocation for metadata's tag buffer (removes 4096 char. limit).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1729&r2=1.1730
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import-export.h.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/tags.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8

--- LVM2/WHATS_NEW	2010/09/09 13:13:12	1.1729
+++ LVM2/WHATS_NEW	2010/09/20 14:23:20	1.1730
@@ -1,5 +1,6 @@
 Version 2.02.74 - 
 ==================================
+  Use dynamic allocation for metadata's tag buffer (removes 4096 char. limit).
   Add random suffix to archive file names to prevent races when being created.
   Reinitialize archive and backup handling on toolcontext refresh.
   Fix opprobriously slow I/O to cluster mirrors created with --nosync.
--- LVM2/lib/format_text/export.c	2010/07/09 15:34:44	1.77
+++ LVM2/lib/format_text/export.c	2010/09/20 14:23:20	1.78
@@ -366,6 +366,7 @@
 static int _print_vg(struct formatter *f, struct volume_group *vg)
 {
 	char buffer[4096];
+	char *tag_buffer = NULL;
 
 	if (!id_write_format(&vg->id, buffer, sizeof(buffer)))
 		return_0;
@@ -378,9 +379,10 @@
 		return_0;
 
 	if (!dm_list_empty(&vg->tags)) {
-		if (!print_tags(&vg->tags, buffer, sizeof(buffer)))
+		if (!(tag_buffer = alloc_printed_tags(&vg->tags)))
 			return_0;
-		outf(f, "tags = %s", buffer);
+		outf(f, "tags = %s", tag_buffer);
+		dm_free(tag_buffer);
 	}
 
 	if (vg->system_id && *vg->system_id)
@@ -426,7 +428,7 @@
 	struct pv_list *pvl;
 	struct physical_volume *pv;
 	char buffer[4096];
-	char *buf;
+	char *buf, *tag_buffer = NULL;
 	const char *name;
 
 	outf(f, "physical_volumes {");
@@ -461,9 +463,10 @@
 			return_0;
 
 		if (!dm_list_empty(&pv->tags)) {
-			if (!print_tags(&pv->tags, buffer, sizeof(buffer)))
+			if (!(tag_buffer = alloc_printed_tags(&pv->tags)))
 				return_0;
-			outf(f, "tags = %s", buffer);
+			outf(f, "tags = %s", tag_buffer);
+			dm_free(tag_buffer);
 		}
 
 		outsize(f, pv->size, "dev_size = %" PRIu64, pv->size);
@@ -484,7 +487,7 @@
 static int _print_segment(struct formatter *f, struct volume_group *vg,
 			  int count, struct lv_segment *seg)
 {
-	char buffer[4096];
+	char *tag_buffer = NULL;
 
 	outf(f, "segment%u {", count);
 	_inc_indent(f);
@@ -497,9 +500,10 @@
 	outf(f, "type = \"%s\"", seg->segtype->name);
 
 	if (!dm_list_empty(&seg->tags)) {
-		if (!print_tags(&seg->tags, buffer, sizeof(buffer)))
+		if (!(tag_buffer = alloc_printed_tags(&seg->tags)))
 			return_0;
-		outf(f, "tags = %s", buffer);
+		outf(f, "tags = %s", tag_buffer);
+		dm_free(tag_buffer);
 	}
 
 	if (seg->segtype->ops->text_export &&
@@ -553,6 +557,7 @@
 {
 	struct lv_segment *seg;
 	char buffer[4096];
+	char *tag_buffer = NULL;
 	int seg_count;
 
 	outnl(f);
@@ -569,9 +574,10 @@
 		return_0;
 
 	if (!dm_list_empty(&lv->tags)) {
-		if (!print_tags(&lv->tags, buffer, sizeof(buffer)))
+		if (!(tag_buffer = alloc_printed_tags(&lv->tags)))
 			return_0;
-		outf(f, "tags = %s", buffer);
+		outf(f, "tags = %s", tag_buffer);
+		dm_free(tag_buffer);
 	}
 
 	if (lv->alloc != ALLOC_INHERIT)
--- LVM2/lib/format_text/import-export.h	2010/03/17 02:11:19	1.24
+++ LVM2/lib/format_text/import-export.h	2010/09/20 14:23:20	1.25
@@ -61,7 +61,7 @@
 int print_flags(uint64_t status, int type, char *buffer, size_t size);
 int read_flags(uint64_t *status, int type, struct config_value *cv);
 
-int print_tags(struct dm_list *tags, char *buffer, size_t size);
+char *alloc_printed_tags(struct dm_list *tags);
 int read_tags(struct dm_pool *mem, struct dm_list *tags, struct config_value *cv);
 
 int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp);
--- LVM2/lib/format_text/tags.c	2008/11/03 22:14:28	1.7
+++ LVM2/lib/format_text/tags.c	2010/09/20 14:23:20	1.8
@@ -19,29 +19,46 @@
 #include "str_list.h"
 #include "lvm-string.h"
 
-int print_tags(struct dm_list *tags, char *buffer, size_t size)
+char *alloc_printed_tags(struct dm_list *tags)
 {
 	struct str_list *sl;
 	int first = 1;
+	size_t size = 0;
+	char *buffer, *buf;
 
-	if (!emit_to_buffer(&buffer, &size, "["))
-		return_0;
+	dm_list_iterate_items(sl, tags)
+		/* '"' + tag + '"' + ',' + ' ' */
+		size += strlen(sl->str) + 4;
+	/* '[' + ']' + '\0' */
+	size += 3;
+
+	if (!(buffer = buf = dm_malloc(size))) {
+		log_error("Could not allocate memory for tag list buffer.");
+		return NULL;
+	}
+
+	if (!emit_to_buffer(&buf, &size, "["))
+		goto bad;
 
 	dm_list_iterate_items(sl, tags) {
 		if (!first) {
-			if (!emit_to_buffer(&buffer, &size, ", "))
-				return_0;
+			if (!emit_to_buffer(&buf, &size, ", "))
+				goto bad;
 		} else
 			first = 0;
 
-		if (!emit_to_buffer(&buffer, &size, "\"%s\"", sl->str))
-			return_0;
+		if (!emit_to_buffer(&buf, &size, "\"%s\"", sl->str))
+			goto bad;
 	}
 
-	if (!emit_to_buffer(&buffer, &size, "]"))
-		return_0;
+	if (!emit_to_buffer(&buf, &size, "]"))
+		goto bad;
 
-	return 1;
+	return buffer;
+
+bad:
+	dm_free(buffer);
+	return_NULL;
 }
 
 int read_tags(struct dm_pool *mem, struct dm_list *tags, struct config_value *cv)


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

* LVM2 ./WHATS_NEW lib/format_text/export.c lib/ ...
@ 2010-01-07 14:45 zkabelac
  0 siblings, 0 replies; 8+ messages in thread
From: zkabelac @ 2010-01-07 14:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-01-07 14:45:29

Modified files:
	.              : WHATS_NEW 
	lib/format_text: export.c text_export.h 

Log message:
	Export function out_text_with_comment() and add outfc() macro that checks
	for error.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1369&r2=1.1370
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_export.h.diff?cvsroot=lvm2&r1=1.7&r2=1.8

--- LVM2/WHATS_NEW	2010/01/07 14:40:46	1.1369
+++ LVM2/WHATS_NEW	2010/01/07 14:45:28	1.1370
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Add macro outfc() and export out_text_with_comment().
   Add macros outsize() and outhint().
   Use offsetof() macro for FIELD() macro in lib/report/report.c.
   Rename mirror_device_fault_policy to mirror_image_fault policy.
--- LVM2/lib/format_text/export.c	2010/01/07 14:40:46	1.74
+++ LVM2/lib/format_text/export.c	2010/01/07 14:45:28	1.75
@@ -286,9 +286,9 @@
 }
 
 /*
- * Appends a comment
+ * The normal output function with comment
  */
-static int _out_comment(struct formatter *f, const char *comment, const char *fmt, ...)
+int out_text_with_comment(struct formatter *f, const char *comment, const char *fmt, ...)
 {
 	va_list ap;
 	int r;
@@ -579,7 +579,7 @@
 
 	switch (lv->read_ahead) {
 	case DM_READ_AHEAD_NONE:
-		_out_comment(f, "# None", "read_ahead = -1");
+		outfc(f, "# None", "read_ahead = -1");
 		break;
 	case DM_READ_AHEAD_AUTO:
 		/* No output - use default */
--- LVM2/lib/format_text/text_export.h	2010/01/07 14:40:46	1.7
+++ LVM2/lib/format_text/text_export.h	2010/01/07 14:45:28	1.8
@@ -18,6 +18,7 @@
 
 #define outsize(args...) do {if (!out_size(args)) return_0;} while (0)
 #define outhint(args...) do {if (!out_hint(args)) return_0;} while (0)
+#define outfc(args...) do {if (!out_text_with_comment(args)) return_0;} while (0)
 #define outf(args...) do {if (!out_text(args)) return_0;} while (0)
 #define outnl(f) do {if (!out_newline(f)) return_0;} while (0)
 
@@ -39,6 +40,9 @@
 int out_areas(struct formatter *f, const struct lv_segment *seg,
 	      const char *type);
 
+int out_text_with_comment(struct formatter *f, const char* comment, const char *fmt, ...)
+    __attribute__ ((format(printf, 3, 4)));
+
 void out_inc_indent(struct formatter *f);
 void out_dec_indent(struct formatter *f);
 int out_newline(struct formatter *f);


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

* LVM2 ./WHATS_NEW lib/format_text/export.c lib/ ...
@ 2010-01-07 14:40 zkabelac
  0 siblings, 0 replies; 8+ messages in thread
From: zkabelac @ 2010-01-07 14:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-01-07 14:40:46

Modified files:
	.              : WHATS_NEW 
	lib/format_text: export.c text_export.h 

Log message:
	Add macros outsize() for out_size() and outhint() for out_hint() that check
	for errors in a similar way as outf() for out_text().

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1368&r2=1.1369
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_export.h.diff?cvsroot=lvm2&r1=1.6&r2=1.7

--- LVM2/WHATS_NEW	2010/01/07 14:37:11	1.1368
+++ LVM2/WHATS_NEW	2010/01/07 14:40:46	1.1369
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Add macros outsize() and outhint().
   Use offsetof() macro for FIELD() macro in lib/report/report.c.
   Rename mirror_device_fault_policy to mirror_image_fault policy.
   Remove empty PV devices if lvconvert --repair is using defined policies.
--- LVM2/lib/format_text/export.c	2009/12/16 19:22:12	1.73
+++ LVM2/lib/format_text/export.c	2010/01/07 14:40:46	1.74
@@ -386,9 +386,8 @@
 	if (vg->system_id && *vg->system_id)
 		outf(f, "system_id = \"%s\"", vg->system_id);
 
-	if (!out_size(f, (uint64_t) vg->extent_size, "extent_size = %u",
-		      vg->extent_size))
-		return_0;
+	outsize(f, (uint64_t) vg->extent_size, "extent_size = %u",
+		vg->extent_size);
 	outf(f, "max_lv = %u", vg->max_lv);
 	outf(f, "max_pv = %u", vg->max_pv);
 
@@ -453,9 +452,8 @@
 			return 0;
 		}
 
-		if (!out_hint(f, "device = \"%s\"",
-			      escape_double_quotes(buf, pv_dev_name(pv))))
-			return_0;
+		outhint(f, "device = \"%s\"",
+			escape_double_quotes(buf, pv_dev_name(pv)));
 		outnl(f);
 
 		if (!_print_flag_config(f, pv->status, PV_FLAGS))
@@ -467,13 +465,11 @@
 			outf(f, "tags = %s", buffer);
 		}
 
-		if (!out_size(f, pv->size, "dev_size = %" PRIu64, pv->size))
-			return_0;
+		outsize(f, pv->size, "dev_size = %" PRIu64, pv->size);
 
 		outf(f, "pe_start = %" PRIu64, pv->pe_start);
-		if (!out_size(f, vg->extent_size * (uint64_t) pv->pe_count,
-			      "pe_count = %u", pv->pe_count))
-			return_0;
+		outsize(f, vg->extent_size * (uint64_t) pv->pe_count,
+			"pe_count = %u", pv->pe_count);
 
 		_dec_indent(f);
 		outf(f, "}");
@@ -493,9 +489,8 @@
 	_inc_indent(f);
 
 	outf(f, "start_extent = %u", seg->le);
-	if (!out_size(f, (uint64_t) seg->len * vg->extent_size,
-		      "extent_count = %u", seg->len))
-		return_0;
+	outsize(f, (uint64_t) seg->len * vg->extent_size,
+		"extent_count = %u", seg->len);
 
 	outnl(f);
 	outf(f, "type = \"%s\"", seg->segtype->name);
--- LVM2/lib/format_text/text_export.h	2009/11/03 11:00:46	1.6
+++ LVM2/lib/format_text/text_export.h	2010/01/07 14:40:46	1.7
@@ -16,6 +16,8 @@
 #ifndef _LVM_TEXT_EXPORT_H
 #define _LVM_TEXT_EXPORT_H
 
+#define outsize(args...) do {if (!out_size(args)) return_0;} while (0)
+#define outhint(args...) do {if (!out_hint(args)) return_0;} while (0)
 #define outf(args...) do {if (!out_text(args)) return_0;} while (0)
 #define outnl(f) do {if (!out_newline(f)) return_0;} while (0)
 


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

* LVM2 ./WHATS_NEW lib/format_text/export.c lib/ ...
@ 2008-07-10 11:30 mornfall
  0 siblings, 0 replies; 8+ messages in thread
From: mornfall @ 2008-07-10 11:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2008-07-10 11:30:58

Modified files:
	.              : WHATS_NEW 
	lib/format_text: export.c flags.c import-export.h import_vsn1.c 

Log message:
	Add "flags" metadata field (akin to "status") for backward-compatible flags.
	
	The "status" field is treated as it ever has been, unknown flags there are
	treated as fatal metadata errors. However, in the "flags" field, any unknown
	flags will be ignored and silently dropped. This improves
	backward-compatibility possibilities. (Any versions without support for this
	new "flag" field will drop the field altogether, which is same as ignoring all
	the flags there.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.927&r2=1.928
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/flags.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import-export.h.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51

--- LVM2/WHATS_NEW	2008/07/10 09:50:23	1.927
+++ LVM2/WHATS_NEW	2008/07/10 11:30:57	1.928
@@ -1,5 +1,6 @@
 Version 2.02.40 - 
 ================================
+  Add "flags" metadata field (akin to "status") for backward-compatible flags.
   Fix dmeventd monitoring libraries to link against liblvm2cmd again. (2.02.39)
 
 Version 2.02.39 - 27th June 2008
--- LVM2/lib/format_text/export.c	2008/04/01 22:40:12	1.63
+++ LVM2/lib/format_text/export.c	2008/07/10 11:30:57	1.64
@@ -321,6 +321,20 @@
 	return 1;
 }
 
+static int _print_flag_config(struct formatter *f, int status, int type)
+{
+	char buffer[4096];
+	if (!print_flags(status, type | STATUS_FLAG, buffer, sizeof(buffer)))
+		return_0;
+	outf(f, "status = %s", buffer);
+
+	if (!print_flags(status, type, buffer, sizeof(buffer)))
+		return_0;
+	outf(f, "flags = %s", buffer);
+
+	return 1;
+}
+
 static int _print_vg(struct formatter *f, struct volume_group *vg)
 {
 	char buffer[4096];
@@ -332,9 +346,8 @@
 
 	outf(f, "seqno = %u", vg->seqno);
 
-	if (!print_flags(vg->status, VG_FLAGS, buffer, sizeof(buffer)))
+	if (!_print_flag_config(f, vg->status, VG_FLAGS))
 		return_0;
-	outf(f, "status = %s", buffer);
 
 	if (!list_empty(&vg->tags)) {
 		if (!print_tags(&vg->tags, buffer, sizeof(buffer)))
@@ -408,9 +421,8 @@
 			return_0;
 		outnl(f);
 
-		if (!print_flags(pv->status, PV_FLAGS, buffer, sizeof(buffer)))
+		if (!_print_flag_config(f, pv->status, PV_FLAGS))
 			return_0;
-		outf(f, "status = %s", buffer);
 
 		if (!list_empty(&pv->tags)) {
 			if (!print_tags(&pv->tags, buffer, sizeof(buffer)))
@@ -520,9 +532,8 @@
 
 	outf(f, "id = \"%s\"", buffer);
 
-	if (!print_flags(lv->status, LV_FLAGS, buffer, sizeof(buffer)))
+	if (!_print_flag_config(f, lv->status, LV_FLAGS))
 		return_0;
-	outf(f, "status = %s", buffer);
 
 	if (!list_empty(&lv->tags)) {
 		if (!print_tags(&lv->tags, buffer, sizeof(buffer)))
--- LVM2/lib/format_text/flags.c	2008/01/30 13:59:59	1.33
+++ LVM2/lib/format_text/flags.c	2008/07/10 11:30:57	1.34
@@ -25,48 +25,49 @@
 struct flag {
 	const int mask;
 	const char *description;
+	int kind;
 };
 
 static struct flag _vg_flags[] = {
-	{EXPORTED_VG, "EXPORTED"},
-	{RESIZEABLE_VG, "RESIZEABLE"},
-	{PARTIAL_VG, "PARTIAL"},
-	{PVMOVE, "PVMOVE"},
-	{LVM_READ, "READ"},
-	{LVM_WRITE, "WRITE"},
-	{CLUSTERED, "CLUSTERED"},
-	{SHARED, "SHARED"},
-	{PRECOMMITTED, NULL},
-	{0, NULL}
+	{EXPORTED_VG, "EXPORTED", STATUS_FLAG},
+	{RESIZEABLE_VG, "RESIZEABLE", STATUS_FLAG},
+	{PARTIAL_VG, "PARTIAL", STATUS_FLAG},
+	{PVMOVE, "PVMOVE", STATUS_FLAG},
+	{LVM_READ, "READ", STATUS_FLAG},
+	{LVM_WRITE, "WRITE", STATUS_FLAG},
+	{CLUSTERED, "CLUSTERED", STATUS_FLAG},
+	{SHARED, "SHARED", STATUS_FLAG},
+	{PRECOMMITTED, NULL, 0},
+	{0, NULL, 0}
 };
 
 static struct flag _pv_flags[] = {
-	{ALLOCATABLE_PV, "ALLOCATABLE"},
-	{EXPORTED_VG, "EXPORTED"},
-	{0, NULL}
+	{ALLOCATABLE_PV, "ALLOCATABLE", STATUS_FLAG},
+	{EXPORTED_VG, "EXPORTED", STATUS_FLAG},
+	{0, NULL, 0}
 };
 
 static struct flag _lv_flags[] = {
-	{LVM_READ, "READ"},
-	{LVM_WRITE, "WRITE"},
-	{FIXED_MINOR, "FIXED_MINOR"},
-	{VISIBLE_LV, "VISIBLE"},
-	{PVMOVE, "PVMOVE"},
-	{LOCKED, "LOCKED"},
-	{MIRROR_NOTSYNCED, "NOTSYNCED"},
-	{MIRROR_IMAGE, NULL},
-	{MIRROR_LOG, NULL},
-	{MIRRORED, NULL},
-	{VIRTUAL, NULL},
-	{SNAPSHOT, NULL},
-	{ACTIVATE_EXCL, NULL},
-	{CONVERTING, NULL},
-	{0, NULL}
+	{LVM_READ, "READ", STATUS_FLAG},
+	{LVM_WRITE, "WRITE", STATUS_FLAG},
+	{FIXED_MINOR, "FIXED_MINOR", STATUS_FLAG},
+	{VISIBLE_LV, "VISIBLE", STATUS_FLAG},
+	{PVMOVE, "PVMOVE", STATUS_FLAG},
+	{LOCKED, "LOCKED", STATUS_FLAG},
+	{MIRROR_NOTSYNCED, "NOTSYNCED", STATUS_FLAG},
+	{MIRROR_IMAGE, NULL, 0},
+	{MIRROR_LOG, NULL, 0},
+	{MIRRORED, NULL, 0},
+	{VIRTUAL, NULL, 0},
+	{SNAPSHOT, NULL, 0},
+	{ACTIVATE_EXCL, NULL, 0},
+	{CONVERTING, NULL, 0},
+	{0, NULL, 0}
 };
 
 static struct flag *_get_flags(int type)
 {
-	switch (type) {
+	switch (type & ~STATUS_FLAG) {
 	case VG_FLAGS:
 		return _vg_flags;
 
@@ -101,6 +102,9 @@
 		if (status & flags[f].mask) {
 			status &= ~flags[f].mask;
 
+			if ((type & STATUS_FLAG) != flags[f].kind)
+				continue;
+
 			/* Internal-only flag? */
 			if (!flags[f].description)
 				continue;
@@ -151,7 +155,7 @@
 				break;
 			}
 
-		if (!flags[f].description) {
+		if (!flags[f].description && (type & STATUS_FLAG)) {
 			log_err("Unknown status flag '%s'.", cv->v.str);
 			return 0;
 		}
@@ -160,6 +164,6 @@
 	}
 
       out:
-	*status = s;
+	*status |= s;
 	return 1;
 }
--- LVM2/lib/format_text/import-export.h	2007/08/20 20:55:26	1.20
+++ LVM2/lib/format_text/import-export.h	2008/07/10 11:30:57	1.21
@@ -36,9 +36,11 @@
  * common code for reading and writing them.
  */
 enum {
+	COMPATIBLE_FLAG = 0x0,
 	VG_FLAGS,
 	PV_FLAGS,
-	LV_FLAGS
+	LV_FLAGS,
+	STATUS_FLAG = 0x8,
 };
 
 struct text_vg_version_ops {
--- LVM2/lib/format_text/import_vsn1.c	2008/01/31 12:35:31	1.50
+++ LVM2/lib/format_text/import_vsn1.c	2008/07/10 11:30:57	1.51
@@ -125,6 +125,31 @@
 	return 1;
 }
 
+static int _read_flag_config(struct config_node *n, int *status, int type)
+{
+	struct config_node *cn;
+	*status = 0;
+
+	if (!(cn = find_config_node(n, "status"))) {
+		log_error("Could not find status flags.");
+		return 0;
+	}
+
+	if (!(read_flags(status, type | STATUS_FLAG, cn->v))) {
+		log_error("Could not read status flags.");
+		return 0;
+	}
+
+	if (cn = find_config_node(n, "flags")) {
+		if (!(read_flags(status, type, cn->v))) {
+			log_error("Could not read flags.");
+			return 0;
+		}
+	}
+
+	return 1;
+}
+
 static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
 		    struct volume_group *vg, struct config_node *pvn,
 		    struct config_node *vgn __attribute((unused)),
@@ -181,12 +206,7 @@
 
 	memcpy(&pv->vgid, &vg->id, sizeof(vg->id));
 
-	if (!(cn = find_config_node(pvn, "status"))) {
-		log_error("Couldn't find status flags for physical volume.");
-		return 0;
-	}
-
-	if (!(read_flags(&pv->status, PV_FLAGS, cn->v))) {
+	if (!_read_flag_config(pvn, &pv->status, PV_FLAGS)) {
 		log_error("Couldn't read status flags for physical volume.");
 		return 0;
 	}
@@ -493,13 +513,9 @@
 		return 0;
 	}
 
-	if (!(cn = find_config_node(lvn, "status"))) {
-		log_error("Couldn't find status flags for logical volume.");
-		return 0;
-	}
-
-	if (!(read_flags(&lv->status, LV_FLAGS, cn->v))) {
-		log_error("Couldn't read status flags for logical volume.");
+	if (!_read_flag_config(lvn, &lv->status, LV_FLAGS)) {
+		log_error("Couldn't read status flags for logical volume %s.",
+			  lv->name);
 		return 0;
 	}
 
@@ -692,14 +708,8 @@
 		goto bad;
 	}
 
-	if (!(cn = find_config_node(vgn, "status"))) {
-		log_error("Couldn't find status flags for volume group %s.",
-			  vg->name);
-		goto bad;
-	}
-
-	if (!(read_flags(&vg->status, VG_FLAGS, cn->v))) {
-		log_error("Couldn't read status flags for volume group %s.",
+	if (!_read_flag_config(vgn, &vg->status, VG_FLAGS)) {
+		log_error("Error reading flags of volume group %s.",
 			  vg->name);
 		goto bad;
 	}
@@ -855,18 +865,12 @@
 		return 0;
 	}
 
-	if (!(cn = find_config_node(vgn, "status"))) {
+	if (!_read_flag_config(vgn, vgstatus, VG_FLAGS)) {
 		log_error("Couldn't find status flags for volume group %s.",
 			  vgname);
 		return 0;
 	}
 
-	if (!(read_flags(vgstatus, VG_FLAGS, cn->v))) {
-		log_error("Couldn't read status flags for volume group %s.",
-			  vgname);
-		return 0;
-	}
-
 	return vgname;
 }
 


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

* LVM2 ./WHATS_NEW lib/format_text/export.c lib/ ...
@ 2005-06-07 11:00 agk
  0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2005-06-07 11:00 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-06-07 11:00:07

Modified files:
	.              : WHATS_NEW 
	lib/format_text: export.c format-text.c import-export.h 
	                 text_export.h 
	lib/metadata   : lv_manip.c 

Log message:
	Remove hard-coded 64k text metadata writing restriction.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.253&r2=1.254
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import-export.h.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_export.h.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79


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

* LVM2 ./WHATS_NEW lib/format_text/export.c lib/ ...
@ 2005-04-07 12:24 agk
  0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2005-04-07 12:24 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-04-07 12:24:49

Modified files:
	.              : WHATS_NEW 
	lib/format_text: export.c 
	lib/metadata   : metadata.h snapshot_manip.c 
	lib/snapshot   : snapshot.c 

Log message:
	store snapshot id as lvid internally

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.223&r2=1.224
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.110&r2=1.111
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/snapshot_manip.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8


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

* LVM2 ./WHATS_NEW lib/format_text/export.c lib/ ...
@ 2004-05-05 17:56 agk
  0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2004-05-05 17:56 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2004-05-05 17:56:21

Modified files:
	.              : WHATS_NEW 
	lib/format_text: export.c import_vsn1.c 
	lib/metadata   : lv_manip.c metadata.h mirror.c 
	lib/mirror     : mirrored.c 
	lib/report     : report.c 
	tools          : Makefile.in lvchange.c pvmove.c vgchange.c 
Added files:
	tools          : polldaemon.c polldaemon.h 

Log message:
	Separate out polldaemon.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.100&r2=1.101
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.h.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/Makefile.in.diff?cvsroot=lvm2&r1=1.59&r2=1.60
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38


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

end of thread, other threads:[~2012-01-19 15:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-19 15:31 LVM2 ./WHATS_NEW lib/format_text/export.c lib/ zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2010-09-20 14:23 prajnoha
2010-01-07 14:45 zkabelac
2010-01-07 14:40 zkabelac
2008-07-10 11:30 mornfall
2005-06-07 11:00 agk
2005-04-07 12:24 agk
2004-05-05 17:56 agk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).