Skip to contentSkip to conversation

multipath: Allow user_friendly_names in more config sections

PATCH New Benjamin Marzinski 1 participant 1 message May 23, 2012 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

PATCH 1/1 multipath: Allow user_friendly_names in more config sections

This patch adds support for setting user_friendly_names in the devices and multipaths config sections.

---
 libmultipath/config.c  |    2 +
 libmultipath/config.h  |    2 +
 libmultipath/dict.c    |   94 +++++++++++++++++++++++++++++++++++++++++++++----
 libmultipath/propsel.c |   14 ++++++-
 libmultipath/structs.h |    6 +++
 5 files changed, 110 insertions(+), 8 deletions(-)
libmultipath/config.c +2 -0
Index: multipath-tools-120518/libmultipath/config.c
===================================================================
@@ -325,6 +325,7 @@ merge_hwe (struct hwentry * dst, struct
 	merge_num(flush_on_last_del);
 	merge_num(fast_io_fail);
 	merge_num(dev_loss);
+	merge_num(user_friendly_names);
 
 	return 0;
 }
@@ -383,6 +384,7 @@ store_hwe (vector hwtable, struct hwentr
 	hwe->flush_on_last_del = dhwe->flush_on_last_del;
 	hwe->fast_io_fail = dhwe->fast_io_fail;
 	hwe->dev_loss = dhwe->dev_loss;
+	hwe->user_friendly_names = dhwe->user_friendly_names;
 
 	if (dhwe->bl_product && !(hwe->bl_product = set_param_str(dhwe->bl_product)))
 		goto out;
libmultipath/config.h +2 -0
Index: multipath-tools-120518/libmultipath/config.h
===================================================================
@@ -44,6 +44,7 @@ struct hwentry {
 	int flush_on_last_del;
 	int fast_io_fail;
 	unsigned int dev_loss;
+	int user_friendly_names;
 	char * bl_product;
 };
 
@@ -66,6 +67,7 @@ struct mpentry {
 	int pg_timeout;
 	int flush_on_last_del;
 	int attribute_flags;
+	int user_friendly_names;
 	uid_t uid;
 	gid_t gid;
 	mode_t mode;
libmultipath/dict.c +87 -7

156 lines not on this page · raw message

libmultipath/propsel.c +13 -1
Index: multipath-tools-120518/libmultipath/propsel.c
===================================================================
@@ -237,6 +237,18 @@ select_alias_prefix (struct multipath *
 		mp->wwid, mp->alias_prefix);
 }
 
+static int
+want_user_friendly_names(struct multipath * mp)
+{
+	if (mp->mpe &&
+	    mp->mpe->user_friendly_names != USER_FRIENDLY_NAMES_UNDEF)
+		return (mp->mpe->user_friendly_names == USER_FRIENDLY_NAMES_ON);
+	if (mp->hwe &&
+	    mp->hwe->user_friendly_names != USER_FRIENDLY_NAMES_UNDEF)
+		return (mp->hwe->user_friendly_names == USER_FRIENDLY_NAMES_ON);
+	return (conf->user_friendly_names  == USER_FRIENDLY_NAMES_ON);
+}
+
 extern int
 select_alias (struct multipath * mp)
 {
@@ -244,7 +256,7 @@ select_alias (struct multipath * mp)
 		mp->alias = STRDUP(mp->mpe->alias);
 	else {
 		mp->alias = NULL;
-		if (conf->user_friendly_names) {
+		if (want_user_friendly_names(mp)) {
 			select_alias_prefix(mp);
 			mp->alias = get_user_friendly_alias(mp->wwid,
 					conf->bindings_file, mp->alias_prefix, conf->bindings_read_only);
libmultipath/structs.h +6 -0
Index: multipath-tools-120518/libmultipath/structs.h
===================================================================
@@ -92,6 +92,12 @@ enum log_checker_err_states {
 	LOG_CHKR_ERR_ONCE,
 };
 
+enum user_friendly_names_states {
+	USER_FRIENDLY_NAMES_UNDEF,
+	USER_FRIENDLY_NAMES_OFF,
+	USER_FRIENDLY_NAMES_ON,
+};
+
 struct scsi_idlun {
 	int dev_id;
 	int host_unique_id;