All of lore.kernel.org
 help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirror.c
@ 2006-12-20 14:34 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2006-12-20 14:34 UTC (permalink / raw)
  To: lvm-devel

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk at sourceware.org	2006-12-20 14:34:05

Modified files:
	.              : WHATS_NEW 
	dmeventd/mirror: dmeventd_mirror.c 

Log message:
	Fix dmeventd mirror to cope if monitored device disappears.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.523&r2=1.524
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9

--- LVM2/WHATS_NEW	2006/12/14 22:21:32	1.523
+++ LVM2/WHATS_NEW	2006/12/20 14:34:04	1.524
@@ -1,5 +1,6 @@
 Version 2.02.18 -
 ====================================
+  Fix dmeventd mirror to cope if monitored device disappears.
 
 Version 2.02.17 - 14th December 2006
 ====================================
--- LVM2/dmeventd/mirror/dmeventd_mirror.c	2006/08/21 12:04:54	1.8
+++ LVM2/dmeventd/mirror/dmeventd_mirror.c	2006/12/20 14:34:05	1.9
@@ -26,6 +26,7 @@
 #include <unistd.h>
 
 #include <syslog.h> /* FIXME Replace syslog with multilog */
+/* FIXME Missing openlog? */
 
 #define ME_IGNORE    0
 #define ME_INSYNC    1
@@ -34,23 +35,29 @@
 static pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER;
 
 /* FIXME: We may need to lock around operations to these */
-static int register_count = 0;
-static struct dm_pool *mem_pool = NULL;
+static int _register_count = 0;
+
+/* FIXME Unsafe static? */
+static struct dm_pool *_mem_pool = NULL;
 
 static int _get_mirror_event(char *params)
 {
-	int i, rtn = ME_INSYNC;
-	int max_args = 30;  /* should support at least 8-way mirrors */
-	char *args[max_args];
+	int i, r = ME_INSYNC;
+
+#define MAX_ARGS 30;  /* should support at least 8-way mirrors */
+/* FIXME Remove unnecessary limit.  It tells you how many devices there are - use it! */
+
+	char *args[MAX_ARGS];
 	char *dev_status_str;
 	char *log_status_str;
 	char *sync_str;
 	char *p;
 	int log_argc, num_devs, num_failures=0;
 
-	if (max_args <= dm_split_words(params, max_args, 0, args)) {
+	/* FIXME Remove unnecessary limit - get num_devs here */
+	if (MAX_ARGS <= dm_split_words(params, MAX_ARGS, 0, args)) {
 		syslog(LOG_ERR, "Unable to split mirror parameters: Arg list too long");
-		return -E2BIG;
+		return -E2BIG;	/* FIXME Why? Unused */
 	}
 
 	/*
@@ -58,18 +65,20 @@
 	 * Used  :  2 253:4 253:5 400/400 1 AA 3 cluster 253:3 A
 	*/
 	num_devs = atoi(args[0]);
+
+	/* FIXME *Now* split rest of args */
+
 	dev_status_str = args[3 + num_devs];
 	log_argc = atoi(args[4 + num_devs]);
 	log_status_str = args[4 + num_devs + log_argc];
 	sync_str = args[1 + num_devs];
 
 	/* Check for bad mirror devices */
-	for (i = 0; i < num_devs; i++) {
+	for (i = 0; i < num_devs; i++)
 		if (dev_status_str[i] == 'D') {
 			syslog(LOG_ERR, "Mirror device, %s, has failed.\n", args[i+1]);
 			num_failures++;
 		}
-	}
 
 	/* Check for bad log device */
 	if (log_status_str[0] == 'D') {
@@ -79,7 +88,7 @@
 	}
 
 	if (num_failures) {
-		rtn = ME_FAILURE;
+		r = ME_FAILURE;
 		goto out;
 	}
 
@@ -87,7 +96,7 @@
 	if (p) {
 		p[0] = '\0';
 		if (strcmp(sync_str, p+1))
-			rtn = ME_IGNORE;
+			r = ME_IGNORE;
 		p[0] = '/';
 	} else {
 		/*
@@ -95,10 +104,10 @@
 		 * Might mean all our parameters are screwed.
 		 */
 		syslog(LOG_ERR, "Unable to parse sync string.");
-		rtn = ME_IGNORE;
+		r = ME_IGNORE;
 	}
  out:
-	return rtn;
+	return r;
 }
 
 static void _temporary_log_fn(int level, const char *file,
@@ -114,25 +123,25 @@
 {
 	int r;
 	void *handle;
-	int cmd_size = 256;	/* FIXME Use system restriction */
-	char cmd_str[cmd_size];
+#define CMD_SIZE 256	/* FIXME Use system restriction */
+	char cmd_str[CMD_SIZE];
 	char *vg = NULL, *lv = NULL, *layer = NULL;
 
-	if (strlen(device) > 200)
-		return -ENAMETOOLONG;
+	if (strlen(device) > 200)  /* FIXME Use real restriction */
+		return -ENAMETOOLONG;	/* FIXME These return code distinctions are not used so remove them! */
 
-	if (!dm_split_lvm_name(mem_pool, device, &vg, &lv, &layer)) {
+	if (!dm_split_lvm_name(_mem_pool, device, &vg, &lv, &layer)) {
 		syslog(LOG_ERR, "Unable to determine VG name from %s",
 		       device);
-		return -ENOMEM;
+		return -ENOMEM;	/* FIXME Replace with generic error return - reason for failure has already got logged */
 	}
 
 	/* FIXME Is any sanity-checking required on %s? */
-	if (cmd_size <= snprintf(cmd_str, cmd_size, "vgreduce --removemissing %s", vg)) {
+	if (CMD_SIZE <= snprintf(cmd_str, CMD_SIZE, "vgreduce --removemissing %s", vg)) {
 		/* this error should be caught above, but doesn't hurt to check again */
 		syslog(LOG_ERR, "Unable to form LVM command: Device name too long");
-		dm_pool_empty(mem_pool);  /* FIXME: not safe with multiple threads */
-		return -ENAMETOOLONG;
+		dm_pool_empty(_mem_pool);  /* FIXME: not safe with multiple threads */
+		return -ENAMETOOLONG; /* FIXME Replace with generic error return - reason for failure has already got logged */
 	}
 
 	lvm2_log_fn(_temporary_log_fn);
@@ -140,8 +149,8 @@
 	lvm2_log_level(handle, 1);
 	r = lvm2_run(handle, cmd_str);
 
-	dm_pool_empty(mem_pool);  /* FIXME: not safe with multiple threads */
-	return (r == 1)? 0: -1;
+	dm_pool_empty(_mem_pool);  /* FIXME: not safe with multiple threads */
+	return (r == 1) ? 0 : -1;
 }
 
 void process_event(const char *device, enum dm_event_type event)
@@ -176,6 +185,10 @@
 		next = dm_get_next_target(dmt, next, &start, &length,
 					  &target_type, &params);
 
+		if (!target_type)
+			syslog(LOG_INFO, "%s mapping lost.\n", device);
+			continue;
+
 		if (strcmp(target_type, "mirror")) {
 			syslog(LOG_INFO, "%s has unmirrored portion.\n", device);
 			continue;
@@ -192,6 +205,7 @@
 		case ME_FAILURE:
 			syslog(LOG_ERR, "Device failure in %s\n", device);
 			if (_remove_failed_devices(device))
+				/* FIXME Why are all the error return codes unused? Get rid of them? */
 				syslog(LOG_ERR, "Failed to remove faulty devices in %s\n",
 				       device);
 			/* Should check before warning user that device is now linear
@@ -203,6 +217,7 @@
 		case ME_IGNORE:
 			break;
 		default:
+			/* FIXME Wrong: it can also return -E2BIG but it's never used! */
 			syslog(LOG_INFO, "Unknown event received.\n");
 		}
 	} while (next);
@@ -221,34 +236,20 @@
 	 * Need some space for allocations.  1024 should be more
 	 * than enough for what we need (device mapper name splitting)
 	 */
-	if (!mem_pool)
-		mem_pool = dm_pool_create("mirror_dso", 1024);
-
-	if (!mem_pool)
+	if (!_mem_pool && !(_mem_pool = dm_pool_create("mirror_dso", 1024)))
 		return 0;
 
-	register_count++;
+	_register_count++;
 
         return 1;
 }
 
 int unregister_device(const char *device)
 {
-	if (!(--register_count)) {
-		dm_pool_destroy(mem_pool);
-		mem_pool = NULL;
+	if (!--_register_count) {
+		dm_pool_destroy(_mem_pool);
+		_mem_pool = NULL;
 	}
 
         return 1;
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain@the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */



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

* LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirror.c
@ 2007-01-11 19:52 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-01-11 19:52 UTC (permalink / raw)
  To: lvm-devel

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk at sourceware.org	2007-01-11 19:52:06

Modified files:
	.              : WHATS_NEW 
	dmeventd/mirror: dmeventd_mirror.c 

Log message:
	Remove dmeventd mirror status line word limit

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.535&r2=1.536
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11

--- LVM2/WHATS_NEW	2007/01/11 17:12:26	1.535
+++ LVM2/WHATS_NEW	2007/01/11 19:52:06	1.536
@@ -1,5 +1,6 @@
 Version 2.02.18 -
 ====================================
+  Remove dmeventd mirror status line word limit.
   Use CFLAGS when linking so mixed sparc builds can supply -m64.
   Prevent permission changes on active mirrors.
   Print warning instead of error message if lvconvert cannot zero volume.
--- LVM2/dmeventd/mirror/dmeventd_mirror.c	2007/01/08 14:24:20	1.10
+++ LVM2/dmeventd/mirror/dmeventd_mirror.c	2007/01/11 19:52:06	1.11
@@ -54,54 +54,51 @@
 static int _get_mirror_event(char *params)
 {
 	int i, r = ME_INSYNC;
-
-#define MAX_ARGS 30	/* should support at least 8-way mirrors */
-/* FIXME Remove unnecessary limit.  It tells you how many devices there are - use it! */
-
-	char *args[MAX_ARGS];
+	char **args = NULL;
 	char *dev_status_str;
 	char *log_status_str;
 	char *sync_str;
 	char *p;
-	int log_argc, num_devs, num_failures=0;
-
-	/* FIXME Remove unnecessary limit - get num_devs here */
-	if (MAX_ARGS <= dm_split_words(params, MAX_ARGS, 0, args)) {
-		syslog(LOG_ERR, "Unable to split mirror parameters: Arg list too long");
-		return -E2BIG;	/* FIXME Why? Unused */
-	}
+	int log_argc, num_devs;
 
 	/*
 	 * Unused:  0 409600 mirror
 	 * Used  :  2 253:4 253:5 400/400 1 AA 3 cluster 253:3 A
-	*/
-	num_devs = atoi(args[0]);
-
-	/* FIXME *Now* split rest of args */
+	 */
 
-	dev_status_str = args[3 + num_devs];
-	log_argc = atoi(args[4 + num_devs]);
-	log_status_str = args[4 + num_devs + log_argc];
-	sync_str = args[1 + num_devs];
+	/* number of devices */
+	if (!dm_split_words(params, 1, 0, &p))
+		goto out_parse;
+
+	num_devs = atoi(p);
+	p += strlen(p) + 1;
+
+	/* devices names + max log parameters */
+	args = dm_malloc((num_devs + 8) * sizeof(char *));
+	if (!args || dm_split_words(p, num_devs + 8, 0, args) < num_devs)
+		goto out_parse;
+
+	dev_status_str = args[2 + num_devs];
+	log_argc = atoi(args[3 + num_devs]);
+	log_status_str = args[3 + num_devs + log_argc];
+	sync_str = args[num_devs];
 
 	/* Check for bad mirror devices */
 	for (i = 0; i < num_devs; i++)
 		if (dev_status_str[i] == 'D') {
-			syslog(LOG_ERR, "Mirror device, %s, has failed.\n", args[i+1]);
-			num_failures++;
+			syslog(LOG_ERR, "Mirror device, %s, has failed.\n", args[i]);
+			r = ME_FAILURE;
 		}
 
-	/* Check for bad log device */
-	if (log_status_str[0] == 'D') {
+	/* Check for bad disk log device */
+	if (log_argc > 1 && log_status_str[0] == 'D') {
 		syslog(LOG_ERR, "Log device, %s, has failed.\n",
-		       args[3 + num_devs + log_argc]);
-		num_failures++;
+		       args[2 + num_devs + log_argc]);
+		r = ME_FAILURE;
 	}
 
-	if (num_failures) {
-		r = ME_FAILURE;
+	if (r == ME_FAILURE)
 		goto out;
-	}
 
 	p = strstr(sync_str, "/");
 	if (p) {
@@ -109,16 +106,19 @@
 		if (strcmp(sync_str, p+1))
 			r = ME_IGNORE;
 		p[0] = '/';
-	} else {
-		/*
-		 * How the hell did we get this?
-		 * Might mean all our parameters are screwed.
-		 */
-		syslog(LOG_ERR, "Unable to parse sync string.");
-		r = ME_IGNORE;
-	}
- out:
+	} else
+		goto out_parse;
+
+out:
+	if (args)
+		dm_free(args);
 	return r;
+	
+out_parse:
+	if (args)
+		dm_free(args);
+	syslog(LOG_ERR, "Unable to parse mirror status string.");
+	return ME_IGNORE;
 }
 
 static void _temporary_log_fn(int level, const char *file,



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

* LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirror.c
@ 2007-01-23 17:40 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-01-23 17:40 UTC (permalink / raw)
  To: lvm-devel

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk at sourceware.org	2007-01-23 17:40:40

Modified files:
	.              : WHATS_NEW 
	dmeventd/mirror: dmeventd_mirror.c 

Log message:
	Add private variable to dmeventd shared library interface.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.553&r2=1.554
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16

--- LVM2/WHATS_NEW	2007/01/23 16:03:53	1.553
+++ LVM2/WHATS_NEW	2007/01/23 17:40:40	1.554
@@ -1,5 +1,6 @@
 Version 2.02.20 -
 ===================================
+  Add private variable to dmeventd shared library interface.
   Long-lived processes write out persistent dev cache in refresh_toolcontext().
   Fix refresh_toolcontext() always to wipe persistent device filter cache.
   Add is_long_lived to toolcontext.
--- LVM2/dmeventd/mirror/dmeventd_mirror.c	2007/01/15 18:22:01	1.15
+++ LVM2/dmeventd/mirror/dmeventd_mirror.c	2007/01/23 17:40:40	1.16
@@ -164,7 +164,8 @@
 	return (r == 1) ? 0 : -1;
 }
 
-void process_event(struct dm_task *dmt, enum dm_event_mask event)
+void process_event(struct dm_task *dmt, enum dm_event_mask event,
+		   void **unused __attribute((unused)))
 {
 	void *next = NULL;
 	uint64_t start, length;
@@ -221,7 +222,8 @@
 	pthread_mutex_unlock(&_event_mutex);
 }
 
-int register_device(const char *device, const char *uuid, int major, int minor)
+int register_device(const char *device, const char *uuid, int major, int minor,
+		   void **unused __attribute((unused)))
 {
 	int r = 0;
 
@@ -257,7 +259,8 @@
 	return r;
 }
 
-int unregister_device(const char *device, const char *uuid, int major, int minor)
+int unregister_device(const char *device, const char *uuid, int major, int minor,
+		   void **unused __attribute((unused)))
 {
 	pthread_mutex_lock(&_register_mutex);
 



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

* LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirror.c
@ 2007-01-25 23:32 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-01-25 23:32 UTC (permalink / raw)
  To: lvm-devel

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk at sourceware.org	2007-01-25 23:32:29

Modified files:
	.              : WHATS_NEW 
	dmeventd/mirror: dmeventd_mirror.c 

Log message:
	dmeventd mirror sets ignore_suspended_devices and avoids scanning mirrors.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.559&r2=1.560
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17

--- LVM2/WHATS_NEW	2007/01/25 21:22:29	1.559
+++ LVM2/WHATS_NEW	2007/01/25 23:32:29	1.560
@@ -1,5 +1,6 @@
 Version 2.02.20 -
 ===================================
+  dmeventd mirror sets ignore_suspended_devices and avoids scanning mirrors.
   Add devices/ignore_suspended_devices to ignore suspended dm devices.
   Add some missing close() and fclose() return code checks.
   Fix exit statuses of reporting tools (2.02.19).
--- LVM2/dmeventd/mirror/dmeventd_mirror.c	2007/01/23 17:40:40	1.16
+++ LVM2/dmeventd/mirror/dmeventd_mirror.c	2007/01/25 23:32:29	1.17
@@ -151,7 +151,7 @@
 	}
 
 	/* FIXME Is any sanity-checking required on %s? */
-	if (CMD_SIZE <= snprintf(cmd_str, CMD_SIZE, "vgreduce --removemissing %s", vg)) {
+	if (CMD_SIZE <= snprintf(cmd_str, CMD_SIZE, "vgreduce --config devices{ignore_suspended_devices=1} --removemissing %s", vg)) {
 		/* this error should be caught above, but doesn't hurt to check again */
 		syslog(LOG_ERR, "Unable to form LVM command: Device name too long");
 		dm_pool_empty(_mem_pool);  /* FIXME: not safe with multiple threads */



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

* LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirror.c
@ 2008-09-25 15:52 mbroz
  0 siblings, 0 replies; 5+ messages in thread
From: mbroz @ 2008-09-25 15:52 UTC (permalink / raw)
  To: lvm-devel

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz at sourceware.org	2008-09-25 15:52:29

Modified files:
	.              : WHATS_NEW 
	dmeventd/mirror: dmeventd_mirror.c 

Log message:
	Fix mirror DSO to call vgreduce with proper parameters.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.965&r2=1.966
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20

--- LVM2/WHATS_NEW	2008/09/24 16:32:51	1.965
+++ LVM2/WHATS_NEW	2008/09/25 15:52:28	1.966
@@ -1,5 +1,6 @@
 Version 2.02.41 -
 =====================================
+  Fix mirror DSO to call vgreduce with proper parameters.
   Fix validation of --minor and --major in lvcreate to require -My always.
   Fix release: clvmd build, vgreduce consolidate & tests, /dev/ioerror warning.
 
--- LVM2/dmeventd/mirror/dmeventd_mirror.c	2008/01/31 12:19:35	1.19
+++ LVM2/dmeventd/mirror/dmeventd_mirror.c	2008/09/25 15:52:29	1.20
@@ -152,7 +152,7 @@
 	}
 
 	/* FIXME Is any sanity-checking required on %s? */
-	if (CMD_SIZE <= snprintf(cmd_str, CMD_SIZE, "vgreduce --config devices{ignore_suspended_devices=1} --removemissing %s", vg)) {
+	if (CMD_SIZE <= snprintf(cmd_str, CMD_SIZE, "vgreduce --config devices{ignore_suspended_devices=1} --removemissing --force %s", vg)) {
 		/* this error should be caught above, but doesn't hurt to check again */
 		syslog(LOG_ERR, "Unable to form LVM command: Device name too long");
 		dm_pool_empty(_mem_pool);  /* FIXME: not safe with multiple threads */



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

end of thread, other threads:[~2008-09-25 15:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-23 17:40 LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirror.c agk
  -- strict thread matches above, loose matches on Subject: below --
2008-09-25 15:52 mbroz
2007-01-25 23:32 agk
2007-01-11 19:52 agk
2006-12-20 14:34 agk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.