multipath: fix scsi timeout code
Benjamin Marzinski
maintainerPATCH 1/1 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.
--- libmultipath/discovery.c | 11 +++++++++-- libmultipath/sysfs.c | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-)
libmultipath/discovery.c +9 -2
@@ -316,8 +316,11 @@ sysfs_set_scsi_tmo (struct multipath *mpif (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 *mpelse 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 ;
libmultipath/sysfs.c +1 -1
@@ -351,7 +351,7 @@ ssize_t sysfs_attr_set_value(const charchar 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)
Quoted 49 lines · Benjamin Marzinski
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 madesysfs_attr_set_valuereturn -1 for all errors.Signed-off-by Benjamin Marzinski <[email protected]>--- libmultipath/discovery.c | 11 +++++++++-- libmultipath/sysfs.c | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-)Index:
multipath-tools-111111/libmultipath/discovery.c
===================================================================libmultipath/discovery.c +9
-2@@ -316,8 +316,11 @@ sysfs_set_scsi_tmo (struct multipath *mpif (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 *mpelse 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
===================================================================
libmultipath/sysfs.c ssize_t sysfs_attr_set_value(const char · line 357
Quoted 8 lines
libmultipath/sysfs.c +1
-1@@ -351,7 +351,7 @@ ssize_t sysfs_attr_set_value(const charchar 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)
Ah. Good point. Thanks.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Quoted 7 lines · Benjamin Marzinski
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 madesysfs_attr_set_valuereturn -1 for all errors.Signed-off-by Benjamin Marzinski <[email protected]>
Merged.
Quoted 49 lines
--- libmultipath/discovery.c | 11 +++++++++-- libmultipath/sysfs.c | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-)Index:
multipath-tools-111111/libmultipath/discovery.c
===================================================================libmultipath/discovery.c +9
-2@@ -316,8 +316,11 @@ sysfs_set_scsi_tmo (struct multipath *mpif (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 *mpelse 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
===================================================================libmultipath/sysfs.c +1
-1@@ -351,7 +351,7 @@ ssize_t sysfs_attr_set_value(const charchar 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)