@@ -947,6 +947,7 @@ static umode_t iser_attr_is_visible(int param_type, int param)
case ISCSI_PARAM_IFACE_NAME:
case ISCSI_PARAM_INITIATOR_NAME:
case ISCSI_PARAM_DISCOVERY_SESS:
+ case ISCSI_PARAM_NODE_STARTUP:
return S_IRUGO;
default:
return 0;
@@ -1401,6 +1401,7 @@ umode_t beiscsi_attr_is_visible(int param_type, int param)
case ISCSI_PARAM_LU_RESET_TMO:
case ISCSI_PARAM_IFACE_NAME:
case ISCSI_PARAM_INITIATOR_NAME:
+ case ISCSI_PARAM_NODE_STARTUP:
return S_IRUGO;
default:
return 0;
@@ -2237,6 +2237,7 @@ static umode_t bnx2i_attr_is_visible(int param_type, int param)
case ISCSI_PARAM_BOOT_ROOT:
case ISCSI_PARAM_BOOT_NIC:
case ISCSI_PARAM_BOOT_TARGET:
+ case ISCSI_PARAM_NODE_STARTUP:
return S_IRUGO;
default:
return 0;
@@ -3063,6 +3063,7 @@ umode_t cxgbi_attr_is_visible(int param_type, int param)
case ISCSI_PARAM_TGT_RESET_TMO:
case ISCSI_PARAM_IFACE_NAME:
case ISCSI_PARAM_INITIATOR_NAME:
+ case ISCSI_PARAM_NODE_STARTUP:
return S_IRUGO;
default:
return 0;
@@ -1036,6 +1036,7 @@ static umode_t iscsi_sw_tcp_attr_is_visible(int param_type, int param)
case ISCSI_PARAM_TGT_RESET_TMO:
case ISCSI_PARAM_IFACE_NAME:
case ISCSI_PARAM_INITIATOR_NAME:
+ case ISCSI_PARAM_NODE_STARTUP:
return S_IRUGO;
default:
return 0;
@@ -3576,6 +3576,8 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
break;
case ISCSI_PARAM_LOCAL_IPADDR:
return iscsi_switch_str_param(&conn->local_ipaddr, buf);
+ case ISCSI_PARAM_NODE_STARTUP:
+ return iscsi_switch_str_param(&session->node_startup, buf);
default:
return -ENOSYS;
}
@@ -3712,6 +3714,9 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
else
len = sysfs_emit(buf, "\n");
break;
+ case ISCSI_PARAM_NODE_STARTUP:
+ len = sysfs_emit(buf, "%s\n", session->node_startup);
+ break;
default:
return -ENOSYS;
}
@@ -1437,6 +1437,7 @@ static umode_t qedi_attr_is_visible(int param_type, int param)
case ISCSI_PARAM_BOOT_ROOT:
case ISCSI_PARAM_BOOT_NIC:
case ISCSI_PARAM_BOOT_TARGET:
+ case ISCSI_PARAM_NODE_STARTUP:
return 0444;
default:
return 0;
@@ -468,6 +468,7 @@ static umode_t qla4_attr_is_visible(int param_type, int param)
case ISCSI_PARAM_DISCOVERY_PARENT_IDX:
case ISCSI_PARAM_DISCOVERY_PARENT_TYPE:
case ISCSI_PARAM_LOCAL_IPADDR:
+ case ISCSI_PARAM_NODE_STARTUP:
return S_IRUGO;
default:
return 0;
@@ -4367,6 +4367,7 @@ iscsi_session_attr(tsid, ISCSI_PARAM_TSID, 0);
iscsi_session_attr(def_taskmgmt_tmo, ISCSI_PARAM_DEF_TASKMGMT_TMO, 0);
iscsi_session_attr(discovery_parent_idx, ISCSI_PARAM_DISCOVERY_PARENT_IDX, 0);
iscsi_session_attr(discovery_parent_type, ISCSI_PARAM_DISCOVERY_PARENT_TYPE, 0);
+iscsi_session_attr(node_startup, ISCSI_PARAM_NODE_STARTUP, 0);
static ssize_t
show_priv_session_state(struct device *dev, struct device_attribute *attr,
@@ -4488,6 +4489,7 @@ static struct attribute *iscsi_session_attrs[] = {
&dev_attr_sess_def_taskmgmt_tmo.attr,
&dev_attr_sess_discovery_parent_idx.attr,
&dev_attr_sess_discovery_parent_type.attr,
+ &dev_attr_sess_node_startup.attr,
NULL,
};
@@ -4587,6 +4589,8 @@ static umode_t iscsi_session_attr_is_visible(struct kobject *kobj,
return S_IRUGO;
else if (attr == &dev_attr_priv_sess_target_id.attr)
return S_IRUGO;
+ else if (attr == &dev_attr_sess_node_startup.attr)
+ param = ISCSI_PARAM_NODE_STARTUP;
else {
WARN_ONCE(1, "Invalid session attr");
return 0;
@@ -610,6 +610,7 @@ enum iscsi_param {
ISCSI_PARAM_DISCOVERY_PARENT_IDX,
ISCSI_PARAM_DISCOVERY_PARENT_TYPE,
ISCSI_PARAM_LOCAL_IPADDR,
+ ISCSI_PARAM_NODE_STARTUP,
/* must always be last */
ISCSI_PARAM_MAX,
};
@@ -327,6 +327,7 @@ struct iscsi_session {
char *boot_target;
char *portal_type;
char *discovery_parent_type;
+ char *node_startup;
uint16_t discovery_parent_idx;
uint16_t def_taskmgmt_tmo;
uint16_t tsid;
There are 3 iscsi session's startup mode which are onboot, manual and automatic. We can boot from iSCSI disks with help of dracut's service in initrd, which would set node's startup mode to onboot, then create iSCSI sessions. While the configure of onboot mode is recorded in file of initrd stage and would be lost when switch to rootfs. Even if we update the startup mode to onboot by hand after switch to rootfs, it is possible that the configure would be covered by another discovery command. root would be mounted on iSCSI disks when boot from iSCSI disks, if the sessions is logged out, the related disks would be removed, which would cause the whole system halt. So we need record session's start up mode in kernel and check this mode before logout this session. Signed-off-by: Wenchao Hao <haowenchao@huawei.com> --- drivers/infiniband/ulp/iser/iscsi_iser.c | 1 + drivers/scsi/be2iscsi/be_iscsi.c | 1 + drivers/scsi/bnx2i/bnx2i_iscsi.c | 1 + drivers/scsi/cxgbi/libcxgbi.c | 1 + drivers/scsi/iscsi_tcp.c | 1 + drivers/scsi/libiscsi.c | 5 +++++ drivers/scsi/qedi/qedi_iscsi.c | 1 + drivers/scsi/qla4xxx/ql4_os.c | 1 + drivers/scsi/scsi_transport_iscsi.c | 4 ++++ include/scsi/iscsi_if.h | 1 + include/scsi/libiscsi.h | 1 + 11 files changed, 18 insertions(+)