iscsi-target: Introduce session_get_next_ttt
Reduce code duplication. Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
631af55062
commit
c1e34b6404
@ -968,11 +968,7 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
|
|||||||
|
|
||||||
conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt;
|
conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt;
|
||||||
if (hdr->flags & ISCSI_FLAG_CMD_READ) {
|
if (hdr->flags & ISCSI_FLAG_CMD_READ) {
|
||||||
spin_lock_bh(&conn->sess->ttt_lock);
|
cmd->targ_xfer_tag = session_get_next_ttt(conn->sess);
|
||||||
cmd->targ_xfer_tag = conn->sess->targ_xfer_tag++;
|
|
||||||
if (cmd->targ_xfer_tag == 0xFFFFFFFF)
|
|
||||||
cmd->targ_xfer_tag = conn->sess->targ_xfer_tag++;
|
|
||||||
spin_unlock_bh(&conn->sess->ttt_lock);
|
|
||||||
} else if (hdr->flags & ISCSI_FLAG_CMD_WRITE)
|
} else if (hdr->flags & ISCSI_FLAG_CMD_WRITE)
|
||||||
cmd->targ_xfer_tag = 0xFFFFFFFF;
|
cmd->targ_xfer_tag = 0xFFFFFFFF;
|
||||||
cmd->cmd_sn = be32_to_cpu(hdr->cmdsn);
|
cmd->cmd_sn = be32_to_cpu(hdr->cmdsn);
|
||||||
@ -3047,11 +3043,7 @@ static int iscsit_send_r2t(
|
|||||||
int_to_scsilun(cmd->se_cmd.orig_fe_lun,
|
int_to_scsilun(cmd->se_cmd.orig_fe_lun,
|
||||||
(struct scsi_lun *)&hdr->lun);
|
(struct scsi_lun *)&hdr->lun);
|
||||||
hdr->itt = cmd->init_task_tag;
|
hdr->itt = cmd->init_task_tag;
|
||||||
spin_lock_bh(&conn->sess->ttt_lock);
|
r2t->targ_xfer_tag = session_get_next_ttt(conn->sess);
|
||||||
r2t->targ_xfer_tag = conn->sess->targ_xfer_tag++;
|
|
||||||
if (r2t->targ_xfer_tag == 0xFFFFFFFF)
|
|
||||||
r2t->targ_xfer_tag = conn->sess->targ_xfer_tag++;
|
|
||||||
spin_unlock_bh(&conn->sess->ttt_lock);
|
|
||||||
hdr->ttt = cpu_to_be32(r2t->targ_xfer_tag);
|
hdr->ttt = cpu_to_be32(r2t->targ_xfer_tag);
|
||||||
hdr->statsn = cpu_to_be32(conn->stat_sn);
|
hdr->statsn = cpu_to_be32(conn->stat_sn);
|
||||||
hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn);
|
hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn);
|
||||||
|
@ -939,13 +939,8 @@ static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response)
|
|||||||
state = (want_response) ? ISTATE_SEND_NOPIN_WANT_RESPONSE :
|
state = (want_response) ? ISTATE_SEND_NOPIN_WANT_RESPONSE :
|
||||||
ISTATE_SEND_NOPIN_NO_RESPONSE;
|
ISTATE_SEND_NOPIN_NO_RESPONSE;
|
||||||
cmd->init_task_tag = RESERVED_ITT;
|
cmd->init_task_tag = RESERVED_ITT;
|
||||||
spin_lock_bh(&conn->sess->ttt_lock);
|
cmd->targ_xfer_tag = (want_response) ?
|
||||||
cmd->targ_xfer_tag = (want_response) ? conn->sess->targ_xfer_tag++ :
|
session_get_next_ttt(conn->sess) : 0xFFFFFFFF;
|
||||||
0xFFFFFFFF;
|
|
||||||
if (want_response && (cmd->targ_xfer_tag == 0xFFFFFFFF))
|
|
||||||
cmd->targ_xfer_tag = conn->sess->targ_xfer_tag++;
|
|
||||||
spin_unlock_bh(&conn->sess->ttt_lock);
|
|
||||||
|
|
||||||
spin_lock_bh(&conn->cmd_lock);
|
spin_lock_bh(&conn->cmd_lock);
|
||||||
list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list);
|
list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list);
|
||||||
spin_unlock_bh(&conn->cmd_lock);
|
spin_unlock_bh(&conn->cmd_lock);
|
||||||
|
@ -880,4 +880,17 @@ struct iscsit_global {
|
|||||||
struct iscsi_portal_group *discovery_tpg;
|
struct iscsi_portal_group *discovery_tpg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline u32 session_get_next_ttt(struct iscsi_session *session)
|
||||||
|
{
|
||||||
|
u32 ttt;
|
||||||
|
|
||||||
|
spin_lock_bh(&session->ttt_lock);
|
||||||
|
ttt = session->targ_xfer_tag++;
|
||||||
|
if (ttt == 0xFFFFFFFF)
|
||||||
|
ttt = session->targ_xfer_tag++;
|
||||||
|
spin_unlock_bh(&session->ttt_lock);
|
||||||
|
|
||||||
|
return ttt;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* ISCSI_TARGET_CORE_H */
|
#endif /* ISCSI_TARGET_CORE_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user