File multipath-tools-select-features-from-multipath of Package multipath-tools

commit 7730ae404420a9b45b5eaac2b7e673bae49e44b8
Author: Hannes Reinecke <hare@suse.de>
Date:   Fri Mar 13 15:21:29 2009 +0100

    Select 'features' from multipath configuration
    
    For some setups we need to set the 'features' keyword from the
    multipath configuration setting.
    
    References: 465009
    
    Signed-off-by: Hannes Reinecke <hare@suse.de>

diff --git a/libmultipath/config.h b/libmultipath/config.h
index 7d23927..08c2542 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -39,6 +39,7 @@ struct mpentry {
 	char * alias;
 	char * getuid;
 	char * selector;
+	char * features;
 
 	char * prio_name;
 	char * prio_arg;
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
index ed77000..162e664 100644
--- a/libmultipath/dict.c
+++ b/libmultipath/dict.c
@@ -1089,6 +1089,22 @@ mp_pg_timeout_handler(vector strvec)
 }
 
 static int
+mp_features_handler(vector strvec)
+{
+	struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
+
+	if (!mpe)
+		return 1;
+
+	mpe->features = set_value(strvec);
+
+	if (!mpe->features)
+		return 1;
+
+	return 0;
+}
+
+static int
 mp_prio_handler (vector strvec)
 {
 	struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
@@ -1255,6 +1271,20 @@ snprint_mp_pg_timeout (char * buff, int len, void * data)
 }
 
 static int
+snprint_mp_features (char * buff, int len, void * data)
+{
+	struct mpentry * mpe = (struct mpentry *)data;
+
+	if (!mpe->features)
+		return 0;
+	if (strlen(mpe->features) == strlen(conf->features) &&
+	    !strcmp(mpe->features, conf->features))
+		return 0;
+
+	return snprintf(buff, len, "%s", mpe->features);
+}
+
+static int
 snprint_mp_prio(char * buff, int len, void * data)
 {
 	struct mpentry * mpe = (struct mpentry *)data;
@@ -1898,5 +1928,6 @@ init_keywords(void)
 	install_keyword("no_path_retry", &mp_no_path_retry_handler, &snprint_mp_no_path_retry);
 	install_keyword("rr_min_io", &mp_minio_handler, &snprint_mp_rr_min_io);
 	install_keyword("pg_timeout", &mp_pg_timeout_handler, &snprint_mp_pg_timeout);
+	install_keyword("features", &mp_features_handler, &snprint_mp_features);
 	install_sublevel_end();
 }
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
index 1fc7c40..72c0fa6 100644
--- a/libmultipath/propsel.c
+++ b/libmultipath/propsel.c
@@ -184,6 +184,16 @@ select_alias (struct multipath * mp)
 extern int
 select_features (struct multipath * mp)
 {
+	struct mpentry * mpe;
+
+	if ((mpe = find_mpe(mp->wwid))) {
+		if (mpe->features) {
+			mp->features = mpe->features;
+			condlog(3, "%s: features = %s (LUN setting)",
+				mp->alias, mp->features);
+			return 0;
+		}
+	}
 	if (mp->hwe && mp->hwe->features) {
 		mp->features = mp->hwe->features;
 		condlog(3, "%s: features = %s (controller setting)",
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
index d29a3b6..51534a0 100644
--- a/multipath/multipath.conf.5
+++ b/multipath/multipath.conf.5
@@ -342,6 +342,8 @@ Index of the container. Mandatory for this subsection.
 The following attributes are optional; if not set the default values
 are taken from the
 .I defaults
+or
+.I devices
 section:
 .sp 1
 .PD .1v
@@ -360,6 +362,8 @@ section:
 .B no_path_retry
 .TP
 .B rr_min_io
+.TP
+.B features
 .RE
 .PD
 .LP
openSUSE Build Service is sponsored by