From owner-svn-src-projects@freebsd.org Thu Jul 9 00:34:08 2020 Return-Path: Delivered-To: svn-src-projects@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 EFEF735A391 for ; Thu, 9 Jul 2020 00:34:08 +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 4B2HH464Z9z4GyJ; Thu, 9 Jul 2020 00:34: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 B40F78DD1; Thu, 9 Jul 2020 00:34: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 0690Y8EX089996; Thu, 9 Jul 2020 00:34:08 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0690Y8Yd089993; Thu, 9 Jul 2020 00:34:08 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <202007090034.0690Y8Yd089993@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Thu, 9 Jul 2020 00:34:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r363033 - in projects/nfs-over-tls/sys/fs: nfs nfsclient X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in projects/nfs-over-tls/sys/fs: nfs nfsclient X-SVN-Commit-Revision: 363033 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jul 2020 00:34:09 -0000 Author: rmacklem Date: Thu Jul 9 00:34:07 2020 New Revision: 363033 URL: https://svnweb.freebsd.org/changeset/base/363033 Log: Essentially revert changes done to nfsm_uiombuflist() to what is in head/. The changes allowed the mbuf list to be created using ext_pgs mbufs. This is used for doing writing to mirrored DSs. However, these writes require that part of the mbuf list be copied (by nfsm_copym()) and m_copym() cannot do this for ext_pgs mbufs. The work to patch m_copym() to do partial copies of ext_pgs mbuf lists is non-trivial, so I am not doing it at this time. This does mean that the write requests will be in mbuf clusters and will need to be copied in the krpc before sosend() for TLS connections, but will work correctly. Modified: projects/nfs-over-tls/sys/fs/nfs/nfs_var.h projects/nfs-over-tls/sys/fs/nfsclient/nfs_clcomsubs.c projects/nfs-over-tls/sys/fs/nfsclient/nfs_clrpcops.c Modified: projects/nfs-over-tls/sys/fs/nfs/nfs_var.h ============================================================================== --- projects/nfs-over-tls/sys/fs/nfs/nfs_var.h Wed Jul 8 21:40:27 2020 (r363032) +++ projects/nfs-over-tls/sys/fs/nfs/nfs_var.h Thu Jul 9 00:34:07 2020 (r363033) @@ -363,7 +363,7 @@ void nfsm_set(struct nfsrv_descript *, u_int); /* nfs_clcomsubs.c */ void nfsm_uiombuf(struct nfsrv_descript *, struct uio *, int); -struct mbuf *nfsm_uiombuflist(bool, int, struct uio *, int, struct mbuf **, char **); +struct mbuf *nfsm_uiombuflist(struct uio *, int, struct mbuf **, char **); nfsuint64 *nfscl_getcookie(struct nfsnode *, off_t off, int); u_int8_t *nfscl_getmyip(struct nfsmount *, struct in6_addr *, int *); int nfsm_getfh(struct nfsrv_descript *, struct nfsfh **); Modified: projects/nfs-over-tls/sys/fs/nfsclient/nfs_clcomsubs.c ============================================================================== --- projects/nfs-over-tls/sys/fs/nfsclient/nfs_clcomsubs.c Wed Jul 8 21:40:27 2020 (r363032) +++ projects/nfs-over-tls/sys/fs/nfsclient/nfs_clcomsubs.c Thu Jul 9 00:34:07 2020 (r363033) @@ -156,24 +156,20 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *ui /* * copies a uio scatter/gather list to an mbuf chain. * This version returns the mbuf list and does not use "nd". - * It allocates mbuf(s) of NFSM_RNDUP(siz) and ensures that - * it is nul padded to a multiple of 4 bytes. - * Since mbufs are allocated by this function, they will - * always have space for an exact multiple of 4 bytes in - * each mbuf. This implies that the nul padding can be - * safely done without checking for available space in - * the mbuf data area (or page for M_EXTPG mbufs). * NOTE: can ony handle iovcnt == 1 + * This function is used to create an mbuf list for doing writing to + * mirrored flexfile DSs. + * It cannot be modified to optionally support ext_pgs mbufs until + * nfsm_copym() is converted to work for ext_pgs mbufs. */ struct mbuf * -nfsm_uiombuflist(bool doextpgs, int maxextsiz, struct uio *uiop, int siz, - struct mbuf **mbp, char **cpp) +nfsm_uiombuflist(struct uio *uiop, int siz, struct mbuf **mbp, char **cpp) { char *uiocp; struct mbuf *mp, *mp2, *firstmp; - int i, left, mlen, rem, xfer; - int uiosiz, clflg, bextpg, bextpgsiz = 0; - char *mcp, *tcp; + int xfer, left, mlen; + int uiosiz, clflg; + char *tcp; KASSERT(uiop->uio_iovcnt == 1, ("nfsm_uiotombuf: iovcnt != 1")); @@ -181,21 +177,11 @@ nfsm_uiombuflist(bool doextpgs, int maxextsiz, struct clflg = 1; else clflg = 0; - rem = NFSM_RNDUP(siz) - siz; - if (doextpgs) { - mp = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK); - mcp = (char *)(void *) - PHYS_TO_DMAP(mp->m_epg_pa[0]); - bextpgsiz = PAGE_SIZE; - bextpg = 0; - } else { - if (clflg != 0) - NFSMCLGET(mp, M_WAITOK); - else - NFSMGET(mp); - mp->m_len = 0; - mcp = mtod(mp, char *); - } + if (clflg != 0) + NFSMCLGET(mp, M_WAITOK); + else + NFSMGET(mp); + mp->m_len = 0; firstmp = mp2 = mp; while (siz > 0) { left = uiop->uio_iov->iov_len; @@ -204,42 +190,27 @@ nfsm_uiombuflist(bool doextpgs, int maxextsiz, struct left = siz; uiosiz = left; while (left > 0) { - if (doextpgs) - mlen = bextpgsiz; - else - mlen = M_TRAILINGSPACE(mp); + mlen = M_TRAILINGSPACE(mp); if (mlen == 0) { - if (doextpgs) { - mp = nfsm_add_ext_pgs(mp, maxextsiz, - &bextpg); - mcp = (char *)(void *)PHYS_TO_DMAP( - mp->m_epg_pa[bextpg]); - mlen = bextpgsiz = PAGE_SIZE; - } else { - if (clflg) - NFSMCLGET(mp, M_WAITOK); - else - NFSMGET(mp); - mp->m_len = 0; - mcp = mtod(mp, char *); - mlen = M_TRAILINGSPACE(mp); - mp2->m_next = mp; - mp2 = mp; - } + if (clflg) + NFSMCLGET(mp, M_WAITOK); + else + NFSMGET(mp); + mp->m_len = 0; + mp2->m_next = mp; + mp2 = mp; + mlen = M_TRAILINGSPACE(mp); } xfer = (left > mlen) ? mlen : left; if (uiop->uio_segflg == UIO_SYSSPACE) - NFSBCOPY(uiocp, mcp, xfer); + NFSBCOPY(uiocp, mtod(mp, caddr_t) + + mp->m_len, xfer); else - copyin(uiocp, mcp, xfer); + copyin(uiocp, mtod(mp, caddr_t) + + mp->m_len, xfer); mp->m_len += xfer; left -= xfer; uiocp += xfer; - mcp += xfer; - if (doextpgs) { - bextpgsiz -= xfer; - mp->m_epg_last_len += xfer; - } uiop->uio_offset += xfer; uiop->uio_resid -= xfer; } @@ -249,14 +220,8 @@ nfsm_uiombuflist(bool doextpgs, int maxextsiz, struct uiop->uio_iov->iov_len -= uiosiz; siz -= uiosiz; } - for (i = 0; i < rem; i++) { - *mcp++ = '\0'; - mp->m_len++; - if (doextpgs) - mp->m_epg_last_len++; - } if (cpp != NULL) - *cpp = mcp; + *cpp = mtod(mp, caddr_t) + mp->m_len; if (mbp != NULL) *mbp = mp; return (firstmp); Modified: projects/nfs-over-tls/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- projects/nfs-over-tls/sys/fs/nfsclient/nfs_clrpcops.c Wed Jul 8 21:40:27 2020 (r363032) +++ projects/nfs-over-tls/sys/fs/nfsclient/nfs_clrpcops.c Thu Jul 9 00:34:07 2020 (r363033) @@ -5759,11 +5759,11 @@ nfscl_doiods(vnode_t vp, struct uio *uiop, int *iomode uint32_t rwaccess, int docommit, struct ucred *cred, NFSPROC_T *p) { struct nfsnode *np = VTONFS(vp); - struct nfsmount *nmp = VFSTONFS(vnode_mount(vp)); + struct nfsmount *nmp = VFSTONFS(vp->v_mount); struct nfscllayout *layp; struct nfscldevinfo *dip; struct nfsclflayout *rflp; - struct mbuf *m, *m2; + struct mbuf *m; struct nfsclwritedsdorpc *drpc, *tdrpc; nfsv4stateid_t stateid; struct ucred *newcred; @@ -5775,11 +5775,6 @@ nfscl_doiods(vnode_t vp, struct uio *uiop, int *iomode size_t iovlen = 0; off_t offs = 0; ssize_t resid = 0; - int maxextsiz; - bool doextpgs; -#ifdef KERN_TLS - u_int maxlen; -#endif if (!NFSHASPNFS(nmp) || nfscl_enablecallb == 0 || nfs_numnfscbd == 0 || (np->n_flag & NNOLAYOUT) != 0) @@ -5873,19 +5868,8 @@ nfscl_doiods(vnode_t vp, struct uio *uiop, int *iomode iovbase = uiop->uio_iov->iov_base; iovlen = uiop->uio_iov->iov_len; - doextpgs = false; - maxextsiz = 0; -#ifdef KERN_TLS - if (NFSHASTLS(nmp) && - rpctls_getinfo(&maxlen, - false, false)) { - doextpgs = true; - maxextsiz = maxlen; - } -#endif - m = nfsm_uiombuflist(doextpgs, - maxextsiz, uiop, len, NULL, - NULL); + m = nfsm_uiombuflist(uiop, len, + NULL, NULL); } tdrpc = drpc = malloc(sizeof(*drpc) * (mirrorcnt - 1), M_TEMP, M_WAITOK | @@ -5893,12 +5877,6 @@ nfscl_doiods(vnode_t vp, struct uio *uiop, int *iomode } } for (i = firstmirror; i < mirrorcnt && error == 0; i++){ - if (m != NULL && i < mirrorcnt - 1) - m2 = m_copym(m, 0, M_COPYALL, M_WAITOK); - else { - m2 = m; - m = NULL; - } if ((layp->nfsly_flags & NFSLY_FLEXFILE) != 0) { dev = rflp->nfsfl_ffm[i].dev; dip = nfscl_getdevinfo(nmp->nm_clp, dev, @@ -5915,7 +5893,7 @@ nfscl_doiods(vnode_t vp, struct uio *uiop, int *iomode uiop, iomode, must_commit, &eof, &stateid, rwaccess, dip, layp, rflp, off, xfer, - i, docommit, m2, tdrpc, + i, docommit, m, tdrpc, newcred, p); else error = nfscl_doflayoutio(vp, @@ -5924,13 +5902,12 @@ nfscl_doiods(vnode_t vp, struct uio *uiop, int *iomode dip, layp, rflp, off, xfer, docommit, newcred, p); nfscl_reldevinfo(dip); - } else { - m_freem(m2); + } else error = EIO; - } tdrpc++; } - m_freem(m); + if (m != NULL) + m_freem(m); tdrpc = drpc; timo = hz / 50; /* Wait for 20msec. */ if (timo < 1)