Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5599179pxb; Mon, 28 Mar 2022 14:47:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgDhgP8RInXnI4+KM9Dgc9UStWjLjcwS7bmnSsViLlCiECPdyxKJgtBJRL+iHVnMBCTrT2 X-Received: by 2002:a05:6102:3a64:b0:320:91a3:f093 with SMTP id bf4-20020a0561023a6400b0032091a3f093mr12889303vsb.58.1648504026467; Mon, 28 Mar 2022 14:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648504026; cv=none; d=google.com; s=arc-20160816; b=u6MJZ74/w2HUuACaOvo4rSoZ8ZauVieD+atS21OthtaeYKGNbyvw2mfZm/1zHfLBdY NctCdOTa+Tm8+5dVi/Uw94USwcDeS3BCaSs3CzjrtJix2unlogxgpKgpXdI5J7o2MMFO 8Gcu4BK4UrJ2y+COLx7Ncu8NjqY8lvkCBdOgOPuThdy5FVMWKmivlALBTkth4MpieOQd hu5OnQzNsfRs2cWvGBqVljs3TOqm+0sux3g/Bd+a3rqiUuewBNeDtT1ScrmeZpMpUzoa rxjS4+TQEPtb7Xwj5/n1pj21WPC68cntpBAJr5EllVR+iCeRskIpQPhtP95KIkuADzPn K5rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date; bh=Zd/HEo3/XayMuX0ddt6KB28cT/8yIdbtJbro3P/u3Jw=; b=s+d3i1doBGZgOzJPEk6G6Ksa5ctyVwsURgcQUsO5vorBMXI9TUNUaPR5lLej6P7Otq RY/BihfiFePwHZBbQywWFNdAS7E7ofV9uSWMgfDwYvNjw3XGqWlSfZWVY6W6BRYPxu3N SeBr5DTqT36gfAXLm6EKVmEQgu+THM3WaxraSUoTEn9SxylqcrCp4IIgS1o39ncJRR7o gc/ddQFKWtNC0DOWfXUqB4jTsEHhJF0u1KzXIuFqvUp96x//saWJumPeIEa3Q7rI10FQ qbDG9H/jpIeMiWLp9gC0TcH6+cEp05YRuYqnC8Txjno6W4tkMpAnjl4PLa/hLv6+oJpF tuZA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a30-20020a67ca9e000000b00324fd60f5a9si3483207vsl.30.2022.03.28.14.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:47:06 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 287A6CC524; Mon, 28 Mar 2022 14:19:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239639AbiC1JF7 (ORCPT + 99 others); Mon, 28 Mar 2022 05:05:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239633AbiC1JF4 (ORCPT ); Mon, 28 Mar 2022 05:05:56 -0400 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B98B63CD; Mon, 28 Mar 2022 02:04:15 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=dust.li@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0V8Q3eBj_1648458252; Received: from localhost(mailfrom:dust.li@linux.alibaba.com fp:SMTPD_---0V8Q3eBj_1648458252) by smtp.aliyun-inc.com(127.0.0.1); Mon, 28 Mar 2022 17:04:12 +0800 Date: Mon, 28 Mar 2022 17:04:11 +0800 From: "dust.li" To: Wen Gu , kgraul@linux.ibm.com, davem@davemloft.net, kuba@kernel.org Cc: linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] net/smc: Send out the remaining data in sndbuf before close Message-ID: <20220328090411.GI35207@linux.alibaba.com> Reply-To: dust.li@linux.alibaba.com References: <1648447836-111521-1-git-send-email-guwen@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1648447836-111521-1-git-send-email-guwen@linux.alibaba.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no 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 On Mon, Mar 28, 2022 at 02:10:36PM +0800, Wen Gu wrote: >The current autocork algorithms will delay the data transmission >in BH context to smc_release_cb() when sock_lock is hold by user. > >So there is a possibility that when connection is being actively >closed (sock_lock is hold by user now), some corked data still >remains in sndbuf, waiting to be sent by smc_release_cb(). This >will cause: > >- smc_close_stream_wait(), which is called under the sock_lock, > has a high probability of timeout because data transmission is > delayed until sock_lock is released. > >- Unexpected data sends may happen after connction closed and use > the rtoken which has been deleted by remote peer through > LLC_DELETE_RKEY messages. > >So this patch will try to send out the remaining corked data in >sndbuf before active close process, to ensure data integrity and >avoid unexpected data transmission after close. I think this issue should also happen if TCP_CORK is set and autocorking is not enabled ? Autocorking and delaying the TX from BH to smc_release_cb() greatly increased the probability of this problem. > >Reported-by: Guangguan Wang >Fixes: 6b88af839d20 ("net/smc: don't send in the BH context if sock_owned_by_user") >Signed-off-by: Wen Gu >--- > net/smc/smc_close.c | 3 +++ > 1 file changed, 3 insertions(+) > >diff --git a/net/smc/smc_close.c b/net/smc/smc_close.c >index 292e4d9..676cb23 100644 >--- a/net/smc/smc_close.c >+++ b/net/smc/smc_close.c >@@ -57,6 +57,9 @@ static void smc_close_stream_wait(struct smc_sock *smc, long timeout) > if (!smc_tx_prepared_sends(&smc->conn)) > return; > >+ /* Send out corked data remaining in sndbuf */ >+ smc_tx_pending(&smc->conn); >+ > smc->wait_close_tx_prepared = 1; > add_wait_queue(sk_sleep(sk), &wait); > while (!signal_pending(current) && timeout) { >-- >1.8.3.1