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