Skip to content

Commit cc79da3

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: target: iscsit: Fix TAS handling during conn cleanup
Fix a bug added in commit f361993 ("scsi: target: iscsi: Fix cmd abort fabric stop race"). If CMD_T_TAS is set on the se_cmd we must call iscsit_free_cmd() to do the last put on the cmd and free it, because the connection is down and we will not up sending the response and doing the put from the normal I/O path. Add a check for CMD_T_TAS in iscsit_release_commands_from_conn() so we now detect this case and run iscsit_free_cmd(). Fixes: f361993 ("scsi: target: iscsi: Fix cmd abort fabric stop race") Signed-off-by: Mike Christie <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20230319015620.96006-9-michael.christie@oracle.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 673db05 commit cc79da3

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

drivers/target/iscsi/iscsi_target.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4220,21 +4220,23 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn)
42204220
list_for_each_entry_safe(cmd, cmd_tmp, &tmp_list, i_conn_node) {
42214221
struct se_cmd *se_cmd = &cmd->se_cmd;
42224222

4223-
if (se_cmd->se_tfo != NULL) {
4224-
spin_lock_irq(&se_cmd->t_state_lock);
4225-
if (se_cmd->transport_state & CMD_T_ABORTED) {
4223+
if (!se_cmd->se_tfo)
4224+
continue;
4225+
4226+
spin_lock_irq(&se_cmd->t_state_lock);
4227+
if (se_cmd->transport_state & CMD_T_ABORTED) {
4228+
if (!(se_cmd->transport_state & CMD_T_TAS))
42264229
/*
42274230
* LIO's abort path owns the cleanup for this,
42284231
* so put it back on the list and let
42294232
* aborted_task handle it.
42304233
*/
42314234
list_move_tail(&cmd->i_conn_node,
42324235
&conn->conn_cmd_list);
4233-
} else {
4234-
se_cmd->transport_state |= CMD_T_FABRIC_STOP;
4235-
}
4236-
spin_unlock_irq(&se_cmd->t_state_lock);
4236+
} else {
4237+
se_cmd->transport_state |= CMD_T_FABRIC_STOP;
42374238
}
4239+
spin_unlock_irq(&se_cmd->t_state_lock);
42384240
}
42394241
spin_unlock_bh(&conn->cmd_lock);
42404242

0 commit comments

Comments
 (0)