Skip to contentSkip to conversation

Make prio timeouts work like checkers

PATCH In review Benjamin Marzinski 2 participants 7 messages Aug 31, 2023 – Sep 1, 2023 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

v2 cover Make prio timeouts work like checkers

This patchset changes how prioritizers set their timeouts, to make them match how the checker functions work, and also cleans up some minor timeout issues.

This patchset has been entirely reworked based on suggestions from Martin Wilck: Patch [1/4] no longer rechecks the timeout values at all in the checker loop. Patch [2/4] makes the checker_timeout a path variable, following Martin's suggestion. Patch [3/4] roughly corresponds to patches 2, 3 & 4 of the previous patchset, except that it uses the path's checker_timeout variable to cleanup a number of function calls, and incidentally fixes the issues in detect_prio() and the path_latency prioritizer. Patch [4/4] is new. It makes the datacore checker respect the checker timeout as well, if no timeout is specified in the prio args.

Benjamin Marzinski (4):
libmultipath: don't bother to recheck timeout
libmultipath: make checker_timeout a path variable
libmultipath: make prioritizer timeouts work like checker timeouts
libmultipath: standardize datacore prioritizer timeouts

 libmultipath/discovery.c                 | 21 ++++----------
 libmultipath/libmultipath.version        |  4 +--
 libmultipath/prio.c                      | 21 ++++++++------
 libmultipath/prio.h                      |  9 +++---
 libmultipath/prioritizers/alua.c         | 12 ++++----
 libmultipath/prioritizers/alua_rtpg.c    | 31 +++++++++++----------
 libmultipath/prioritizers/alua_rtpg.h    |  7 ++---
 libmultipath/prioritizers/ana.c          |  3 +-
 libmultipath/prioritizers/const.c        |  3 +-
 libmultipath/prioritizers/datacore.c     | 19 +++++--------
 libmultipath/prioritizers/emc.c          |  9 +++---
 libmultipath/prioritizers/hds.c          |  9 +++---
 libmultipath/prioritizers/hp_sw.c        |  9 +++---
 libmultipath/prioritizers/iet.c          |  3 +-
 libmultipath/prioritizers/ontap.c        | 20 ++++++--------
 libmultipath/prioritizers/path_latency.c |  9 +++---
 libmultipath/prioritizers/random.c       |  3 +-
 libmultipath/prioritizers/rdac.c         |  9 +++---
 libmultipath/prioritizers/sysfs.c        |  3 +-
 libmultipath/prioritizers/weightedpath.c |  3 +-
 libmultipath/propsel.c                   | 35 +++++++++++++++---------
 libmultipath/structs.c                   |  1 +
 libmultipath/structs.h                   |  1 +
 23 files changed, 117 insertions(+), 127 deletions(-)
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#1 lore raw

PATCH v2 1/4 libmultipath: don't bother to recheck timeout

This is almost always pointless work. c->timeout has already been set. The only reason why this recheck existed was to deal with the possibility that the sysfs value had changed. It is unlikely that users will update the sysfs value to change the multipath timeout while multipathd is running. They can alway reload multipathd if they want it changed, anyways.

---
 libmultipath/discovery.c | 3 ---
 1 file changed, 3 deletions(-)
libmultipath/discovery.c +0 -3
index 5626d48d..c90c51a6 100644
@@ -1965,9 +1965,6 @@ get_state (struct path * pp, struct config *conf, int daemon, int oldstate)
 		checker_set_async(c);
 	else
 		checker_set_sync(c);
-	if (!conf->checker_timeout &&
-	    sysfs_get_timeout(pp, &(c->timeout)) <= 0)
-		c->timeout = DEF_TIMEOUT;
 	state = checker_check(c, oldstate);
 	condlog(3, "%s: %s state = %s", pp->dev,
 		checker_name(c), checker_state_name(state));
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#2 lore raw

PATCH v2 2/4 libmultipath: make checker_timeout a path variable

In reply to Benjamin Marzinski

Factor the code to get the checker_timeout out of select_checker() into its own select_checker_timeout function, and use that to set a path variable. This variable will be used by future patches.

---
 libmultipath/propsel.c | 33 ++++++++++++++++++++-------------
 libmultipath/structs.c |  1 +
 libmultipath/structs.h |  1 +
 3 files changed, 22 insertions(+), 13 deletions(-)
libmultipath/propsel.c +20 -13
index df10a68f..91a59880 100644
@@ -628,6 +628,23 @@ out:
 	return 0;
 }
 
+
+int select_checker_timeout(struct config *conf, struct path *pp)
+{
+	const char *origin;
+
+	pp_set_conf(checker_timeout);
+	if (sysfs_get_timeout(pp, &pp->checker_timeout) > 0) {
+		origin = "(setting: kernel sysfs)";
+		goto out;
+	}
+	pp_set_default(checker_timeout, DEF_TIMEOUT);
+out:
+	condlog(3, "%s checker timeout = %u s %s", pp->dev, pp->checker_timeout,
+		origin);
+	return 0;
+}
+
 /*
  * Current RDAC (NetApp E/EF Series) firmware relies
  * on periodic REPORT TARGET PORT GROUPS for
@@ -664,6 +681,8 @@ int select_checker(struct config *conf, struct path *pp)
 	char *ckr_name;
 	struct checker * c = &pp->checker;
 
+	if (!pp->checker_timeout)
+		select_checker_timeout(conf, pp);
 	if (pp->detect_checker == DETECT_CHECKER_ON) {
 		origin = autodetect_origin;
 		if (check_rdac(pp)) {
@@ -684,19 +703,7 @@ out:
 	checker_get(c, ckr_name);
 	condlog(3, "%s: path_checker = %s %s", pp->dev,
 		checker_name(c), origin);
-	if (conf->checker_timeout) {
-		c->timeout = conf->checker_timeout;
-		condlog(3, "%s: checker timeout = %u s %s",
-			pp->dev, c->timeout, conf_origin);
-	}
-	else if (sysfs_get_timeout(pp, &c->timeout) > 0)
-		condlog(3, "%s: checker timeout = %u s (setting: kernel sysfs)",
-			pp->dev, c->timeout);
-	else {
-		c->timeout = DEF_TIMEOUT;
-		condlog(3, "%s: checker timeout = %u s %s",
-			pp->dev, c->timeout, default_origin);
-	}
+	c->timeout = pp->checker_timeout;
 	return 0;
 }
 
libmultipath/structs.c +1 -0
index 39504dca..1b305fd1 100644
@@ -147,6 +147,7 @@ uninitialize_path(struct path *pp)
 
 	pp->dmstate = PSTATE_UNDEF;
 	pp->uid_attribute = NULL;
+	pp->checker_timeout = 0;
 
 	if (checker_selected(&pp->checker))
 		checker_put(&pp->checker);
libmultipath/structs.h +1 -0
index 97f9de5a..17e13ee7 100644
@@ -383,6 +383,7 @@ struct path {
 	int eh_deadline;
 	bool is_checked;
 	bool can_use_env_uid;
+	unsigned int checker_timeout;
 	/* configlet pointers */
 	vector hwe;
 	struct gen_path generic_path;
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#3 lore raw

PATCH v2 3/4 libmultipath: make prioritizer timeouts work like checker timeouts

In reply to Benjamin Marzinski

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. When selecting a prioritizer, select_checker_timeout() is called if the path doesn't already have a checker_timeout set, an the prioritizers that use timeouts now all use the path's checker_timeout. This change also incidentally fixes some bugs where the detect_alua() function and the path_latency prioritizer were assuming that the timeout was in a different unit than it was (seconds vs milliseconds).

---
 libmultipath/discovery.c                 | 18 +++++---------
 libmultipath/libmultipath.version        |  4 +--
 libmultipath/prio.c                      | 21 ++++++++++------
 libmultipath/prio.h                      |  9 +++----
 libmultipath/prioritizers/alua.c         | 12 ++++-----
 libmultipath/prioritizers/alua_rtpg.c    | 31 ++++++++++++------------
 libmultipath/prioritizers/alua_rtpg.h    |  7 +++---
 libmultipath/prioritizers/ana.c          |  3 +--
 libmultipath/prioritizers/const.c        |  3 +--
 libmultipath/prioritizers/datacore.c     |  3 +--
 libmultipath/prioritizers/emc.c          |  9 +++----
 libmultipath/prioritizers/hds.c          |  9 +++----
 libmultipath/prioritizers/hp_sw.c        |  9 +++----
 libmultipath/prioritizers/iet.c          |  3 +--
 libmultipath/prioritizers/ontap.c        | 20 +++++++--------
 libmultipath/prioritizers/path_latency.c |  9 ++++---
 libmultipath/prioritizers/random.c       |  3 +--
 libmultipath/prioritizers/rdac.c         |  9 +++----
 libmultipath/prioritizers/sysfs.c        |  3 +--
 libmultipath/prioritizers/weightedpath.c |  3 +--
 libmultipath/propsel.c                   |  2 ++
 21 files changed, 89 insertions(+), 101 deletions(-)
libmultipath/discovery.c +6 -12
index c90c51a6..e4de48e7 100644
@@ -1015,18 +1015,13 @@ detect_alua(struct path * pp)
 {
 	int ret;
 	int tpgs;
-	unsigned int timeout;
-
 
 	if (pp->bus != SYSFS_BUS_SCSI) {
 		pp->tpgs = TPGS_NONE;
 		return;
 	}
 
-	if (sysfs_get_timeout(pp, &timeout) <= 0)
-		timeout = DEF_TIMEOUT;
-
-	tpgs = get_target_port_group_support(pp, timeout);
+	tpgs = get_target_port_group_support(pp);
 	if (tpgs == -RTPG_INQUIRY_FAILED)
 		return;
 	else if (tpgs <= 0) {
@@ -1037,8 +1032,8 @@ detect_alua(struct path * pp)
 	if (pp->fd == -1 || pp->offline)
 		return;
 
-	ret = get_target_port_group(pp, timeout);
-	if (ret < 0 || get_asymmetric_access_state(pp, ret, timeout) < 0) {
+	ret = get_target_port_group(pp);
+	if (ret < 0 || get_asymmetric_access_state(pp, ret) < 0) {
 		int state;
 
 		if (ret == -RTPG_INQUIRY_FAILED)
@@ -1976,7 +1971,7 @@ get_state (struct path * pp, struct config *conf, int daemon, int oldstate)
 }
 
 static int
-get_prio (struct path * pp, int timeout)
+get_prio (struct path * pp)
 {
 	struct prio * p;
 	struct config *conf;
@@ -1999,7 +1994,7 @@ get_prio (struct path * pp, int timeout)
 		}
 	}
 	old_prio = pp->priority;
-	pp->priority = prio_getprio(p, pp, timeout);
+	pp->priority = prio_getprio(p, pp);
 	if (pp->priority < 0) {
 		/* this changes pp->offline, but why not */
 		int state = path_offline(pp);
@@ -2477,8 +2472,7 @@ int pathinfo(struct path *pp, struct config *conf, int mask)
 	  */
 	if ((mask & DI_PRIO) && path_state == PATH_UP && strlen(pp->wwid)) {
 		if (pp->state != PATH_DOWN || pp->priority == PRIO_UNDEF) {
-			get_prio(pp, (pp->state != PATH_DOWN)?
-				     (conf->checker_timeout * 1000) : 10);
+			get_prio(pp);
 		}
 	}
 
libmultipath/libmultipath.version +2 -2
index 20a5056c..a7b8c337 100644
@@ -43,7 +43,7 @@ LIBMPATHCOMMON_1.0.0 {
 	put_multipath_config;
 };
 
-LIBMULTIPATH_19.0.0 {
+LIBMULTIPATH_20.0.0 {
 global:
 	/* symbols referenced by multipath and multipathd */
 	add_foreign;
@@ -214,7 +214,7 @@ global:
 
 	/* prioritizers */
 	get_asymmetric_access_state;
-	get_prio_timeout;
+	get_prio_timeout_ms;
 	get_target_port_group;
 	get_target_port_group_support;
 	libmp_nvme_ana_log;
libmultipath/prio.c +13 -8
index cdd37529..a54487f3 100644
@@ -3,20 +3,25 @@
 #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_ms(const struct path *pp)
 {
-	if (timeout_ms)
-		return timeout_ms;
-	return default_timeout;
+	if (pp->state == PATH_DOWN)
+		return 10;
+	else if (pp->checker_timeout)
+		return pp->checker_timeout * 1000;
+	else
+		return DEF_TIMEOUT;
 }
 
 int init_prio(void)
@@ -136,7 +141,7 @@ struct prio *add_prio (const char *name)
 				errstr);
 		goto out;
 	}
-	p->getprio = (int (*)(struct path *, char *, unsigned int)) dlsym(p->handle, "getprio");
+	p->getprio = (int (*)(struct path *, char *)) dlsym(p->handle, "getprio");
 	errstr = dlerror();
 	if (errstr != NULL)
 		condlog(0, "A dynamic linking error occurred: (%s)", errstr);
@@ -149,9 +154,9 @@ out:
 	return NULL;
 }
 
-int prio_getprio (struct prio * p, struct path * pp, unsigned int timeout)
+int prio_getprio (struct prio * p, struct path * pp)
 {
-	return p->getprio(pp, p->args, timeout);
+	return p->getprio(pp, p->args);
 }
 
 int prio_selected (const struct prio * p)
libmultipath/prio.h +4 -5
index 184bf65f..318d2608 100644
@@ -49,15 +49,14 @@ struct prio {
 	struct list_head node;
 	char name[PRIO_NAME_LEN];
 	char args[PRIO_ARGS_LEN];
-	int (*getprio)(struct path *, char *, unsigned int);
+	int (*getprio)(struct path *, char *);
 };
 
-unsigned int get_prio_timeout(unsigned int checker_timeout,
-			      unsigned int default_timeout);
+unsigned int get_prio_timeout_ms(const struct path *);
 int init_prio(void);
 void cleanup_prio (void);
 struct prio * add_prio (const char *);
-int prio_getprio (struct prio *, struct path *, unsigned int);
+int prio_getprio (struct prio *, struct path *);
 void prio_get (struct prio *, const char *, const char *);
 void prio_put (struct prio *);
 int prio_selected (const struct prio *);
@@ -66,6 +65,6 @@ const char * prio_args (const struct prio *);
 int prio_set_args (struct prio *, const char *);
 
 /* The only function exported by prioritizer dynamic libraries (.so) */
-int getprio(struct path *, char *, unsigned int);
+int getprio(struct path *, char *);
 
 #endif /* _PRIO_H */
libmultipath/prioritizers/alua.c +6 -6
index a28bca05..ec68f370 100644
@@ -51,15 +51,15 @@ static const char *aas_print_string(int rc)
 }
 
 int
-get_alua_info(struct path * pp, unsigned int timeout)
+get_alua_info(struct path * pp)
 {
 	int	rc;
 	int	tpg;
 	bool	diff_tpg;
 
-	tpg = get_target_port_group(pp, timeout);
+	tpg = get_target_port_group(pp);
 	if (tpg < 0) {
-		rc = get_target_port_group_support(pp, timeout);
+		rc = get_target_port_group_support(pp);
 		if (rc < 0)
 			return -ALUA_PRIO_TPGS_FAILED;
 		if (rc == TPGS_NONE)
@@ -70,7 +70,7 @@ get_alua_info(struct path * pp, unsigned int timeout)
 	pp->tpg_id = tpg;
 	condlog((diff_tpg) ? 2 : 4, "%s: reported target port group is %i",
 		pp->dev, tpg);
-	rc = get_asymmetric_access_state(pp, tpg, timeout);
+	rc = get_asymmetric_access_state(pp, tpg);
 	if (rc < 0) {
 		condlog(2, "%s: get_asymmetric_access_state returned %d",
 			__func__, rc);
@@ -98,7 +98,7 @@ int get_exclusive_pref_arg(char *args)
 	return 1;
 }
 
-int getprio (struct path * pp, char * args, unsigned int timeout)
+int getprio (struct path * pp, char * args)
 {
 	int rc;
 	int aas;
@@ -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);
 	if (rc >= 0) {
 		aas = (rc & 0x0f);
 		priopath = (rc & 0x80);
libmultipath/prioritizers/alua_rtpg.c +16 -15
index 2db91536..dd2224c4 100644
@@ -136,7 +136,7 @@ scsi_error(struct sg_io_hdr *hdr, int opcode)
  */
 static int
 do_inquiry_sg(int fd, int evpd, unsigned int codepage,
-	      void *resp, int resplen, unsigned int timeout)
+	      void *resp, int resplen, unsigned int timeout_ms)
 {
 	struct inquiry_command	cmd;
 	struct sg_io_hdr	hdr;
@@ -162,7 +162,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_ms;
 
 	if (ioctl(fd, SG_IO, &hdr) < 0) {
 		PRINT_DEBUG("do_inquiry: IOCTL failed!");
@@ -185,7 +185,7 @@ retry:
 }
 
 int do_inquiry(const struct path *pp, int evpd, unsigned int codepage,
-	       void *resp, int resplen, unsigned int timeout)
+	       void *resp, int resplen)
 {
 	struct udev_device *ud = NULL;
 
@@ -206,7 +206,8 @@ int do_inquiry(const struct path *pp, int evpd, unsigned int codepage,
 			return 0;
 		}
 	}
-	return do_inquiry_sg(pp->fd, evpd, codepage, resp, resplen, timeout);
+	return do_inquiry_sg(pp->fd, evpd, codepage, resp, resplen,
+			     get_prio_timeout_ms(pp));
 }
 
 /*
@@ -214,13 +215,13 @@ int do_inquiry(const struct path *pp, int evpd, unsigned int codepage,
  * data returned by the standard inquiry command.
  */
 int
-get_target_port_group_support(const struct path *pp, unsigned int timeout)
+get_target_port_group_support(const struct path *pp)
 {
 	struct inquiry_data	inq;
 	int			rc;
 
 	memset((unsigned char *)&inq, 0, sizeof(inq));
-	rc = do_inquiry(pp, 0, 0x00, &inq, sizeof(inq), timeout);
+	rc = do_inquiry(pp, 0, 0x00, &inq, sizeof(inq));
 	if (!rc) {
 		rc = inquiry_data_get_tpgs(&inq);
 	}
@@ -229,7 +230,7 @@ get_target_port_group_support(const struct path *pp, unsigned int timeout)
 }
 
 int
-get_target_port_group(const struct path * pp, unsigned int timeout)
+get_target_port_group(const struct path * pp)
 {
 	unsigned char		*buf;
 	const struct vpd83_data *	vpd83;
@@ -246,7 +247,7 @@ get_target_port_group(const struct path * pp, unsigned int timeout)
 	}
 
 	memset(buf, 0, buflen);
-	rc = do_inquiry(pp, 1, 0x83, buf, buflen, timeout);
+	rc = do_inquiry(pp, 1, 0x83, buf, buflen);
 	if (rc < 0)
 		goto out;
 
@@ -263,7 +264,7 @@ get_target_port_group(const struct path * pp, unsigned int timeout)
 		}
 		buflen = scsi_buflen;
 		memset(buf, 0, buflen);
-		rc = do_inquiry(pp, 1, 0x83, buf, buflen, timeout);
+		rc = do_inquiry(pp, 1, 0x83, buf, buflen);
 		if (rc < 0)
 			goto out;
 	}
@@ -293,7 +294,7 @@ out:
 }
 
 int
-do_rtpg(int fd, void* resp, long resplen, unsigned int timeout)
+do_rtpg(int fd, void* resp, long resplen, unsigned int timeout_ms)
 {
 	struct rtpg_command	cmd;
 	struct sg_io_hdr	hdr;
@@ -316,7 +317,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_ms;
 
 	if (ioctl(fd, SG_IO, &hdr) < 0) {
 		condlog(2, "%s: sg ioctl failed: %s",
@@ -340,8 +341,7 @@ retry:
 }
 
 int
-get_asymmetric_access_state(const struct path *pp, unsigned int tpg,
-			    unsigned int timeout)
+get_asymmetric_access_state(const struct path *pp, unsigned int tpg)
 {
 	unsigned char		*buf;
 	struct rtpg_data *	tpgd;
@@ -349,6 +349,7 @@ get_asymmetric_access_state(const struct path *pp, unsigned int tpg,
 	int			rc;
 	unsigned int		buflen;
 	uint64_t		scsi_buflen;
+	unsigned int		timeout_ms = get_prio_timeout_ms(pp);
 	int fd = pp->fd;
 
 	buflen = VPD_BUFLEN;
@@ -359,7 +360,7 @@ get_asymmetric_access_state(const struct path *pp, unsigned int tpg,
 		return -RTPG_RTPG_FAILED;
 	}
 	memset(buf, 0, buflen);
-	rc = do_rtpg(fd, buf, buflen, timeout);
+	rc = do_rtpg(fd, buf, buflen, timeout_ms);
 	if (rc < 0) {
 		PRINT_DEBUG("%s: do_rtpg returned %d", __func__, rc);
 		goto out;
@@ -377,7 +378,7 @@ get_asymmetric_access_state(const struct path *pp, unsigned int tpg,
 		}
 		buflen = scsi_buflen;
 		memset(buf, 0, buflen);
-		rc = do_rtpg(fd, buf, buflen, timeout);
+		rc = do_rtpg(fd, buf, buflen, timeout_ms);
 		if (rc < 0)
 			goto out;
 	}
libmultipath/prioritizers/alua_rtpg.h +3 -4
index 675709ff..c5f9a8f9 100644
@@ -22,9 +22,8 @@
 #define RTPG_RTPG_FAILED			3
 #define RTPG_TPG_NOT_FOUND			4
 
-int get_target_port_group_support(const struct path *pp, unsigned int timeout);
-int get_target_port_group(const struct path *pp, unsigned int timeout);
-int get_asymmetric_access_state(const struct path *pp,
-				unsigned int tpg, unsigned int timeout);
+int get_target_port_group_support(const struct path *pp);
+int get_target_port_group(const struct path *pp);
+int get_asymmetric_access_state(const struct path *pp, unsigned int tpg);
 
 #endif /* __RTPG_H__ */
libmultipath/prioritizers/ana.c +1 -2
index b5c7873d..e9827dca 100644
@@ -203,8 +203,7 @@ static int get_ana_info(struct path * pp)
  * - ALUA's LBA-dependent state has no ANA equivalent.
  */
 
-int getprio(struct path *pp, __attribute__((unused)) char *args,
-	    __attribute__((unused)) unsigned int timeout)
+int getprio(struct path *pp, __attribute__((unused)) char *args)
 {
 	int rc;
 
libmultipath/prioritizers/const.c +1 -2
index 059d8593..2b07f47b 100644
@@ -3,8 +3,7 @@
 #include "prio.h"
 
 int getprio(__attribute__((unused)) struct path * pp,
-	    __attribute__((unused)) char * args,
-	    __attribute__((unused)) unsigned int timeout)
+	    __attribute__((unused)) char * args)
 {
 	return 1;
 }
libmultipath/prioritizers/datacore.c +1 -2
index d1d473d4..74e15f3e 100644
@@ -98,8 +98,7 @@ int datacore_prio (const char *dev, int sg_fd, char * args)
 	return 0;
 }
 
-int getprio(struct path * pp, char * args,
-	    __attribute__((unused)) unsigned int timeout)
+int getprio(struct path * pp, char * args)
 {
 	return datacore_prio(pp->dev, pp->fd, args);
 }
libmultipath/prioritizers/emc.c +4 -5
index 3b63cca0..856c23d6 100644
@@ -12,7 +12,7 @@
 
 #define pp_emc_log(prio, msg) condlog(prio, "%s: emc prio: " msg, dev)
 
-int emc_clariion_prio(const char *dev, int fd, unsigned int timeout)
+int emc_clariion_prio(const char *dev, int fd, unsigned int timeout_ms)
 {
 	unsigned char sense_buffer[128];
 	unsigned char sb[128];
@@ -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_ms;
 	io_hdr.pack_id = 0;
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
 		pp_emc_log(0, "sending query command failed");
@@ -81,8 +81,7 @@ out:
 	return(ret);
 }
 
-int getprio (struct path *pp, __attribute__((unused)) char *args,
-	     unsigned int timeout)
+int getprio (struct path *pp, __attribute__((unused)) char *args)
 {
-	return emc_clariion_prio(pp->dev, pp->fd, timeout);
+	return emc_clariion_prio(pp->dev, pp->fd, get_prio_timeout_ms(pp));
 }
libmultipath/prioritizers/hds.c +4 -5
index d569f2d7..212301ea 100644
@@ -84,7 +84,7 @@
 #define pp_hds_log(prio, fmt, args...) \
 	condlog(prio, "%s: hds prio: " fmt, dev, ##args)
 
-int hds_modular_prio (const char *dev, int fd, unsigned int timeout)
+int hds_modular_prio (const char *dev, int fd, unsigned int timeout_ms)
 {
 	int k;
 	char vendor[9];
@@ -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_ms;
 
 	if (ioctl (fd, SG_IO, &io_hdr) < 0) {
 		pp_hds_log(0, "SG_IO error");
@@ -168,8 +168,7 @@ int hds_modular_prio (const char *dev, int fd, unsigned int timeout)
 	return -1;
 }
 
-int getprio (struct path * pp, __attribute__((unused)) char *args,
-	     unsigned int timeout)
+int getprio (struct path * pp, __attribute__((unused)) char *args)
 {
-	return hds_modular_prio(pp->dev, pp->fd, timeout);
+	return hds_modular_prio(pp->dev, pp->fd, get_prio_timeout_ms(pp));
 }
libmultipath/prioritizers/hp_sw.c +4 -5
index 5b85ad2e..5570271d 100644
@@ -32,7 +32,7 @@
 #define pp_hp_sw_log(prio, fmt, args...) \
 	condlog(prio, "%s: hp_sw prio: " fmt, dev, ##args)
 
-int hp_sw_prio(const char *dev, int fd, unsigned int timeout)
+int hp_sw_prio(const char *dev, int fd, unsigned int timeout_ms)
 {
 	unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 };
 	unsigned char sb[128];
@@ -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_ms;
 	io_hdr.pack_id = 0;
 retry:
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
@@ -95,8 +95,7 @@ out:
 	return(ret);
 }
 
-int getprio (struct path *pp, __attribute__((unused)) char *args,
-	     unsigned int timeout)
+int getprio (struct path *pp, __attribute__((unused)) char *args)
 {
-	return hp_sw_prio(pp->dev, pp->fd, timeout);
+	return hp_sw_prio(pp->dev, pp->fd, get_prio_timeout_ms(pp));
 }
libmultipath/prioritizers/iet.c +1 -2
index 167a46b0..f3bf64c5 100644
@@ -138,8 +138,7 @@ int iet_prio(const char *dev, char * args)
 	return 10;
 }
 
-int getprio(struct path * pp, char * args,
-	    __attribute__((unused)) unsigned int timeout)
+int getprio(struct path * pp, char * args)
 {
 	return iet_prio(pp->dev, args);
 }
libmultipath/prioritizers/ontap.c +9 -11
index 262e69d2..117886ea 100644
@@ -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)
@@ -72,7 +71,7 @@ static void process_sg_error(struct sg_io_hdr *io_hdr)
  */
 static int send_gva(const char *dev, int fd, unsigned char pg,
 		    unsigned char *results, int *results_size,
-		    unsigned int timeout)
+		    unsigned int timeout_ms)
 {
 	unsigned char sb[128];
 	unsigned char cdb[10] = {0xc0, 0, 0x1, 0xa, 0x98, 0xa,
@@ -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_ms;
 	io_hdr.pack_id = 0;
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
 		pp_ontap_log(0, "SG_IO ioctl failed, errno=%d", errno);
@@ -123,7 +122,7 @@ out:
  *  0: Device _not_ proxy path
  *  1: Device _is_ proxy path
  */
-static int get_proxy(const char *dev, int fd, unsigned int timeout)
+static int get_proxy(const char *dev, int fd, unsigned int timeout_ms)
 {
 	unsigned char results[256];
 	unsigned char sb[128];
@@ -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_ms;
 	io_hdr.pack_id = 0;
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
 		pp_ontap_log(0, "ioctl sending inquiry command failed, "
@@ -183,7 +182,7 @@ out:
  * 2: iSCSI software
  * 1: FCP proxy
  */
-static int ontap_prio(const char *dev, int fd, unsigned int timeout)
+static int ontap_prio(const char *dev, int fd, unsigned int timeout_ms)
 {
 	unsigned char results[RESULTS_MAX];
 	int results_size=RESULTS_MAX;
@@ -196,7 +195,7 @@ static int ontap_prio(const char *dev, int fd, unsigned int timeout)
 	is_iscsi_software = is_iscsi_hardware = is_proxy = 0;
 
 	memset(&results, 0, sizeof (results));
-	rc = send_gva(dev, fd, 0x41, results, &results_size, timeout);
+	rc = send_gva(dev, fd, 0x41, results, &results_size, timeout_ms);
 	if (rc >= 0) {
 		tot_len = get_unaligned_be32(&results[0]);
 		if (tot_len <= 8) {
@@ -221,7 +220,7 @@ static int ontap_prio(const char *dev, int fd, unsigned int timeout)
 	}
 
 try_fcp_proxy:
-	rc = get_proxy(dev, fd, timeout);
+	rc = get_proxy(dev, fd, timeout_ms);
 	if (rc >= 0) {
 		is_proxy = rc;
 	}
@@ -241,8 +240,7 @@ prio_select:
 	}
 }
 
-int getprio (struct path *pp, __attribute__((unused)) char *args,
-	     unsigned int timeout)
+int getprio (struct path *pp, __attribute__((unused)) char *args)
 {
-	return ontap_prio(pp->dev, pp->fd, timeout);
+	return ontap_prio(pp->dev, pp->fd, get_prio_timeout_ms(pp));
 }
libmultipath/prioritizers/path_latency.c +5 -4
index 2f5be9b9..f4142577 100644
@@ -104,10 +104,10 @@ static void cleanup_directio_read(int fd, char *buf, int restore_flags)
 	}
 }
 
-static int do_directio_read(int fd, unsigned int timeout, char *buf, int sz)
+static int do_directio_read(int fd, unsigned int timeout_ms, char *buf, int sz)
 {
 	fd_set read_fds;
-	struct timeval tm = { .tv_sec = timeout };
+	struct timeval tm = { .tv_sec = timeout_ms / 1000};
 	int ret;
 	int num_read;
 
@@ -208,7 +208,7 @@ int calcPrio(double lg_avglatency, double lg_maxavglatency,
 	return lg_maxavglatency - lg_avglatency;
 }
 
-int getprio(struct path *pp, char *args, unsigned int timeout)
+int getprio(struct path *pp, char *args)
 {
 	int rc, temp;
 	int io_num = 0;
@@ -247,7 +247,8 @@ int getprio(struct path *pp, char *args, unsigned int timeout)
 
 		(void)clock_gettime(CLOCK_MONOTONIC, &tv_before);
 
-		if (do_directio_read(pp->fd, timeout, buf, blksize)) {
+		if (do_directio_read(pp->fd, get_prio_timeout_ms(pp), buf,
+				     blksize)) {
 			pp_pl_log(0, "%s: path down", pp->dev);
 			cleanup_directio_read(pp->fd, buf, restore_flags);
 			return -1;
libmultipath/prioritizers/random.c +1 -2
index b742ac23..148b957d 100644
@@ -6,8 +6,7 @@
 #include "prio.h"
 
 int getprio(__attribute__((unused)) struct path *pp,
-	    __attribute__((unused)) char *args,
-	    __attribute__((unused)) unsigned int timeout)
+	    __attribute__((unused)) char *args)
 {
 	struct timeval tv;
 
libmultipath/prioritizers/rdac.c +4 -5
index 92a2fb85..f40cd841 100644
@@ -12,7 +12,7 @@
 
 #define pp_rdac_log(prio, msg) condlog(prio, "%s: rdac prio: " msg, dev)
 
-int rdac_prio(const char *dev, int fd, unsigned int timeout)
+int rdac_prio(const char *dev, int fd, unsigned int timeout_ms)
 {
 	unsigned char sense_buffer[128];
 	unsigned char sb[128];
@@ -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_ms;
 	io_hdr.pack_id = 0;
 	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
 		pp_rdac_log(0, "sending inquiry command failed");
@@ -91,8 +91,7 @@ out:
 	return(ret);
 }
 
-int getprio (struct path *pp, __attribute__((unused)) char *args,
-	     unsigned int timeout)
+int getprio (struct path *pp, __attribute__((unused)) char *args)
 {
-	return rdac_prio(pp->dev, pp->fd, timeout);
+	return rdac_prio(pp->dev, pp->fd, get_prio_timeout_ms(pp));
 }
libmultipath/prioritizers/sysfs.c +1 -2
index a6feb421..5e8adc05 100644
@@ -36,8 +36,7 @@ int get_exclusive_pref_arg(char *args)
 	return 1;
 }
 
-int getprio (struct path * pp, char *args,
-	     __attribute__((unused)) unsigned int timeout)
+int getprio (struct path * pp, char *args)
 {
 	int prio = 0, rc, i;
 	char buff[512];
libmultipath/prioritizers/weightedpath.c +1 -2
index 561ebb48..de51a9e7 100644
@@ -125,8 +125,7 @@ int prio_path_weight(struct path *pp, char *prio_args)
 	return priority;
 }
 
-int getprio(struct path *pp, char *args,
-	    __attribute__((unused)) unsigned int timeout)
+int getprio(struct path *pp, char *args)
 {
 	return prio_path_weight(pp, args);
 }
libmultipath/propsel.c +2 -0
index 91a59880..d6bce129 100644
@@ -813,6 +813,8 @@ int select_prio(struct config *conf, struct path *pp)
 	struct prio * p = &pp->prio;
 	int log_prio = 3;
 
+	if (!pp->checker_timeout)
+		select_checker_timeout(conf, pp);
 	if (pp->detect_prio == DETECT_PRIO_ON) {
 		detect_prio(pp);
 		if (prio_selected(p)) {
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#4 lore raw

PATCH v2 4/4 libmultipath: standardize datacore prioritizer timeouts

In reply to Benjamin Marzinski

If users don't add a timeout to the datacore priorizier arguments, it should use the checker_timeout. Also, don't limit possible timeout values, to match the other prioritizers.

---
 libmultipath/prioritizers/datacore.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
libmultipath/prioritizers/datacore.c +6 -10
index 74e15f3e..f288306c 100644
@@ -32,7 +32,8 @@
 
 #define dc_log(prio, msg) condlog(prio, "%s: datacore prio: " msg, dev)
 
-int datacore_prio (const char *dev, int sg_fd, char * args)
+int datacore_prio (const char *dev, int sg_fd, char * args,
+		   unsigned int timeout_ms)
 {
 	int k;
 	char sdsname[32];
@@ -42,7 +43,6 @@ int datacore_prio (const char *dev, int sg_fd, char * args)
 	unsigned char sense_buffer[32];
 	sg_io_hdr_t io_hdr;
 
-	int timeout = 2000;
 	char preferredsds_buff[255] = "";
 	char * preferredsds = &preferredsds_buff[0];
 
@@ -52,9 +52,9 @@ int datacore_prio (const char *dev, int sg_fd, char * args)
 	}
 
 	if (sscanf(args, "timeout=%i preferredsds=%s",
-		   &timeout, preferredsds) == 2) {}
+		   (int *)&timeout_ms, preferredsds) == 2) {}
 	else if (sscanf(args, "preferredsds=%s timeout=%i",
-			preferredsds, &timeout) == 2) {}
+			preferredsds, (int *)&timeout_ms) == 2) {}
 	else if (sscanf(args, "preferredsds=%s",
 			preferredsds) == 1) {}
 	else {
@@ -67,10 +67,6 @@ int datacore_prio (const char *dev, int sg_fd, char * args)
 		dc_log(0, "prio args: preferredsds too short (1 character min)");
 		return 0;
 	}
-	if ((timeout < 500) || (timeout > 20000)) {
-		dc_log(0, "prio args: timeout out of bounds [500:20000]");
-		return 0;
-	}
 	if ((ioctl(sg_fd, SG_GET_VERSION_NUM, &k) < 0) || (k < 30000))
 		return 0;
 
@@ -83,7 +79,7 @@ int datacore_prio (const char *dev, int sg_fd, char * args)
 	io_hdr.dxferp = inqBuff;
 	io_hdr.cmdp = inqCmdBlk;
 	io_hdr.sbp = sense_buffer;
-	io_hdr.timeout = timeout;
+	io_hdr.timeout = timeout_ms;
 
 	// on error just return prio 0
 	if (ioctl(sg_fd, SG_IO, &io_hdr) < 0)
@@ -100,5 +96,5 @@ int datacore_prio (const char *dev, int sg_fd, char * args)
 
 int getprio(struct path * pp, char * args)
 {
-	return datacore_prio(pp->dev, pp->fd, args);
+	return datacore_prio(pp->dev, pp->fd, args, get_prio_timeout_ms(pp));
 }
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#5 lore raw
In reply to Benjamin Marzinski
Quoted 21 lines · Benjamin Marzinski

This patchset changes how prioritizers set their timeouts, to make them
match how the checker functions work, and also cleans up some minor timeout issues.

This patchset has been entirely reworked based on suggestions from Martin Wilck: Patch [1/4] no longer rechecks the timeout values at all
in the checker loop. Patch [2/4] makes the checker_timeout a path variable, following Martin's suggestion. Patch [3/4] roughly corresponds
to patches 2, 3 & 4 of the previous patchset, except that it uses the path's checker_timeout variable to cleanup a number of function calls,
and incidentally fixes the issues in detect_prio() and the path_latency
prioritizer. Patch [4/4] is new. It makes the datacore checker respect
the checker timeout as well, if no timeout is specified in the prio args.

Quoted 6 lines

Benjamin Marzinski (4):
  libmultipath: don't bother to recheck timeout
  libmultipath: make checker_timeout a path variable
  libmultipath: make prioritizer timeouts work like checker timeouts
  libmultipath: standardize datacore prioritizer timeouts

For the series: Reviewed-by: Martin Wilck <[email protected]>

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

#6 lore raw
Quoted 31 lines · Martin Wilck
Quoted 22 lines · Benjamin Marzinski

This patchset changes how prioritizers set their timeouts, to make them
match how the checker functions work, and also cleans up some minor timeout issues.

This patchset has been entirely reworked based on suggestions from Martin Wilck: Patch [1/4] no longer rechecks the timeout values at all
in the checker loop. Patch [2/4] makes the checker_timeout a path variable, following Martin's suggestion. Patch [3/4] roughly corresponds
to patches 2, 3 & 4 of the previous patchset, except that it uses the
path's checker_timeout variable to cleanup a number of function calls,
and incidentally fixes the issues in detect_prio() and the path_latency
prioritizer. Patch [4/4] is new. It makes the datacore checker respect
the checker timeout as well, if no timeout is specified in the prio args.

Quoted 7 lines

Benjamin Marzinski (4):
  libmultipath: don't bother to recheck timeout
  libmultipath: make checker_timeout a path variable
  libmultipath: make prioritizer timeouts work like checker timeouts
  libmultipath: standardize datacore prioritizer timeouts

Quoted 2 lines

For the series: Reviewed-by: Martin Wilck <[email protected]>

It turns out that the series breaks the hwtable unit test. I'll see if I can fix it.

Martin

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel