dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@gmail.com>
Subject: [PATCH] multipath: fix scsi timeout code
Date: Mon, 19 Dec 2011 16:19:56 -0600	[thread overview]
Message-ID: <20111219221956.GP24133@ether.msp.redhat.com> (raw)

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 <bmarzins@redhat.com>
---
 libmultipath/discovery.c |   11 +++++++++--
 libmultipath/sysfs.c     |    2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

Index: multipath-tools-111111/libmultipath/discovery.c
===================================================================
--- multipath-tools-111111.orig/libmultipath/discovery.c
+++ multipath-tools-111111/libmultipath/discovery.c
@@ -316,8 +316,11 @@ sysfs_set_scsi_tmo (struct multipath *mp
 		if (mpp->dev_loss){
 			snprintf(value, 11, "%u", mpp->dev_loss);
 			if (sysfs_attr_set_value(attr_path, "dev_loss_tmo",
-						 value, 11))
+						 value, 11) < 0) {
+				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 *mp
 			else
 				snprintf(value, 11, "%u", mpp->fast_io_fail);
 			if (sysfs_attr_set_value(attr_path, "fast_io_fail_tmo",
-						 value, 11))
+						 value, 11) < 0) {
+				condlog(0,
+					"%s failed to set %s/fast_io_fail_tmo", 
+					mpp->alias, attr_path);
 				return 1;
+			}
 		}
 	}
 	return 0;
Index: multipath-tools-111111/libmultipath/sysfs.c
===================================================================
--- multipath-tools-111111.orig/libmultipath/sysfs.c
+++ multipath-tools-111111/libmultipath/sysfs.c
@@ -351,7 +351,7 @@ ssize_t sysfs_attr_set_value(const char
 	char path_full[PATH_SIZE];
 	struct stat statbuf;
 	int fd;
-	ssize_t size = 0;
+	ssize_t size = -1;
 	size_t sysfs_len;
 
 	if (!attr_name || !value || !value_len)

             reply	other threads:[~2011-12-19 22:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-19 22:19 Benjamin Marzinski [this message]
2011-12-20 15:18 ` [PATCH] multipath: fix scsi timeout code Hannes Reinecke
2011-12-23 20:04 ` Christophe Varoqui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111219221956.GP24133@ether.msp.redhat.com \
    --to=bmarzins@redhat.com \
    --cc=christophe.varoqui@gmail.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).