Skip to content

Commit 9c8108a

Browse files
cleechJames Bottomley
authored andcommitted
iSCSI: let session recovery_tmo sysfs writes persist across recovery
The iSCSI session recovery_tmo setting is writeable in sysfs, but it's also set every time a connection is established when parameters are set from iscsid over netlink. That results in the timeout being reset to the default value after every recovery. The DM multipath tools want to use the sysfs interface to lower the default timeout when there are multiple paths to fail over. It has caused confusion that we have a writeable sysfs value that seem to keep resetting itself. This patch adds an in-kernel flag that gets set once a sysfs write occurs, and then ignores netlink parameter setting once it's been modified via the sysfs interface. My thinking here is that the sysfs interface is much simpler for external tools to influence the session timeout, but if we're going to allow it to be modified directly we should ensure that setting is maintained. Signed-off-by: Chris Leech <cleech@redhat.com> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Odin.com>
1 parent aaf1b05 commit 9c8108a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,6 +2042,7 @@ iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport,
20422042
session->transport = transport;
20432043
session->creator = -1;
20442044
session->recovery_tmo = 120;
2045+
session->recovery_tmo_sysfs_override = false;
20452046
session->state = ISCSI_SESSION_FREE;
20462047
INIT_DELAYED_WORK(&session->recovery_work, session_recovery_timedout);
20472048
INIT_LIST_HEAD(&session->sess_list);
@@ -2786,7 +2787,8 @@ iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev)
27862787
switch (ev->u.set_param.param) {
27872788
case ISCSI_PARAM_SESS_RECOVERY_TMO:
27882789
sscanf(data, "%d", &value);
2789-
session->recovery_tmo = value;
2790+
if (!session->recovery_tmo_sysfs_override)
2791+
session->recovery_tmo = value;
27902792
break;
27912793
default:
27922794
err = transport->set_param(conn, ev->u.set_param.param,
@@ -4049,13 +4051,15 @@ store_priv_session_##field(struct device *dev, \
40494051
if ((session->state == ISCSI_SESSION_FREE) || \
40504052
(session->state == ISCSI_SESSION_FAILED)) \
40514053
return -EBUSY; \
4052-
if (strncmp(buf, "off", 3) == 0) \
4054+
if (strncmp(buf, "off", 3) == 0) { \
40534055
session->field = -1; \
4054-
else { \
4056+
session->field##_sysfs_override = true; \
4057+
} else { \
40554058
val = simple_strtoul(buf, &cp, 0); \
40564059
if (*cp != '\0' && *cp != '\n') \
40574060
return -EINVAL; \
40584061
session->field = val; \
4062+
session->field##_sysfs_override = true; \
40594063
} \
40604064
return count; \
40614065
}
@@ -4066,6 +4070,7 @@ store_priv_session_##field(struct device *dev, \
40664070
static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO | S_IWUSR, \
40674071
show_priv_session_##field, \
40684072
store_priv_session_##field)
4073+
40694074
iscsi_priv_session_rw_attr(recovery_tmo, "%d");
40704075

40714076
static struct attribute *iscsi_session_attrs[] = {

include/scsi/scsi_transport_iscsi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ struct iscsi_cls_session {
241241

242242
/* recovery fields */
243243
int recovery_tmo;
244+
bool recovery_tmo_sysfs_override;
244245
struct delayed_work recovery_work;
245246

246247
unsigned int target_id;

0 commit comments

Comments
 (0)