Skip to contentSkip to conversation

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

PATCH [email protected] 1 participant 1 message Oct 27, 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-10-27 21:36:20

Modified files:
libmultipath : config.c config.h dict.c print.c
multipathd : main.c

Log message:
fix for bz #703277. When checking for mounts to keep in the multipathd namespace, check if a necessary directory is a symlink, and if so, keep mounts at its target, or at any parent directories. Also add a new default option, keep_dir, to allow users to manually select directories to keep. Mounts at these, or their parent directories will also be kept. Not applicable upstream.

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.10&r2=1.19.2.11
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/config.h.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.18.2.15&r2=1.18.2.16
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/dict.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.17.2.21&r2=1.17.2.22
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/print.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.5.2.3&r2=1.5.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/main.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.69.2.38&r2=1.69.2.39

libmultipath/config.c +4 -0
@@ -394,6 +394,7 @@
 	free_hwtable(conf->hwtable);
 	free_keywords(conf->keywords);
 	free_strvec(conf->binvec);
+	free_strvec(conf->keep_dirs);
 	FREE(conf);
 }
 
@@ -418,6 +419,9 @@
 	conf->attribute_flags = 0;
 	conf->flush_on_last_del = 0;
 	conf->file_timeout = DEFAULT_FILE_TIMEOUT;
+	conf->keep_dirs = vector_alloc();
+	if (!conf->keep_dirs)
+		goto out;
 
 	/*
 	 * read the config file
libmultipath/config.h +1 -0
@@ -103,6 +103,7 @@
 	vector mptable;
 	vector hwtable;
 	vector binvec;
+	vector keep_dirs;
 
 	vector blist_devnode;
 	vector blist_wwid;
libmultipath/dict.c +29 -0
@@ -524,6 +524,24 @@
 	return 0;
 }
 
+static int
+keep_dir_handler(vector strvec)
+{
+	char * buff;
+
+	buff = set_value(strvec);
+	if (!buff)
+		return 1;
+
+	if (!vector_alloc_slot(conf->keep_dirs)) {
+		free(buff);
+		return 1;
+	}
+	vector_set_slot(conf->keep_dirs, buff);
+
+	return 0;
+}
+
 /*
  * blacklist block handlers
  */
@@ -2117,6 +2135,16 @@
 }
 
 static int
+snprint_keep_dir(char * buff, int len, void * data)
+{
+	char *str = (char *)data;
+
+	if (!str || str[0] == '\0')
+		return 0;
+	return snprintf(buff, len, "\"%s\"", str);
+}
+
+static int
 snprint_ble_simple (char * buff, int len, void * data)
 {
 	struct blentry * ble = (struct blentry *)data;
@@ -2176,6 +2204,7 @@
 	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);
+	install_keyword_multi("keep_dir", &keep_dir_handler, &snprint_keep_dir);
 	__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/print.c +14 -0
@@ -853,6 +853,20 @@
 		return len;
 
 	iterate_sub_keywords(rootkw, kw, i) {
+		if (strcmp(kw->string, "keep_dir") == 0) {
+			char *str;
+			int j;
+			if (!conf->keep_dirs)
+				continue;
+			vector_foreach_slot(conf->keep_dirs, str, j) {
+				fwd += snprint_keyword(buff + fwd, len - fwd,
+						       "\t%k %v\n", kw, str);
+				if (fwd > len)
+					return len;
+			}
+			continue;
+
+		}
 		fwd += snprint_keyword(buff + fwd, len - fwd, "\t%k %v\n",
 				kw, NULL);
 		if (fwd > len)
multipathd/main.c +56 -4

85 lines not on this page · raw message