All of lore.kernel.org
 help / color / mirror / Atom feed
* multipath-tools libmultipath/configure.c libmu ...
@ 2007-06-15 19:03 bmarzins
  0 siblings, 0 replies; 13+ messages in thread
From: bmarzins @ 2007-06-15 19:03 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	multipath-tools
Branch: 	RHEL5_FC6
Changes by:	bmarzins@sourceware.org	2007-06-15 19:03:02

Modified files:
	libmultipath   : configure.c debug.c debug.h devmapper.c 
	                 devmapper.h log_pthread.c log_pthread.h 
	                 structs_vec.c waiter.c 
	multipath      : main.c 
	multipathd     : main.c 

Log message:
	Pulled in some upstream fixes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/configure.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.2&r2=1.2.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/debug.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.7&r2=1.7.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/debug.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.5&r2=1.5.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/devmapper.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.22&r2=1.22.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/devmapper.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.11&r2=1.11.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/log_pthread.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/log_pthread.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/structs_vec.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/waiter.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipath/main.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.44.2.1&r2=1.44.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/main.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.69.2.1&r2=1.69.2.2

--- multipath-tools/libmultipath/configure.c	2006/07/13 20:35:22	1.2
+++ multipath-tools/libmultipath/configure.c	2007/06/15 19:03:02	1.2.2.1
@@ -324,7 +324,6 @@
 				mpp->alias);
 			return DOMAP_RETRY;
 		}
-		dm_shut_log();
 
 		if (dm_map_present(mpp->alias))
 			break;
@@ -345,7 +344,6 @@
 		}
 
 		lock_multipath(mpp, 0);
-		dm_restore_log();
 		break;
 
 	case ACT_RELOAD:
--- multipath-tools/libmultipath/debug.c	2006/08/02 21:37:22	1.7
+++ multipath-tools/libmultipath/debug.c	2007/06/15 19:03:02	1.7.2.1
@@ -14,7 +14,7 @@
 #include "vector.h"
 #include "config.h"
 
-void dlog (int sink, int prio, char * fmt, ...)
+void dlog (int sink, int prio, const char * fmt, ...)
 {
 	va_list ap;
 	int thres;
--- multipath-tools/libmultipath/debug.h	2006/08/02 21:37:22	1.5
+++ multipath-tools/libmultipath/debug.h	2007/06/15 19:03:02	1.5.2.1
@@ -1,4 +1,4 @@
-void dlog (int sink, int prio, char * fmt, ...)
+void dlog (int sink, int prio, const char * fmt, ...)
 	__attribute__((format(printf, 3, 4)));
 
 #if DAEMON
--- multipath-tools/libmultipath/devmapper.c	2006/11/28 15:46:21	1.22
+++ multipath-tools/libmultipath/devmapper.c	2007/06/15 19:03:02	1.22.2.1
@@ -20,6 +20,13 @@
 #include "debug.h"
 #include "memory.h"
 #include "devmapper.h"
+#include "config.h"
+
+#if DAEMON
+#include "log_pthread.h"
+#include <sys/types.h>
+#include <time.h>
+#endif
 
 #define MAX_WAIT 5
 #define LOOPS_PER_SEC 5
@@ -29,21 +36,50 @@
 
 
 static void
-dm_dummy_log (int level, const char *file, int line, const char *f, ...)
+dm_write_log (int level, const char *file, int line, const char *f, ...)
 {
-	return;
-}
+	va_list ap;
+	int thres;
 
-void
-dm_restore_log (void)
-{
-	dm_log_init(NULL);
+	if (level > 6)
+		level = 6;
+
+	thres = (conf) ? conf->verbosity : 0;
+	if (thres <= 3 || level > thres)
+		return;
+
+        va_start(ap, f);
+#if DAEMON
+	if (!logsink) {
+		time_t t = time(NULL);
+		struct tm *tb = localtime(&t);
+		char buff[16];
+
+		strftime(buff, sizeof(buff), "%b %d %H:%M:%S", tb);
+		buff[sizeof(buff)-1] = '\0';
+
+		fprintf(stdout, "%s | ", buff);
+		fprintf(stdout, "libdevmapper: %s(%i): ", file, line);
+		vfprintf(stdout, f, ap);
+		fprintf(stdout, "\n");
+	} else {
+		condlog(level, "libdevmapper: %s(%i): ", file, line);
+		log_safe(level + 3, f, ap);
+	}
+#else
+	fprintf(stdout, "libdevmapper: %s(%i): ", file, line);
+	vfprintf(stdout, f, ap);
+	fprintf(stdout, "\n");
+#endif
+        va_end(ap);
+
+	return;
 }
 
-void
-dm_shut_log (void)
-{
-	dm_log_init(&dm_dummy_log);
+extern void
+dm_init(void) {
+	dm_log_init(&dm_write_log);
+	dm_log_init_verbose(conf ? conf->verbosity + 3 : 0);
 }
 
 extern int
@@ -733,9 +769,7 @@
 	 * daemon uev_trigger -> uev_add_map
 	 */
 	while (--loop) {
-		dm_shut_log();
 		r = dm_task_run(dmt);
-		dm_restore_log();
 
 		if (r)
 			break;
--- multipath-tools/libmultipath/devmapper.h	2006/06/06 18:32:43	1.11
+++ multipath-tools/libmultipath/devmapper.h	2007/06/15 19:03:02	1.11.2.1
@@ -1,5 +1,4 @@
-void dm_shut_log(void);
-void dm_restore_log(void);
+void dm_init(void);
 int dm_prereq (char *, int, int, int);
 int dm_simplecmd (int, const char *);
 int dm_addmap (int, const char *, const char *, const char *,
--- multipath-tools/libmultipath/log_pthread.c	2006/06/06 18:46:38	1.1
+++ multipath-tools/libmultipath/log_pthread.c	2007/06/15 19:03:02	1.1.2.1
@@ -12,7 +12,7 @@
 #include "log_pthread.h"
 #include "log.h"
 
-void log_safe (int prio, char * fmt, va_list ap)
+void log_safe (int prio, const char * fmt, va_list ap)
 {
 	pthread_mutex_lock(logq_lock);
 	//va_start(ap, fmt);
--- multipath-tools/libmultipath/log_pthread.h	2006/06/06 18:46:38	1.1
+++ multipath-tools/libmultipath/log_pthread.h	2007/06/15 19:03:02	1.1.2.1
@@ -7,7 +7,7 @@
 pthread_mutex_t *logev_lock;
 pthread_cond_t *logev_cond;
 
-void log_safe(int prio, char * fmt, va_list ap);
+void log_safe(int prio, const char * fmt, va_list ap);
 void log_thread_start(void);
 void log_thread_stop(void);
 
--- multipath-tools/libmultipath/structs_vec.c	2006/06/06 18:46:38	1.1
+++ multipath-tools/libmultipath/structs_vec.c	2007/06/15 19:03:02	1.1.2.1
@@ -16,7 +16,6 @@
 #include "discovery.h"
 #include "waiter.h"
 
-
 /*
  * creates or updates mpp->paths reading mpp->pg
  */
@@ -118,6 +117,8 @@
 {
 	int i;
 
+	condlog(4, "%s: remove multipath map", mpp->alias);
+
 	/*
 	 * stop the DM event waiter thread
 	 */
@@ -245,8 +246,17 @@
 setup_multipath (struct vectors * vecs, struct multipath * mpp)
 {
 retry:
-	if (dm_get_info(mpp->alias, &mpp->dmi))
+	if (dm_get_info(mpp->alias, &mpp->dmi)) {
+		/* Error accessing table */
+		condlog(3, "%s: cannot access table", mpp->alias); 
+		goto out;
+	}
+
+	if (!dm_map_present(mpp->alias)) {
+		/* Table has been removed */
+		condlog(3, "%s: table does not exist", mpp->alias); 
 		goto out;
+	}
 
 	set_multipath_wwid(mpp);
 	mpp->mpe = find_mpe(mpp->wwid);
@@ -270,6 +280,7 @@
 #endif
 			goto retry;
 		}
+		condlog(0, "%s: failed to setup multipath", mpp->alias);
 		goto out;
 	}
 
@@ -282,7 +293,6 @@
 
 	return 0;
 out:
-	condlog(0, "%s: failed to setup multipath", mpp->alias);
 	remove_map(mpp, vecs, NULL, 1);
 	return 1;
 }
@@ -390,18 +400,19 @@
 	struct pathgroup  *pgp;
 	struct path *pp;
 	int i, j;
-	int r = 1;
 
 	mpp = find_mp_by_alias(vecs->mpvec, mapname);
 
-	if (!mpp)
-		goto out;
+	if (!mpp) {
+		condlog(3, "%s: multipath map not found\n", mapname);
+		return 2;
+	}
 
 	free_pgvec(mpp->pg, KEEP_PATHS);
 	mpp->pg = NULL;
 
 	if (setup_multipath(vecs, mpp))
-		goto out; /* mpp freed in setup_multipath */
+		return 1; /* mpp freed in setup_multipath */
 
 	/*
 	 * compare checkers states with DM states
@@ -429,11 +440,8 @@
 			}
 		}
 	}
-	r = 0;
-out:
-	if (r)
-		condlog(0, "failed to update multipath");
-	return r;
+
+	return 0;
 }
 
 /*
--- multipath-tools/libmultipath/waiter.c	2006/06/06 18:46:38	1.1
+++ multipath-tools/libmultipath/waiter.c	2007/06/15 19:03:02	1.1.2.1
@@ -117,15 +117,11 @@
 	/* accept wait interruption */
 	set = unblock_signals();
 
-	/* interruption spits messages */
-	dm_shut_log();
-
 	/* wait */
 	r = dm_task_run(waiter->dmt);
 
 	/* wait is over : event or interrupt */
 	pthread_sigmask(SIG_SETMASK, &set, NULL);
-	//dm_restore_log();
 
 	if (!r) /* wait interrupted by signal */
 		return -1;
@@ -157,8 +153,11 @@
 		r = update_multipath(waiter->vecs, waiter->mapname);
 		lock_cleanup_pop(waiter->vecs->lock);
 
-		if (r)
+		if (r) {
+			condlog(2, "%s: event checker exit", 
+				waiter->mapname);
 			return -1; /* stop the thread */
+		}
 
 		event_nr = dm_geteventnr(waiter->mapname);
 
--- multipath-tools/multipath/main.c	2007/01/10 20:08:08	1.44.2.1
+++ multipath-tools/multipath/main.c	2007/06/15 19:03:02	1.44.2.2
@@ -1,7 +1,7 @@
 /*
  * Soft:        multipath device mapper target autoconfig
  *
- * Version:     $Id: main.c,v 1.44.2.1 2007/01/10 20:08:08 bmarzins Exp $
+ * Version:     $Id: main.c,v 1.44.2.2 2007/06/15 19:03:02 bmarzins Exp $
  *
  * Author:      Christophe Varoqui
  *
@@ -395,6 +395,7 @@
 			conf->dev_type = DEV_DEVMAP;
 
 	}
+	dm_init();
 
 	if (conf->remove == FLUSH_ONE) {
 		if (conf->dev_type == DEV_DEVMAP)
--- multipath-tools/multipathd/main.c	2007/01/10 20:08:09	1.69.2.1
+++ multipath-tools/multipathd/main.c	2007/06/15 19:03:02	1.69.2.2
@@ -225,6 +225,8 @@
 	int map_present;
 	int r = 1;
 
+	/* libsysfs seems to forget to terminate the string... */
+	memset(dev_t, 0, BLK_DEV_SIZE);
 	if (sscanf(devname, "dm-%d", &minor) == 1 &&
 	    !sysfs_get_dev(sysfs_path, devname, dev_t, BLK_DEV_SIZE) &&
 	    sscanf(dev_t, "%d:%d", &major, &minor) == 2)
@@ -654,10 +656,12 @@
 	lock(vecs->lock);
 
 	/*
-	 * device map add/remove event
+	 * device map event
+	 * Add events are ignored here as the tables
+	 * are not fully initialised then.
 	 */
 	if (!strncmp(devname, "dm-", 3)) {
-		if (!strncmp(uev->action, "add", 3)) {
+		if (!strncmp(uev->action, "change", 6)) {
 			r = uev_add_map(devname, vecs);
 			goto out;
 		}
@@ -1424,6 +1428,7 @@
 	int err;
 	
 	logsink = 1;
+	dm_init();
 
 	if (getuid() != 0) {
 		fprintf(stderr, "need to be root\n");

^ permalink raw reply	[flat|nested] 13+ messages in thread
* multipath-tools libmultipath/configure.c libmu ...
@ 2008-09-19  3:27 bmarzins
  2008-09-19  8:52 ` Pasi Kärkkäinen
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: bmarzins @ 2008-09-19  3:27 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	multipath-tools
Branch: 	RHEL5_FC6
Changes by:	bmarzins@sourceware.org	2008-09-19 03:27:08

Modified files:
	libmultipath   : configure.c configure.h devmapper.c devmapper.h 
	multipathd     : cli.c cli.h cli_handlers.c cli_handlers.h 
	                 main.c main.h 

Log message:
	Fix for bz #455692. There is now a command for multipathd, 'resize map'. This
	does online grows or shrinks for your multipath device. It has some warts.
	
	1. It needs to remove and re-add every path in the device. This can cause two
	annoyances. First, if you only have one valid path, you go into an all paths
	down scenario. However, you will immediately re-add the path, so it won't
	trigger problem #2. Second, if the path is inaccessable, you may not be able to
	re-add it.
	
	2. You can't disable flushing on suspend for a device-mapper device, when you
	want to change size. This means that if all your paths are down, you will fail
	the queued IOs when you suspend. This is a problem with the device-mapper kernel
	code, and there's no real way to avoid it, except by fixing it in the kernel.
	
	This commit also has some minor fixups for 238421, and adds the ability to
	disable and restore queueing on all multipath devices through multipathd

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/configure.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.2.2.3&r2=1.2.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/configure.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/devmapper.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.22.2.5&r2=1.22.2.6
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/devmapper.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.11.2.4&r2=1.11.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/cli.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.5.2.2&r2=1.5.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/cli.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.5.2.2&r2=1.5.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/cli_handlers.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.6.2.2&r2=1.6.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/cli_handlers.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.3.2.2&r2=1.3.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/main.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.69.2.13&r2=1.69.2.14
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/main.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.7&r2=1.7.2.1

--- multipath-tools/libmultipath/configure.c	2008/08/25 20:59:06	1.2.2.3
+++ multipath-tools/libmultipath/configure.c	2008/09/19 03:27:08	1.2.2.4
@@ -360,7 +360,16 @@
 			r = dm_addmap(DM_DEVICE_RELOAD, DEFAULT_TARGET, mpp, 0,
 				      1);
 		if (r)
-			r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias);
+			r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, 1);
+		break;
+
+	case ACT_RESIZE:
+		r = dm_addmap(DM_DEVICE_RELOAD, DEFAULT_TARGET, mpp, 0, 0);
+		if (!r)
+			r = dm_addmap(DM_DEVICE_RELOAD, DEFAULT_TARGET, mpp, 0,
+				      1);
+		if (r)
+			r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, 0);
 		break;
 
 	case ACT_RENAME:
--- multipath-tools/libmultipath/configure.h	2006/06/06 18:46:38	1.1
+++ multipath-tools/libmultipath/configure.h	2008/09/19 03:27:08	1.1.2.1
@@ -15,7 +15,8 @@
 	ACT_RELOAD,
 	ACT_SWITCHPG,
 	ACT_RENAME,
-	ACT_CREATE
+	ACT_CREATE,
+	ACT_RESIZE,
 };
 
 #define FLUSH_ONE 1
--- multipath-tools/libmultipath/devmapper.c	2008/08/25 20:59:06	1.22.2.5
+++ multipath-tools/libmultipath/devmapper.c	2008/09/19 03:27:08	1.22.2.6
@@ -130,7 +130,7 @@
 }
 
 extern int
-dm_simplecmd (int task, const char *name) {
+dm_simplecmd (int task, const char *name, int no_flush) {
 	int r = 0;
 	struct dm_task *dmt;
 
@@ -142,7 +142,8 @@
 
 	dm_task_no_open_count(dmt);
 	dm_task_skip_lockfs(dmt);       /* for DM_DEVICE_RESUME */
-	dm_task_no_flush(dmt);		/* for DM_DEVICE_SUSPEND/RESUME */
+	if (no_flush)
+		dm_task_no_flush(dmt);		/* for DM_DEVICE_SUSPEND/RESUME */
 
 	r = dm_task_run (dmt);
 
@@ -474,7 +475,7 @@
 		return 1;
 	}	
 
-	r = dm_simplecmd(DM_DEVICE_REMOVE, mapname);
+	r = dm_simplecmd(DM_DEVICE_REMOVE, mapname, 0);
 
 	if (r) {
 		condlog(4, "multipath map %s removed", mapname);
@@ -883,7 +884,7 @@
 				 */
 				condlog(4, "partition map %s removed",
 					names->name);
-				dm_simplecmd(DM_DEVICE_REMOVE, names->name);
+				dm_simplecmd(DM_DEVICE_REMOVE, names->name, 0);
 		   }
 
 		next = names->next;
--- multipath-tools/libmultipath/devmapper.h	2008/08/26 22:25:07	1.11.2.4
+++ multipath-tools/libmultipath/devmapper.h	2008/09/19 03:27:08	1.11.2.5
@@ -4,7 +4,7 @@
 
 void dm_init(void);
 int dm_prereq (char *, int, int, int);
-int dm_simplecmd (int, const char *);
+int dm_simplecmd (int, const char *, int);
 int dm_addmap (int, const char *, struct multipath *, int, int); 
 int dm_map_present (char *);
 int dm_get_map(char *, unsigned long long *, char *);
--- multipath-tools/multipathd/cli.c	2008/09/04 20:09:48	1.5.2.2
+++ multipath-tools/multipathd/cli.c	2008/09/19 03:27:08	1.5.2.3
@@ -131,6 +131,7 @@
 	r += add_key(keys, "fail", FAIL, 0);
 	r += add_key(keys, "disablequeueing", DISABLEQ, 0);
 	r += add_key(keys, "restorequeueing", RESTOREQ, 0);
+	r += add_key(keys, "resize", RESIZE, 0);
 	r += add_key(keys, "paths", PATHS, 0);
 	r += add_key(keys, "maps", MAPS, 0);
 	r += add_key(keys, "multipaths", MAPS, 0);
--- multipath-tools/multipathd/cli.h	2008/09/04 20:09:48	1.5.2.2
+++ multipath-tools/multipathd/cli.h	2008/09/19 03:27:08	1.5.2.3
@@ -9,6 +9,7 @@
 	__FAIL,
 	__DISABLEQ,
 	__RESTOREQ,
+	__RESIZE,
 	__PATHS,
 	__MAPS,
 	__PATH,
@@ -33,6 +34,7 @@
 #define FAIL		(1 << __FAIL)
 #define DISABLEQ	(1 << __DISABLEQ)
 #define RESTOREQ	(1 << __RESTOREQ)
+#define RESIZE		(1 << __RESIZE)
 #define PATHS		(1 << __PATHS)
 #define MAPS		(1 << __MAPS)
 #define PATH		(1 << __PATH)
--- multipath-tools/multipathd/cli_handlers.c	2008/09/04 20:09:48	1.6.2.2
+++ multipath-tools/multipathd/cli_handlers.c	2008/09/19 03:27:08	1.6.2.3
@@ -13,6 +13,8 @@
 #include <blacklist.h>
 #include <debug.h>
 #include <print.h>
+#include <discovery.h>
+#include <errno.h>
 
 #include "main.h"
 #include "cli.h"
@@ -343,11 +345,17 @@
 	struct multipath *mpp;
 	int minor;
 
+	condlog(2, "%s: restore map queueing (operator)", mapname);
 	if (sscanf(mapname, "dm-%d", &minor) == 1)
 		mpp = find_mp_by_minor(vecs->mpvec, minor);
 	else
 		mpp = find_mp_by_alias(vecs->mpvec, mapname);
 
+	if (!mpp) {
+		condlog(0, "%s: invalid map name, cannot restore queueing", mapname);
+		return 1;
+	}
+
 	if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF &&
 			mpp->no_path_retry != NO_PATH_RETRY_FAIL) {
 		dm_queue_if_no_path(mpp->alias, 1);
@@ -360,6 +368,27 @@
 }
 
 int
+cli_restore_all_queueing(void *v, char **reply, int *len, void *data)
+{
+	struct vectors * vecs = (struct vectors *)data;
+	struct multipath *mpp;
+	int i;
+
+	condlog(2, "restore queueing (operator)");
+	vector_foreach_slot(vecs->mpvec, mpp, i) {
+		if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF &&
+		    mpp->no_path_retry != NO_PATH_RETRY_FAIL) {
+			dm_queue_if_no_path(mpp->alias, 1);
+			if (mpp->nr_active > 0)
+				mpp->retry_tick = 0;
+			else
+				mpp->retry_tick = mpp->no_path_retry * conf->checkint;
+		}
+	}
+	return 0;
+}
+
+int
 cli_disable_queueing(void *v, char **reply, int *len, void *data)
 {
 	struct vectors * vecs = (struct vectors *)data;
@@ -367,17 +396,162 @@
 	struct multipath *mpp;
 	int minor;
 
+	condlog(2, "%s: disable map queueing (operator)", mapname);
 	if (sscanf(mapname, "dm-%d", &minor) == 1)
 		mpp = find_mp_by_minor(vecs->mpvec, minor);
 	else
 		mpp = find_mp_by_alias(vecs->mpvec, mapname);
 
+	if (!mpp) {
+		condlog(0, "%s: invalid map name, cannot disable queueing", mapname);
+		return 1;
+	}
+
 	mpp->retry_tick = 0;
 	dm_queue_if_no_path(mpp->alias, 0);
 	return 0;
 }
 
 int
+cli_disable_all_queueing(void *v, char **reply, int *len, void *data)
+{
+	struct vectors * vecs = (struct vectors *)data;
+	struct multipath *mpp;
+	int i;
+
+	condlog(2, "disable queueing (operator)");
+	vector_foreach_slot(vecs->mpvec, mpp, i) {
+		mpp->retry_tick = 0;
+		dm_queue_if_no_path(mpp->alias, 0);
+	}
+	return 0;
+}
+
+
+int
+reload_paths(struct multipath *mpp, struct vectors * vecs)
+{
+	struct pathgroup *pgp;
+	struct path *pp;
+	int i, j, err = 1;
+	char *dev;
+	vector path_names;
+
+	path_names = vector_alloc();
+	if (!path_names){
+		condlog(0, "%s: unable to allcoate space for pathnames vector",
+			mpp->alias);
+		return 1;
+	}
+	vector_foreach_slot(mpp->pg, pgp, i) {
+		vector_foreach_slot(pgp->paths, pp, j) {
+
+			dev = strdup(pp->dev);
+			if (!dev) {
+				condlog(0, "%s: unable to allocate space for path name", mpp->alias);
+				goto out;
+			}
+			if (!vector_alloc_slot(path_names)){
+				condlog(0, "%s: unable to allocate space for path name slot", mpp->alias);
+				free(dev);
+				goto out;
+			}
+			vector_set_slot(path_names, dev);
+		}
+	}
+	vector_foreach_slot(path_names, dev, i) {
+		err = ev_remove_path(dev, vecs);
+		if (err) {
+			condlog(0, "%s: couldn't remove path '%s' : %s",
+				mpp->alias, dev, strerror(errno));
+			goto out;
+		}
+		err = ev_add_path(dev, vecs);
+		if (err)
+			condlog(0, "%s: couldn't add path '%s' : %s",
+				mpp->alias, dev, strerror(errno));
+	}
+out:
+	vector_foreach_slot(path_names, dev, i)
+		free(dev);
+	vector_free(path_names);
+	return err;
+}
+
+int resize_map(struct multipath *mpp, unsigned long long size, struct vectors * vecs)
+{
+	mpp->size = size;
+	update_mpp_paths(mpp, vecs->pathvec);
+	setup_map(mpp);
+	mpp->action = ACT_RESIZE;
+	if (domap(mpp) <= 0) {
+		condlog(0, "%s: failed to resize map : %s", mpp->alias,
+			strerror(errno));
+		return 1;
+	}
+	return 0;
+}
+
+int
+cli_resize(void *v, char **reply, int *len, void *data)
+{
+	struct vectors * vecs = (struct vectors *)data;
+	char * mapname = get_keyparam(v, MAP);
+	struct multipath *mpp;
+	int minor;
+	unsigned long long size;
+	struct pathgroup *pgp;
+	struct path *pp;
+
+	condlog(2, "%s: resize map (operator)", mapname);
+	if (sscanf(mapname, "dm-%d", &minor) == 1)
+		mpp = find_mp_by_minor(vecs->mpvec, minor);
+	else
+		mpp = find_mp_by_alias(vecs->mpvec, mapname);
+
+	if (!mpp) {
+		condlog(0, "%s: invalid map name. cannot resize", mapname);
+		return 1;
+	}
+
+	pgp = VECTOR_SLOT(mpp->pg, 0);
+	pp = VECTOR_SLOT(pgp->paths, 0);
+	if (sysfs_get_size(sysfs_path, pp->dev, &size)) {
+		condlog(0, "%s: couldn't get size for sysfs. cannot resize",
+			mapname);
+		return 1;
+	}
+	if (size == mpp->size) {
+		condlog(0, "%s: map is still the same size (%llu)", mapname,
+			mpp->size);
+		return 0;
+	}
+	condlog(3, "%s old size is %llu, new size is %llu", mapname, mpp->size,
+		size);
+	if (size > mpp->size) {
+		if (reload_paths(mpp, vecs) != 0) {
+			condlog(0, "%s: failed to reload paths", mapname);
+			return 1;
+		}
+		if (resize_map(mpp, size, vecs) != 0)
+			return 1;
+	}
+	else {
+		if (resize_map(mpp, size, vecs) != 0)
+			return 1;
+		if (reload_paths(mpp, vecs) != 0) {
+			condlog(0, "%s: failed to reload paths", mapname);
+			return 1;
+		}
+	}
+	dm_lib_release();
+	setup_multipath(vecs, mpp);
+	sync_map_state(mpp);
+
+	return 0;
+}
+
+int
 cli_switch_group(void * v, char ** reply, int * len, void * data)
 {
 	char * mapname = get_keyparam(v, MAP);
@@ -403,7 +577,7 @@
 {
 	struct vectors * vecs = (struct vectors *)data;
 	char * param = get_keyparam(v, MAP);
-	int r = dm_simplecmd(DM_DEVICE_SUSPEND, param);
+	int r = dm_simplecmd(DM_DEVICE_SUSPEND, param, 1);
 
 	condlog(2, "%s: suspend (operator)", param);
 
@@ -424,7 +598,7 @@
 {
 	struct vectors * vecs = (struct vectors *)data;
 	char * param = get_keyparam(v, MAP);
-	int r = dm_simplecmd(DM_DEVICE_RESUME, param);
+	int r = dm_simplecmd(DM_DEVICE_RESUME, param, 1);
 
 	condlog(2, "%s: resume (operator)", param);
 
--- multipath-tools/multipathd/cli_handlers.h	2008/09/04 20:09:48	1.3.2.2
+++ multipath-tools/multipathd/cli_handlers.h	2008/09/19 03:27:08	1.3.2.3
@@ -14,7 +14,10 @@
 int cli_switch_group(void * v, char ** reply, int * len, void * data);
 int cli_reconfigure(void * v, char ** reply, int * len, void * data);
 int cli_disable_queueing(void * v, char ** reply, int * len, void * data);
+int cli_disable_all_queueing(void * v, char ** reply, int * len, void * data);
 int cli_restore_queueing(void * v, char ** reply, int * len, void * data);
+int cli_restore_all_queueing(void * v, char ** reply, int * len, void * data);
+int cli_resize(void * v, char ** reply, int * len, void * data);
 int cli_suspend(void * v, char ** reply, int * len, void * data);
 int cli_resume(void * v, char ** reply, int * len, void * data);
 int cli_reinstate(void * v, char ** reply, int * len, void * data);
--- multipath-tools/multipathd/main.c	2008/09/12 23:49:57	1.69.2.13
+++ multipath-tools/multipathd/main.c	2008/09/19 03:27:08	1.69.2.14
@@ -158,7 +158,7 @@
 	return 0;
 }
 
-static void
+void
 sync_map_state(struct multipath *mpp)
 {
 	struct pathgroup *pgp;
@@ -768,6 +768,9 @@
 	add_handler(FAIL+PATH, cli_fail);
 	add_handler(DISABLEQ+MAP, cli_disable_queueing);
 	add_handler(RESTOREQ+MAP, cli_restore_queueing);
+	add_handler(DISABLEQ+MAPS, cli_disable_all_queueing);
+	add_handler(RESTOREQ+MAPS, cli_restore_all_queueing);
+	add_handler(RESIZE+MAP, cli_resize);
 
 	uxsock_listen(&uxsock_trigger, ap);
 
--- multipath-tools/multipathd/main.h	2006/06/06 18:32:44	1.7
+++ multipath-tools/multipathd/main.h	2008/09/19 03:27:08	1.7.2.1
@@ -9,5 +9,6 @@
 int ev_remove_path (char *, struct vectors *);
 int ev_add_map (char *, struct vectors *);
 int ev_remove_map (char *, struct vectors *);
+void sync_map_state (struct multipath *);
 
 #endif /* MAIN_H */

^ permalink raw reply	[flat|nested] 13+ messages in thread
* multipath-tools libmultipath/configure.c libmu ...
@ 2010-06-23 16:28 bmarzins
  0 siblings, 0 replies; 13+ messages in thread
From: bmarzins @ 2010-06-23 16:28 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	multipath-tools
Branch: 	RHEL5_FC6
Changes by:	bmarzins@sourceware.org	2010-06-23 16:28:08

Modified files:
	libmultipath   : configure.c discovery.c discovery.h 
	                 structs_vec.c 
	multipathd     : main.c 

Log message:
	Fixes for bzs #599053, #584742, and #597789.
	
	The 599053 fix checks if the sysfs path for a block device exists, when
	wait_for_file can't find a sysfs file.  If the path doesn't exist, it doesn't
	wait, since the block device path should always be there for devices that exist.
	
	The 584742 fix deals with 3 seperate errors, pidfile_check() wasn't closing
	the fd, when pathinfo freed it's fd, it wasn't also freeing the checker,
	which needs to be reinitialized for the new fd. Finally, when you run
	multipath on a resized device, it now uses ACT_RESIZE instead of ACT_RELOAD,
	to properly allow flushing.
	
	The 597789 fix moves setting the multipath hwe to before verifying the path,
	in case the path gets removed during verification.  It also uses checks
	the sysfs block device path, instead of the dev file.
	
	Not applicable upstream

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/configure.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.2.2.8&r2=1.2.2.9
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/discovery.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.32.2.13&r2=1.32.2.14
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/discovery.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.14.2.3&r2=1.14.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/structs_vec.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.1.2.4&r2=1.1.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/main.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.69.2.26&r2=1.69.2.27

--- multipath-tools/libmultipath/configure.c	2010/04/24 05:28:06	1.2.2.8
+++ multipath-tools/libmultipath/configure.c	2010/06/23 16:28:07	1.2.2.9
@@ -177,8 +177,8 @@
 		return;
 	}
 	if (cmpp->size != mpp->size) {
-		mpp->action = ACT_RELOAD;
-		condlog(3, "%s: set ACT_RELOAD (size change)",
+		mpp->action = ACT_RESIZE;
+		condlog(3, "%s: set ACT_RESIZE (size change)",
 			mpp->alias);
 		return;
 	}
@@ -463,6 +463,7 @@
 			strerror(errno));
 		return -1;
 	}
+	close(fd);
 	if (lock.l_type == F_UNLCK)
 		return 0;
 	return 1;
--- multipath-tools/libmultipath/discovery.c	2010/01/27 22:33:29	1.32.2.13
+++ multipath-tools/libmultipath/discovery.c	2010/06/23 16:28:07	1.32.2.14
@@ -162,6 +162,19 @@
 	return r;
 }
 
+int
+check_sysfs_dir(char *sysfs_path, char * dev)
+{
+	char dev_dir[SYSFS_PATH_SIZE];
+	struct stat stats;
+
+	if (sysfs_path && safe_sprintf(dev_dir, "%s/block/%s", sysfs_path, dev))
+		return 1;
+	if (stat(dev_dir, &stats) != 0)
+		return 1;
+	return 0;
+}
+
 /*
  * the daemon can race udev upon path add,
  * not multipath(8), ran by udev
@@ -171,11 +184,11 @@
 #define WAIT_LOOP_PER_SECOND 5
 
 static int
-wait_for_file (char * filename)
+wait_for_file (char * filename, char * sysfs_path, char * dev)
 {
 	int loop;
 	struct stat stats;
-	
+
 	loop = WAIT_MAX_SECONDS * WAIT_LOOP_PER_SECOND;
 	
 	while (--loop) {
@@ -185,13 +198,16 @@
 		if (errno != ENOENT)
 			return 1;
 
+		if (sysfs_path && check_sysfs_dir(sysfs_path, dev) != 0)
+			return 1;
+
 		usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND);
 	}
 	return 1;
 }
 #else
 static int
-wait_for_file (char * filename)
+wait_for_file (char * filename, char * sysfs_path, char * dev)
 {
 	return 0;
 }
@@ -207,7 +223,7 @@
 	if (safe_sprintf(attr_path, fmt, sysfs_path, dev)) \
 		return 1; \
 \
-	if (dowait && wait_for_file(attr_path)) \
+	if (dowait && wait_for_file(attr_path, sysfs_path, dev)) \
 		return 1; \
 \
 	if (!(attr = sysfs_open_attribute(attr_path))) \
@@ -320,7 +336,7 @@
 		return -1;
 	}
 
-	if (wait_for_file(devpath)) {
+	if (wait_for_file(devpath, NULL, NULL)) {
 		condlog(3, "failed to open %s", devpath);
 		return -1;
 	}
@@ -857,6 +873,8 @@
 		get_prio(pp);
 
 #ifndef DAEMON
+	if (checker_selected(&pp->checker))
+		checker_put(&pp->checker);
 	close(pp->fd);
 	pp->fd = -1;
 #endif
--- multipath-tools/libmultipath/discovery.h	2010/01/27 16:46:48	1.14.2.3
+++ multipath-tools/libmultipath/discovery.h	2010/06/23 16:28:07	1.14.2.4
@@ -24,6 +24,7 @@
 #define SCSI_COMMAND_TERMINATED 0x22
 #define SG_ERR_DRIVER_SENSE     0x08
 
+int check_sysfs_dir(char *sysfs_path, char * dev);
 int device_ok_to_add(char *devname);
 int sysfs_get_vendor (char * sysfs_path, char * dev, char * buff, int len);
 int sysfs_get_model (char * sysfs_path, char * dev, char * buff, int len);
--- multipath-tools/libmultipath/structs_vec.c	2009/03/26 03:28:09	1.1.2.4
+++ multipath-tools/libmultipath/structs_vec.c	2010/06/23 16:28:07	1.1.2.5
@@ -378,8 +378,7 @@
 		 * see if path is in sysfs
 		 */
 		if (!(*pp->dev) ||
-		    sysfs_get_dev(sysfs_path, pp->dev, pp->dev_t,
-				  BLK_DEV_SIZE)) {
+		    check_sysfs_dir(sysfs_path, pp->dev)) {
 			if (!(*pp->dev))
 				condlog(3,
 					"%s: removing path %s with no devname",
--- multipath-tools/multipathd/main.c	2010/01/27 17:21:48	1.69.2.26
+++ multipath-tools/multipathd/main.c	2010/06/23 16:28:08	1.69.2.27
@@ -411,8 +411,8 @@
 		if (adopt_paths(vecs->pathvec, mpp))
 			return 1; /* leave path added to pathvec */
 
-		verify_paths(mpp, vecs, NULL);
 		mpp->hwe = pp->hwe;
+		verify_paths(mpp, vecs, NULL);
 		mpp->flush_on_last_del = FLUSH_UNDEF;
 		mpp->action = ACT_RELOAD;
 	}

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

end of thread, other threads:[~2010-06-23 16:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-15 19:03 multipath-tools libmultipath/configure.c libmu bmarzins
  -- strict thread matches above, loose matches on Subject: below --
2008-09-19  3:27 bmarzins
2008-09-19  8:52 ` Pasi Kärkkäinen
2008-09-19 18:53 ` Andy
2008-09-19 21:57   ` Andy
2008-09-23 18:05     ` Benjamin Marzinski
2008-09-30  9:22       ` Pasi Kärkkäinen
2008-09-30  9:38         ` Pasi Kärkkäinen
2008-09-30 19:20           ` Benjamin Marzinski
2008-10-01 13:03             ` Pasi Kärkkäinen
2008-12-18 20:26 ` Konrad Rzeszutek
2008-12-18 21:21   ` Benjamin Marzinski
2010-06-23 16:28 bmarzins

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.