From patchwork Wed Apr 27 11:10:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 8955371 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2B866BF440 for ; Wed, 27 Apr 2016 11:15:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21892201E4 for ; Wed, 27 Apr 2016 11:15:27 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55BFD20259 for ; Wed, 27 Apr 2016 11:15:23 +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 u3RBBvwH005634; Wed, 27 Apr 2016 07:11:57 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3RBBJBA012349 for ; Wed, 27 Apr 2016 07:11:19 -0400 Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3RBBJ4q006237 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 27 Apr 2016 07:11:19 -0400 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F39477F368; Wed, 27 Apr 2016 11:11:14 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 26C2BACBC; Wed, 27 Apr 2016 11:11:09 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Wed, 27 Apr 2016 13:10:11 +0200 Message-Id: <1461755458-29225-11-git-send-email-hare@suse.de> In-Reply-To: <1461755458-29225-1-git-send-email-hare@suse.de> References: <1461755458-29225-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -0.607 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.75 on 10.5.110.26 X-loop: dm-devel@redhat.com Cc: Hannes Reinecke , dm-devel@redhat.com, Mike Snitzer Subject: [dm-devel] [PATCH 10/57] libmultipath: finally fix dev_loss_tmo setting X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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 X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to take the current value when comparing 'dev_loss_tmo' and 'fast_io_fail', otherwise we still might be getting an error as we might comparing wrong values. Signed-off-by: Hannes Reinecke --- libmultipath/defaults.h | 1 + libmultipath/discovery.c | 72 ++++++++++++++++++++++++---------------------- multipath/multipath.conf.5 | 2 +- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h index bce8bcc..96f5a2c 100644 --- a/libmultipath/defaults.h +++ b/libmultipath/defaults.h @@ -15,6 +15,7 @@ #define DEFAULT_REASSIGN_MAPS 0 #define DEFAULT_FIND_MULTIPATHS 0 #define DEFAULT_FAST_IO_FAIL 5 +#define DEFAULT_DEV_LOSS_TMO 600 #define DEFAULT_RETAIN_HWHANDLER RETAIN_HWHANDLER_OFF #define DEFAULT_DETECT_PRIO DETECT_PRIO_OFF #define DEFAULT_DEFERRED_REMOVE DEFERRED_REMOVE_OFF diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 324e217..83cc4f7 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -504,6 +504,22 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp) pp->sg_id.channel, pp->sg_id.scsi_id, rport_id); /* + * read the current dev_loss_tmo value from sysfs + */ + ret = sysfs_attr_get_value(rport_dev, "dev_loss_tmo", value, 16); + if (ret <= 0) { + condlog(0, "%s: failed to read dev_loss_tmo value, " + "error %d", rport_id, -ret); + goto out; + } + tmo = strtoull(value, &eptr, 0); + if (value == eptr || tmo == ULLONG_MAX) { + condlog(0, "%s: Cannot parse dev_loss_tmo " + "attribute '%s'", rport_id, value); + goto out; + } + + /* * This is tricky. * dev_loss_tmo will be limited to 600 if fast_io_fail * is _not_ set. @@ -514,45 +530,31 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp) * then set fast_io_fail, and _then_ set dev_loss_tmo * to the correct value. */ - memset(value, 0, 16); if (mpp->fast_io_fail != MP_FAST_IO_FAIL_UNSET && mpp->fast_io_fail != MP_FAST_IO_FAIL_ZERO && mpp->fast_io_fail != MP_FAST_IO_FAIL_OFF) { /* Check if we need to temporarily increase dev_loss_tmo */ - ret = sysfs_attr_get_value(rport_dev, "dev_loss_tmo", - value, 16); - if (ret <= 0) { - condlog(0, "%s: failed to read dev_loss_tmo value, " - "error %d", rport_id, -ret); - goto out; - } - tmo = strtoull(value, &eptr, 0); - if (value == eptr || tmo == ULLONG_MAX) { - condlog(0, "%s: Cannot parse dev_loss_tmo " - "attribute '%s'", rport_id, value); - goto out; - } if (mpp->fast_io_fail >= tmo) { + /* Increase dev_loss_tmo temporarily */ snprintf(value, 16, "%u", mpp->fast_io_fail + 1); + ret = sysfs_attr_set_value(rport_dev, "dev_loss_tmo", + value, strlen(value)); + if (ret <= 0) { + if (ret == -EBUSY) + condlog(3, "%s: rport blocked", + rport_id); + else + condlog(0, "%s: failed to set " + "dev_loss_tmo to %s, error %d", + rport_id, value, -ret); + goto out; + } } - } else if (mpp->dev_loss > 600) { - condlog(3, "%s: limiting dev_loss_tmo to 600, since " - "fast_io_fail is not set", rport_id); - snprintf(value, 16, "%u", 600); - } else { - snprintf(value, 16, "%u", mpp->dev_loss); - } - if (strlen(value)) { - ret = sysfs_attr_set_value(rport_dev, "dev_loss_tmo", - value, strlen(value)); - if (ret <= 0) { - if (ret == -EBUSY) - condlog(3, "%s: rport blocked", rport_id); - else - condlog(0, "%s: failed to set dev_loss_tmo to %s, error %d", - rport_id, value, -ret); - goto out; - } + } else if (mpp->dev_loss > DEFAULT_DEV_LOSS_TMO) { + condlog(3, "%s: limiting dev_loss_tmo to %d, since " + "fast_io_fail is not set", + rport_id, DEFAULT_DEV_LOSS_TMO); + mpp->dev_loss = DEFAULT_DEV_LOSS_TMO; } if (mpp->fast_io_fail != MP_FAST_IO_FAIL_UNSET) { if (mpp->fast_io_fail == MP_FAST_IO_FAIL_OFF) @@ -571,7 +573,7 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp) rport_id, value, -ret); } } - if (tmo > 0) { + if (mpp->dev_loss > 0) { snprintf(value, 16, "%u", mpp->dev_loss); ret = sysfs_attr_set_value(rport_dev, "dev_loss_tmo", value, strlen(value)); @@ -673,11 +675,11 @@ sysfs_set_scsi_tmo (struct multipath *mpp) no_path_retry_tmo = MAX_DEV_LOSS_TMO; if (no_path_retry_tmo > dev_loss_tmo) dev_loss_tmo = no_path_retry_tmo; - condlog(3, "%s: update dev_loss_tmo to %d", + condlog(3, "%s: update dev_loss_tmo to %u", mpp->alias, dev_loss_tmo); } else if (mpp->no_path_retry == NO_PATH_RETRY_QUEUE) { dev_loss_tmo = MAX_DEV_LOSS_TMO; - condlog(3, "%s: update dev_loss_tmo to %d", + condlog(3, "%s: update dev_loss_tmo to %u", mpp->alias, dev_loss_tmo); } mpp->dev_loss = dev_loss_tmo; diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 index 0d4df0f..b21279e 100644 --- a/multipath/multipath.conf.5 +++ b/multipath/multipath.conf.5 @@ -394,7 +394,7 @@ retry interval if a number of retries is given with \fIno_path_retry\fR and the overall retry interval is longer than the specified \fIdev_loss_tmo\fR value. The linux kernel will cap this value to \fI300\fR if \fBfast_io_fail_tmo\fR -is not set. +is not set. Default is 600. .TP .B queue_without_daemon If set to