Received: by 10.192.165.148 with SMTP id m20csp2429446imm; Sun, 22 Apr 2018 06:59:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx48wkl0FEpTfRZizC89n72PEbc12ilcJmdjnxm56nLktdakShTNEBBKmvAzHCY7Fru0hGHf/ X-Received: by 10.101.102.143 with SMTP id b15mr13884084pgw.183.1524405597840; Sun, 22 Apr 2018 06:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405597; cv=none; d=google.com; s=arc-20160816; b=Nz/vAeq/9v0yztAQtzys1lU3i6CXttIb0m5kA2q47HYCLjPdwdv6IHZTrnvxvRv2us TsmhsUKpxGrP7npKVc8+FPh4N3NuMFnXzocfLagP8Fv5KXSfIb2rOtKDMHAmjLuk95ZQ sEOyaju6E16eJ0TFZtE9BnZa44rjldmnCqNnxPfYQyAha014xG/LA3Fc2aUmVXYzndOX jAHN+LXm1DqRWaUNWtsbSxbMVtxc18FEbxCzvyn5LR4e0/O2ZyjFqvksOYsuMuxtNriH F1BX4WDHC00Hw8t73BT2Zi5ctdqIOExYv3+aBbPP5vxVgdRbrgwJ986wVr+qHDvCIZXQ 9X1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iPhYAjQHvwI5dnsSPFFmfiO/kEMS9oadGxAWh5YIlbQ=; b=n3CqDvsEgWJ6wdpUsqVn/1cphm9p2firS05IyWzwdtHoaBp9MW6C8IM2VCQa024Ym1 o+2wr1f3KqV1i7TUNycVkf8usL6irCaqku4FElfG3YXuJIG1Mp8yPzp/7rPpRdrErmM0 hUaOqCdNJEeSPe7NbX9Q0WBcoQooq57YymNpK6LjzDmkCO4lcJvZK5AFWNdGZFX1woQX X9vuPTIk1B0aqNRZmYVqDxCeSAad/xdQ883iJzEH3psGq7x132+Fh5VIEZGLkgHll98Z P4P0nP64E1hHVz7prGXEKuS9FQkLkp2Qle/XVtqDCKyuABj+gcsGQTETqgY8BEovVgFG UaqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b60-v6si10314975plc.270.2018.04.22.06.59.43; Sun, 22 Apr 2018 06:59:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754107AbeDVN6M (ORCPT + 99 others); Sun, 22 Apr 2018 09:58:12 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46074 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754089AbeDVN6G (ORCPT ); Sun, 22 Apr 2018 09:58:06 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0977FCD8; Sun, 22 Apr 2018 13:58:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Long Li , Steve French , Ronnie Sahlberg Subject: [PATCH 4.16 048/196] cifs: smbd: avoid reconnect lockup Date: Sun, 22 Apr 2018 15:51:08 +0200 Message-Id: <20180422135106.570822475@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Long Li commit 48f238a79f668f8ff013024d83010de551833d7f upstream. During transport reconnect, other processes may have registered memory and blocked on transport. This creates a deadlock situation because the transport resources can't be freed, and reconnect is blocked. Fix this by returning to upper layer on timeout. Before returning, transport status is set to reconnecting so other processes will release memory registration resources. Upper layer will retry the reconnect. This is not in fast I/O path so setting the timeout to 5 seconds. Signed-off-by: Long Li Signed-off-by: Steve French Reviewed-by: Ronnie Sahlberg CC: Stable Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smbdirect.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -1498,8 +1498,8 @@ int smbd_reconnect(struct TCP_Server_Inf log_rdma_event(INFO, "reconnecting rdma session\n"); if (!server->smbd_conn) { - log_rdma_event(ERR, "rdma session already destroyed\n"); - return -EINVAL; + log_rdma_event(INFO, "rdma session already destroyed\n"); + goto create_conn; } /* @@ -1512,15 +1512,19 @@ int smbd_reconnect(struct TCP_Server_Inf } /* wait until the transport is destroyed */ - wait_event(server->smbd_conn->wait_destroy, - server->smbd_conn->transport_status == SMBD_DESTROYED); + if (!wait_event_timeout(server->smbd_conn->wait_destroy, + server->smbd_conn->transport_status == SMBD_DESTROYED, 5*HZ)) + return -EAGAIN; destroy_workqueue(server->smbd_conn->workqueue); kfree(server->smbd_conn); +create_conn: 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); return server->smbd_conn ? 0 : -ENOENT; }