This is a note to let you know that I've just added the patch titled iser-target: Fix flush + disconnect completion handling to the 3.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: iser-target-fix-flush-disconnect-completion-handling.patch and it can be found in the queue-3.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From nab@xxxxxxxxxxxxxxx Tue Feb 3 15:08:10 2015 From: "Nicholas A. Bellinger" <nab@xxxxxxxxxxxxxxx> Date: Fri, 30 Jan 2015 22:17:26 +0000 Subject: iser-target: Fix flush + disconnect completion handling To: target-devel <target-devel@xxxxxxxxxxxxxxx> Cc: Greg-KH <gregkh@xxxxxxxxxxxxxxxxxxx>, stable <stable@xxxxxxxxxxxxxxx>, Sagi Grimberg <sagig@xxxxxxxxxxxx> Message-ID: <1422656251-29468-8-git-send-email-nab@xxxxxxxxxxxxxxx> From: Sagi Grimberg <sagig@xxxxxxxxxxxx> commit 128e9cc84566a84146baea2335b3824288eed817 upstream. ISER_CONN_UP state is not sufficient to know if we should wait for completion of flush errors and disconnected_handler event. Instead, split it to 2 states: - ISER_CONN_UP: Got to CM connected phase, This state indicates that we need to wait for a CM disconnect event before going to teardown. - ISER_CONN_FULL_FEATURE: Got to full feature phase after we posted login response, This state indicates that we posted recv buffers and we need to wait for flush completions before going to teardown. Also avoid deffering disconnected handler to a work, and handle it within disconnected handler. More work here is needed to handle DEVICE_REMOVAL event correctly (cleanup all resources). Squashed: iser-target: Don't deffer disconnected handler to a work Signed-off-by: Sagi Grimberg <sagig@xxxxxxxxxxxx> Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/infiniband/ulp/isert/ib_isert.c | 50 ++++++++++++++++++-------------- drivers/infiniband/ulp/isert/ib_isert.h | 2 - 2 files changed, 30 insertions(+), 22 deletions(-) --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -544,6 +544,9 @@ isert_connected_handler(struct rdma_cm_i { struct isert_conn *isert_conn = cma_id->context; + pr_info("conn %p\n", isert_conn); + + isert_conn->state = ISER_CONN_UP; kref_get(&isert_conn->conn_kref); } @@ -570,8 +573,9 @@ isert_put_conn(struct isert_conn *isert_ * @isert_conn: isert connection struct * * Notes: - * In case the connection state is UP, move state + * In case the connection state is FULL_FEATURE, move state * to TEMINATING and start teardown sequence (rdma_disconnect). + * In case the connection state is UP, complete flush as well. * * This routine must be called with conn_mutex held. Thus it is * safe to call multiple times. @@ -581,32 +585,31 @@ isert_conn_terminate(struct isert_conn * { int err; - if (isert_conn->state == ISER_CONN_UP) { - isert_conn->state = ISER_CONN_TERMINATING; + switch (isert_conn->state) { + case ISER_CONN_TERMINATING: + break; + case ISER_CONN_UP: + /* + * No flush completions will occur as we didn't + * get to ISER_CONN_FULL_FEATURE yet, complete + * to allow teardown progress. + */ + complete(&isert_conn->conn_wait_comp_err); + case ISER_CONN_FULL_FEATURE: /* FALLTHRU */ pr_info("Terminating conn %p state %d\n", isert_conn, isert_conn->state); + isert_conn->state = ISER_CONN_TERMINATING; err = rdma_disconnect(isert_conn->conn_cm_id); if (err) pr_warn("Failed rdma_disconnect isert_conn %p\n", isert_conn); + break; + default: + pr_warn("conn %p teminating in state %d\n", + isert_conn, isert_conn->state); } } -static void -isert_disconnect_work(struct work_struct *work) -{ - struct isert_conn *isert_conn = container_of(work, - struct isert_conn, conn_logout_work); - - pr_debug("isert_disconnect_work(): >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); - mutex_lock(&isert_conn->conn_mutex); - isert_conn_terminate(isert_conn); - mutex_unlock(&isert_conn->conn_mutex); - - pr_info("conn %p completing conn_wait\n", isert_conn); - complete(&isert_conn->conn_wait); -} - static int isert_disconnected_handler(struct rdma_cm_id *cma_id) { @@ -621,8 +624,12 @@ isert_disconnected_handler(struct rdma_c isert_conn = (struct isert_conn *)cma_id->context; - INIT_WORK(&isert_conn->conn_logout_work, isert_disconnect_work); - schedule_work(&isert_conn->conn_logout_work); + mutex_lock(&isert_conn->conn_mutex); + isert_conn_terminate(isert_conn); + mutex_unlock(&isert_conn->conn_mutex); + + pr_info("conn %p completing conn_wait\n", isert_conn); + complete(&isert_conn->conn_wait); return 0; } @@ -865,7 +872,8 @@ isert_put_login_tx(struct iscsi_conn *co if (ret) return ret; - isert_conn->state = ISER_CONN_UP; + /* Now we are in FULL_FEATURE phase */ + isert_conn->state = ISER_CONN_FULL_FEATURE; goto post_send; } --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h @@ -21,6 +21,7 @@ enum iser_ib_op_code { enum iser_conn_state { ISER_CONN_INIT, ISER_CONN_UP, + ISER_CONN_FULL_FEATURE, ISER_CONN_TERMINATING, ISER_CONN_DOWN, }; @@ -100,7 +101,6 @@ struct isert_conn { struct ib_mr *conn_mr; struct ib_qp *conn_qp; struct isert_device *conn_device; - struct work_struct conn_logout_work; struct mutex conn_mutex; struct completion conn_wait; struct completion conn_wait_comp_err; Patches currently in stable-queue which might be from nab@xxxxxxxxxxxxxxx are queue-3.10/iser-target-fix-connected_handler-teardown-flow-race.patch queue-3.10/iscsi-iser-target-initiate-termination-only-once.patch queue-3.10/ib_isert-add-max_send_sge-2-minimum-for-control-pdu-responses.patch queue-3.10/iser-target-fix-implicit-termination-of-connections.patch queue-3.10/iser-target-parallelize-cm-connection-establishment.patch queue-3.10/vhost-scsi-take-configfs-group-dependency-during-vhost_scsi_set_endpoint.patch queue-3.10/ib-isert-adjust-cq-size-to-hw-limits.patch queue-3.10/iser-target-handle-addr_change-event-for-listener-cm_id.patch queue-3.10/vhost-scsi-add-missing-virtio-scsi-tcm-attribute-conversion.patch queue-3.10/target-drop-arbitrary-maximum-i-o-size-limit.patch queue-3.10/tcm_loop-fix-wrong-i_t-nexus-association.patch queue-3.10/iser-target-fix-flush-disconnect-completion-handling.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html