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