From nobody Fri Oct 29 23:58:05 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 661B5181CCC1; Fri, 29 Oct 2021 23:58:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgzrt6vsWz4V6k; Fri, 29 Oct 2021 23:58:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 73F9F2023E; Fri, 29 Oct 2021 23:58:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TNw5Su003287; Fri, 29 Oct 2021 23:58:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TNw5Ym003286; Fri, 29 Oct 2021 23:58:05 GMT (envelope-from git) Date: Fri, 29 Oct 2021 23:58:05 GMT Message-Id: <202110292358.19TNw5Ym003286@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: cdb8017d0bb1 - stable/13 - cxgbe tom: Account for pre-iSCSI mode data on suspended connections. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cdb8017d0bb1e6cdf28555108b86968e17d0178b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=cdb8017d0bb1e6cdf28555108b86968e17d0178b commit cdb8017d0bb1e6cdf28555108b86968e17d0178b Author: John Baldwin AuthorDate: 2021-05-14 19:17:02 +0000 Commit: John Baldwin CommitDate: 2021-10-29 22:48:44 +0000 cxgbe tom: Account for pre-iSCSI mode data on suspended connections. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29907 (cherry picked from commit 23b209ee885b7891f806ecfe1bb944e40b3b4728) --- sys/dev/cxgbe/tom/t4_cpl_io.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index 0d37804c4f8e..acb2d3408244 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -1058,9 +1058,7 @@ t4_push_pdus(struct adapter *sc, struct toepcb *toep, int drop) struct fw_wr_hdr *wrhdr; struct wrqe *wr; u_int plen, credits; -#ifdef INVARIANTS struct inpcb *inp = toep->inp; -#endif struct ofld_tx_sdesc *txsd = &toep->txsd[toep->txsd_pidx]; struct mbufq *pduq = &toep->ulp_pduq; @@ -1083,8 +1081,34 @@ t4_push_pdus(struct adapter *sc, struct toepcb *toep, int drop) return; } - if (drop) + if (drop) { + struct socket *so = inp->inp_socket; + struct sockbuf *sb = &so->so_snd; + int sbu; + + /* + * An unlocked read is ok here as the data should only + * transition from a non-zero value to either another + * non-zero value or zero. Once it is zero it should + * stay zero. + */ + if (__predict_false(sbused(sb)) > 0) { + SOCKBUF_LOCK(sb); + sbu = sbused(sb); + if (sbu > 0) { + /* + * The data transmitted before the + * tid's ULP mode changed to ISCSI is + * still in so_snd. Incoming credits + * should account for so_snd first. + */ + sbdrop_locked(sb, min(sbu, drop)); + drop -= min(sbu, drop); + } + sowwakeup_locked(so); /* unlocks so_snd */ + } rqdrop_locked(&toep->ulp_pdu_reclaimq, drop); + } while ((sndptr = mbufq_first(pduq)) != NULL) { wr = write_iscsi_mbuf_wr(toep, sndptr);