339e1da
From 9c8108a4d3a837c51a29f28229a06d97654eaeb6 Mon Sep 17 00:00:00 2001
339e1da
From: Chris Leech <cleech@redhat.com>
339e1da
Date: Tue, 16 Jun 2015 16:07:13 -0700
339e1da
Subject: iSCSI: let session recovery_tmo sysfs writes persist across recovery
339e1da
339e1da
The iSCSI session recovery_tmo setting is writeable in sysfs, but it's
339e1da
also set every time a connection is established when parameters are set
339e1da
from iscsid over netlink.  That results in the timeout being reset to
339e1da
the default value after every recovery.
339e1da
339e1da
The DM multipath tools want to use the sysfs interface to lower the
339e1da
default timeout when there are multiple paths to fail over.  It has
339e1da
caused confusion that we have a writeable sysfs value that seem to keep
339e1da
resetting itself.
339e1da
339e1da
This patch adds an in-kernel flag that gets set once a sysfs write
339e1da
occurs, and then ignores netlink parameter setting once it's been
339e1da
modified via the sysfs interface.  My thinking here is that the sysfs
339e1da
interface is much simpler for external tools to influence the session
339e1da
timeout, but if we're going to allow it to be modified directly we
339e1da
should ensure that setting is maintained.
339e1da
339e1da
Signed-off-by: Chris Leech <cleech@redhat.com>
339e1da
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
339e1da
Signed-off-by: James Bottomley <JBottomley@Odin.com>
339e1da
339e1da
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
339e1da
index 55647aa..4c25539 100644
339e1da
--- a/drivers/scsi/scsi_transport_iscsi.c
339e1da
+++ b/drivers/scsi/scsi_transport_iscsi.c
339e1da
@@ -2042,6 +2042,7 @@ iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport,
339e1da
 	session->transport = transport;
339e1da
 	session->creator = -1;
339e1da
 	session->recovery_tmo = 120;
339e1da
+	session->recovery_tmo_sysfs_override = false;
339e1da
 	session->state = ISCSI_SESSION_FREE;
339e1da
 	INIT_DELAYED_WORK(&session->recovery_work, session_recovery_timedout);
339e1da
 	INIT_LIST_HEAD(&session->sess_list);
339e1da
@@ -2786,7 +2787,8 @@ iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev)
339e1da
 	switch (ev->u.set_param.param) {
339e1da
 	case ISCSI_PARAM_SESS_RECOVERY_TMO:
339e1da
 		sscanf(data, "%d", &value);
339e1da
-		session->recovery_tmo = value;
339e1da
+		if (!session->recovery_tmo_sysfs_override)
339e1da
+			session->recovery_tmo = value;
339e1da
 		break;
339e1da
 	default:
339e1da
 		err = transport->set_param(conn, ev->u.set_param.param,
339e1da
@@ -4049,13 +4051,15 @@ store_priv_session_##field(struct device *dev,				\
339e1da
 	if ((session->state == ISCSI_SESSION_FREE) ||			\
339e1da
 	    (session->state == ISCSI_SESSION_FAILED))			\
339e1da
 		return -EBUSY;						\
339e1da
-	if (strncmp(buf, "off", 3) == 0)				\
339e1da
+	if (strncmp(buf, "off", 3) == 0) {				\
339e1da
 		session->field = -1;					\
339e1da
-	else {								\
339e1da
+		session->field##_sysfs_override = true;			\
339e1da
+	} else {							\
339e1da
 		val = simple_strtoul(buf, &cp, 0);			\
339e1da
 		if (*cp != '\0' && *cp != '\n')				\
339e1da
 			return -EINVAL;					\
339e1da
 		session->field = val;					\
339e1da
+		session->field##_sysfs_override = true;			\
339e1da
 	}								\
339e1da
 	return count;							\
339e1da
 }
339e1da
@@ -4066,6 +4070,7 @@ store_priv_session_##field(struct device *dev,				\
339e1da
 static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO | S_IWUSR,		\
339e1da
 			show_priv_session_##field,			\
339e1da
 			store_priv_session_##field)
339e1da
+
339e1da
 iscsi_priv_session_rw_attr(recovery_tmo, "%d");
339e1da
 
339e1da
 static struct attribute *iscsi_session_attrs[] = {
339e1da
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
339e1da
index 2555ee5..6183d20 100644
339e1da
--- a/include/scsi/scsi_transport_iscsi.h
339e1da
+++ b/include/scsi/scsi_transport_iscsi.h
339e1da
@@ -241,6 +241,7 @@ struct iscsi_cls_session {
339e1da
 
339e1da
 	/* recovery fields */
339e1da
 	int recovery_tmo;
339e1da
+	bool recovery_tmo_sysfs_override;
339e1da
 	struct delayed_work recovery_work;
339e1da
 
339e1da
 	unsigned int target_id;
339e1da
-- 
339e1da
cgit v0.10.2
339e1da