diff -Nru multipath-tools-0.4.9/debian/changelog multipath-tools-0.4.9/debian/changelog --- multipath-tools-0.4.9/debian/changelog 2014-10-14 04:27:04.000000000 -0700 +++ multipath-tools-0.4.9/debian/changelog 2015-04-22 06:29:25.000000000 -0700 @@ -1,3 +1,13 @@ +multipath-tools (0.4.9-3ubuntu7.2fctimeoutattrs4) UNRELEASED; urgency=medium + + * Correctly write FC timeout attributes to sysfs (dev_loss_tmo, fast_io_fail_tmo): + - 0020-fc-timeout-attrs-multipath-add-fast_io_fail-and_dev-loss_tmo-config-parameters-fix-rport_id.patch + - 0021-fc-timeout-attrs-multipath-make-sure-all-the-hwe-attributes-get-merged.patch + - 0022-fc-timeout-attrs-multipath-fix-scsi-timeout-code.patch + - 0023-fc-timeout-attrs-multipath-make-sure-we-store-all-the-hwentry-attributes.patch + + -- Mauricio Faria de Oliveira Wed, 22 Apr 2015 10:29:07 -0300 + multipath-tools (0.4.9-3ubuntu7.2) trusty; urgency=medium * 1002-fix-linking-library.patch: Move $(LIBDEPS) to the end of the diff -Nru multipath-tools-0.4.9/debian/patches/0020-fc-timeout-attrs-multipath-add-fast_io_fail-and_dev-loss_tmo-config-parameters-fix-rport_id.patch multipath-tools-0.4.9/debian/patches/0020-fc-timeout-attrs-multipath-add-fast_io_fail-and_dev-loss_tmo-config-parameters-fix-rport_id.patch --- multipath-tools-0.4.9/debian/patches/0020-fc-timeout-attrs-multipath-add-fast_io_fail-and_dev-loss_tmo-config-parameters-fix-rport_id.patch 1969-12-31 17:00:00.000000000 -0700 +++ multipath-tools-0.4.9/debian/patches/0020-fc-timeout-attrs-multipath-add-fast_io_fail-and_dev-loss_tmo-config-parameters-fix-rport_id.patch 2015-04-22 06:28:31.000000000 -0700 @@ -0,0 +1,153 @@ +Origin: upstream, http://git.opensvc.com/gitweb.cgi?p=multipath-tools/.git;a=commit;h=dab80d6aa7decf2fe76971f23dbe41d1c3e5ae95 +From: Jun'ichi Nomura +Date: Fri, 30 Jul 2010 09:13:14 +0000 (+0900) +Subject: multipath: add fast_io_fail and dev_loss_tmo config parameters +X-Git-Tag: 0.5.0~363 +X-Git-Url: http://git.opensvc.com/gitweb.cgi?p=multipath-tools%2F.git;a=commitdiff_plain;h=dab80d6aa7decf2fe76971f23dbe41d1c3e5ae95 + +multipath: add fast_io_fail and dev_loss_tmo config parameters + +Hi, + +(03/23/10 11:44), Benjamin Marzinski wrote: +> 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-:-/fast_io_fail_tmo and +> /sys/class/fc_remote_ports/rport-:-/dev_loss_tmo +... + +This is nice feature but the code uses scsi_id instead of rport_id: + +> +sysfs_set_scsi_tmo (struct multipath *mpp) +... +> + 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; +> + } + +So it sets fast_io_fail_tmo/dev_loss_tmo for wrong rport. + +For example, I have a storage with node_id 0x2000003013842bcb +connected via switch, whose node_id is 0x100000051e09ee30. +When I set 'fast_io_fail_tmo = 8' in multipath.conf, +multipath command sets the timeout like this: + # for f in /sys/class/fc_remote_ports/rport-*/fast_io_fail_tmo; do d=$(dirname $f); echo $(basename $d):$(cat $d/node_name):$(cat $f); done + rport-0:0-0:0x100000051e09ee30:8 + rport-0:0-1:0x100000051e09ee30:8 + rport-0:0-2:0x2000003013842bcb:off + rport-0:0-3:0x2000003013842bcb:off + rport-1:0-0:0x100000051e09ee30:8 + rport-1:0-1:0x100000051e09ee30:8 + rport-1:0-2:0x2000003013842bcb:off + rport-1:0-3:0x2000003013842bcb:off +As a result, when a link is down for the storage and fast_io_fail_tmo +has passed, I/O will be still blocked. + +Attached is a quick patch for this problem. + +With this patch, fast_io_fail_tmo is set like this: + rport-0:0-0:0x100000051e09ee30:8 + rport-0:0-1:0x100000051e09ee30:8 + rport-0:0-2:0x2000003013842bcb:off + rport-0:0-3:0x2000003013842bcb:off + rport-1:0-0:0x100000051e09ee30:8 + rport-1:0-1:0x100000051e09ee30:8 + rport-1:0-2:0x2000003013842bcb:off + rport-1:0-3:0x2000003013842bcb:off + +Others might have better idea about resolving rport_id from target. +Mike, Hannes, any comments? + +Thanks, +-- +Jun'ichi Nomura, NEC Corporation + +rport_id != scsi_id + +multipath should find rport_id from the target_id. +--- + +diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c +index 122eb8f..c371b47 100644 +--- a/libmultipath/discovery.c ++++ b/libmultipath/discovery.c +@@ -10,6 +10,7 @@ + #include + #include + #include ++#include + + #include "checkers.h" + #include "vector.h" +@@ -204,6 +205,41 @@ sysfs_get_fc_nodename (struct sysfs_device * dev, char * node, + return 1; + } + ++static int ++find_rport_id(struct path *pp) ++{ ++ char attr_path[SYSFS_PATH_SIZE]; ++ char *dir, *base; ++ int host, channel, rport_id = -1; ++ ++ if (safe_sprintf(attr_path, ++ "/class/fc_transport/target%i:%i:%i", ++ pp->sg_id.host_no, pp->sg_id.channel, ++ pp->sg_id.scsi_id)) { ++ condlog(0, "attr_path too small for target"); ++ return 1; ++ } ++ ++ if (sysfs_resolve_link(attr_path, SYSFS_PATH_SIZE)) ++ return -1; ++ ++ condlog(4, "target%d:%d:%d -> path %s", pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.scsi_id, attr_path); ++ dir = attr_path; ++ do { ++ base = basename(dir); ++ dir = dirname(dir); ++ ++ if (sscanf((const char *)base, "rport-%d:%d-%d", &host, &channel, &rport_id) == 3) ++ break; ++ } while (strcmp((const char *)dir, "/")); ++ ++ if (rport_id < 0) ++ return -1; ++ ++ condlog(4, "target%d:%d:%d -> rport_id %d", pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.scsi_id, rport_id); ++ return rport_id; ++} ++ + int + sysfs_set_scsi_tmo (struct multipath *mpp) + { +@@ -211,15 +247,22 @@ sysfs_set_scsi_tmo (struct multipath *mpp) + struct path *pp; + int i; + char value[11]; ++ int rport_id; + + if (!mpp->dev_loss && !mpp->fast_io_fail) + return 0; + vector_foreach_slot(mpp->paths, pp, i) { ++ rport_id = find_rport_id(pp); ++ if (rport_id < 0) { ++ condlog(0, "failed to find rport_id for target%d:%d:%d", pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.scsi_id); ++ return 1; ++ } ++ + 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); ++ rport_id)) { ++ condlog(0, "attr_path '/class/fc_remote_ports/rport-%d:%d-%d' too large", pp->sg_id.host_no, pp->sg_id.channel, rport_id); + return 1; + } + if (mpp->dev_loss){ diff -Nru multipath-tools-0.4.9/debian/patches/0021-fc-timeout-attrs-multipath-make-sure-all-the-hwe-attributes-get-merged.patch multipath-tools-0.4.9/debian/patches/0021-fc-timeout-attrs-multipath-make-sure-all-the-hwe-attributes-get-merged.patch --- multipath-tools-0.4.9/debian/patches/0021-fc-timeout-attrs-multipath-make-sure-all-the-hwe-attributes-get-merged.patch 1969-12-31 17:00:00.000000000 -0700 +++ multipath-tools-0.4.9/debian/patches/0021-fc-timeout-attrs-multipath-make-sure-all-the-hwe-attributes-get-merged.patch 2015-04-22 06:28:31.000000000 -0700 @@ -0,0 +1,32 @@ +Origin: backport, http://git.opensvc.com/gitweb.cgi?p=multipath-tools/.git;a=commit;h=8d01e08897c95bcaa09b64a9ea763d34e9accbb1 +From: Benjamin Marzinski +Date: Wed, 5 Oct 2011 04:13:49 +0000 (-0500) +Subject: multipath: make sure all the hwe attributes get merged +X-Git-Tag: 0.5.0~303 +X-Git-Url: http://git.opensvc.com/gitweb.cgi?p=multipath-tools%2F.git;a=commitdiff_plain;h=8d01e08897c95bcaa09b64a9ea763d34e9accbb1 + +multipath: make sure all the hwe attributes get merged + +Not all of the hwe attributes were getting merged. Also, +multipathd show config was putting an extra set of quotes around the entries +in the devices section. + +Signed-off-by: Benjamin Marzinski +--- + +diff --git a/libmultipath/config.c b/libmultipath/config.c +index 4236088..51009ac 100644 +--- a/libmultipath/config.c ++++ b/libmultipath/config.c +@@ -320,6 +320,11 @@ merge_hwe (struct hwentry * dst, struct hwentry * src) + merge_num(rr_weight); + merge_num(no_path_retry); + merge_num(minio); ++ // NOT BACKPORTED. merge_num(minio_rq); ++ merge_num(pg_timeout); ++ merge_num(flush_on_last_del); ++ merge_num(fast_io_fail); ++ merge_num(dev_loss); + + return 0; + } diff -Nru multipath-tools-0.4.9/debian/patches/0022-fc-timeout-attrs-multipath-fix-scsi-timeout-code.patch multipath-tools-0.4.9/debian/patches/0022-fc-timeout-attrs-multipath-fix-scsi-timeout-code.patch --- multipath-tools-0.4.9/debian/patches/0022-fc-timeout-attrs-multipath-fix-scsi-timeout-code.patch 1969-12-31 17:00:00.000000000 -0700 +++ multipath-tools-0.4.9/debian/patches/0022-fc-timeout-attrs-multipath-fix-scsi-timeout-code.patch 2015-04-22 06:28:31.000000000 -0700 @@ -0,0 +1,53 @@ +Origin: backport, http://git.opensvc.com/gitweb.cgi?p=multipath-tools/.git;a=commit;h=bb817e4b8c2eef12fb831a17cf935db8a1677d06 +Description: (error messages from) multipath: fix scsi timeout code + The upstream commit depends on others neither required now nor small to introduce. + Pick just the error messages for debugging/verbosity. +Last-Update: 2015-04-22 +From: Benjamin Marzinski +Date: Mon, 19 Dec 2011 22:19:56 +0000 (-0600) +Subject: multipath: fix scsi timeout code +X-Git-Tag: 0.5.0~282 +X-Git-Url: http://git.opensvc.com/gitweb.cgi?p=multipath-tools%2F.git;a=commitdiff_plain;h=bb817e4b8c2eef12fb831a17cf935db8a1677d06 + +multipath: fix scsi timeout code + +sysfs_attr_set_value() returns the amount written on on success, or -1 on +failure. sysfs_setc_scsi_tmo() was checking if the return was nonzero, and +failing if it was. This meant that it always failed out silently after writing +the first value. I've changed the check, and added some error messages. I also +made sysfs_attr_set_value return -1 for all errors. + +Signed-off-by: Benjamin Marzinski +--- + +diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c +index fdcffe7..298c2d3 100644 +--- a/libmultipath/discovery.c ++++ b/libmultipath/discovery.c +@@ -316,8 +316,11 @@ sysfs_set_scsi_tmo (struct multipath *mpp) + if (mpp->dev_loss){ + snprintf(value, 11, "%u", mpp->dev_loss); + if (sysfs_attr_set_value(attr_path, "dev_loss_tmo", +- value)) ++ value)) { ++ condlog(0, "%s failed to set %s/dev_loss_tmo", ++ mpp->alias, attr_path); + return 1; ++ } + } + if (mpp->fast_io_fail){ + if (mpp->fast_io_fail == -1) +@@ -325,8 +328,12 @@ sysfs_set_scsi_tmo (struct multipath *mpp) + else + snprintf(value, 11, "%u", mpp->fast_io_fail); + if (sysfs_attr_set_value(attr_path, "fast_io_fail_tmo", +- value)) ++ value)) { ++ condlog(0, ++ "%s failed to set %s/fast_io_fail_tmo", ++ mpp->alias, attr_path); + return 1; ++ } + } + } + return 0; diff -Nru multipath-tools-0.4.9/debian/patches/0023-fc-timeout-attrs-multipath-make-sure-we-store-all-the-hwentry-attributes.patch multipath-tools-0.4.9/debian/patches/0023-fc-timeout-attrs-multipath-make-sure-we-store-all-the-hwentry-attributes.patch --- multipath-tools-0.4.9/debian/patches/0023-fc-timeout-attrs-multipath-make-sure-we-store-all-the-hwentry-attributes.patch 1969-12-31 17:00:00.000000000 -0700 +++ multipath-tools-0.4.9/debian/patches/0023-fc-timeout-attrs-multipath-make-sure-we-store-all-the-hwentry-attributes.patch 2015-04-22 06:28:31.000000000 -0700 @@ -0,0 +1,31 @@ +Origin: backport, http://git.opensvc.com/gitweb.cgi?p=multipath-tools/.git;a=commit;h=5e8538e1bb69308eda6a137570f2d4131a396779 +From: Benjamin Marzinski +Date: Wed, 23 May 2012 20:29:05 +0000 (-0500) +Subject: multipath: Make sure we store all the hwentry attributes. +X-Git-Tag: 0.5.0~238 +X-Git-Url: http://git.opensvc.com/gitweb.cgi?p=multipath-tools%2F.git;a=commitdiff_plain;h=5e8538e1bb69308eda6a137570f2d4131a396779 + +multipath: Make sure we store all the hwentry attributes. + +Not all of the attributes from the hardware table entries were getting stored +when the built-in devices configurations were being setup. + +Signed-off-by: Benjamin Marzinski +--- + +diff --git a/libmultipath/config.c b/libmultipath/config.c +index 0f17f03..065a334 100644 +--- a/libmultipath/config.c ++++ b/libmultipath/config.c +@@ -379,6 +379,11 @@ store_hwe (vector hwtable, struct hwentry * dhwe) + hwe->rr_weight = dhwe->rr_weight; + hwe->no_path_retry = dhwe->no_path_retry; + hwe->minio = dhwe->minio; ++ // NOT BACKPORTED. hwe->minio_rq = dhwe->minio_rq; ++ hwe->pg_timeout = dhwe->pg_timeout; ++ hwe->flush_on_last_del = dhwe->flush_on_last_del; ++ hwe->fast_io_fail = dhwe->fast_io_fail; ++ hwe->dev_loss = dhwe->dev_loss; + + if (dhwe->bl_product && !(hwe->bl_product = set_param_str(dhwe->bl_product))) + goto out; diff -Nru multipath-tools-0.4.9/debian/patches/series multipath-tools-0.4.9/debian/patches/series --- multipath-tools-0.4.9/debian/patches/series 2014-10-14 04:26:43.000000000 -0700 +++ multipath-tools-0.4.9/debian/patches/series 2015-04-22 06:28:21.000000000 -0700 @@ -15,3 +15,7 @@ 0013-multipath-clean-up-code-for-stopping-the-waiter-thre.patch 0014-Fix-race-condition-in-stop_waiter_thread.patch 1002-fix-linking-library.patch +0020-fc-timeout-attrs-multipath-add-fast_io_fail-and_dev-loss_tmo-config-parameters-fix-rport_id.patch +0021-fc-timeout-attrs-multipath-make-sure-all-the-hwe-attributes-get-merged.patch +0022-fc-timeout-attrs-multipath-fix-scsi-timeout-code.patch +0023-fc-timeout-attrs-multipath-make-sure-we-store-all-the-hwentry-attributes.patch