@@ -4230,6 +4230,15 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn)
*/
list_move_tail(&cmd->i_conn_node,
&conn->conn_cmd_list);
+ } else if (conn->sess->sess_ops->RDMAExtensions &&
+ (se_cmd->transport_state & CMD_T_COMPLETE) &&
+ !iscsit_cmd_failed(cmd)) {
+ /*
+ * isert is still handling these cmds so wait in
+ * target_wait_for_cmds.
+ */
+ list_move_tail(&cmd->i_conn_node,
+ &conn->conn_cmd_list);
} else {
se_cmd->transport_state |= CMD_T_FABRIC_STOP;
}
@@ -4242,19 +4251,27 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn)
list_del_init(&cmd->i_conn_node);
iscsit_increment_maxcmdsn(cmd, sess);
+ /*
+ * Free cmds that:
+ * 1. we have not got acks for.
+ * 2. are (or will be when the backend completes them) stuck
+ * on the response/immediate queue (failed cmds, TMRs, iscsi
+ * reqs).
+ * 3. completed ok on the backend, but hit the CMD_T_FABRIC_STOP
+ * or CMD_T_STOP checks.
+ */
iscsit_free_cmd(cmd, true);
-
}
/*
- * Wait on commands that were cleaned up via the aborted_task path.
- * LLDs that implement iscsit_wait_conn will already have waited for
- * commands.
+ * We need to wait:
+ * 1. for commands that are being cleaned up via the aborted_task path.
+ * 2. for isert we need to wait for iscsit_queue_status calls
+ * that posted a response after the ib_drain_qp call returned but
+ * have not yet called isert_send_done.
*/
- if (!conn->conn_transport->iscsit_wait_conn) {
- target_stop_cmd_counter(conn->cmd_cnt);
- target_wait_for_cmds(conn->cmd_cnt);
- }
+ target_stop_cmd_counter(conn->cmd_cnt);
+ target_wait_for_cmds(conn->cmd_cnt);
}
static void iscsit_stop_timers_for_cmds(
@@ -753,7 +753,13 @@ void iscsit_free_cmd(struct iscsit_cmd *cmd, bool shutdown)
if (se_cmd) {
rc = transport_generic_free_cmd(se_cmd, shutdown);
if (!rc && shutdown && se_cmd->se_sess) {
- __iscsit_free_cmd(cmd, shutdown);
+ struct iscsit_conn *conn = cmd->conn;
+ /*
+ * The command wasn't aborted via ABORT_TASK but didn't
+ * reach the driver so allow it to cleanup resources
+ * now.
+ */
+ conn->conn_transport->iscsit_aborted_task(conn, cmd);
target_put_sess_cmd(se_cmd);
}
} else {
Currently, isert does target_wait_for_cmds before iscsit calls iscsit_release_commands_from_conn because we can race where LIO core calls into isert when it wants to cleanup the connection. The wait prevents isert from freeing the connection while trying to post responses but it can result in a hang during connection closure if there are se_cmds on the iscsit response queue, because when isert calls target_wait_for_cmds the tx thread is stopped or we are running the wait from it. For example this is hit when a command times out on the initiator, the initiator sends an ABORT, then the connection is closed. When the command completes it will be placed on the response queue if TAS is set, and the ABORT response will be placed on the response queue. So at the very least we will hang waiting on the last put on the ABORT's se_cmd which will never happen. This patch adds support to iscsit so it can now handle isert and iscsit running commands during connection closure so we can have a common place for the code. Signed-off-by: Mike Christie <michael.christie@oracle.com> --- drivers/target/iscsi/iscsi_target.c | 33 ++++++++++++++++++------ drivers/target/iscsi/iscsi_target_util.c | 8 +++++- 2 files changed, 32 insertions(+), 9 deletions(-)