aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2011-10-09 04:00:58 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-10-23 23:20:54 -0400
commitd14921d6ad192868184686b3af5bb99cf3380510 (patch)
treea6ffc3a5a695d6dc50ca1885cf41f2c372607fca /drivers/target
parentdd503a5fcc0dfb8b5fd887bd967b6f431176864b (diff)
target: Convert ->transport_wait_for_tasks usage to transport_generic_free_cmd
This patch converts se_cmd->transport_wait_for_tasks(se_cmd, 1) usage to use transport_generic_free_cmd() directly in target-core and iscsi-target fabric usage. The includes: *) Removal of the optional transport_generic_free_cmd() call from within transport_generic_wait_for_tasks() *) Usage of existing SCF_SUPPORTED_SAM_OPCODE to determine when transport_generic_wait_for_tasks() processing may occur instead of checking se_cmd->transport_wait_for_tasks() *) Move transport_generic_wait_for_tasks() call ahead of core_dec_lacl_count() and transport_lun_remove_cmd() in transport_generic_free_cmd() to follow existing logic for iscsi-target w/ se_cmd->transport_wait_for_tasks(se_cmd, 1) *) Removal of se_cmd->transport_wait_for_tasks() function pointer *) Rename transport_generic_wait_for_tasks() -> transport_wait_for_tasks(), and add docbook comment. *) Add EXPORT_SYMBOL for transport_wait_for_tasks() For the case in iscsi_target_erl2.c:iscsit_prepare_cmds_for_realligance() where se_cmd->transport_wait_for_tasks(se_cmd, 0) is called, this patch adds a direct call to transport_wait_for_tasks(). (hch: Fix transport_generic_free_cmd() usage in iscsit_release_commands_from_conn) (nab: Add patch: Ensure that TMRs hit wait_for_tasks logic during release) 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.c12
-rw-r--r--drivers/target/iscsi/iscsi_target_erl2.c41
-rw-r--r--drivers/target/target_core_transport.c82
3 files changed, 50 insertions, 85 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 354a8339a3f9..e4b9ba296dcf 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -3940,7 +3940,6 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
3940{ 3940{
3941 struct iscsi_cmd *cmd = NULL, *cmd_tmp = NULL; 3941 struct iscsi_cmd *cmd = NULL, *cmd_tmp = NULL;
3942 struct iscsi_session *sess = conn->sess; 3942 struct iscsi_session *sess = conn->sess;
3943 struct se_cmd *se_cmd;
3944 /* 3943 /*
3945 * We expect this function to only ever be called from either RX or TX 3944 * We expect this function to only ever be called from either RX or TX
3946 * thread context via iscsit_close_connection() once the other context 3945 * thread context via iscsit_close_connection() once the other context
@@ -3953,16 +3952,13 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
3953 list_del(&cmd->i_list); 3952 list_del(&cmd->i_list);
3954 spin_unlock_bh(&conn->cmd_lock); 3953 spin_unlock_bh(&conn->cmd_lock);
3955 iscsit_increment_maxcmdsn(cmd, sess); 3954 iscsit_increment_maxcmdsn(cmd, sess);
3956 se_cmd = &cmd->se_cmd;
3957 /* 3955 /*
3958 * Special cases for active iSCSI TMR, and 3956 * Special cases for active iSCSI TMR, and
3959 * transport_lookup_cmd_lun() failing from 3957 * transport_lookup_cmd_lun() failing from
3960 * iscsit_get_lun_for_cmd() in iscsit_handle_scsi_cmd(). 3958 * iscsit_get_lun_for_cmd() in iscsit_handle_scsi_cmd().
3961 */ 3959 */
3962 if (cmd->tmr_req && se_cmd->transport_wait_for_tasks) 3960 if (cmd->tmr_req)
3963 se_cmd->transport_wait_for_tasks(se_cmd, 1); 3961 transport_generic_free_cmd(&cmd->se_cmd, 1);
3964 else if (cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)
3965 transport_release_cmd(se_cmd);
3966 else 3962 else
3967 iscsit_release_cmd(cmd); 3963 iscsit_release_cmd(cmd);
3968 3964
@@ -3973,10 +3969,8 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
3973 spin_unlock_bh(&conn->cmd_lock); 3969 spin_unlock_bh(&conn->cmd_lock);
3974 3970
3975 iscsit_increment_maxcmdsn(cmd, sess); 3971 iscsit_increment_maxcmdsn(cmd, sess);
3976 se_cmd = &cmd->se_cmd;
3977 3972
3978 if (se_cmd->transport_wait_for_tasks) 3973 transport_generic_free_cmd(&cmd->se_cmd, 1);
3979 se_cmd->transport_wait_for_tasks(se_cmd, 1);
3980 3974
3981 spin_lock_bh(&conn->cmd_lock); 3975 spin_lock_bh(&conn->cmd_lock);
3982 } 3976 }
diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c
index 000356baf0b5..c3803b2fdd65 100644
--- a/drivers/target/iscsi/iscsi_target_erl2.c
+++ b/drivers/target/iscsi/iscsi_target_erl2.c
@@ -143,12 +143,10 @@ 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 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD))
147 !(cmd->se_cmd.transport_wait_for_tasks))
148 iscsit_release_cmd(cmd); 147 iscsit_release_cmd(cmd);
149 else 148 else
150 cmd->se_cmd.transport_wait_for_tasks( 149 transport_generic_free_cmd(&cmd->se_cmd, 1);
151 &cmd->se_cmd, 1);
152 spin_lock(&cr->conn_recovery_cmd_lock); 150 spin_lock(&cr->conn_recovery_cmd_lock);
153 } 151 }
154 spin_unlock(&cr->conn_recovery_cmd_lock); 152 spin_unlock(&cr->conn_recovery_cmd_lock);
@@ -170,12 +168,10 @@ void iscsit_free_connection_recovery_entires(struct iscsi_session *sess)
170 list_del(&cmd->i_list); 168 list_del(&cmd->i_list);
171 cmd->conn = NULL; 169 cmd->conn = NULL;
172 spin_unlock(&cr->conn_recovery_cmd_lock); 170 spin_unlock(&cr->conn_recovery_cmd_lock);
173 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) || 171 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD))
174 !(cmd->se_cmd.transport_wait_for_tasks))
175 iscsit_release_cmd(cmd); 172 iscsit_release_cmd(cmd);
176 else 173 else
177 cmd->se_cmd.transport_wait_for_tasks( 174 transport_generic_free_cmd(&cmd->se_cmd, 1);
178 &cmd->se_cmd, 1);
179 spin_lock(&cr->conn_recovery_cmd_lock); 175 spin_lock(&cr->conn_recovery_cmd_lock);
180 } 176 }
181 spin_unlock(&cr->conn_recovery_cmd_lock); 177 spin_unlock(&cr->conn_recovery_cmd_lock);
@@ -260,12 +256,10 @@ void iscsit_discard_cr_cmds_by_expstatsn(
260 iscsit_remove_cmd_from_connection_recovery(cmd, sess); 256 iscsit_remove_cmd_from_connection_recovery(cmd, sess);
261 257
262 spin_unlock(&cr->conn_recovery_cmd_lock); 258 spin_unlock(&cr->conn_recovery_cmd_lock);
263 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) || 259 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD))
264 !(cmd->se_cmd.transport_wait_for_tasks))
265 iscsit_release_cmd(cmd); 260 iscsit_release_cmd(cmd);
266 else 261 else
267 cmd->se_cmd.transport_wait_for_tasks( 262 transport_generic_free_cmd(&cmd->se_cmd, 1);
268 &cmd->se_cmd, 1);
269 spin_lock(&cr->conn_recovery_cmd_lock); 263 spin_lock(&cr->conn_recovery_cmd_lock);
270 } 264 }
271 spin_unlock(&cr->conn_recovery_cmd_lock); 265 spin_unlock(&cr->conn_recovery_cmd_lock);
@@ -319,12 +313,10 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn)
319 list_del(&cmd->i_list); 313 list_del(&cmd->i_list);
320 314
321 spin_unlock_bh(&conn->cmd_lock); 315 spin_unlock_bh(&conn->cmd_lock);
322 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) || 316 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD))
323 !(cmd->se_cmd.transport_wait_for_tasks))
324 iscsit_release_cmd(cmd); 317 iscsit_release_cmd(cmd);
325 else 318 else
326 cmd->se_cmd.transport_wait_for_tasks( 319 transport_generic_free_cmd(&cmd->se_cmd, 1);
327 &cmd->se_cmd, 1);
328 spin_lock_bh(&conn->cmd_lock); 320 spin_lock_bh(&conn->cmd_lock);
329 } 321 }
330 spin_unlock_bh(&conn->cmd_lock); 322 spin_unlock_bh(&conn->cmd_lock);
@@ -378,12 +370,10 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
378 list_del(&cmd->i_list); 370 list_del(&cmd->i_list);
379 spin_unlock_bh(&conn->cmd_lock); 371 spin_unlock_bh(&conn->cmd_lock);
380 372
381 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) || 373 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD))
382 !(cmd->se_cmd.transport_wait_for_tasks))
383 iscsit_release_cmd(cmd); 374 iscsit_release_cmd(cmd);
384 else 375 else
385 cmd->se_cmd.transport_wait_for_tasks( 376 transport_generic_free_cmd(&cmd->se_cmd, 1);
386 &cmd->se_cmd, 1);
387 spin_lock_bh(&conn->cmd_lock); 377 spin_lock_bh(&conn->cmd_lock);
388 continue; 378 continue;
389 } 379 }
@@ -404,12 +394,10 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
404 list_del(&cmd->i_list); 394 list_del(&cmd->i_list);
405 spin_unlock_bh(&conn->cmd_lock); 395 spin_unlock_bh(&conn->cmd_lock);
406 396
407 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) || 397 if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD))
408 !(cmd->se_cmd.transport_wait_for_tasks))
409 iscsit_release_cmd(cmd); 398 iscsit_release_cmd(cmd);
410 else 399 else
411 cmd->se_cmd.transport_wait_for_tasks( 400 transport_generic_free_cmd(&cmd->se_cmd, 1);
412 &cmd->se_cmd, 1);
413 spin_lock_bh(&conn->cmd_lock); 401 spin_lock_bh(&conn->cmd_lock);
414 continue; 402 continue;
415 } 403 }
@@ -434,9 +422,8 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
434 422
435 iscsit_free_all_datain_reqs(cmd); 423 iscsit_free_all_datain_reqs(cmd);
436 424
437 if ((cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) && 425 if (cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)
438 cmd->se_cmd.transport_wait_for_tasks) 426 transport_wait_for_tasks(&cmd->se_cmd);
439 cmd->se_cmd.transport_wait_for_tasks(&cmd->se_cmd, 0);
440 /* 427 /*
441 * Add the struct iscsi_cmd to the connection recovery cmd list 428 * Add the struct iscsi_cmd to the connection recovery cmd list
442 */ 429 */
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index ae1efc7c9ec6..f8de042e532e 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1638,8 +1638,6 @@ static int transport_check_alloc_task_attr(struct se_cmd *cmd)
1638 return 0; 1638 return 0;
1639} 1639}
1640 1640
1641static void transport_generic_wait_for_tasks(struct se_cmd *, int);
1642
1643/* transport_generic_allocate_tasks(): 1641/* transport_generic_allocate_tasks():
1644 * 1642 *
1645 * Called from fabric RX Thread. 1643 * Called from fabric RX Thread.
@@ -1651,12 +1649,6 @@ int transport_generic_allocate_tasks(
1651 int ret; 1649 int ret;
1652 1650
1653 transport_generic_prepare_cdb(cdb); 1651 transport_generic_prepare_cdb(cdb);
1654
1655 /*
1656 * This is needed for early exceptions.
1657 */
1658 cmd->transport_wait_for_tasks = &transport_generic_wait_for_tasks;
1659
1660 /* 1652 /*
1661 * Ensure that the received CDB is less than the max (252 + 8) bytes 1653 * Ensure that the received CDB is less than the max (252 + 8) bytes
1662 * for VARIABLE_LENGTH_CMD 1654 * for VARIABLE_LENGTH_CMD
@@ -1739,7 +1731,7 @@ int transport_handle_cdb_direct(
1739 * Set TRANSPORT_NEW_CMD state and cmd->t_transport_active=1 following 1731 * Set TRANSPORT_NEW_CMD state and cmd->t_transport_active=1 following
1740 * transport_generic_handle_cdb*() -> transport_add_cmd_to_queue() 1732 * transport_generic_handle_cdb*() -> transport_add_cmd_to_queue()
1741 * in existing usage to ensure that outstanding descriptors are handled 1733 * in existing usage to ensure that outstanding descriptors are handled
1742 * correctly during shutdown via transport_generic_wait_for_tasks() 1734 * correctly during shutdown via transport_wait_for_tasks()
1743 * 1735 *
1744 * Also, we don't take cmd->t_state_lock here as we only expect 1736 * Also, we don't take cmd->t_state_lock here as we only expect
1745 * this to be called for initial descriptor submission. 1737 * this to be called for initial descriptor submission.
@@ -1819,11 +1811,6 @@ EXPORT_SYMBOL(transport_generic_handle_data);
1819int transport_generic_handle_tmr( 1811int transport_generic_handle_tmr(
1820 struct se_cmd *cmd) 1812 struct se_cmd *cmd)
1821{ 1813{
1822 /*
1823 * This is needed for early exceptions.
1824 */
1825 cmd->transport_wait_for_tasks = &transport_generic_wait_for_tasks;
1826
1827 transport_add_cmd_to_queue(cmd, TRANSPORT_PROCESS_TMR); 1814 transport_add_cmd_to_queue(cmd, TRANSPORT_PROCESS_TMR);
1828 return 0; 1815 return 0;
1829} 1816}
@@ -2504,8 +2491,6 @@ void transport_new_cmd_failure(struct se_cmd *se_cmd)
2504 spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); 2491 spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
2505} 2492}
2506 2493
2507static void transport_nop_wait_for_tasks(struct se_cmd *, int);
2508
2509static inline u32 transport_get_sectors_6( 2494static inline u32 transport_get_sectors_6(
2510 unsigned char *cdb, 2495 unsigned char *cdb,
2511 struct se_cmd *cmd, 2496 struct se_cmd *cmd,
@@ -2780,7 +2765,6 @@ static int transport_get_sense_data(struct se_cmd *cmd)
2780static int 2765static int
2781transport_handle_reservation_conflict(struct se_cmd *cmd) 2766transport_handle_reservation_conflict(struct se_cmd *cmd)
2782{ 2767{
2783 cmd->transport_wait_for_tasks = &transport_nop_wait_for_tasks;
2784 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; 2768 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
2785 cmd->se_cmd_flags |= SCF_SCSI_RESERVATION_CONFLICT; 2769 cmd->se_cmd_flags |= SCF_SCSI_RESERVATION_CONFLICT;
2786 cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT; 2770 cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT;
@@ -2881,8 +2865,6 @@ static int transport_generic_cmd_sequencer(
2881 * Check for an existing UNIT ATTENTION condition 2865 * Check for an existing UNIT ATTENTION condition
2882 */ 2866 */
2883 if (core_scsi3_ua_check(cmd, cdb) < 0) { 2867 if (core_scsi3_ua_check(cmd, cdb) < 0) {
2884 cmd->transport_wait_for_tasks =
2885 &transport_nop_wait_for_tasks;
2886 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; 2868 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
2887 cmd->scsi_sense_reason = TCM_CHECK_CONDITION_UNIT_ATTENTION; 2869 cmd->scsi_sense_reason = TCM_CHECK_CONDITION_UNIT_ATTENTION;
2888 return -EINVAL; 2870 return -EINVAL;
@@ -2892,7 +2874,6 @@ static int transport_generic_cmd_sequencer(
2892 */ 2874 */
2893 ret = su_dev->t10_alua.alua_state_check(cmd, cdb, &alua_ascq); 2875 ret = su_dev->t10_alua.alua_state_check(cmd, cdb, &alua_ascq);
2894 if (ret != 0) { 2876 if (ret != 0) {
2895 cmd->transport_wait_for_tasks = &transport_nop_wait_for_tasks;
2896 /* 2877 /*
2897 * Set SCSI additional sense code (ASC) to 'LUN Not Accessible'; 2878 * Set SCSI additional sense code (ASC) to 'LUN Not Accessible';
2898 * The ALUA additional sense code qualifier (ASCQ) is determined 2879 * The ALUA additional sense code qualifier (ASCQ) is determined
@@ -3396,7 +3377,6 @@ static int transport_generic_cmd_sequencer(
3396 pr_warn("TARGET_CORE[%s]: Unsupported SCSI Opcode" 3377 pr_warn("TARGET_CORE[%s]: Unsupported SCSI Opcode"
3397 " 0x%02x, sending CHECK_CONDITION.\n", 3378 " 0x%02x, sending CHECK_CONDITION.\n",
3398 cmd->se_tfo->get_fabric_name(), cdb[0]); 3379 cmd->se_tfo->get_fabric_name(), cdb[0]);
3399 cmd->transport_wait_for_tasks = &transport_nop_wait_for_tasks;
3400 goto out_unsupported_cdb; 3380 goto out_unsupported_cdb;
3401 } 3381 }
3402 3382
@@ -4304,17 +4284,20 @@ EXPORT_SYMBOL(transport_release_cmd);
4304 4284
4305void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) 4285void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
4306{ 4286{
4307 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) 4287 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) {
4288 if (wait_for_tasks && cmd->se_tmr_req)
4289 transport_wait_for_tasks(cmd);
4290
4308 transport_release_cmd(cmd); 4291 transport_release_cmd(cmd);
4309 else { 4292 } else {
4293 if (wait_for_tasks)
4294 transport_wait_for_tasks(cmd);
4295
4310 core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd); 4296 core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd);
4311 4297
4312 if (cmd->se_lun) 4298 if (cmd->se_lun)
4313 transport_lun_remove_cmd(cmd); 4299 transport_lun_remove_cmd(cmd);
4314 4300
4315 if (wait_for_tasks && cmd->transport_wait_for_tasks)
4316 cmd->transport_wait_for_tasks(cmd, 0);
4317
4318 transport_free_dev_tasks(cmd); 4301 transport_free_dev_tasks(cmd);
4319 4302
4320 transport_put_cmd(cmd); 4303 transport_put_cmd(cmd);
@@ -4322,13 +4305,6 @@ void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
4322} 4305}
4323EXPORT_SYMBOL(transport_generic_free_cmd); 4306EXPORT_SYMBOL(transport_generic_free_cmd);
4324 4307
4325static void transport_nop_wait_for_tasks(
4326 struct se_cmd *cmd,
4327 int remove_cmd)
4328{
4329 return;
4330}
4331
4332/* transport_lun_wait_for_tasks(): 4308/* transport_lun_wait_for_tasks():
4333 * 4309 *
4334 * Called from ConfigFS context to stop the passed struct se_cmd to allow 4310 * Called from ConfigFS context to stop the passed struct se_cmd to allow
@@ -4498,21 +4474,30 @@ int transport_clear_lun_from_sessions(struct se_lun *lun)
4498 return 0; 4474 return 0;
4499} 4475}
4500 4476
4501/* transport_generic_wait_for_tasks(): 4477/**
4478 * transport_wait_for_tasks - wait for completion to occur
4479 * @cmd: command to wait
4502 * 4480 *
4503 * Called from frontend or passthrough context to wait for storage engine 4481 * Called from frontend fabric context to wait for storage engine
4504 * to pause and/or release frontend generated struct se_cmd. 4482 * to pause and/or release frontend generated struct se_cmd.
4505 */ 4483 */
4506static void transport_generic_wait_for_tasks( 4484void transport_wait_for_tasks(struct se_cmd *cmd)
4507 struct se_cmd *cmd,
4508 int remove_cmd)
4509{ 4485{
4510 unsigned long flags; 4486 unsigned long flags;
4511 4487
4512 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) && !(cmd->se_tmr_req))
4513 return;
4514
4515 spin_lock_irqsave(&cmd->t_state_lock, flags); 4488 spin_lock_irqsave(&cmd->t_state_lock, flags);
4489 if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) && !(cmd->se_tmr_req)) {
4490 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
4491 return;
4492 }
4493 /*
4494 * Only perform a possible wait_for_tasks if SCF_SUPPORTED_SAM_OPCODE
4495 * has been set in transport_set_supported_SAM_opcode().
4496 */
4497 if (!(cmd->se_cmd_flags & SCF_SUPPORTED_SAM_OPCODE) && !cmd->se_tmr_req) {
4498 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
4499 return;
4500 }
4516 /* 4501 /*
4517 * If we are already stopped due to an external event (ie: LUN shutdown) 4502 * If we are already stopped due to an external event (ie: LUN shutdown)
4518 * sleep until the connection can have the passed struct se_cmd back. 4503 * sleep until the connection can have the passed struct se_cmd back.
@@ -4552,8 +4537,10 @@ static void transport_generic_wait_for_tasks(
4552 atomic_set(&cmd->transport_lun_stop, 0); 4537 atomic_set(&cmd->transport_lun_stop, 0);
4553 } 4538 }
4554 if (!atomic_read(&cmd->t_transport_active) || 4539 if (!atomic_read(&cmd->t_transport_active) ||
4555 atomic_read(&cmd->t_transport_aborted)) 4540 atomic_read(&cmd->t_transport_aborted)) {
4556 goto remove; 4541 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
4542 return;
4543 }
4557 4544
4558 atomic_set(&cmd->t_transport_stop, 1); 4545 atomic_set(&cmd->t_transport_stop, 1);
4559 4546
@@ -4576,13 +4563,10 @@ static void transport_generic_wait_for_tasks(
4576 pr_debug("wait_for_tasks: Stopped wait_for_compltion(" 4563 pr_debug("wait_for_tasks: Stopped wait_for_compltion("
4577 "&cmd->t_transport_stop_comp) for ITT: 0x%08x\n", 4564 "&cmd->t_transport_stop_comp) for ITT: 0x%08x\n",
4578 cmd->se_tfo->get_task_tag(cmd)); 4565 cmd->se_tfo->get_task_tag(cmd));
4579remove:
4580 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
4581 if (!remove_cmd)
4582 return;
4583 4566
4584 transport_generic_free_cmd(cmd, 0); 4567 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
4585} 4568}
4569EXPORT_SYMBOL(transport_wait_for_tasks);
4586 4570
4587static int transport_get_sense_codes( 4571static int transport_get_sense_codes(
4588 struct se_cmd *cmd, 4572 struct se_cmd *cmd,