Skip to contentSkip to conversation

multipath-tools/libmultipath config.c config.h ...

PATCH [email protected] 1 participant 1 message Apr 5, 2011 Device mapper

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/dm
Module name: multipath-tools
Branch: RHEL5_FC6
Changes by: [email protected] 2011-04-05 18:41:45

Modified files:
libmultipath : config.c config.h defaults.h dict.c discovery.c

Log message:
Fix for bz #674366. Multipath has a new defaults config value file_timeout. This allows users to set the length of time multipathd will wait for a necessary file to appear. Previously, it used the hardcoded value, WAIT_MAX_SECONDS.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/config.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.19.2.9&r2=1.19.2.10
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/config.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.18.2.14&r2=1.18.2.15
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/defaults.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.7.2.1&r2=1.7.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/dict.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.17.2.18&r2=1.17.2.19
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/discovery.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.32.2.19&r2=1.32.2.20

libmultipath/config.c +1 -0
@@ -417,6 +417,7 @@
 	conf->max_fds = 0;
 	conf->attribute_flags = 0;
 	conf->flush_on_last_del = 0;
+	conf->file_timeout = DEFAULT_FILE_TIMEOUT;
 
 	/*
 	 * read the config file
libmultipath/config.h +1 -0
@@ -84,6 +84,7 @@
 	int pg_prio_calc;
 	int log_checker_err;
 	int fast_io_fail;
+	int file_timeout;
 	unsigned int dev_loss;
 	uid_t uid;
 	gid_t gid;
libmultipath/defaults.h +1 -0
@@ -12,6 +12,7 @@
 #define DEFAULT_PGTIMEOUT      -PGTIMEOUT_NONE
 #define DEFAULT_USER_FRIENDLY_NAMES    0
 #define DEFAULT_VERBOSITY      2
+#define DEFAULT_FILE_TIMEOUT	90
 
 #define DEFAULT_CHECKINT	5
 #define MAX_CHECKINT(a)		(a << 2)
libmultipath/dict.c +22 -0
@@ -85,6 +85,21 @@
 }
 
 static int
+file_timeout_handler(vector strvec)
+{
+	char * buff;
+	buff = set_value(strvec);
+	if (!buff)
+		return 1;
+	conf->file_timeout = atoi(buff);
+	if (conf->file_timeout < 0)
+		 conf->file_timeout = DEFAULT_FILE_TIMEOUT;
+
+	FREE(buff);
+	return 0;
+}
+
+static int
 udev_dir_handler(vector strvec)
 {
 	conf->udev_dir = set_value(strvec);
@@ -1848,6 +1863,12 @@
 }
 
 static int
+snprint_file_timeout(char * buff, int len, void * data)
+{
+	return snprintf(buff, len, "%i", conf->file_timeout);
+}
+
+static int
 snprint_def_udev_dir (char * buff, int len, void * data)
 {
 	if (!conf->udev_dir)
@@ -2153,6 +2174,7 @@
 	install_keyword("gid", &def_gid_handler, &snprint_def_gid);
 	install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail);
 	install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss);
+	install_keyword("file_timeout", &file_timeout_handler, &snprint_file_timeout);
 	__deprecated install_keyword("default_selector", &def_selector_handler, NULL);
 	__deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
 	__deprecated install_keyword("default_getuid_callout", &def_getuid_callout_handler, NULL);
libmultipath/discovery.c +2 -3
@@ -181,7 +181,6 @@
  * not multipath(8), ran by udev
  */
 #if DAEMON
-#define WAIT_MAX_SECONDS 90
 #define WAIT_LOOP_PER_SECOND 5
 
 static int
@@ -190,7 +189,7 @@
 	int loop;
 	struct stat stats;
 
-	loop = WAIT_MAX_SECONDS * WAIT_LOOP_PER_SECOND;
+	loop = conf->file_timeout * WAIT_LOOP_PER_SECOND;
 	
 	while (--loop) {
 		if (stat(filename, &stats) == 0)
@@ -632,7 +631,7 @@
 		return 1;
 
 #if DAEMON
-	int loop = WAIT_MAX_SECONDS * WAIT_LOOP_PER_SECOND;
+	int loop = conf->file_timeout * WAIT_LOOP_PER_SECOND;
 
 	while (loop--) {
 		sdev = sysfs_open_device_path(attr_buff);