From patchwork Wed Jan 16 12:14:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 1987591 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by patchwork2.kernel.org (Postfix) with ESMTP id 7C05BDF2A2 for ; Wed, 16 Jan 2013 12:18:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0GCFehv003365; Wed, 16 Jan 2013 07:15:40 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0GCEONZ032087 for ; Wed, 16 Jan 2013 07:14:24 -0500 Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.18]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0GCEOKU015919 for ; Wed, 16 Jan 2013 07:14:24 -0500 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0GCENoU016593 for ; Wed, 16 Jan 2013 07:14:23 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id DF986A50DD; Wed, 16 Jan 2013 13:14:21 +0100 (CET) From: Hannes Reinecke To: Christophe Varoqui Date: Wed, 16 Jan 2013 13:14:15 +0100 Message-Id: <1358338456-1234-13-git-send-email-hare@suse.de> In-Reply-To: <1358338456-1234-1-git-send-email-hare@suse.de> References: <1358338456-1234-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -7.301 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.18 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH 12/13] Set I_T_nexus_loss_timeout on SAS devices 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: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Some SAS driver have an I_T_nexus_loss setting, which works similar to the 'dev_loss_tmo' setting on FibreChannel. So update it with the current values, too. Signed-off-by: Hannes Reinecke --- libmultipath/discovery.c | 51 +++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 48 insertions(+), 3 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index a099996..65f9c57 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -215,9 +215,21 @@ sysfs_get_tgt_nodename (struct path *pp, char * node) /* Check for SAS */ value = udev_device_get_sysattr_value(parent, "sas_address"); if (value) { - pp->sg_id.proto_id = SCSI_PROTOCOL_SAS; - strncpy(node, value, NODE_NAME_SIZE); - return 0; + tgtdev = udev_device_get_parent(parent); + while (tgtdev) { + targetid = udev_device_get_sysname(tgtdev); + if (sscanf(targetid, "end_device-%d:%d", + &host, &rport_id) == 2) + break; + tgtdev = udev_device_get_parent(tgtdev); + rport_id = -1; + } + if (rport_id >= 0) { + pp->sg_id.proto_id = SCSI_PROTOCOL_SAS; + pp->sg_id.transport_id = rport_id; + strncpy(node, value, NODE_NAME_SIZE); + return 0; + } } parent = udev_device_get_parent_with_subsystem_devtype(pp->udev, "scsi", "scsi_target"); @@ -391,6 +403,37 @@ sysfs_set_session_tmo(struct multipath *mpp, struct path *pp) return; } +static void +sysfs_set_nexus_loss_tmo(struct multipath *mpp, struct path *pp) +{ + struct udev_device *sas_dev = NULL; + char end_dev_id[64]; + char value[11]; + + sprintf(end_dev_id, "end_device-%d:%d", + pp->sg_id.host_no, pp->sg_id.transport_id); + sas_dev = udev_device_new_from_subsystem_sysname(conf->udev, + "sas_end_device", end_dev_id); + if (!sas_dev) { + condlog(1, "%s: No SAS end device for '%s'", pp->dev, + end_dev_id); + return; + } + condlog(4, "target%d:%d:%d -> %s", pp->sg_id.host_no, + pp->sg_id.channel, pp->sg_id.scsi_id, end_dev_id); + + if (mpp->dev_loss) { + snprintf(value, 11, "%u", mpp->dev_loss); + if (sysfs_attr_set_value(sas_dev, "I_T_nexus_loss_timeout", + value, 11) <= 0) + condlog(3, "%s: failed to update " + "I_T Nexus loss timeout, error %d", + pp->dev, errno); + } + udev_device_unref(sas_dev); + return; +} + int sysfs_set_scsi_tmo (struct multipath *mpp) { @@ -426,6 +469,8 @@ sysfs_set_scsi_tmo (struct multipath *mpp) sysfs_set_rport_tmo(mpp, pp); if (pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI) sysfs_set_session_tmo(mpp, pp); + if (pp->sg_id.proto_id == SCSI_PROTOCOL_SAS) + sysfs_set_nexus_loss_tmo(mpp, pp); } return 0; }