From patchwork Mon Feb 27 03:03:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9592657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 73FEE60574 for ; Mon, 27 Feb 2017 03:05:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6515A27FA8 for ; Mon, 27 Feb 2017 03:05:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59AFF2811E; Mon, 27 Feb 2017 03:05:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC29F2811C for ; Mon, 27 Feb 2017 03:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751297AbdB0DFa (ORCPT ); Sun, 26 Feb 2017 22:05:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35656 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751301AbdB0DF3 (ORCPT ); Sun, 26 Feb 2017 22:05:29 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD2F2C04BD39; Mon, 27 Feb 2017 03:04:04 +0000 (UTC) Received: from rh2.redhat.com (ovpn-120-121.rdu2.redhat.com [10.10.120.121] (may be forged)) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1R342kt007727; Sun, 26 Feb 2017 22:04:04 -0500 From: Mike Christie To: target-devel@vger.kernel.org, nab@linux-iscsi.org Cc: Mike Christie Subject: [PATCH 2/4] iscsi target: make iscsit_cause_connection_reinstatement interruptible Date: Sun, 26 Feb 2017 21:03:58 -0600 Message-Id: <1488164640-8751-3-git-send-email-mchristi@redhat.com> In-Reply-To: <1488164640-8751-1-git-send-email-mchristi@redhat.com> References: <1488164640-8751-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 27 Feb 2017 03:04:04 +0000 (UTC) Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To handle initiators dropping tcp connections while the login process is waiting on connections getting cleaned up, we need to make that login path interruptible. This patch modifies iscsit_cause_connection_reinstatement. Signed-off-by: Mike Christie --- drivers/infiniband/ulp/isert/ib_isert.c | 12 ++++++------ drivers/target/iscsi/iscsi_target.c | 19 +++++++++++++------ drivers/target/iscsi/iscsi_target_erl0.c | 23 +++++++++++++++++------ drivers/target/iscsi/iscsi_target_erl0.h | 2 +- drivers/target/iscsi/iscsi_target_erl1.c | 2 +- drivers/target/iscsi/iscsi_target_util.c | 2 +- include/target/iscsi/iscsi_transport.h | 2 +- 7 files changed, 40 insertions(+), 22 deletions(-) diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 314e955..c80a18c 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -725,7 +725,7 @@ break; case ISER_CONN_BOUND: case ISER_CONN_FULL_FEATURE: /* FALLTHRU */ - iscsit_cause_connection_reinstatement(isert_conn->conn, 0); + iscsit_cause_connection_reinstatement(isert_conn->conn, 0, 0); break; default: isert_warn("conn %p teminating in state %d\n", @@ -1393,7 +1393,7 @@ if (unlikely(wc->status != IB_WC_SUCCESS)) { isert_print_wc(wc, "recv"); if (wc->status != IB_WC_WR_FLUSH_ERR) - iscsit_cause_connection_reinstatement(isert_conn->conn, 0); + iscsit_cause_connection_reinstatement(isert_conn->conn, 0, 0); return; } @@ -1649,7 +1649,7 @@ if (unlikely(wc->status != IB_WC_SUCCESS)) { isert_print_wc(wc, "rdma write"); if (wc->status != IB_WC_WR_FLUSH_ERR) - iscsit_cause_connection_reinstatement(isert_conn->conn, 0); + iscsit_cause_connection_reinstatement(isert_conn->conn, 0, 0); isert_completion_put(desc, isert_cmd, device->ib_device, true); return; } @@ -1679,7 +1679,7 @@ if (unlikely(wc->status != IB_WC_SUCCESS)) { isert_print_wc(wc, "rdma read"); if (wc->status != IB_WC_WR_FLUSH_ERR) - iscsit_cause_connection_reinstatement(isert_conn->conn, 0); + iscsit_cause_connection_reinstatement(isert_conn->conn, 0, 0); isert_completion_put(desc, isert_cmd, device->ib_device, true); return; } @@ -1748,7 +1748,7 @@ if (unlikely(wc->status != IB_WC_SUCCESS)) { isert_print_wc(wc, "login send"); if (wc->status != IB_WC_WR_FLUSH_ERR) - iscsit_cause_connection_reinstatement(isert_conn->conn, 0); + iscsit_cause_connection_reinstatement(isert_conn->conn, 0, 0); } isert_unmap_tx_desc(tx_desc, ib_dev); @@ -1765,7 +1765,7 @@ if (unlikely(wc->status != IB_WC_SUCCESS)) { isert_print_wc(wc, "send"); if (wc->status != IB_WC_WR_FLUSH_ERR) - iscsit_cause_connection_reinstatement(isert_conn->conn, 0); + iscsit_cause_connection_reinstatement(isert_conn->conn, 0, 0); isert_completion_put(tx_desc, isert_cmd, ib_dev, true); return; } diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 4328036..a2e6a4f 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -4448,7 +4448,7 @@ static void iscsit_logout_post_handler_samecid( atomic_set(&conn->conn_logout_remove, 0); complete(&conn->conn_logout_comp); - iscsit_cause_connection_reinstatement(conn, sleep); + iscsit_cause_connection_reinstatement(conn, sleep, 0); iscsit_dec_conn_usage_count(conn); } @@ -4484,7 +4484,7 @@ static void iscsit_logout_post_handler_diffcid( l_conn->conn_state = TARG_CONN_STATE_IN_LOGOUT; spin_unlock_bh(&l_conn->state_lock); - iscsit_cause_connection_reinstatement(l_conn, 1); + iscsit_cause_connection_reinstatement(l_conn, 1, 0); iscsit_dec_conn_usage_count(l_conn); } @@ -4589,7 +4589,7 @@ int iscsit_free_session(struct iscsi_session *sess) iscsit_inc_conn_usage_count(conn); spin_unlock_bh(&sess->conn_lock); - iscsit_cause_connection_reinstatement(conn, 1); + iscsit_cause_connection_reinstatement(conn, 1, 0); spin_lock_bh(&sess->conn_lock); iscsit_dec_conn_usage_count(conn); @@ -4617,7 +4617,7 @@ int iscsit_stop_session( { u16 conn_count = atomic_read(&sess->nconn); struct iscsi_conn *conn, *conn_tmp = NULL; - int is_last; + int is_last, ret; spin_lock_bh(&sess->conn_lock); if (session_sleep) @@ -4638,17 +4638,24 @@ int iscsit_stop_session( iscsit_inc_conn_usage_count(conn); spin_unlock_bh(&sess->conn_lock); - iscsit_cause_connection_reinstatement(conn, 1); + ret = iscsit_cause_connection_reinstatement(conn, 1, + interruptible); spin_lock_bh(&sess->conn_lock); iscsit_dec_conn_usage_count(conn); if (is_last == 0) iscsit_dec_conn_usage_count(conn_tmp); + + if (ret) { + spin_unlock_bh(&sess->conn_lock); + return -1; + } + conn_count--; } } else { list_for_each_entry(conn, &sess->sess_conn_list, conn_list) - iscsit_cause_connection_reinstatement(conn, 0); + iscsit_cause_connection_reinstatement(conn, 0, 0); } if (session_sleep && atomic_read(&sess->nconn)) { diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c index a8bcbc4..42f3610 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.c +++ b/drivers/target/iscsi/iscsi_target_erl0.c @@ -867,22 +867,25 @@ void iscsit_connection_reinstatement_rcfr(struct iscsi_conn *conn) complete(&conn->conn_post_wait_comp); } -void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep) +int iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep, + int interruptible) { + int ret = 0; + spin_lock_bh(&conn->state_lock); if (atomic_read(&conn->connection_exit)) { spin_unlock_bh(&conn->state_lock); - return; + return 0; } if (atomic_read(&conn->transport_failed)) { spin_unlock_bh(&conn->state_lock); - return; + return 0; } if (atomic_read(&conn->connection_reinstatement)) { spin_unlock_bh(&conn->state_lock); - return; + return 0; } if (conn->tx_thread && conn->tx_thread_active) @@ -893,14 +896,22 @@ void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep) atomic_set(&conn->connection_reinstatement, 1); if (!sleep) { spin_unlock_bh(&conn->state_lock); - return; + return 0; } atomic_set(&conn->sleep_on_conn_wait_comp, 1); spin_unlock_bh(&conn->state_lock); - wait_for_completion(&conn->conn_wait_comp); + if (interruptible) + ret = wait_for_completion_interruptible(&conn->conn_wait_comp); + else + wait_for_completion(&conn->conn_wait_comp); + complete(&conn->conn_post_wait_comp); + if (ret == -ERESTARTSYS) + return -1; + + return 0; } EXPORT_SYMBOL(iscsit_cause_connection_reinstatement); diff --git a/drivers/target/iscsi/iscsi_target_erl0.h b/drivers/target/iscsi/iscsi_target_erl0.h index 60e69e2..1c71fb0 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.h +++ b/drivers/target/iscsi/iscsi_target_erl0.h @@ -13,7 +13,7 @@ extern void iscsit_start_time2retain_handler(struct iscsi_session *); extern int iscsit_stop_time2retain_timer(struct iscsi_session *); extern void iscsit_connection_reinstatement_rcfr(struct iscsi_conn *); -extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int); +extern int iscsit_cause_connection_reinstatement(struct iscsi_conn *, int, int); extern void iscsit_fall_back_to_erl0(struct iscsi_session *); extern void iscsit_take_action_for_connection_exit(struct iscsi_conn *); diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index fe9b7f1..5cbccce 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c @@ -1225,7 +1225,7 @@ static void iscsit_handle_dataout_timeout(unsigned long data) failure: spin_unlock_bh(&cmd->dataout_timeout_lock); - iscsit_cause_connection_reinstatement(conn, 0); + iscsit_cause_connection_reinstatement(conn, 0, 0); iscsit_dec_conn_usage_count(conn); } diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index f46eadf..ec11318 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -946,7 +946,7 @@ static void iscsit_handle_nopin_response_timeout(unsigned long data) } } - iscsit_cause_connection_reinstatement(conn, 0); + iscsit_cause_connection_reinstatement(conn, 0, 0); iscsit_dec_conn_usage_count(conn); } diff --git a/include/target/iscsi/iscsi_transport.h b/include/target/iscsi/iscsi_transport.h index ff1a4f4..b9a76ed 100644 --- a/include/target/iscsi/iscsi_transport.h +++ b/include/target/iscsi/iscsi_transport.h @@ -108,7 +108,7 @@ extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsi_cmd *, /* * From iscsi_target_erl0.c */ -extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int); +extern int iscsit_cause_connection_reinstatement(struct iscsi_conn *, int, int); /* * From iscsi_target_erl1.c */