aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Marzinski <bmarzins@redhat.com>2011-12-19 16:19:56 -0600
committerChristophe Varoqui <christophe.varoqui@opensvc.com>2011-12-23 21:03:15 +0100
commitbb817e4b8c2eef12fb831a17cf935db8a1677d06 (patch)
tree32cd479b9ef6bce416173cd3636a8af84921d63a
parentbc43d66e29982de4b039e26aed4a700b95485dfb (diff)
downloadmultipath-tools-bb817e4b8c2eef12fb831a17cf935db8a1677d06.tar.gz
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 <bmarzins@redhat.com>
-rw-r--r--libmultipath/discovery.c11
-rw-r--r--libmultipath/sysfs.c2
2 files changed, 10 insertions, 3 deletions
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, 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 *mpp)
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;
diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c
index ff63a1b..16dce4a 100644
--- a/libmultipath/sysfs.c
+++ b/libmultipath/sysfs.c
@@ -351,7 +351,7 @@ ssize_t sysfs_attr_set_value(const char *devpath, const char *attr_name,
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)