From patchwork Fri Jul 30 09:13:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junichi Nomura X-Patchwork-Id: 115435 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mx02.colomx.prod.int.phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6U9HKvG006358 for ; Fri, 30 Jul 2010 09:17:56 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx02.colomx.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6U9FX0E006980; Fri, 30 Jul 2010 05:15:38 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6U9FVuw028935 for ; Fri, 30 Jul 2010 05:15:31 -0400 Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.5]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6U9FQxg026869; Fri, 30 Jul 2010 05:15:26 -0400 Received: from tyo202.gate.nec.co.jp (TYO202.gate.nec.co.jp [202.32.8.206]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6U9F41q013050; Fri, 30 Jul 2010 05:15:05 -0400 Received: from mailgate4.nec.co.jp ([10.7.69.184]) by tyo202.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id o6U9F3BB013963; Fri, 30 Jul 2010 18:15:03 +0900 (JST) Received: (from root@localhost) by mailgate4.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id o6U9F3j25697; Fri, 30 Jul 2010 18:15:03 +0900 (JST) Received: from mail02.kamome.nec.co.jp (mail02.kamome.nec.co.jp [10.25.43.5]) by mailsv3.nec.co.jp (8.13.8/8.13.4) with ESMTP id o6U9F3eT010784; Fri, 30 Jul 2010 18:15:03 +0900 (JST) Received: from togyo.jp.nec.com ([10.26.220.4] [10.26.220.4]) by mail03.kamome.nec.co.jp with ESMTP id BT-MMP-342979; Fri, 30 Jul 2010 18:13:16 +0900 Received: from xzibit.linux.bs1.fc.nec.co.jp ([10.34.125.170] [10.34.125.170]) by mail.jp.nec.com with ESMTP; Fri, 30 Jul 2010 18:13:14 +0900 Message-ID: <4C5297AA.4070708@ce.jp.nec.com> Date: Fri, 30 Jul 2010 18:13:14 +0900 From: "Jun'ichi Nomura" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Thunderbird/3.0.5 MIME-Version: 1.0 To: device-mapper development , Benjamin Marzinski X-RedHat-Spam-Score: -0.002 (SPF_HELO_PASS,SPF_PASS) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.5 X-loop: dm-devel@redhat.com Cc: Kiyoshi Ueda , Michael Christie Subject: Re: [dm-devel] [PATCH] multipath: add fast_io_fail and dev_loss_tmo config parameters X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 30 Jul 2010 09:17:56 +0000 (UTC) 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){