Commit c6037cc5 authored by Andy Grover's avatar Andy Grover Committed by Nicholas Bellinger

target/iscsi: Misc cleanups from Agrover (round 1)

*) Use decoded cmd->immediate_cmd for conditional instead of
   re-examining hdr->opcode
*) Make iscist_dataout_post_crc_passed more legible
*) use max() to reduce code in build_r2ts_for_cmd()
*) Remove CONFIG_SMP and if 0 ifdefs
*) Replace if/goto with a while loop
*) Remove unused conn->tx_immediate_queue and tx_response_queue
Signed-off-by: default avatarAndy Grover <agrover@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 2fbb471e
...@@ -2178,7 +2178,7 @@ static int iscsit_handle_logout_cmd( ...@@ -2178,7 +2178,7 @@ static int iscsit_handle_logout_cmd(
* Immediate commands are executed, well, immediately. * Immediate commands are executed, well, immediately.
* Non-Immediate Logout Commands are executed in CmdSN order. * Non-Immediate Logout Commands are executed in CmdSN order.
*/ */
if (hdr->opcode & ISCSI_OP_IMMEDIATE) { if (cmd->immediate_cmd) {
int ret = iscsit_execute_cmd(cmd, 0); int ret = iscsit_execute_cmd(cmd, 0);
if (ret < 0) if (ret < 0)
...@@ -2923,8 +2923,7 @@ int iscsit_build_r2ts_for_cmd( ...@@ -2923,8 +2923,7 @@ int iscsit_build_r2ts_for_cmd(
} }
if (conn->sess->sess_ops->DataSequenceInOrder && (type != 2)) if (conn->sess->sess_ops->DataSequenceInOrder && (type != 2))
if (cmd->r2t_offset < cmd->write_data_done) cmd->r2t_offset = max(cmd->r2t_offset, cmd->write_data_done);
cmd->r2t_offset = cmd->write_data_done;
while (cmd->outstanding_r2ts < conn->sess->sess_ops->MaxOutstandingR2T) { while (cmd->outstanding_r2ts < conn->sess->sess_ops->MaxOutstandingR2T) {
if (conn->sess->sess_ops->DataSequenceInOrder) { if (conn->sess->sess_ops->DataSequenceInOrder) {
...@@ -3418,8 +3417,6 @@ static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *conn) ...@@ -3418,8 +3417,6 @@ static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *conn)
} }
} }
#ifdef CONFIG_SMP
void iscsit_thread_get_cpumask(struct iscsi_conn *conn) void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
{ {
struct iscsi_thread_set *ts = conn->thread_set; struct iscsi_thread_set *ts = conn->thread_set;
...@@ -3433,10 +3430,6 @@ void iscsit_thread_get_cpumask(struct iscsi_conn *conn) ...@@ -3433,10 +3430,6 @@ void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
* execute upon. * execute upon.
*/ */
ord = ts->thread_id % cpumask_weight(cpu_online_mask); ord = ts->thread_id % cpumask_weight(cpu_online_mask);
#if 0
pr_debug(">>>>>>>>>>>>>>>>>>>> Generated ord: %d from"
" thread_id: %d\n", ord, ts->thread_id);
#endif
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
if (ord-- == 0) { if (ord-- == 0) {
cpumask_set_cpu(cpu, conn->conn_cpumask); cpumask_set_cpu(cpu, conn->conn_cpumask);
...@@ -3476,23 +3469,9 @@ static inline void iscsit_thread_check_cpumask( ...@@ -3476,23 +3469,9 @@ static inline void iscsit_thread_check_cpumask(
*/ */
memset(buf, 0, 128); memset(buf, 0, 128);
cpumask_scnprintf(buf, 128, conn->conn_cpumask); cpumask_scnprintf(buf, 128, conn->conn_cpumask);
#if 0
pr_debug(">>>>>>>>>>>>>> Calling set_cpus_allowed_ptr():"
" %s for %s\n", buf, p->comm);
#endif
set_cpus_allowed_ptr(p, conn->conn_cpumask); set_cpus_allowed_ptr(p, conn->conn_cpumask);
} }
#else
void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
{
return;
}
#define iscsit_thread_check_cpumask(X, Y, Z) ({})
#endif /* CONFIG_SMP */
int iscsi_target_tx_thread(void *arg) int iscsi_target_tx_thread(void *arg)
{ {
u8 state; u8 state;
...@@ -3531,9 +3510,7 @@ int iscsi_target_tx_thread(void *arg) ...@@ -3531,9 +3510,7 @@ int iscsi_target_tx_thread(void *arg)
signal_pending(current)) signal_pending(current))
goto transport_err; goto transport_err;
get_immediate: while ((qr = iscsit_get_cmd_from_immediate_queue(conn))) {
qr = iscsit_get_cmd_from_immediate_queue(conn);
if (qr) {
atomic_set(&conn->check_immediate_queue, 0); atomic_set(&conn->check_immediate_queue, 0);
cmd = qr->cmd; cmd = qr->cmd;
state = qr->state; state = qr->state;
...@@ -3556,7 +3533,7 @@ int iscsi_target_tx_thread(void *arg) ...@@ -3556,7 +3533,7 @@ int iscsi_target_tx_thread(void *arg)
spin_unlock_bh(&conn->cmd_lock); spin_unlock_bh(&conn->cmd_lock);
iscsit_free_cmd(cmd); iscsit_free_cmd(cmd);
goto get_immediate; continue;
case ISTATE_SEND_NOPIN_WANT_RESPONSE: case ISTATE_SEND_NOPIN_WANT_RESPONSE:
spin_unlock_bh(&cmd->istate_lock); spin_unlock_bh(&cmd->istate_lock);
iscsit_mod_nopin_response_timer(conn); iscsit_mod_nopin_response_timer(conn);
...@@ -3576,13 +3553,10 @@ int iscsi_target_tx_thread(void *arg) ...@@ -3576,13 +3553,10 @@ int iscsi_target_tx_thread(void *arg)
spin_unlock_bh(&cmd->istate_lock); spin_unlock_bh(&cmd->istate_lock);
goto transport_err; goto transport_err;
} }
if (ret < 0) { if (ret < 0)
conn->tx_immediate_queue = 0;
goto transport_err; goto transport_err;
}
if (iscsit_send_tx_data(cmd, conn, 1) < 0) { if (iscsit_send_tx_data(cmd, conn, 1) < 0) {
conn->tx_immediate_queue = 0;
iscsit_tx_thread_wait_for_tcp(conn); iscsit_tx_thread_wait_for_tcp(conn);
goto transport_err; goto transport_err;
} }
...@@ -3611,13 +3585,9 @@ int iscsi_target_tx_thread(void *arg) ...@@ -3611,13 +3585,9 @@ int iscsi_target_tx_thread(void *arg)
spin_unlock_bh(&cmd->istate_lock); spin_unlock_bh(&cmd->istate_lock);
goto transport_err; goto transport_err;
} }
goto get_immediate; }
} else
conn->tx_immediate_queue = 0;
get_response: while ((qr = iscsit_get_cmd_from_response_queue(conn))) {
qr = iscsit_get_cmd_from_response_queue(conn);
if (qr) {
cmd = qr->cmd; cmd = qr->cmd;
state = qr->state; state = qr->state;
kmem_cache_free(lio_qr_cache, qr); kmem_cache_free(lio_qr_cache, qr);
...@@ -3681,21 +3651,17 @@ int iscsi_target_tx_thread(void *arg) ...@@ -3681,21 +3651,17 @@ int iscsi_target_tx_thread(void *arg)
spin_unlock_bh(&cmd->istate_lock); spin_unlock_bh(&cmd->istate_lock);
goto transport_err; goto transport_err;
} }
if (ret < 0) { if (ret < 0)
conn->tx_response_queue = 0;
goto transport_err; goto transport_err;
}
if (map_sg && !conn->conn_ops->IFMarker) { if (map_sg && !conn->conn_ops->IFMarker) {
if (iscsit_fe_sendpage_sg(cmd, conn) < 0) { if (iscsit_fe_sendpage_sg(cmd, conn) < 0) {
conn->tx_response_queue = 0;
iscsit_tx_thread_wait_for_tcp(conn); iscsit_tx_thread_wait_for_tcp(conn);
iscsit_unmap_iovec(cmd); iscsit_unmap_iovec(cmd);
goto transport_err; goto transport_err;
} }
} else { } else {
if (iscsit_send_tx_data(cmd, conn, use_misc) < 0) { if (iscsit_send_tx_data(cmd, conn, use_misc) < 0) {
conn->tx_response_queue = 0;
iscsit_tx_thread_wait_for_tcp(conn); iscsit_tx_thread_wait_for_tcp(conn);
iscsit_unmap_iovec(cmd); iscsit_unmap_iovec(cmd);
goto transport_err; goto transport_err;
...@@ -3771,11 +3737,8 @@ int iscsi_target_tx_thread(void *arg) ...@@ -3771,11 +3737,8 @@ int iscsi_target_tx_thread(void *arg)
spin_unlock_bh(&cmd->istate_lock); spin_unlock_bh(&cmd->istate_lock);
if (atomic_read(&conn->check_immediate_queue)) if (atomic_read(&conn->check_immediate_queue))
goto get_immediate; break;
}
goto get_response;
} else
conn->tx_response_queue = 0;
} }
transport_err: transport_err:
......
...@@ -500,8 +500,6 @@ struct iscsi_conn { ...@@ -500,8 +500,6 @@ struct iscsi_conn {
u8 network_transport; u8 network_transport;
enum iscsi_timer_flags_table nopin_timer_flags; enum iscsi_timer_flags_table nopin_timer_flags;
enum iscsi_timer_flags_table nopin_response_timer_flags; enum iscsi_timer_flags_table nopin_response_timer_flags;
u8 tx_immediate_queue;
u8 tx_response_queue;
/* Used to know what thread encountered a transport failure */ /* Used to know what thread encountered a transport failure */
u8 which_thread; u8 which_thread;
/* connection id assigned by the Initiator */ /* connection id assigned by the Initiator */
......
...@@ -640,9 +640,12 @@ static int iscsit_dataout_post_crc_passed( ...@@ -640,9 +640,12 @@ static int iscsit_dataout_post_crc_passed(
cmd->write_data_done += payload_length; cmd->write_data_done += payload_length;
return (cmd->write_data_done == cmd->data_length) ? if (cmd->write_data_done == cmd->data_length)
DATAOUT_SEND_TO_TRANSPORT : (send_r2t) ? return DATAOUT_SEND_TO_TRANSPORT;
DATAOUT_SEND_R2T : DATAOUT_NORMAL; else if (send_r2t)
return DATAOUT_SEND_R2T;
else
return DATAOUT_NORMAL;
} }
static int iscsit_dataout_post_crc_failed( static int iscsit_dataout_post_crc_failed(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment