From patchwork Wed Oct 16 20:51:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 11194459 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42EB713BD for ; Wed, 16 Oct 2019 20:52:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21EFE207FF for ; Wed, 16 Oct 2019 20:52:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="qFIs8dpv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394733AbfJPUwP (ORCPT ); Wed, 16 Oct 2019 16:52:15 -0400 Received: from linux.microsoft.com ([13.77.154.182]:58588 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394732AbfJPUwP (ORCPT ); Wed, 16 Oct 2019 16:52:15 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id BF51D20B7116; Wed, 16 Oct 2019 13:52:14 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BF51D20B7116 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1571259134; bh=Rtb+2kdRn8perdldTeE4yqY1kvTunTWHiFSixuBZlIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:From; b=qFIs8dpv54C9das6jYmoorkcU1WOfWMzyE/TM3h00P4otkQow6ti1I5WBN1DrUC8v wc6Tp40NyAoe/4bzDAjpGC+eW4V3heFmgQxPmx8UyLi2mCvnGsbXMEhxLbL8v2/K9l kPGS38PPSFtcPD5j83wFEL+Scqy6legGkoxmblUc= From: longli@linuxonhyperv.com To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [PATCH 1/7] cifs: Don't display RDMA transport on reconnect Date: Wed, 16 Oct 2019 13:51:50 -0700 Message-Id: <1571259116-102015-2-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> References: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Long Li On reconnect, the transport data structure is NULL and its information is not available. Signed-off-by: Long Li Cc: stable@vger.kernel.org --- fs/cifs/cifs_debug.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 0b4eee3bed66..efb2928ff6c8 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c @@ -256,6 +256,11 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) if (!server->rdma) goto skip_rdma; + if (!server->smbd_conn) { + seq_printf(m, "\nSMBDirect transport not available"); + goto skip_rdma; + } + seq_printf(m, "\nSMBDirect (in hex) protocol version: %x " "transport status: %x", server->smbd_conn->protocol, From patchwork Wed Oct 16 20:51:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 11194461 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED50213BD for ; Wed, 16 Oct 2019 20:52:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDFA221D7A for ; Wed, 16 Oct 2019 20:52:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="olaFMTd7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437251AbfJPUwU (ORCPT ); Wed, 16 Oct 2019 16:52:20 -0400 Received: from linux.microsoft.com ([13.77.154.182]:58622 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437248AbfJPUwU (ORCPT ); Wed, 16 Oct 2019 16:52:20 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id CA92920B711B; Wed, 16 Oct 2019 13:52:19 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CA92920B711B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1571259139; bh=sUUcSC83PEh9XnoXq1c/QwoVpW+DLqUxNnS3yQphdiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:From; b=olaFMTd7pK7xQmBODB3EmL9Qy8tc7oqsQdmNfteF01rhgWyf9gYTi4A8wzO+L/FEm xlbRnr7e/fhRJJtgfFH6dwA4yzAlUKt5plWDvpkpJsL8UkB+wtPz67jziIYaWSX7Df MSKG35MU3dTlpzjXE0zbdvY7jYfDTx4z+cFJfT8Y= From: longli@linuxonhyperv.com To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [PATCH 2/7] cifs: smbd: Invalidate and deregister memory registration on re-send Date: Wed, 16 Oct 2019 13:51:51 -0700 Message-Id: <1571259116-102015-3-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> References: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Long Li On re-send, there might be a reconnect and all prevoius memory registrations need to be invalidated and deregistered. Signed-off-by: Long Li Cc: stable@vger.kernel.org --- fs/cifs/file.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 4b95700c507c..3c4e01e56798 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2747,9 +2747,17 @@ cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list, if (!rc) { if (wdata->cfile->invalidHandle) rc = -EAGAIN; - else + else { +#ifdef CONFIG_CIFS_SMB_DIRECT + if (wdata->mr) { + wdata->mr->need_invalidate = true; + smbd_deregister_mr(wdata->mr); + wdata->mr = NULL; + } +#endif rc = server->ops->async_writev(wdata, cifs_uncached_writedata_release); + } } /* If the write was successfully sent, we are done */ @@ -3472,7 +3480,14 @@ static int cifs_resend_rdata(struct cifs_readdata *rdata, if (!rc) { if (rdata->cfile->invalidHandle) rc = -EAGAIN; - else + else { +#ifdef CONFIG_CIFS_SMB_DIRECT + if (rdata->mr) { + rdata->mr->need_invalidate = true; + smbd_deregister_mr(rdata->mr); + rdata->mr = NULL; + } +#endif rc = server->ops->async_readv(rdata); } From patchwork Wed Oct 16 20:51:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 11194463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46A1313BD for ; Wed, 16 Oct 2019 20:52:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27E41218DE for ; Wed, 16 Oct 2019 20:52:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="Y0eBDBHq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437263AbfJPUwZ (ORCPT ); Wed, 16 Oct 2019 16:52:25 -0400 Received: from linux.microsoft.com ([13.77.154.182]:58678 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437248AbfJPUwY (ORCPT ); Wed, 16 Oct 2019 16:52:24 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id 60F3F20B711C; Wed, 16 Oct 2019 13:52:24 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 60F3F20B711C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1571259144; bh=/J1KAoDt4Ozk7FB45NoOpcC31EITTBCBFxE5mPDky0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:From; b=Y0eBDBHquq6cYy1+wkmaiQuaVrwGocFDF9ABfnRExz/FxhSPac8J/t7NassnmR6nV S9YQv4Ait77buBeYE2tCeL+OtoBuYbmyZl2JObo5m11m0lkg1jOAE3Qi4T9dHSugfT cWiu3jU1tgK+MA7bJHOq3Hep9xGbV9ikyeDBEznY= From: longli@linuxonhyperv.com To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [PATCH 3/7] cifs: smbd: Return -EINVAL when the number of iovs exceeds SMBDIRECT_MAX_SGE Date: Wed, 16 Oct 2019 13:51:52 -0700 Message-Id: <1571259116-102015-4-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> References: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Long Li While it's not friendly to fail user processes that issue more iovs than we support, at least we should return the correct error code so the user process gets a chance to retry with smaller number of iovs. Signed-off-by: Long Li Cc: stable@vger.kernel.org --- fs/cifs/smbdirect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index cd07e5301d42..d41a9345f90d 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -1069,7 +1069,7 @@ static int smbd_post_send_data( if (n_vec > SMBDIRECT_MAX_SGE) { cifs_dbg(VFS, "Can't fit data to SGL, n_vec=%d\n", n_vec); - return -ENOMEM; + return -EINVAL; } sg_init_table(sgl, n_vec); From patchwork Wed Oct 16 20:51:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 11194465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB52414DB for ; Wed, 16 Oct 2019 20:52:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CBD4221A49 for ; Wed, 16 Oct 2019 20:52:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="DmTeNs6K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437226AbfJPUwb (ORCPT ); Wed, 16 Oct 2019 16:52:31 -0400 Received: from linux.microsoft.com ([13.77.154.182]:58740 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437248AbfJPUwa (ORCPT ); Wed, 16 Oct 2019 16:52:30 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id 162A520B711D; Wed, 16 Oct 2019 13:52:30 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 162A520B711D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1571259150; bh=kg9qGUDQcR5JB1IHvCLmx3ZDZ+TrLbgdykBbU9w7tdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:From; b=DmTeNs6KJM8TsNqZY3tBn7BUSFj/UBSqLPISDnWJGYtDxqW+exlE5EvnzcesfLF1S 8FVov1VK7Yp0J0X/M4Yjd4mAvT3+rjcTndBR61APY+nBtbPsG1JZRv0peEjbLGyplh zRrfZYHLaedXJuhSKBn/qFmPE0Dz5EAyZlm2FB28= From: longli@linuxonhyperv.com To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [PATCH 4/7] cifs: smbd: Add messages on RDMA session destroy and reconnection Date: Wed, 16 Oct 2019 13:51:53 -0700 Message-Id: <1571259116-102015-5-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> References: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Long Li Log these activities to help production support. Signed-off-by: Long Li Cc: stable@vger.kernel.org --- fs/cifs/smbdirect.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index d41a9345f90d..227ef51c0712 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -1476,6 +1476,7 @@ void smbd_destroy(struct TCP_Server_Info *server) info->transport_status = SMBD_DESTROYED; destroy_workqueue(info->workqueue); + log_rdma_event(INFO, "rdma session destroyed\n"); kfree(info); } @@ -1505,8 +1506,9 @@ int smbd_reconnect(struct TCP_Server_Info *server) log_rdma_event(INFO, "creating rdma session\n"); server->smbd_conn = smbd_get_connection( server, (struct sockaddr *) &server->dstaddr); - log_rdma_event(INFO, "created rdma session info=%p\n", - server->smbd_conn); + + if (server->smbd_conn) + cifs_dbg(VFS, "RDMA transport re-established\n"); return server->smbd_conn ? 0 : -ENOENT; } From patchwork Wed Oct 16 20:51:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 11194467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1DE914DB for ; Wed, 16 Oct 2019 20:52:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A2D4F21A49 for ; Wed, 16 Oct 2019 20:52:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="javdQhW7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437288AbfJPUwf (ORCPT ); Wed, 16 Oct 2019 16:52:35 -0400 Received: from linux.microsoft.com ([13.77.154.182]:58774 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437248AbfJPUwe (ORCPT ); Wed, 16 Oct 2019 16:52:34 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id 2608C20B711E; Wed, 16 Oct 2019 13:52:34 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2608C20B711E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1571259154; bh=5FICGste6jToJaBBTX9BeJ88MaaNvL9+/uQnD2Xs5i0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:From; b=javdQhW7M6QQqLxECCB4aG4rwSEvYr7aXdN2IxS3niWxp73wOWOhPHG8LTKnE/LFP sNRup78L8b7k6jN1r20mtSW9icuT+KeHIWnXVTgu/CuaGXasiELvGsQwSM9BrKCuiM qAeIGALM3yaduZB1I877V3w8qi/3j1eNnebendsE= From: longli@linuxonhyperv.com To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [PATCH 5/7] cifs: smbd: Return -ECONNABORTED when trasnport is not in connected state Date: Wed, 16 Oct 2019 13:51:54 -0700 Message-Id: <1571259116-102015-6-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> References: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Long Li The transport should return this error so the upper layer will reconnect. Signed-off-by: Long Li Cc: stable@vger.kernel.org --- fs/cifs/smbdirect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index 227ef51c0712..cf001f10d555 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -1970,7 +1970,7 @@ static int smbd_recv_buf(struct smbd_connection *info, char *buf, if (info->transport_status != SMBD_CONNECTED) { log_read(ERR, "disconnected\n"); - return 0; + return -ECONNABORTED; } goto again; From patchwork Wed Oct 16 20:51:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 11194469 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BBC2813BD for ; Wed, 16 Oct 2019 20:52:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9321321A49 for ; Wed, 16 Oct 2019 20:52:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="cXyWJwAm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437300AbfJPUwm (ORCPT ); Wed, 16 Oct 2019 16:52:42 -0400 Received: from linux.microsoft.com ([13.77.154.182]:58814 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437248AbfJPUwi (ORCPT ); Wed, 16 Oct 2019 16:52:38 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id C7ECA20B9C00; Wed, 16 Oct 2019 13:52:37 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C7ECA20B9C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1571259157; bh=2YV6IZfNKusYy95VZq7usZ04z/v2U6/1CdgSHm4EGRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:From; b=cXyWJwAm4Uz6OgM2sXS10Ye6hGGR5w1eyiWIeT7rPwwJTHzVwJG+qd4mNC+7Ud814 KzJ6gC07S6vp4Bm/+W4jkfkbX8m95r9vceBKzhTWb/I/onq8y3up8TsogJjoPX+EJ8 wU57KV1RgWTeVHlGlAA1k1ohjhopp93xy3wAqTf0= From: longli@linuxonhyperv.com To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [PATCH 6/7] cifs: smbd: Only queue work for error recovery on memory registration Date: Wed, 16 Oct 2019 13:51:55 -0700 Message-Id: <1571259116-102015-7-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> References: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Long Li It's not necessary to queue invalidated memory registration to work queue, as all we need to do is to unmap the SG and make it usable again. This can save CPU cycles in normal data paths as memory registration errors are rare and normally only happens during reconnection. Signed-off-by: Long Li Cc: stable@vger.kernel.org --- fs/cifs/smbdirect.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index cf001f10d555..c00629a41d81 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -2269,12 +2269,7 @@ static void smbd_mr_recovery_work(struct work_struct *work) int rc; list_for_each_entry(smbdirect_mr, &info->mr_list, list) { - if (smbdirect_mr->state == MR_INVALIDATED) - ib_dma_unmap_sg( - info->id->device, smbdirect_mr->sgl, - smbdirect_mr->sgl_count, - smbdirect_mr->dir); - else if (smbdirect_mr->state == MR_ERROR) { + if (smbdirect_mr->state == MR_ERROR) { /* recover this MR entry */ rc = ib_dereg_mr(smbdirect_mr->mr); @@ -2602,11 +2597,20 @@ int smbd_deregister_mr(struct smbd_mr *smbdirect_mr) */ smbdirect_mr->state = MR_INVALIDATED; - /* - * Schedule the work to do MR recovery for future I/Os - * MR recovery is slow and we don't want it to block the current I/O - */ - queue_work(info->workqueue, &info->mr_recovery_work); + if (smbdirect_mr->state == MR_INVALIDATED) { + ib_dma_unmap_sg( + info->id->device, smbdirect_mr->sgl, + smbdirect_mr->sgl_count, + smbdirect_mr->dir); + smbdirect_mr->state = MR_READY; + if (atomic_inc_return(&info->mr_ready_count) == 1) + wake_up_interruptible(&info->wait_mr); + } else + /* + * Schedule the work to do MR recovery for future I/Os + * MR recovery is slow and we don't want it to block the + * current I/O */ + queue_work(info->workqueue, &info->mr_recovery_work); done: if (atomic_dec_and_test(&info->mr_used_count)) From patchwork Wed Oct 16 20:51:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 11194471 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6352A13BD for ; Wed, 16 Oct 2019 20:52:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4446021A4C for ; Wed, 16 Oct 2019 20:52:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linuxonhyperv.com header.i=@linuxonhyperv.com header.b="fEJ5jG1S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437304AbfJPUwm (ORCPT ); Wed, 16 Oct 2019 16:52:42 -0400 Received: from linux.microsoft.com ([13.77.154.182]:58846 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437299AbfJPUwk (ORCPT ); Wed, 16 Oct 2019 16:52:40 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id 74F4120B9C01; Wed, 16 Oct 2019 13:52:39 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 74F4120B9C01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1571259159; bh=4sfYqfNcpqUyQQbNHu50T1zrwYwZAKGk5e7iBBIfSaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:From; b=fEJ5jG1S1MwamTnSlDlKPEPKPQZoloArDSkK1MWu89vIhffBH8pIzueXDS3OyoKRe hOpdrnE4BABVWf5KhMLqSS2oASgx141KJp5415iAzkLTiOMdBMZX9O6hlD0nVyeisd Kam0Tmk3Iiy6f4NIs+n4nQ54gqqU/u4GhABEWH5c= From: longli@linuxonhyperv.com To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [PATCH 7/7] cifs: smbd: Return -EAGAIN when transport is reconnecting Date: Wed, 16 Oct 2019 13:51:56 -0700 Message-Id: <1571259116-102015-8-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> References: <1571259116-102015-1-git-send-email-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Long Li During reconnecting, the transport may have already been destroyed and is in the process being reconnected. In this case, return -EAGAIN to not fail and to retry this I/O. Signed-off-by: Long Li Cc: stable@vger.kernel.org --- fs/cifs/transport.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index afe66f9cb15e..66fde7bfec4f 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -318,8 +318,11 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, int val = 1; __be32 rfc1002_marker; - if (cifs_rdma_enabled(server) && server->smbd_conn) { - rc = smbd_send(server, num_rqst, rqst); + if (cifs_rdma_enabled(server)) { + /* return -EAGAIN when connecting or reconnecting */ + rc = -EAGAIN; + if (server->smbd_conn) + rc = smbd_send(server, num_rqst, rqst); goto smbd_done; }