From owner-svn-src-head@freebsd.org Wed Jul 8 02:28:09 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 249BB35367E; Wed, 8 Jul 2020 02:28:09 +0000 (UTC) (envelope-from rmacklem@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B1js46Bg5z4N34; Wed, 8 Jul 2020 02:28:08 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B7E5F19560; Wed, 8 Jul 2020 02:28:08 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0682S8Ph043719; Wed, 8 Jul 2020 02:28:08 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0682S8J5043718; Wed, 8 Jul 2020 02:28:08 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <202007080228.0682S8J5043718@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 8 Jul 2020 02:28:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363001 - head/sys/fs/nfsclient X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/sys/fs/nfsclient X-SVN-Commit-Revision: 363001 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jul 2020 02:28:09 -0000 Author: rmacklem Date: Wed Jul 8 02:28:08 2020 New Revision: 363001 URL: https://svnweb.freebsd.org/changeset/base/363001 Log: Add support for ext_pgs mbufs to nfsm_uiombuf(). This patch uses a slightly different algorithm for the non-ext_pgs case, where a variable called "mcp" is maintained, pointing to the current location that mbuf data can be filled into. This avoids use of mtod(mp, char *) + mp->m_len to calculate the location, since this does not work for ext_pgs mbufs and I think it makes the algorithm more readable. This change should not result in semantic changes for the non-ext_pgs case. This is another in the series of commits that add support to the NFS client and server for building RPC messages in ext_pgs mbufs with anonymous pages. This is useful so that the entire mbuf list does not need to be copied before calling sosend() when NFS over TLS is enabled. Since ND_EXTPG is never set yet, there is no semantic change at this time. Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clcomsubs.c Wed Jul 8 01:47:20 2020 (r363000) +++ head/sys/fs/nfsclient/nfs_clcomsubs.c Wed Jul 8 02:28:08 2020 (r363001) @@ -62,7 +62,7 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *ui struct mbuf *mp, *mp2; int xfer, left, mlen; int uiosiz, clflg, rem; - char *cp, *tcp; + char *mcp, *tcp; KASSERT(uiop->uio_iovcnt == 1, ("nfsm_uiotombuf: iovcnt != 1")); @@ -72,41 +72,52 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *ui clflg = 0; rem = NFSM_RNDUP(siz) - siz; mp = mp2 = nd->nd_mb; + mcp = nd->nd_bpos; while (siz > 0) { + KASSERT((nd->nd_flag & ND_EXTPG) != 0 || mcp == + mtod(mp, char *) + mp->m_len, ("nfsm_uiombuf: mcp wrong")); left = uiop->uio_iov->iov_len; uiocp = uiop->uio_iov->iov_base; if (left > siz) left = siz; uiosiz = left; while (left > 0) { - mlen = M_TRAILINGSPACE(mp); - if (mlen == 0) { - if (clflg) - NFSMCLGET(mp, M_WAITOK); - else - NFSMGET(mp); - mp->m_len = 0; - mp2->m_next = mp; - mp2 = mp; + if ((nd->nd_flag & ND_EXTPG) != 0) + mlen = nd->nd_bextpgsiz; + else mlen = M_TRAILINGSPACE(mp); + if (mlen == 0) { + if ((nd->nd_flag & ND_EXTPG) != 0) { + mp = nfsm_add_ext_pgs(mp, + nd->nd_maxextsiz, &nd->nd_bextpg); + mcp = (char *)(void *)PHYS_TO_DMAP( + mp->m_epg_pa[nd->nd_bextpg]); + nd->nd_bextpgsiz = PAGE_SIZE; + } else { + if (clflg) + NFSMCLGET(mp, M_WAITOK); + else + NFSMGET(mp); + mp->m_len = 0; + mlen = M_TRAILINGSPACE(mp); + mcp = mtod(mp, char *); + mp2->m_next = mp; + mp2 = mp; + } } xfer = (left > mlen) ? mlen : left; -#ifdef notdef - /* Not Yet.. */ - if (uiop->uio_iov->iov_op != NULL) - (*(uiop->uio_iov->iov_op)) - (uiocp, mtod(mp, caddr_t) + mp->m_len, - xfer); - else -#endif if (uiop->uio_segflg == UIO_SYSSPACE) - NFSBCOPY(uiocp, mtod(mp, caddr_t) + mp->m_len, - xfer); + NFSBCOPY(uiocp, mcp, xfer); else - copyin(uiocp, mtod(mp, caddr_t) + mp->m_len, xfer); + copyin(uiocp, mcp, xfer); mp->m_len += xfer; left -= xfer; uiocp += xfer; + mcp += xfer; + if ((nd->nd_flag & ND_EXTPG) != 0) { + nd->nd_bextpgsiz -= xfer; + mp->m_epg_last_len += xfer; + } uiop->uio_offset += xfer; uiop->uio_resid -= xfer; } @@ -117,18 +128,30 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *ui siz -= uiosiz; } if (rem > 0) { - if (rem > M_TRAILINGSPACE(mp)) { + if ((nd->nd_flag & ND_EXTPG) == 0 && rem > + M_TRAILINGSPACE(mp)) { NFSMGET(mp); mp->m_len = 0; mp2->m_next = mp; + mcp = mtod(mp, char *); + } else if ((nd->nd_flag & ND_EXTPG) != 0 && rem > + nd->nd_bextpgsiz) { + mp = nfsm_add_ext_pgs(mp, nd->nd_maxextsiz, + &nd->nd_bextpg); + mcp = (char *)(void *) + PHYS_TO_DMAP(mp->m_epg_pa[nd->nd_bextpg]); + nd->nd_bextpgsiz = PAGE_SIZE; } - cp = mtod(mp, caddr_t) + mp->m_len; for (left = 0; left < rem; left++) - *cp++ = '\0'; + *mcp++ = '\0'; mp->m_len += rem; - nd->nd_bpos = cp; + nd->nd_bpos = mcp; + if ((nd->nd_flag & ND_EXTPG) != 0) { + nd->nd_bextpgsiz -= rem; + mp->m_epg_last_len += rem; + } } else - nd->nd_bpos = mtod(mp, caddr_t) + mp->m_len; + nd->nd_bpos = mcp; nd->nd_mb = mp; }