@@ -49,7 +49,6 @@
static DEFINE_MUTEX(np_lock);
static struct idr tiqn_idr;
-DEFINE_IDA(sess_ida);
struct mutex auth_id_lock;
struct iscsit_global *iscsit_global;
@@ -2328,7 +2327,7 @@ int iscsit_logout_closesession(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
struct iscsi_session *sess = conn->sess;
pr_debug("Received logout request CLOSESESSION on CID: %hu"
- " for SID: %u.\n", conn->cid, conn->sess->sid);
+ " for SID: %u.\n", conn->cid, conn->sess->se_sess->sid);
atomic_set(&sess->session_logout, 1);
atomic_set(&conn->conn_logout_remove, 1);
@@ -4107,7 +4106,7 @@ int iscsit_close_connection(
struct iscsi_session *sess = conn->sess;
pr_debug("Closing iSCSI connection CID %hu on SID:"
- " %u\n", conn->cid, sess->sid);
+ " %u\n", conn->cid, sess->se_sess->sid);
/*
* Always up conn_logout_comp for the traditional TCP and HW_OFFLOAD
* case just in case the RX Thread in iscsi_target_rx_opcode() is
@@ -4403,7 +4402,6 @@ int iscsit_close_session(struct iscsi_session *sess)
pr_debug("Decremented number of active iSCSI Sessions on"
" iSCSI TPG: %hu to %u\n", tpg->tpgt, tpg->nsessions);
- ida_free(&sess_ida, sess->session_index);
kfree(sess->sess_ops);
sess->sess_ops = NULL;
spin_unlock_bh(&se_tpg->session_lock);
@@ -520,7 +520,7 @@ static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)
rb += sprintf(page+rb,
"LIO Session ID: %u ISID: 0x%6ph TSIH: %hu ",
- sess->sid, sess->isid, sess->tsih);
+ se_sess->sid, sess->isid, sess->tsih);
rb += sprintf(page+rb, "SessionType: %s\n",
(sess->sess_ops->SessionType) ?
"Discovery" : "Normal");
@@ -1344,9 +1344,7 @@ static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
static u32 lio_sess_get_index(struct se_session *se_sess)
{
- struct iscsi_session *sess = se_sess->fabric_sess_ptr;
-
- return sess->session_index;
+ return se_sess->sid;
}
static int lio_queue_data_in(struct se_cmd *se_cmd)
@@ -761,7 +761,7 @@ void iscsit_handle_time2retain_timeout(struct timer_list *t)
sess->time2retain_timer_flags |= ISCSI_TF_EXPIRED;
pr_err("Time2Retain timer expired for SID: %u, cleaning up"
- " iSCSI session.\n", sess->sid);
+ " iSCSI session.\n", sess->se_sess->sid);
iscsit_fill_cxn_timeout_err_stats(sess);
spin_unlock_bh(&se_tpg->session_lock);
@@ -786,7 +786,8 @@ void iscsit_start_time2retain_handler(struct iscsi_session *sess)
return;
pr_debug("Starting Time2Retain timer for %u seconds on"
- " SID: %u\n", sess->sess_ops->DefaultTime2Retain, sess->sid);
+ " SID: %u\n", sess->sess_ops->DefaultTime2Retain,
+ sess->se_sess->sid);
sess->time2retain_timer_flags &= ~ISCSI_TF_STOP;
sess->time2retain_timer_flags |= ISCSI_TF_RUNNING;
@@ -815,7 +816,7 @@ int iscsit_stop_time2retain_timer(struct iscsi_session *sess)
spin_lock(&se_tpg->session_lock);
sess->time2retain_timer_flags &= ~ISCSI_TF_RUNNING;
pr_debug("Stopped Time2Retain Timer for SID: %u\n",
- sess->sid);
+ sess->se_sess->sid);
return 0;
}
@@ -882,8 +883,8 @@ void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep)
void iscsit_fall_back_to_erl0(struct iscsi_session *sess)
{
- pr_debug("Falling back to ErrorRecoveryLevel=0 for SID:"
- " %u\n", sess->sid);
+ pr_debug("Falling back to ErrorRecoveryLevel=0 for SID: %u\n",
+ sess->se_sess->sid);
atomic_set(&sess->session_fall_back_to_erl0, 1);
}
@@ -93,7 +93,7 @@ static int iscsit_attach_inactive_connection_recovery_entry(
sess->conn_recovery_count++;
pr_debug("Incremented connection recovery count to %u for"
- " SID: %u\n", sess->conn_recovery_count, sess->sid);
+ " SID: %u\n", sess->conn_recovery_count, sess->se_sess->sid);
spin_unlock(&sess->cr_i_lock);
return 0;
@@ -176,7 +176,7 @@ int iscsit_remove_active_connection_recovery_entry(
sess->conn_recovery_count--;
pr_debug("Decremented connection recovery count to %u for"
- " SID: %u\n", sess->conn_recovery_count, sess->sid);
+ " SID: %u\n", sess->conn_recovery_count, sess->se_sess->sid);
spin_unlock(&sess->cr_a_lock);
kfree(cr);
@@ -251,11 +251,11 @@ void iscsit_discard_cr_cmds_by_expstatsn(
if (!cr->cmd_count) {
pr_debug("No commands to be reassigned for failed"
" connection CID: %hu on SID: %u\n",
- cr->cid, sess->sid);
+ cr->cid, sess->se_sess->sid);
iscsit_remove_inactive_connection_recovery_entry(cr, sess);
iscsit_attach_active_connection_recovery_entry(sess, cr);
pr_debug("iSCSI connection recovery successful for CID:"
- " %hu on SID: %u\n", cr->cid, sess->sid);
+ " %hu on SID: %u\n", cr->cid, sess->se_sess->sid);
iscsit_remove_active_connection_recovery_entry(cr, sess);
} else {
iscsit_remove_inactive_connection_recovery_entry(cr, sess);
@@ -186,7 +186,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
pr_debug("%s iSCSI Session SID %u is still active for %s,"
" performing session reinstatement.\n", (sessiontype) ?
- "Discovery" : "Normal", sess->sid,
+ "Discovery" : "Normal", sess->se_sess->sid,
sess->sess_ops->InitiatorName);
spin_lock_bh(&sess->conn_lock);
@@ -258,7 +258,6 @@ static int iscsi_login_zero_tsih_s1(
{
struct iscsi_session *sess = NULL;
struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
- int ret;
sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL);
if (!sess) {
@@ -292,15 +291,6 @@ static int iscsi_login_zero_tsih_s1(
timer_setup(&sess->time2retain_timer,
iscsit_handle_time2retain_timeout, 0);
- ret = ida_alloc(&sess_ida, GFP_KERNEL);
- if (ret < 0) {
- pr_err("Session ID allocation failed %d\n", ret);
- iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
- ISCSI_LOGIN_STATUS_NO_RESOURCES);
- goto free_sess;
- }
-
- sess->session_index = ret;
sess->creation_time = get_jiffies_64();
/*
* The FFP CmdSN window values will be allocated from the TPG's
@@ -314,7 +304,7 @@ static int iscsi_login_zero_tsih_s1(
ISCSI_LOGIN_STATUS_NO_RESOURCES);
pr_err("Unable to allocate memory for"
" struct iscsi_sess_ops.\n");
- goto free_id;
+ goto free_sess;
}
sess->se_sess = transport_alloc_session(TARGET_PROT_NORMAL);
@@ -328,8 +318,6 @@ static int iscsi_login_zero_tsih_s1(
free_ops:
kfree(sess->sess_ops);
-free_id:
- ida_free(&sess_ida, sess->session_index);
free_sess:
kfree(sess);
conn->sess = NULL;
@@ -768,9 +756,6 @@ void iscsi_post_login_handler(
sess->sess_ops->InitiatorName);
spin_unlock_bh(&sess->conn_lock);
- sess->sid = tpg->sid++;
- if (!sess->sid)
- sess->sid = tpg->sid++;
pr_debug("Established iSCSI session from node: %s\n",
sess->sess_ops->InitiatorName);
@@ -1161,7 +1146,6 @@ void iscsi_target_login_sess_out(struct iscsi_conn *conn,
goto old_sess_out;
transport_free_session(conn->sess->se_sess);
- ida_free(&sess_ida, conn->sess->session_index);
kfree(conn->sess->sess_ops);
kfree(conn->sess);
conn->sess = NULL;
@@ -630,8 +630,7 @@ static ssize_t iscsi_stat_sess_indx_show(struct config_item *item, char *page)
if (se_sess) {
sess = se_sess->fabric_sess_ptr;
if (sess)
- ret = snprintf(page, PAGE_SIZE, "%u\n",
- sess->session_index);
+ ret = snprintf(page, PAGE_SIZE, "%u\n", se_sess->sid);
}
spin_unlock_bh(&se_nacl->nacl_sess_lock);
@@ -186,7 +186,7 @@ static void iscsit_task_reassign_remove_cmd(
spin_unlock(&cr->conn_recovery_cmd_lock);
if (!ret) {
pr_debug("iSCSI connection recovery successful for CID:"
- " %hu on SID: %u\n", cr->cid, sess->sid);
+ " %hu on SID: %u\n", cr->cid, sess->se_sess->sid);
iscsit_remove_active_connection_recovery_entry(cr, sess);
}
}
@@ -64,16 +64,13 @@ int iscsit_load_discovery_tpg(void)
*/
tpg->tpg_se_tpg.se_tpg_tfo = &iscsi_ops;
ret = core_tpg_register(NULL, &tpg->tpg_se_tpg, -1);
- if (ret < 0) {
- kfree(tpg);
- return -1;
- }
+ if (ret < 0)
+ goto free_tpg;
- tpg->sid = 1; /* First Assigned LIO Session ID */
iscsit_set_default_tpg_attribs(tpg);
if (iscsi_create_default_params(&tpg->param_list) < 0)
- goto out;
+ goto dereg_se_tpg;
/*
* By default we disable authentication for discovery sessions,
* this can be changed with:
@@ -97,11 +94,12 @@ int iscsit_load_discovery_tpg(void)
pr_debug("CORE[0] - Allocated Discovery TPG\n");
return 0;
+
free_pl_out:
iscsi_release_param_list(tpg->param_list);
-out:
- if (tpg->sid == 1)
- core_tpg_deregister(&tpg->tpg_se_tpg);
+dereg_se_tpg:
+ core_tpg_deregister(&tpg->tpg_se_tpg);
+free_tpg:
kfree(tpg);
return -1;
}
@@ -1219,7 +1219,7 @@ void iscsit_print_session_params(struct iscsi_session *sess)
struct iscsi_conn *conn;
pr_debug("-----------------------------[Session Params for"
- " SID: %u]-----------------------------\n", sess->sid);
+ " SID: %u]-----------------------------\n", sess->se_sess->sid);
spin_lock_bh(&sess->conn_lock);
list_for_each_entry(conn, &sess->sess_conn_list, conn_list)
iscsi_dump_conn_ops(conn->conn_ops);
@@ -654,11 +654,7 @@ struct iscsi_session {
atomic_t max_cmd_sn;
struct list_head sess_ooo_cmdsn_list;
- /* LIO specific session ID */
- u32 sid;
char auth_type[8];
- /* unique within the target */
- int session_index;
/* Used for session reference counting */
int session_usage_count;
int session_waiting_on_uc;
@@ -830,8 +826,6 @@ struct iscsi_portal_group {
u32 nsessions;
/* Number of Network Portals available for this TPG */
u32 num_tpg_nps;
- /* Per TPG LIO specific session ID. */
- u32 sid;
/* Spinlock for adding/removing Network Portals */
spinlock_t tpg_np_lock;
spinlock_t tpg_state_lock;
This is the first phase in hooking iscsi into the sysfs API. This patch has it use lio core's sid instead of its internal ones. We have 2 sids in the iscsi target layer: - module sid: int id that is unique across all iscsi targets. Used for sess_get_index(). - iscsi target port group sid: int id that is unique in the tpg. Uses for logging. The lio one works exactly like the iscsi target module one, and the iscsi tpg one is not very useful because when you have multiple tpgs you can't tell which tpg the session is under. In the latter case the lio core one is more useful, because it matches what we see in userspace and logs and we can distinguish what fabric/target/tpg the session is under. Signed-off-by: Mike Christie <michael.christie@oracle.com> --- drivers/target/iscsi/iscsi_target.c | 6 ++---- drivers/target/iscsi/iscsi_target_configfs.c | 6 ++---- drivers/target/iscsi/iscsi_target_erl0.c | 11 ++++++----- drivers/target/iscsi/iscsi_target_erl2.c | 8 ++++---- drivers/target/iscsi/iscsi_target_login.c | 20 ++------------------ drivers/target/iscsi/iscsi_target_stat.c | 3 +-- drivers/target/iscsi/iscsi_target_tmr.c | 2 +- drivers/target/iscsi/iscsi_target_tpg.c | 16 +++++++--------- drivers/target/iscsi/iscsi_target_util.c | 2 +- include/target/iscsi/iscsi_target_core.h | 6 ------ 10 files changed, 26 insertions(+), 54 deletions(-)