Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753431AbdHBUSF (ORCPT ); Wed, 2 Aug 2017 16:18:05 -0400 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:36970 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753012AbdHBUMZ (ORCPT ); Wed, 2 Aug 2017 16:12:25 -0400 x-originating-ip: 107.180.71.197 From: Long Li To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li Subject: [[PATCH v1] 17/37] [CIFS] SMBD: Track status for transport Date: Wed, 2 Aug 2017 13:10:28 -0700 Message-Id: <1501704648-20159-18-git-send-email-longli@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1501704648-20159-1-git-send-email-longli@exchange.microsoft.com> References: <1501704648-20159-1-git-send-email-longli@exchange.microsoft.com> X-CMAE-Envelope: MS4wfLp8aWyXiEZEB+XrQLNGMc13SHHAONMn/Mg9o7Xh5e2l46XQQMqGiGiQ2d29zGcPxiQFxZnNhEhdynQsvyPKF38Jcj32z8Yrs+IgoRjtXr81ant5oBqE pMkyBOVwOj+coYZtH3OM985kJvsFz+WuNse7q9FUQnkIrGLtjBLu3AiNComz0zUjG4DyJPgz4sl9Z2K853g123BtLJiFSODcC+L09sOqk+APfQtiB4tYJ6Uv 4UPH3T86GxkeVYO0+sRyFrU2zDs6ghdQGX/WPK9xPPytykMJypEFVSrqqJ7TVLoRKL6hF39B8gR7XFhVgVGRUtLwdxoXScUd2uLDIgId+0g= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3634 Lines: 128 From: Long Li Introduce status for tracking the status of SMBD transport. They are used in transport reconnect and shutdown. Signed-off-by: Long Li --- fs/cifs/cifsrdma.c | 25 +++++++++++++++++++++++++ fs/cifs/cifsrdma.h | 11 +++++++++++ 2 files changed, 36 insertions(+) diff --git a/fs/cifs/cifsrdma.c b/fs/cifs/cifsrdma.c index cf71bb1..ef21f1c 100644 --- a/fs/cifs/cifsrdma.c +++ b/fs/cifs/cifsrdma.c @@ -173,9 +173,12 @@ static int cifs_rdma_conn_upcall( case RDMA_CM_EVENT_DEVICE_REMOVAL: log_rdma_event("connected event=%d\n", event->event); info->connect_state = event->event; + info->transport_status = CIFS_RDMA_CONNECTED; + wake_up_all(&info->conn_wait); break; case RDMA_CM_EVENT_DISCONNECTED: + info->transport_status = CIFS_RDMA_DISCONNECTED; break; default: @@ -581,6 +584,12 @@ static int cifs_rdma_post_send_page(struct cifs_rdma_info *info, struct page *pa int rc = -ENOMEM; int i; + // disconnected? + if (info->transport_status != CIFS_RDMA_CONNECTED) { + log_outgoing("disconnected not sending\n"); + return -ENOENT; + } + request = mempool_alloc(info->request_mempool, GFP_KERNEL); if (!request) return rc; @@ -686,6 +695,12 @@ static int cifs_rdma_post_send_empty(struct cifs_rdma_info *info) int rc; u16 credits_granted, flags=0; + // disconnected? + if (info->transport_status != CIFS_RDMA_CONNECTED) { + log_outgoing("disconnected not sending\n"); + return -ENOENT; + } + request = mempool_alloc(info->request_mempool, GFP_KERNEL); if (!request) { log_rdma_send("failed to get send buffer for empty packet\n"); @@ -785,6 +800,12 @@ static int cifs_rdma_post_send_data( int rc = -ENOMEM, i; u32 data_length; + // disconnected? + if (info->transport_status != CIFS_RDMA_CONNECTED) { + log_outgoing("disconnected not sending\n"); + return -ENOENT; + } + request = mempool_alloc(info->request_mempool, GFP_KERNEL); if (!request) return rc; @@ -1056,6 +1077,7 @@ struct cifs_rdma_info* cifs_create_rdma_session( return NULL; info->server_info = server; + info->transport_status = CIFS_RDMA_CONNECTING; rc = cifs_rdma_ia_open(info, dstaddr); if (rc) { @@ -1122,12 +1144,15 @@ struct cifs_rdma_info* cifs_create_rdma_session( conn_param.retry_count = 6; conn_param.rnr_retry_count = 6; conn_param.flow_control = 0; + init_waitqueue_head(&info->conn_wait); rc = rdma_connect(info->id, &conn_param); if (rc) { log_rdma_event("rdma_connect() failed with %i\n", rc); goto out2; } + wait_event_interruptible( + info->conn_wait, info->transport_status == CIFS_RDMA_CONNECTED); if (info->connect_state != RDMA_CM_EVENT_ESTABLISHED) goto out2; diff --git a/fs/cifs/cifsrdma.h b/fs/cifs/cifsrdma.h index 4a4c191..9618e0b 100644 --- a/fs/cifs/cifsrdma.h +++ b/fs/cifs/cifsrdma.h @@ -25,6 +25,15 @@ #include #include +enum cifs_rdma_transport_status { + CIFS_RDMA_CREATED, + CIFS_RDMA_CONNECTING, + CIFS_RDMA_CONNECTED, + CIFS_RDMA_DISCONNECTING, + CIFS_RDMA_DISCONNECTED, + CIFS_RDMA_DESTROYED +}; + /* * The context for the SMBDirect transport * Everything related to the transport is here. It has several logical parts @@ -35,6 +44,7 @@ */ struct cifs_rdma_info { struct TCP_Server_Info *server_info; + enum cifs_rdma_transport_status transport_status; // RDMA related struct rdma_cm_id *id; @@ -45,6 +55,7 @@ struct cifs_rdma_info { int connect_state; int ri_rc; struct completion ri_done; + wait_queue_head_t conn_wait; struct completion negotiate_completion; bool negotiate_done; -- 2.7.4