diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-10-09 04:48:14 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-10-23 23:20:56 -0400 |
commit | d270190a75e5b859c6d8eed8d4095fbb45f78264 (patch) | |
tree | 61f3a7a031433a7a31d5d38f7662f445d3441fa3 /drivers/target | |
parent | d14921d6ad192868184686b3af5bb99cf3380510 (diff) |
iscsi-target: Remove SCF_SE_LUN_CMD flag abuses
This patch removes a number of SCF_SE_LUN_CMD flag abuses within iscsi-target
code to determine when iscsit_release_cmd() or transport_generic_free_cmd()
should be called while releasing an individual iscsi_cmd descriptor.
In the place of SCF_SE_LUN_CMD checks, this patch converts existing code to
use a new iscsit_free_cmd() that inspects iscsi_cmd->iscsi_opcode types to
determine which of the above functions should be invoked. It also removes the
now unnecessary special case checking in iscsit_release_commands_from_conn().
(hch: Use iscsit_free_cmd instead of open-coded alternative)
Reported-by: Christoph Hellwig <hch@lst.de>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 31 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_erl2.c | 35 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_util.c | 17 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_util.h | 1 |
4 files changed, 28 insertions, 56 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index e4b9ba296dcf..d86e18dc163a 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -3538,16 +3538,8 @@ get_immediate: | |||
3538 | spin_lock_bh(&conn->cmd_lock); | 3538 | spin_lock_bh(&conn->cmd_lock); |
3539 | list_del(&cmd->i_list); | 3539 | list_del(&cmd->i_list); |
3540 | spin_unlock_bh(&conn->cmd_lock); | 3540 | spin_unlock_bh(&conn->cmd_lock); |
3541 | /* | 3541 | |
3542 | * Determine if a struct se_cmd is assoicated with | 3542 | iscsit_free_cmd(cmd); |
3543 | * this struct iscsi_cmd. | ||
3544 | */ | ||
3545 | if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) && | ||
3546 | !(cmd->tmr_req)) | ||
3547 | iscsit_release_cmd(cmd); | ||
3548 | else | ||
3549 | transport_generic_free_cmd(&cmd->se_cmd, | ||
3550 | 1); | ||
3551 | goto get_immediate; | 3543 | goto get_immediate; |
3552 | case ISTATE_SEND_NOPIN_WANT_RESPONSE: | 3544 | case ISTATE_SEND_NOPIN_WANT_RESPONSE: |
3553 | spin_unlock_bh(&cmd->istate_lock); | 3545 | spin_unlock_bh(&cmd->istate_lock); |
@@ -3947,30 +3939,13 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) | |||
3947 | */ | 3939 | */ |
3948 | spin_lock_bh(&conn->cmd_lock); | 3940 | spin_lock_bh(&conn->cmd_lock); |
3949 | list_for_each_entry_safe(cmd, cmd_tmp, &conn->conn_cmd_list, i_list) { | 3941 | list_for_each_entry_safe(cmd, cmd_tmp, &conn->conn_cmd_list, i_list) { |
3950 | if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)) { | ||
3951 | |||
3952 | list_del(&cmd->i_list); | ||
3953 | spin_unlock_bh(&conn->cmd_lock); | ||
3954 | iscsit_increment_maxcmdsn(cmd, sess); | ||
3955 | /* | ||
3956 | * Special cases for active iSCSI TMR, and | ||
3957 | * transport_lookup_cmd_lun() failing from | ||
3958 | * iscsit_get_lun_for_cmd() in iscsit_handle_scsi_cmd(). | ||
3959 | */ | ||
3960 | if (cmd->tmr_req) | ||
3961 | transport_generic_free_cmd(&cmd->se_cmd, 1); | ||
3962 | else | ||
3963 | iscsit_release_cmd(cmd); | ||
3964 | 3942 | ||
3965 | spin_lock_bh(&conn->cmd_lock); | ||
3966 | continue; | ||
3967 | } | ||
3968 | list_del(&cmd->i_list); | 3943 | list_del(&cmd->i_list); |
3969 | spin_unlock_bh(&conn->cmd_lock); | 3944 | spin_unlock_bh(&conn->cmd_lock); |
3970 | 3945 | ||
3971 | iscsit_increment_maxcmdsn(cmd, sess); | 3946 | iscsit_increment_maxcmdsn(cmd, sess); |
3972 | 3947 | ||
3973 | transport_generic_free_cmd(&cmd->se_cmd, 1); | 3948 | iscsit_free_cmd(cmd); |
3974 | 3949 | ||
3975 | spin_lock_bh(&conn->cmd_lock); | 3950 | spin_lock_bh(&conn->cmd_lock); |
3976 | } | 3951 | } |
diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c index c3803b2fdd65..0b8404c30125 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.c +++ b/drivers/target/iscsi/iscsi_target_erl2.c | |||
@@ -143,10 +143,7 @@ void iscsit_free_connection_recovery_entires(struct iscsi_session *sess) | |||
143 | list_del(&cmd->i_list); | 143 | list_del(&cmd->i_list); |
144 | cmd->conn = NULL; | 144 | cmd->conn = NULL; |
145 | spin_unlock(&cr->conn_recovery_cmd_lock); | 145 | spin_unlock(&cr->conn_recovery_cmd_lock); |
146 | if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)) | 146 | iscsit_free_cmd(cmd); |
147 | iscsit_release_cmd(cmd); | ||
148 | else | ||
149 | transport_generic_free_cmd(&cmd->se_cmd, 1); | ||
150 | spin_lock(&cr->conn_recovery_cmd_lock); | 147 | spin_lock(&cr->conn_recovery_cmd_lock); |
151 | } | 148 | } |
152 | spin_unlock(&cr->conn_recovery_cmd_lock); | 149 | spin_unlock(&cr->conn_recovery_cmd_lock); |
@@ -168,10 +165,7 @@ void iscsit_free_connection_recovery_entires(struct iscsi_session *sess) | |||
168 | list_del(&cmd->i_list); | 165 | list_del(&cmd->i_list); |
169 | cmd->conn = NULL; | 166 | cmd->conn = NULL; |
170 | spin_unlock(&cr->conn_recovery_cmd_lock); | 167 | spin_unlock(&cr->conn_recovery_cmd_lock); |
171 | if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)) | 168 | iscsit_free_cmd(cmd); |
172 | iscsit_release_cmd(cmd); | ||
173 | else | ||
174 | transport_generic_free_cmd(&cmd->se_cmd, 1); | ||
175 | spin_lock(&cr->conn_recovery_cmd_lock); | 169 | spin_lock(&cr->conn_recovery_cmd_lock); |
176 | } | 170 | } |
177 | spin_unlock(&cr->conn_recovery_cmd_lock); | 171 | spin_unlock(&cr->conn_recovery_cmd_lock); |
@@ -256,10 +250,7 @@ void iscsit_discard_cr_cmds_by_expstatsn( | |||
256 | iscsit_remove_cmd_from_connection_recovery(cmd, sess); | 250 | iscsit_remove_cmd_from_connection_recovery(cmd, sess); |
257 | 251 | ||
258 | spin_unlock(&cr->conn_recovery_cmd_lock); | 252 | spin_unlock(&cr->conn_recovery_cmd_lock); |
259 | if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)) | 253 | iscsit_free_cmd(cmd); |
260 | iscsit_release_cmd(cmd); | ||
261 | else | ||
262 | transport_generic_free_cmd(&cmd->se_cmd, 1); | ||
263 | spin_lock(&cr->conn_recovery_cmd_lock); | 254 | spin_lock(&cr->conn_recovery_cmd_lock); |
264 | } | 255 | } |
265 | spin_unlock(&cr->conn_recovery_cmd_lock); | 256 | spin_unlock(&cr->conn_recovery_cmd_lock); |
@@ -313,10 +304,7 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn) | |||
313 | list_del(&cmd->i_list); | 304 | list_del(&cmd->i_list); |
314 | 305 | ||
315 | spin_unlock_bh(&conn->cmd_lock); | 306 | spin_unlock_bh(&conn->cmd_lock); |
316 | if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)) | 307 | iscsit_free_cmd(cmd); |
317 | iscsit_release_cmd(cmd); | ||
318 | else | ||
319 | transport_generic_free_cmd(&cmd->se_cmd, 1); | ||
320 | spin_lock_bh(&conn->cmd_lock); | 308 | spin_lock_bh(&conn->cmd_lock); |
321 | } | 309 | } |
322 | spin_unlock_bh(&conn->cmd_lock); | 310 | spin_unlock_bh(&conn->cmd_lock); |
@@ -369,11 +357,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn) | |||
369 | 357 | ||
370 | list_del(&cmd->i_list); | 358 | list_del(&cmd->i_list); |
371 | spin_unlock_bh(&conn->cmd_lock); | 359 | spin_unlock_bh(&conn->cmd_lock); |
372 | 360 | iscsit_free_cmd(cmd); | |
373 | if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)) | ||
374 | iscsit_release_cmd(cmd); | ||
375 | else | ||
376 | transport_generic_free_cmd(&cmd->se_cmd, 1); | ||
377 | spin_lock_bh(&conn->cmd_lock); | 361 | spin_lock_bh(&conn->cmd_lock); |
378 | continue; | 362 | continue; |
379 | } | 363 | } |
@@ -393,11 +377,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn) | |||
393 | (cmd->cmd_sn >= conn->sess->exp_cmd_sn)) { | 377 | (cmd->cmd_sn >= conn->sess->exp_cmd_sn)) { |
394 | list_del(&cmd->i_list); | 378 | list_del(&cmd->i_list); |
395 | spin_unlock_bh(&conn->cmd_lock); | 379 | spin_unlock_bh(&conn->cmd_lock); |
396 | 380 | iscsit_free_cmd(cmd); | |
397 | if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)) | ||
398 | iscsit_release_cmd(cmd); | ||
399 | else | ||
400 | transport_generic_free_cmd(&cmd->se_cmd, 1); | ||
401 | spin_lock_bh(&conn->cmd_lock); | 381 | spin_lock_bh(&conn->cmd_lock); |
402 | continue; | 382 | continue; |
403 | } | 383 | } |
@@ -422,8 +402,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn) | |||
422 | 402 | ||
423 | iscsit_free_all_datain_reqs(cmd); | 403 | iscsit_free_all_datain_reqs(cmd); |
424 | 404 | ||
425 | if (cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) | 405 | transport_wait_for_tasks(&cmd->se_cmd); |
426 | transport_wait_for_tasks(&cmd->se_cmd); | ||
427 | /* | 406 | /* |
428 | * Add the struct iscsi_cmd to the connection recovery cmd list | 407 | * Add the struct iscsi_cmd to the connection recovery cmd list |
429 | */ | 408 | */ |
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index c4be6223b9cc..02348f727bd4 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c | |||
@@ -840,6 +840,23 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd) | |||
840 | kmem_cache_free(lio_cmd_cache, cmd); | 840 | kmem_cache_free(lio_cmd_cache, cmd); |
841 | } | 841 | } |
842 | 842 | ||
843 | void iscsit_free_cmd(struct iscsi_cmd *cmd) | ||
844 | { | ||
845 | /* | ||
846 | * Determine if a struct se_cmd is assoicated with | ||
847 | * this struct iscsi_cmd. | ||
848 | */ | ||
849 | switch (cmd->iscsi_opcode) { | ||
850 | case ISCSI_OP_SCSI_CMD: | ||
851 | case ISCSI_OP_SCSI_TMFUNC: | ||
852 | transport_generic_free_cmd(&cmd->se_cmd, 1); | ||
853 | break; | ||
854 | default: | ||
855 | iscsit_release_cmd(cmd); | ||
856 | break; | ||
857 | } | ||
858 | } | ||
859 | |||
843 | int iscsit_check_session_usage_count(struct iscsi_session *sess) | 860 | int iscsit_check_session_usage_count(struct iscsi_session *sess) |
844 | { | 861 | { |
845 | spin_lock_bh(&sess->session_usage_lock); | 862 | spin_lock_bh(&sess->session_usage_lock); |
diff --git a/drivers/target/iscsi/iscsi_target_util.h b/drivers/target/iscsi/iscsi_target_util.h index 2cd49d607bda..835bf7de0281 100644 --- a/drivers/target/iscsi/iscsi_target_util.h +++ b/drivers/target/iscsi/iscsi_target_util.h | |||
@@ -30,6 +30,7 @@ extern struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_c | |||
30 | extern void iscsit_remove_cmd_from_tx_queues(struct iscsi_cmd *, struct iscsi_conn *); | 30 | extern void iscsit_remove_cmd_from_tx_queues(struct iscsi_cmd *, struct iscsi_conn *); |
31 | extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *); | 31 | extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *); |
32 | extern void iscsit_release_cmd(struct iscsi_cmd *); | 32 | extern void iscsit_release_cmd(struct iscsi_cmd *); |
33 | extern void iscsit_free_cmd(struct iscsi_cmd *); | ||
33 | extern int iscsit_check_session_usage_count(struct iscsi_session *); | 34 | extern int iscsit_check_session_usage_count(struct iscsi_session *); |
34 | extern void iscsit_dec_session_usage_count(struct iscsi_session *); | 35 | extern void iscsit_dec_session_usage_count(struct iscsi_session *); |
35 | extern void iscsit_inc_session_usage_count(struct iscsi_session *); | 36 | extern void iscsit_inc_session_usage_count(struct iscsi_session *); |