[RFC PATCH 2/4] libmultipath: make prioritizer timeouts work like checker timeouts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Multipath's prioritizers previously didn't use the sysfs timeout for
scsi devices, and used a prioritizer specific default timeout (although
in practice, all the prioritizers except hds used 60 seconds). Now
prioritizers deal with timeouts the same way as the checkers. They first
use checker_time if set, then use the sysfs tiemout for scsi devices, or
30 seconds for non-scsi devices.

Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
 libmultipath/prio.c                   | 14 +++++++++-----
 libmultipath/prio.h                   |  3 +--
 libmultipath/prioritizers/alua.c      |  2 +-
 libmultipath/prioritizers/alua_rtpg.c |  5 ++---
 libmultipath/prioritizers/emc.c       |  5 +++--
 libmultipath/prioritizers/hds.c       |  4 ++--
 libmultipath/prioritizers/hp_sw.c     |  4 ++--
 libmultipath/prioritizers/ontap.c     |  7 +++----
 libmultipath/prioritizers/rdac.c      |  4 ++--
 9 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/libmultipath/prio.c b/libmultipath/prio.c
index cdd37529..69b71578 100644
--- a/libmultipath/prio.c
+++ b/libmultipath/prio.c
@@ -3,20 +3,24 @@
 #include <stddef.h>
 #include <dlfcn.h>
 #include <sys/stat.h>
+#include <libudev.h>
 
 #include "debug.h"
 #include "util.h"
 #include "prio.h"
+#include "structs.h"
+#include "discovery.h"
 
 static const char * const prio_dir = MULTIPATH_DIR;
 static LIST_HEAD(prioritizers);
 
-unsigned int get_prio_timeout(unsigned int timeout_ms,
-			      unsigned int default_timeout)
+unsigned int get_prio_timeout(struct path *pp, unsigned int timeout)
 {
-	if (timeout_ms)
-		return timeout_ms;
-	return default_timeout;
+	if (timeout)
+		return timeout;
+	timeout = DEF_TIMEOUT;
+	sysfs_get_timeout(pp, &timeout);
+	return timeout * 1000;
 }
 
 int init_prio(void)
diff --git a/libmultipath/prio.h b/libmultipath/prio.h
index 184bf65f..20808fd7 100644
--- a/libmultipath/prio.h
+++ b/libmultipath/prio.h
@@ -52,8 +52,7 @@ struct prio {
 	int (*getprio)(struct path *, char *, unsigned int);
 };
 
-unsigned int get_prio_timeout(unsigned int checker_timeout,
-			      unsigned int default_timeout);
+unsigned int get_prio_timeout(struct path *pp, unsigned int checker_timeout);
 int init_prio(void);
 void cleanup_prio (void);
 struct prio * add_prio (const char *);
diff --git a/libmultipath/prioritizers/alua.c b/libmultipath/prioritizers/alua.c
index a28bca05..d3ba367f 100644
--- a/libmultipath/prioritizers/alua.c
+++ b/libmultipath/prioritizers/alua.c
@@ -109,7 +109,7 @@ int getprio (struct path * pp, char * args, unsigned int timeout)
 		return -ALUA_PRIO_NO_INFORMATION;
 
 	exclusive_pref = get_exclusive_pref_arg(args);
-	rc = get_alua_info(pp, timeout);
+	rc = get_alua_info(pp, get_prio_timeout(pp, timeout));
 	if (rc >= 0) {
 		aas = (rc & 0x0f);
 		priopath = (rc & 0x80);
diff --git a/libmultipath/prioritizers/alua_rtpg.c b/libmultipath/prioritizers/alua_rtpg.c
index 2db91536..49982545 100644
--- a/libmultipath/prioritizers/alua_rtpg.c
+++ b/libmultipath/prioritizers/alua_rtpg.c
@@ -31,7 +31,6 @@
 #include "alua_rtpg.h"
 
 #define SENSE_BUFF_LEN  32
-#define SGIO_TIMEOUT     60000
 
 #define PRINT_DEBUG(f, a...) \
 	condlog(4, "alua: " f, ##a)
@@ -162,7 +161,7 @@ retry:
 	hdr.dxfer_len		= resplen;
 	hdr.sbp			= sense;
 	hdr.mx_sb_len		= sizeof(sense);
-	hdr.timeout		= get_prio_timeout(timeout, SGIO_TIMEOUT);
+	hdr.timeout		= timeout;
 
 	if (ioctl(fd, SG_IO, &hdr) < 0) {
 		PRINT_DEBUG("do_inquiry: IOCTL failed!");
@@ -316,7 +315,7 @@ retry:
 	hdr.dxfer_len		= resplen;
 	hdr.mx_sb_len		= sizeof(sense);
 	hdr.sbp			= sense;
-	hdr.timeout		= get_prio_timeout(timeout, SGIO_TIMEOUT);
+	hdr.timeout		= timeout;
 
 	if (ioctl(fd, SG_IO, &hdr) < 0) {
 		condlog(2, "%s: sg ioctl failed: %s",
diff --git a/libmultipath/prioritizers/emc.c b/libmultipath/prioritizers/emc.c
index 3b63cca0..97fde31b 100644
--- a/libmultipath/prioritizers/emc.c
+++ b/libmultipath/prioritizers/emc.c
@@ -31,7 +31,7 @@ int emc_clariion_prio(const char *dev, int fd, unsigned int timeout)
 	io_hdr.dxferp = sense_buffer;
 	io_hdr.cmdp = inqCmdBlk;
 	io_hdr.sbp = sb;
-	io_hdr.timeout = get_prio_timeout(timeout, 60000);
+	io_hdr.timeout = timeout;
 	io_hdr.pack_id = 0;
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
 		pp_emc_log(0, "sending query command failed");
@@ -84,5 +84,6 @@ out:
 int getprio (struct path *pp, __attribute__((unused)) char *args,
 	     unsigned int timeout)
 {
-	return emc_clariion_prio(pp->dev, pp->fd, timeout);
+	return emc_clariion_prio(pp->dev, pp->fd,
+				 get_prio_timeout(pp, timeout));
 }
diff --git a/libmultipath/prioritizers/hds.c b/libmultipath/prioritizers/hds.c
index d569f2d7..13f497cc 100644
--- a/libmultipath/prioritizers/hds.c
+++ b/libmultipath/prioritizers/hds.c
@@ -114,7 +114,7 @@ int hds_modular_prio (const char *dev, int fd, unsigned int timeout)
 	io_hdr.dxferp = inqBuff;
 	io_hdr.cmdp = inqCmdBlk;
 	io_hdr.sbp = sense_buffer;
-	io_hdr.timeout = get_prio_timeout(timeout, 2000); /* TimeOut = 2 seconds */
+	io_hdr.timeout = timeout;
 
 	if (ioctl (fd, SG_IO, &io_hdr) < 0) {
 		pp_hds_log(0, "SG_IO error");
@@ -171,5 +171,5 @@ int hds_modular_prio (const char *dev, int fd, unsigned int timeout)
 int getprio (struct path * pp, __attribute__((unused)) char *args,
 	     unsigned int timeout)
 {
-	return hds_modular_prio(pp->dev, pp->fd, timeout);
+	return hds_modular_prio(pp->dev, pp->fd, get_prio_timeout(pp, timeout));
 }
diff --git a/libmultipath/prioritizers/hp_sw.c b/libmultipath/prioritizers/hp_sw.c
index 5b85ad2e..b4cbc58f 100644
--- a/libmultipath/prioritizers/hp_sw.c
+++ b/libmultipath/prioritizers/hp_sw.c
@@ -46,7 +46,7 @@ int hp_sw_prio(const char *dev, int fd, unsigned int timeout)
 	io_hdr.dxfer_direction = SG_DXFER_NONE;
 	io_hdr.cmdp = turCmdBlk;
 	io_hdr.sbp = sb;
-	io_hdr.timeout = get_prio_timeout(timeout, 60000);
+	io_hdr.timeout = timeout;
 	io_hdr.pack_id = 0;
 retry:
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
@@ -98,5 +98,5 @@ out:
 int getprio (struct path *pp, __attribute__((unused)) char *args,
 	     unsigned int timeout)
 {
-	return hp_sw_prio(pp->dev, pp->fd, timeout);
+	return hp_sw_prio(pp->dev, pp->fd, get_prio_timeout(pp, timeout));
 }
diff --git a/libmultipath/prioritizers/ontap.c b/libmultipath/prioritizers/ontap.c
index 262e69d2..b9860974 100644
--- a/libmultipath/prioritizers/ontap.c
+++ b/libmultipath/prioritizers/ontap.c
@@ -28,7 +28,6 @@
 #define INQUIRY_CMDLEN	6
 #define DEFAULT_PRIOVAL	10
 #define RESULTS_MAX	256
-#define SG_TIMEOUT	60000
 
 #define pp_ontap_log(prio, fmt, args...) \
 	condlog(prio, "%s: ontap prio: " fmt, dev, ##args)
@@ -90,7 +89,7 @@ static int send_gva(const char *dev, int fd, unsigned char pg,
 	io_hdr.dxferp = results;
 	io_hdr.cmdp = cdb;
 	io_hdr.sbp = sb;
-	io_hdr.timeout = get_prio_timeout(timeout, SG_TIMEOUT);
+	io_hdr.timeout = timeout;
 	io_hdr.pack_id = 0;
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
 		pp_ontap_log(0, "SG_IO ioctl failed, errno=%d", errno);
@@ -142,7 +141,7 @@ static int get_proxy(const char *dev, int fd, unsigned int timeout)
 	io_hdr.dxferp = results;
 	io_hdr.cmdp = cdb;
 	io_hdr.sbp = sb;
-	io_hdr.timeout = get_prio_timeout(timeout, SG_TIMEOUT);
+	io_hdr.timeout = timeout;
 	io_hdr.pack_id = 0;
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
 		pp_ontap_log(0, "ioctl sending inquiry command failed, "
@@ -244,5 +243,5 @@ prio_select:
 int getprio (struct path *pp, __attribute__((unused)) char *args,
 	     unsigned int timeout)
 {
-	return ontap_prio(pp->dev, pp->fd, timeout);
+	return ontap_prio(pp->dev, pp->fd, get_prio_timeout(pp, timeout));
 }
diff --git a/libmultipath/prioritizers/rdac.c b/libmultipath/prioritizers/rdac.c
index 92a2fb85..0faa8155 100644
--- a/libmultipath/prioritizers/rdac.c
+++ b/libmultipath/prioritizers/rdac.c
@@ -31,7 +31,7 @@ int rdac_prio(const char *dev, int fd, unsigned int timeout)
 	io_hdr.dxferp = sense_buffer;
 	io_hdr.cmdp = inqCmdBlk;
 	io_hdr.sbp = sb;
-	io_hdr.timeout = get_prio_timeout(timeout, 60000);
+	io_hdr.timeout = timeout;
 	io_hdr.pack_id = 0;
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
 		pp_rdac_log(0, "sending inquiry command failed");
@@ -94,5 +94,5 @@ out:
 int getprio (struct path *pp, __attribute__((unused)) char *args,
 	     unsigned int timeout)
 {
-	return rdac_prio(pp->dev, pp->fd, timeout);
+	return rdac_prio(pp->dev, pp->fd, get_prio_timeout(pp, timeout));
 }
-- 
2.17.2

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux