Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1783892pxp; Mon, 7 Mar 2022 02:13:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJhnznkwqksxHhDvv4qmn2K41YBbvPY+3hrvmUuwjqKzc3EDAlU5BkbbdJGHIRxnNXcaPo X-Received: by 2002:a50:d550:0:b0:416:2ac8:b98e with SMTP id f16-20020a50d550000000b004162ac8b98emr8630625edj.236.1646647897239; Mon, 07 Mar 2022 02:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647897; cv=none; d=google.com; s=arc-20160816; b=cRyn016iLPvYjG+gt/z8oQC7jCb7LtKuMu7+YODaHEpBAMdlOkjH8rbxoh4l9DRmH8 fMSbbsuvwPSnllZpbYu+GnN2XbuIeFFygSiWYz+a+aZmsRQ85hVzoF/BNOWr7rlrkVkF 9ilIBfTSA8Y9PDepp6MsBtS1U7sJJd/+GaKbNi3N3k9gogKHxIMlnbVHG9gkZ8HEarix QCvXuEABFCRm7p23t8Pybdq4DyQhh/Ipmzbu0qQM4PQ8sCcefpnMjSYrOvR68o+/wjJO SRXSdrWAYATJWxhuDACE012pXraY5DExb6+uvc8i8OcVlrAWrrtdpaFY4RtFtz2n61+M DJLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=30tgSrZ9p6S0v23etbK8UuncZfTWIMeHMvtt6842Stw=; b=q2E1ZA5BS3pHK0U82xDypi1sPD8qKheeoH+fcbB7kVj9KywqZuCaJdaUxAZno3cZWM cJzaMnA9sXsT1LtzAvp55DGzviNfaySqg/6jj2W8L8BNEMTuycG7ceMPUuOOSuyNrAQr q+66IMqIWx3wL1FeVQ7DDlZ5SjGs07WISz1Ydrh+m7rn5OinYJX+OsOPQHZ7ZfjLd/U1 XIwYSAsTk6K/I1lA1Jjg+lhjNQ5xvS9YzlwFuY6sQBaG4cLuQhhh71i1PsmD0GLOEZXv P/3/id5gbKtJGdCH1IlgwNgT/JzpnW3VRy+vfYogRT2WjPjupvWe116lx9/aO1wEznMM xyAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qHt3otFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a05640227c800b00415e91a7499si8802488ede.75.2022.03.07.02.11.14; Mon, 07 Mar 2022 02:11:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qHt3otFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237773AbiCGJgy (ORCPT + 99 others); Mon, 7 Mar 2022 04:36:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237452AbiCGJ2H (ORCPT ); Mon, 7 Mar 2022 04:28:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B2285AEE7; Mon, 7 Mar 2022 01:25:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C9ED361150; Mon, 7 Mar 2022 09:25:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3082C340E9; Mon, 7 Mar 2022 09:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645124; bh=fWF0zr88aLR5/eYRbmN2pjGVjZ4Y0TtYS7lCtnAOpzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qHt3otFs078D0Iu6xiXns1Fc+TUSmRldOOpQEJ8UNo8C86ExjDV/BwCeQ73KdiZTu Yv21mjqruBRmOrpNZdPgX+y/2qleKLUGCMR1GrGzAVaW+umEGVlc7ILOyLMjaN82/s cQ+Jb/+qeErgOwAQH0uAhVlHggo+8fG+IX60v7FY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "D. Wythe" , "David S. Miller" Subject: [PATCH 4.19 28/51] net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error cause by server Date: Mon, 7 Mar 2022 10:19:03 +0100 Message-Id: <20220307091637.792801662@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.988950823@linuxfoundation.org> References: <20220307091636.988950823@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: D. Wythe commit 4940a1fdf31c39f0806ac831cde333134862030b upstream. The problem of SMC_CLC_DECL_ERR_REGRMB on the server is very clear. Based on the fact that whether a new SMC connection can be accepted or not depends on not only the limit of conn nums, but also the available entries of rtoken. Since the rtoken release is trigger by peer, while the conn nums is decrease by local, tons of thing can happen in this time difference. This only thing that needs to be mentioned is that now all connection creations are completely protected by smc_server_lgr_pending lock, it's enough to check only the available entries in rtokens_used_mask. Fixes: cd6851f30386 ("smc: remote memory buffers (RMBs)") Signed-off-by: D. Wythe Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/smc/smc_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -609,7 +609,8 @@ int smc_conn_create(struct smc_sock *smc !lgr->sync_err && lgr->vlan_id == vlan_id && (role == SMC_CLNT || - lgr->conns_num < SMC_RMBS_PER_LGR_MAX)) { + (lgr->conns_num < SMC_RMBS_PER_LGR_MAX && + !bitmap_full(lgr->rtokens_used_mask, SMC_RMBS_PER_LGR_MAX)))) { /* link group found */ local_contact = SMC_REUSE_CONTACT; conn->lgr = lgr;