Skip to contentSkip to conversation

multipath: add fast_io_fail and dev_loss_tmo config parameters

PATCH New Benjamin Marzinski 1 participant 1 message Mar 23, 2010 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

PATCH 1/1 multipath: add fast_io_fail and dev_loss_tmo config parameters

This patch adds two new configuration parameters to multipath.conf, fast_io_fail_tmo and dev_loss_tmo which set

/sys/class/fc_remote_ports/rport-<host>:<channel>-<rport_id>/fast_io_fail_tmo and /sys/class/fc_remote_ports/rport-<host>:<channel>-<rport_id>/dev_loss_tmo

for all the capable paths in a multipath device.

---
 libmultipath/config.h      |    4 +
 libmultipath/configure.c   |    3 +
 libmultipath/dict.c        |  102 +++++++++++++++++++++++++++++++++++++++++++++
 libmultipath/discovery.c   |   37 ++++++++++++++++
 libmultipath/discovery.h   |    1 
 libmultipath/propsel.c     |   42 ++++++++++++++++++
 libmultipath/propsel.h     |    2 
 libmultipath/structs.h     |    2 
 libmultipath/sysfs.c       |   56 ++++++++++++++++++++++++
 libmultipath/sysfs.h       |    3 -
 multipath.conf.annotated   |   38 ++++++++++++++++
 multipath/multipath.conf.5 |   15 ++++++
 12 files changed, 303 insertions(+), 2 deletions(-)
multipath.conf.annotated +37 -1
Index: multipath-tools-100322/multipath.conf.annotated
===================================================================
@@ -191,6 +191,25 @@
 #	# default : determined by the process
 #	gid disk
 #
+#	#
+#	# name    : fast_io_fail_tmo
+#	# scope   : multipath & multipathd
+#	# desc    : The number of seconds the scsi layer will wait after a
+#	#           problem has been detected on a FC remote port before failing
+#	#           IO to devices on that remote port.
+#	# values  : off | n >= 0 (smaller than dev_loss_tmo)
+#	# default : determined by the OS
+#	fast_io_fail_tmo 5
+#
+#	#
+#	# name    : dev_loss_tmo
+#	# scope   : multipath & multipathd
+#	# desc    : The number of seconds the scsi layer will wait after a
+#	#           problem has been detected on a FC remote port before
+#	#           removing it from the system.
+#	# values  : n > 0
+#	# default : determined by the OS
+#	dev_loss_tmo 600
 #}
 #	
 ##
@@ -504,7 +523,6 @@
 #		# desc    : If set to "yes", multipathd will disable queueing
 #		#           when the last path to a device has been deleted.
 #		# values  : yes|no
-#		# default : no
 #		#
 #		flush_on_last_del       yes
 #
@@ -514,6 +532,24 @@
 #		# desc    : product strings to blacklist for this vendor
 #		#
 #		product_blacklist	LUN_Z
+#
+#		#
+#		# name    : fast_io_fail_tmo
+#		# scope   : multipath & multipathd
+#		# desc    : The number of seconds the scsi layer will wait after
+#		#           a problem has been detected on a FC remote port
+#		#           before failing IO to devices on that remote port.
+#		# values  : off | n >= 0 (smaller than dev_loss_tmo)
+#		fast_io_fail_tmo 5
+#
+#		#
+#		# name    : dev_loss_tmo
+#		# scope   : multipath & multipathd
+#		# desc    : The number of seconds the scsi layer will wait after
+#		#           a problem has been detected on a FC remote port
+#		#           before removing it from the system.
+#		# values  : n > 0
+#		dev_loss_tmo 600
 #	}
 #	device {
 #		vendor			"COMPAQ  "
multipath/multipath.conf.5 +15 -0
Index: multipath-tools-100322/multipath/multipath.conf.5
===================================================================
@@ -240,6 +240,17 @@ this to the system limit from /proc/sys/
 maximum number of open fds is taken from the calling process. It is usually
 1024. To be safe, this should be set to the maximum number of paths plus 32,
 if that number is greated than 1024.
+.TP
+.B fast_io_fail_tmo
+Specify the number of seconds the scsi layer will wait after a problem has been
+detected on a FC remote port before failing IO to devices on that remote port.
+This should be smaller than dev_loss_tmo. Setting this to
+.I off
+will disable the timeout.
+.TP
+.B dev_loss_tmo
+Specify the number of seconds the scsi layer will wait after a problem has
+been detected on a FC remote port before removing it from the system.
 .
 .SH "blacklist section"
 The
@@ -384,6 +395,10 @@ section:
 .B no_path_retry
 .TP
 .B rr_min_io
+.TP
+.B fast_io_fail_tmo
+.TP
+.B dev_loss_tmo
 .RE
 .PD
 .LP
libmultipath/dict.c +102 -0

138 lines not on this page · raw message

libmultipath/config.h +4 -0
Index: multipath-tools-100322/libmultipath/config.h
===================================================================
@@ -31,6 +31,8 @@ struct hwentry {
 	int minio;
 	int pg_timeout;
 	int flush_on_last_del;
+	int fast_io_fail;
+	unsigned int dev_loss;
 	char * bl_product;
 };
 
@@ -75,6 +77,8 @@ struct config {
 	int daemon;
 	int flush_on_last_del;
 	int attribute_flags;
+	int fast_io_fail;
+	unsigned int dev_loss;
 	uid_t uid;
 	gid_t gid;
 	mode_t mode;
libmultipath/propsel.c +42 -0

48 lines not on this page · raw message

libmultipath/structs.h +2 -0
Index: multipath-tools-100322/libmultipath/structs.h
===================================================================
@@ -166,6 +166,8 @@ struct multipath {
 	int pg_timeout;
 	int flush_on_last_del;
 	int attribute_flags;
+	int fast_io_fail;
+	unsigned int dev_loss;
 	uid_t uid;
 	gid_t gid;
 	mode_t mode;
libmultipath/configure.c +3 -0
Index: multipath-tools-100322/libmultipath/configure.c
===================================================================
@@ -70,7 +70,10 @@ setup_map (struct multipath * mpp)
 	select_mode(mpp);
 	select_uid(mpp);
 	select_gid(mpp);
+	select_fast_io_fail(mpp);
+	select_dev_loss(mpp);
 
+	sysfs_set_scsi_tmo(mpp);
 	/*
 	 * assign paths to path groups -- start with no groups and all paths
 	 * in mpp->paths
libmultipath/discovery.c +37 -0
Index: multipath-tools-100322/libmultipath/discovery.c
===================================================================
@@ -204,6 +204,43 @@ sysfs_get_fc_nodename (struct sysfs_devi
 	return 1;
 }
 
+int
+sysfs_set_scsi_tmo (struct multipath *mpp)
+{
+	char attr_path[SYSFS_PATH_SIZE];
+	struct path *pp;
+	int i;
+	char value[11];
+
+	if (!mpp->dev_loss && !mpp->fast_io_fail)
+		return 0;
+	vector_foreach_slot(mpp->paths, pp, i) {
+		if (safe_snprintf(attr_path, SYSFS_PATH_SIZE,
+	        	          "/class/fc_remote_ports/rport-%d:%d-%d",
+				  pp->sg_id.host_no, pp->sg_id.channel,
+				  pp->sg_id.scsi_id)) {
+			condlog(0, "attr_path '/class/fc_remote_ports/rport-%d:%d-%d' too large", pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.scsi_id);
+			return 1;
+		}
+		if (mpp->dev_loss){
+			snprintf(value, 11, "%u", mpp->dev_loss);
+ 			if (sysfs_attr_set_value(attr_path, "dev_loss_tmo",
+						 value))
+				return 1;
+		}
+		if (mpp->fast_io_fail){
+			if (mpp->fast_io_fail == -1)
+				sprintf(value, "off");
+			else
+				snprintf(value, 11, "%u", mpp->fast_io_fail);
+			if (sysfs_attr_set_value(attr_path, "fast_io_fail",
+						 value))
+				return 1;
+		}
+	}
+	return 0;
+}
+
 static int
 opennode (char * dev, int mode)
 {
libmultipath/propsel.h +2 -0
Index: multipath-tools-100322/libmultipath/propsel.h
===================================================================
@@ -15,3 +15,5 @@ int select_minio(struct multipath *mp);
 int select_mode(struct multipath *mp);
 int select_uid(struct multipath *mp);
 int select_gid(struct multipath *mp);
+int select_fast_io_fail(struct multipath *mp);
+int select_dev_loss(struct multipath *mp);
libmultipath/discovery.h +1 -0
Index: multipath-tools-100322/libmultipath/discovery.h
===================================================================
@@ -33,6 +33,7 @@ int path_offline (struct path *);
 int pathinfo (struct path *, vector hwtable, int mask);
 struct path * store_pathinfo (vector pathvec, vector hwtable,
 			      char * devname, int flag);
+int sysfs_set_scsi_tmo (struct multipath *mpp);
 
 /*
  * discovery bitmask
libmultipath/sysfs.c +56 -0

62 lines not on this page · raw message

libmultipath/sysfs.h +2 -1
Index: multipath-tools-100322/libmultipath/sysfs.h
===================================================================
@@ -22,5 +22,6 @@ void sysfs_device_put(struct sysfs_devic
 char *sysfs_attr_get_value(const char *devpath, const char *attr_name);
 int sysfs_resolve_link(char *path, size_t size);
 int sysfs_get_size (struct sysfs_device * dev, unsigned long long * size);
-
+int sysfs_attr_set_value(const char *devpath, const char *attr_name,
+			 const char *value);
 #endif