diff options
author | Andy Grover <agrover@redhat.com> | 2012-04-03 18:51:02 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-04-14 20:40:33 -0400 |
commit | c6037cc546ca10cbdc5b60f0598b4ddcb181fe5d (patch) | |
tree | e94de0fb6cd142cad6e8152c7130da1caefcf951 /drivers/target/iscsi | |
parent | 2fbb471e7821e3a12334054cd90aa3f3edb22cc3 (diff) |
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: Andy Grover <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/iscsi')
-rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 57 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_core.h | 2 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_erl0.c | 9 |
3 files changed, 16 insertions, 52 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index e635e263eb9d..e77b045c9b78 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -2178,7 +2178,7 @@ static int iscsit_handle_logout_cmd( | |||
2178 | * Immediate commands are executed, well, immediately. | 2178 | * Immediate commands are executed, well, immediately. |
2179 | * Non-Immediate Logout Commands are executed in CmdSN order. | 2179 | * Non-Immediate Logout Commands are executed in CmdSN order. |
2180 | */ | 2180 | */ |
2181 | if (hdr->opcode & ISCSI_OP_IMMEDIATE) { | 2181 | if (cmd->immediate_cmd) { |
2182 | int ret = iscsit_execute_cmd(cmd, 0); | 2182 | int ret = iscsit_execute_cmd(cmd, 0); |
2183 | 2183 | ||
2184 | if (ret < 0) | 2184 | if (ret < 0) |
@@ -2923,8 +2923,7 @@ int iscsit_build_r2ts_for_cmd( | |||
2923 | } | 2923 | } |
2924 | 2924 | ||
2925 | if (conn->sess->sess_ops->DataSequenceInOrder && (type != 2)) | 2925 | if (conn->sess->sess_ops->DataSequenceInOrder && (type != 2)) |
2926 | if (cmd->r2t_offset < cmd->write_data_done) | 2926 | cmd->r2t_offset = max(cmd->r2t_offset, cmd->write_data_done); |
2927 | cmd->r2t_offset = cmd->write_data_done; | ||
2928 | 2927 | ||
2929 | while (cmd->outstanding_r2ts < conn->sess->sess_ops->MaxOutstandingR2T) { | 2928 | while (cmd->outstanding_r2ts < conn->sess->sess_ops->MaxOutstandingR2T) { |
2930 | if (conn->sess->sess_ops->DataSequenceInOrder) { | 2929 | if (conn->sess->sess_ops->DataSequenceInOrder) { |
@@ -3418,8 +3417,6 @@ static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *conn) | |||
3418 | } | 3417 | } |
3419 | } | 3418 | } |
3420 | 3419 | ||
3421 | #ifdef CONFIG_SMP | ||
3422 | |||
3423 | void iscsit_thread_get_cpumask(struct iscsi_conn *conn) | 3420 | void iscsit_thread_get_cpumask(struct iscsi_conn *conn) |
3424 | { | 3421 | { |
3425 | struct iscsi_thread_set *ts = conn->thread_set; | 3422 | struct iscsi_thread_set *ts = conn->thread_set; |
@@ -3433,10 +3430,6 @@ void iscsit_thread_get_cpumask(struct iscsi_conn *conn) | |||
3433 | * execute upon. | 3430 | * execute upon. |
3434 | */ | 3431 | */ |
3435 | ord = ts->thread_id % cpumask_weight(cpu_online_mask); | 3432 | ord = ts->thread_id % cpumask_weight(cpu_online_mask); |
3436 | #if 0 | ||
3437 | pr_debug(">>>>>>>>>>>>>>>>>>>> Generated ord: %d from" | ||
3438 | " thread_id: %d\n", ord, ts->thread_id); | ||
3439 | #endif | ||
3440 | for_each_online_cpu(cpu) { | 3433 | for_each_online_cpu(cpu) { |
3441 | if (ord-- == 0) { | 3434 | if (ord-- == 0) { |
3442 | cpumask_set_cpu(cpu, conn->conn_cpumask); | 3435 | cpumask_set_cpu(cpu, conn->conn_cpumask); |
@@ -3476,23 +3469,9 @@ static inline void iscsit_thread_check_cpumask( | |||
3476 | */ | 3469 | */ |
3477 | memset(buf, 0, 128); | 3470 | memset(buf, 0, 128); |
3478 | cpumask_scnprintf(buf, 128, conn->conn_cpumask); | 3471 | cpumask_scnprintf(buf, 128, conn->conn_cpumask); |
3479 | #if 0 | ||
3480 | pr_debug(">>>>>>>>>>>>>> Calling set_cpus_allowed_ptr():" | ||
3481 | " %s for %s\n", buf, p->comm); | ||
3482 | #endif | ||
3483 | set_cpus_allowed_ptr(p, conn->conn_cpumask); | 3472 | set_cpus_allowed_ptr(p, conn->conn_cpumask); |
3484 | } | 3473 | } |
3485 | 3474 | ||
3486 | #else | ||
3487 | |||
3488 | void iscsit_thread_get_cpumask(struct iscsi_conn *conn) | ||
3489 | { | ||
3490 | return; | ||
3491 | } | ||
3492 | |||
3493 | #define iscsit_thread_check_cpumask(X, Y, Z) ({}) | ||
3494 | #endif /* CONFIG_SMP */ | ||
3495 | |||
3496 | int iscsi_target_tx_thread(void *arg) | 3475 | int iscsi_target_tx_thread(void *arg) |
3497 | { | 3476 | { |
3498 | u8 state; | 3477 | u8 state; |
@@ -3531,9 +3510,7 @@ restart: | |||
3531 | signal_pending(current)) | 3510 | signal_pending(current)) |
3532 | goto transport_err; | 3511 | goto transport_err; |
3533 | 3512 | ||
3534 | get_immediate: | 3513 | while ((qr = iscsit_get_cmd_from_immediate_queue(conn))) { |
3535 | qr = iscsit_get_cmd_from_immediate_queue(conn); | ||
3536 | if (qr) { | ||
3537 | atomic_set(&conn->check_immediate_queue, 0); | 3514 | atomic_set(&conn->check_immediate_queue, 0); |
3538 | cmd = qr->cmd; | 3515 | cmd = qr->cmd; |
3539 | state = qr->state; | 3516 | state = qr->state; |
@@ -3556,7 +3533,7 @@ get_immediate: | |||
3556 | spin_unlock_bh(&conn->cmd_lock); | 3533 | spin_unlock_bh(&conn->cmd_lock); |
3557 | 3534 | ||
3558 | iscsit_free_cmd(cmd); | 3535 | iscsit_free_cmd(cmd); |
3559 | goto get_immediate; | 3536 | continue; |
3560 | case ISTATE_SEND_NOPIN_WANT_RESPONSE: | 3537 | case ISTATE_SEND_NOPIN_WANT_RESPONSE: |
3561 | spin_unlock_bh(&cmd->istate_lock); | 3538 | spin_unlock_bh(&cmd->istate_lock); |
3562 | iscsit_mod_nopin_response_timer(conn); | 3539 | iscsit_mod_nopin_response_timer(conn); |
@@ -3576,13 +3553,10 @@ get_immediate: | |||
3576 | spin_unlock_bh(&cmd->istate_lock); | 3553 | spin_unlock_bh(&cmd->istate_lock); |
3577 | goto transport_err; | 3554 | goto transport_err; |
3578 | } | 3555 | } |
3579 | if (ret < 0) { | 3556 | if (ret < 0) |
3580 | conn->tx_immediate_queue = 0; | ||
3581 | goto transport_err; | 3557 | goto transport_err; |
3582 | } | ||
3583 | 3558 | ||
3584 | if (iscsit_send_tx_data(cmd, conn, 1) < 0) { | 3559 | if (iscsit_send_tx_data(cmd, conn, 1) < 0) { |
3585 | conn->tx_immediate_queue = 0; | ||
3586 | iscsit_tx_thread_wait_for_tcp(conn); | 3560 | iscsit_tx_thread_wait_for_tcp(conn); |
3587 | goto transport_err; | 3561 | goto transport_err; |
3588 | } | 3562 | } |
@@ -3611,13 +3585,9 @@ get_immediate: | |||
3611 | spin_unlock_bh(&cmd->istate_lock); | 3585 | spin_unlock_bh(&cmd->istate_lock); |
3612 | goto transport_err; | 3586 | goto transport_err; |
3613 | } | 3587 | } |
3614 | goto get_immediate; | 3588 | } |
3615 | } else | ||
3616 | conn->tx_immediate_queue = 0; | ||
3617 | 3589 | ||
3618 | get_response: | 3590 | while ((qr = iscsit_get_cmd_from_response_queue(conn))) { |
3619 | qr = iscsit_get_cmd_from_response_queue(conn); | ||
3620 | if (qr) { | ||
3621 | cmd = qr->cmd; | 3591 | cmd = qr->cmd; |
3622 | state = qr->state; | 3592 | state = qr->state; |
3623 | kmem_cache_free(lio_qr_cache, qr); | 3593 | kmem_cache_free(lio_qr_cache, qr); |
@@ -3681,21 +3651,17 @@ check_rsp_state: | |||
3681 | spin_unlock_bh(&cmd->istate_lock); | 3651 | spin_unlock_bh(&cmd->istate_lock); |
3682 | goto transport_err; | 3652 | goto transport_err; |
3683 | } | 3653 | } |
3684 | if (ret < 0) { | 3654 | if (ret < 0) |
3685 | conn->tx_response_queue = 0; | ||
3686 | goto transport_err; | 3655 | goto transport_err; |
3687 | } | ||
3688 | 3656 | ||
3689 | if (map_sg && !conn->conn_ops->IFMarker) { | 3657 | if (map_sg && !conn->conn_ops->IFMarker) { |
3690 | if (iscsit_fe_sendpage_sg(cmd, conn) < 0) { | 3658 | if (iscsit_fe_sendpage_sg(cmd, conn) < 0) { |
3691 | conn->tx_response_queue = 0; | ||
3692 | iscsit_tx_thread_wait_for_tcp(conn); | 3659 | iscsit_tx_thread_wait_for_tcp(conn); |
3693 | iscsit_unmap_iovec(cmd); | 3660 | iscsit_unmap_iovec(cmd); |
3694 | goto transport_err; | 3661 | goto transport_err; |
3695 | } | 3662 | } |
3696 | } else { | 3663 | } else { |
3697 | if (iscsit_send_tx_data(cmd, conn, use_misc) < 0) { | 3664 | if (iscsit_send_tx_data(cmd, conn, use_misc) < 0) { |
3698 | conn->tx_response_queue = 0; | ||
3699 | iscsit_tx_thread_wait_for_tcp(conn); | 3665 | iscsit_tx_thread_wait_for_tcp(conn); |
3700 | iscsit_unmap_iovec(cmd); | 3666 | iscsit_unmap_iovec(cmd); |
3701 | goto transport_err; | 3667 | goto transport_err; |
@@ -3771,11 +3737,8 @@ check_rsp_state: | |||
3771 | spin_unlock_bh(&cmd->istate_lock); | 3737 | spin_unlock_bh(&cmd->istate_lock); |
3772 | 3738 | ||
3773 | if (atomic_read(&conn->check_immediate_queue)) | 3739 | if (atomic_read(&conn->check_immediate_queue)) |
3774 | goto get_immediate; | 3740 | break; |
3775 | 3741 | } | |
3776 | goto get_response; | ||
3777 | } else | ||
3778 | conn->tx_response_queue = 0; | ||
3779 | } | 3742 | } |
3780 | 3743 | ||
3781 | transport_err: | 3744 | transport_err: |
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h index cf784ccbd52f..8a1d18ae8872 100644 --- a/drivers/target/iscsi/iscsi_target_core.h +++ b/drivers/target/iscsi/iscsi_target_core.h | |||
@@ -500,8 +500,6 @@ struct iscsi_conn { | |||
500 | u8 network_transport; | 500 | u8 network_transport; |
501 | enum iscsi_timer_flags_table nopin_timer_flags; | 501 | enum iscsi_timer_flags_table nopin_timer_flags; |
502 | enum iscsi_timer_flags_table nopin_response_timer_flags; | 502 | enum iscsi_timer_flags_table nopin_response_timer_flags; |
503 | u8 tx_immediate_queue; | ||
504 | u8 tx_response_queue; | ||
505 | /* Used to know what thread encountered a transport failure */ | 503 | /* Used to know what thread encountered a transport failure */ |
506 | u8 which_thread; | 504 | u8 which_thread; |
507 | /* connection id assigned by the Initiator */ | 505 | /* connection id assigned by the Initiator */ |
diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c index 1ab0560b0924..dd11520eb8b4 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.c +++ b/drivers/target/iscsi/iscsi_target_erl0.c | |||
@@ -640,9 +640,12 @@ static int iscsit_dataout_post_crc_passed( | |||
640 | 640 | ||
641 | cmd->write_data_done += payload_length; | 641 | cmd->write_data_done += payload_length; |
642 | 642 | ||
643 | return (cmd->write_data_done == cmd->data_length) ? | 643 | if (cmd->write_data_done == cmd->data_length) |
644 | DATAOUT_SEND_TO_TRANSPORT : (send_r2t) ? | 644 | return DATAOUT_SEND_TO_TRANSPORT; |
645 | DATAOUT_SEND_R2T : DATAOUT_NORMAL; | 645 | else if (send_r2t) |
646 | return DATAOUT_SEND_R2T; | ||
647 | else | ||
648 | return DATAOUT_NORMAL; | ||
646 | } | 649 | } |
647 | 650 | ||
648 | static int iscsit_dataout_post_crc_failed( | 651 | static int iscsit_dataout_post_crc_failed( |