Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1775867pxp; Mon, 7 Mar 2022 02:03:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3/35/YbVHZItOvJlUoMrOeL3lsbBaO4LgBIfYzhHwx1lW+OcI1CiY0fEhAoo/XodmBBPU X-Received: by 2002:a05:6402:40d0:b0:412:f86a:efd1 with SMTP id z16-20020a05640240d000b00412f86aefd1mr10306339edb.194.1646647383133; Mon, 07 Mar 2022 02:03:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647383; cv=none; d=google.com; s=arc-20160816; b=hpk9VQN3RCwk5b/Th/1zCMLXTUqry9lXAQZj+iyUnEOIkp0RH2B5miLof69lKOcaAF Rm3bf3y41mrJJNg5q862lws77CXgUQW2SAlv+dqPfQ6uFpE3UNFS9tPqMG7EBnxJ8PiN y8B+8vbx3bXeHDo1mwSQ6DxN0Lpw7zA/CDWuNG2jAPlRRzyMrQBvIZeFjge9hKjbgEtq anHeHLulyhzXYwuJMQFt+fHmtYLI1gVp5BjzkCoAEyW4PyRlPnRXs65ONT2GMBpZLJHW rx2bcir0/oSehBMx61yVl6j2m1a4vI+S3eYbKNOL0kn1L4lzrWHAQLF6au+tSBsX3sOx FJ6Q== 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=ScEL9vTBHZidD7/j/WmYngqWo2vlWuHcoabKUp9+ii0=; b=RZrY9WWVEW3wqHWMeakR2xb9JT72wXjQ+UYaaEvpMe7SshYDLGs+FvLT9F/RREutnn Fjd7TcsgFKuFpP7ZcvbDySWYgBAfsfqOVnMxKJ0PQaXDVSEPFMU5TQsXH81kFx9BHHtU va7EHKc/kbwWyarzhRLwr7s5d/BDbhxVU8LQN7sgX3N1Be3gu3EaOZQECFo4muyAL9WM 5wM6d/SZp2fyqZ0+DpmyXTsHipIYWURKALUt3tCRcvSd+jUuw+WtDXeuh+kVSP0XdDmP 4bbzVBS+Ff0/XqC8gipGkKXkyX46tXmo3+MXbUx/zLdXhBoGtNKBGf1Uixz0qmENNAVN 8orQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CJI5bqOZ; 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 ba3-20020a0564021ac300b00416463d69f8si1584813edb.580.2022.03.07.02.02.40; Mon, 07 Mar 2022 02:03:03 -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=CJI5bqOZ; 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 S236939AbiCGJ0J (ORCPT + 99 others); Mon, 7 Mar 2022 04:26:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237447AbiCGJYE (ORCPT ); Mon, 7 Mar 2022 04:24:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A139A56410; Mon, 7 Mar 2022 01:23:10 -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 ams.source.kernel.org (Postfix) with ESMTPS id 54DB5B810AC; Mon, 7 Mar 2022 09:23:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4110C340F3; Mon, 7 Mar 2022 09:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646644988; bh=BFFp1pVHCDEv00xgtl+NWNa9vFm2290tTNvwIjg8F74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CJI5bqOZI18Fl74/qctSfVTSIQKVr2HSv8DWPYRY6XVFzG9Jn0xBw0iYvCzCyAnbI DwFX73mIAYV9rbFReE9S56nofZLtgu21z9cX+vbdsV3BXZjbFzriLAGu+eWRIlAib9 aKnJ8LSmX685TqWsG9ZnegNkp6Pu/lqVfhlCUZjQ= 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.14 25/42] net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error cause by server Date: Mon, 7 Mar 2022 10:18:59 +0100 Message-Id: <20220307091636.884201563@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.146155347@linuxfoundation.org> References: <20220307091636.146155347@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 @@ -428,7 +428,8 @@ int smc_conn_create(struct smc_sock *smc (lgr->role == role) && (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;