From owner-svn-src-projects@freebsd.org Sun Oct 20 01:09:15 2019 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 2378C15B799 for ; Sun, 20 Oct 2019 01:09:15 +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) server-signature RSA-PSS (4096 bits) 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 46whVz062tz3M8d; Sun, 20 Oct 2019 01:09:15 +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 C11392E59; Sun, 20 Oct 2019 01:09:14 +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 x9K19E4F097171; Sun, 20 Oct 2019 01:09:14 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9K19ETn097170; Sun, 20 Oct 2019 01:09:14 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201910200109.x9K19ETn097170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Sun, 20 Oct 2019 01:09:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r353772 - projects/nfsv42/sys/fs/nfsserver X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/nfsv42/sys/fs/nfsserver X-SVN-Commit-Revision: 353772 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.29 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: Sun, 20 Oct 2019 01:09:15 -0000 Author: rmacklem Date: Sun Oct 20 01:09:14 2019 New Revision: 353772 URL: https://svnweb.freebsd.org/changeset/base/353772 Log: Replace the two sysctls with one to enable a Linux compatible NFSv4.2 server. To be compatible with the NFSv4.2 client shipping in the 5.n Linux kernel, two changes in behaviour are currently required. Replace the two sysctls that enable these with the single sysctl vfs.nfsd.linux42server to minimize confusion over what needs to be done to be Linux compatible. There may also be more of these behaviour changes that have not yet been found during interoperability testing with Linux. Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Sat Oct 19 21:44:33 2019 (r353771) +++ projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Sun Oct 20 01:09:14 2019 (r353772) @@ -77,13 +77,10 @@ SYSCTL_INT(_vfs_nfsd, OID_AUTO, async, CTLFLAG_RW, &nf extern int nfsrv_doflexfile; SYSCTL_INT(_vfs_nfsd, OID_AUTO, default_flexfile, CTLFLAG_RW, &nfsrv_doflexfile, 0, "Make Flex File Layout the default for pNFS"); -static int nfsrv_linuxseekdata = 1; -SYSCTL_INT(_vfs_nfsd, OID_AUTO, linuxseekdata, CTLFLAG_RW, - &nfsrv_linuxseekdata, 0, "Return EINVAL for SEEK_DATA at EOF"); -static int nfsrv_checkcopysize = 0; -SYSCTL_INT(_vfs_nfsd, OID_AUTO, checkcopysize, CTLFLAG_RW, - &nfsrv_checkcopysize, 0, - "Enable check for Copy inoff + len > file_size"); +static int nfsrv_linux42server = 1; +SYSCTL_INT(_vfs_nfsd, OID_AUTO, linux42server, CTLFLAG_RW, + &nfsrv_linux42server, 0, + "Enable Linux style NFSv4.2 server (non-RFC compliant)"); /* * This list defines the GSS mechanisms supported. @@ -5359,15 +5356,15 @@ nfsrvd_copy_file_range(struct nfsrv_descript *nd, __un * leave len == 0. */ len = at.na_size - inoff; - } else if (nfsrv_checkcopysize != 0 && + } else if (nfsrv_linux42server == 0 && inoff + len > at.na_size) { /* * RFC-7862 says that NFSERR_INVAL must * be returned when inoff + len exceeds * the file size, however the NFSv4.2 * Linux client likes to do this, so - * only check if nfsrv_checkcopysize - * is set. + * only check if nfsrv_linux42server + * is not set. */ nd->nd_repstat = NFSERR_INVAL; } @@ -5480,7 +5477,7 @@ nfsrvd_seek(struct nfsrv_descript *nd, __unused int is nd->nd_cred, curthread); vrele(vp); if (nd->nd_repstat == 0 && eof && content == NFSV4CONTENT_DATA && - nfsrv_linuxseekdata != 0) + nfsrv_linux42server != 0) nd->nd_repstat = NFSERR_INVAL; if (nd->nd_repstat == 0) { NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED + NFSX_HYPER); From owner-svn-src-projects@freebsd.org Wed Oct 23 01:29:10 2019 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 68EB016A733 for ; Wed, 23 Oct 2019 01:29:10 +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) server-signature RSA-PSS (4096 bits) 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 46yXpZ27hrz4V5V; Wed, 23 Oct 2019 01:29:10 +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 28C591D046; Wed, 23 Oct 2019 01:29:10 +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 x9N1TASh086463; Wed, 23 Oct 2019 01:29:10 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9N1T9sF086461; Wed, 23 Oct 2019 01:29:09 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201910230129.x9N1T9sF086461@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 23 Oct 2019 01:29:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r353910 - projects/nfsv42/sys/fs/nfsclient X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/nfsv42/sys/fs/nfsclient X-SVN-Commit-Revision: 353910 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.29 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: Wed, 23 Oct 2019 01:29:10 -0000 Author: rmacklem Date: Wed Oct 23 01:29:09 2019 New Revision: 353910 URL: https://svnweb.freebsd.org/changeset/base/353910 Log: Add a flag for Advise not supported and fix Copy for length == 0. When an NFSv4.2 reports that the Advise operation is not supported, note that so that no more Advise operations will be attempted for the mount. For Copy where the NFSv4.2 server replies a copied length == 0, fix the client so that it recognizes this as "at EOF". This will not normally happen, since the client clips the requested copy length at EOF, however if another client truncates the file, this could happen for a Linux style NFSv4.2 server. Modified: projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c projects/nfsv42/sys/fs/nfsclient/nfsmount.h Modified: projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c Wed Oct 23 01:11:25 2019 (r353909) +++ projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c Wed Oct 23 01:29:09 2019 (r353910) @@ -3475,12 +3475,21 @@ nfs_advise(struct vop_advise_args *ap) else len = ap->a_end - ap->a_start + 1; nmp = VFSTONFS(ap->a_vp->v_mount); + mtx_lock(&nmp->nm_mtx); if (!NFSHASNFSV4(nmp) || nmp->nm_minorvers < NFSV42_MINORVERSION || (NFSHASPNFS(nmp) && (nmp->nm_privflag & NFSMNTP_IOADVISETHRUMDS) == - 0)) + 0) || (nmp->nm_privflag & NFSMNTP_NOADVISE) != 0) { + mtx_unlock(&nmp->nm_mtx); return (0); - nfsrpc_advise(ap->a_vp, ap->a_start, len, ap->a_advice, + } + mtx_unlock(&nmp->nm_mtx); + error = nfsrpc_advise(ap->a_vp, ap->a_start, len, ap->a_advice, td->td_ucred, td); + if (error == NFSERR_NOTSUPP) { + mtx_lock(&nmp->nm_mtx); + nmp->nm_privflag |= NFSMNTP_NOADVISE; + mtx_unlock(&nmp->nm_mtx); + } return (0); } @@ -3533,10 +3542,11 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a struct vnode *outvp = ap->a_outvp; struct mount *mp; struct nfsvattr innfsva, outnfsva; + struct vattr *vap; struct uio io; struct nfsmount *nmp; - size_t len, len2; - int error, inattrflag, outattrflag, ret; + size_t len, len2, copiedlen; + int error, inattrflag, outattrflag, ret, ret2; off_t inoff, outoff; bool consecutive, must_commit, tryoutcred; @@ -3610,6 +3620,24 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a outoff = *ap->a_outoffp; tryoutcred = true; must_commit = false; + if (error == 0) { + vap = &VTONFS(invp)->n_vattr.na_vattr; + error = VOP_GETATTR(invp, vap, ap->a_incred); + if (error == 0) { + /* + * Clip "len" at va_size so that RFC compliant servers + * will not reply NFSERR_INVAL. + * Setting "len == 0" for the RPC would be preferred, + * but some Linux servers do not support that, + */ + if (inoff >= vap->va_size) + *ap->a_lenp = len = 0; + else if (inoff + len > vap->va_size) + *ap->a_lenp = len = vap->va_size - inoff; + } else + error = 0; + } + copiedlen = 0; while (len > 0 && error == 0) { inattrflag = outattrflag = 0; len2 = len; @@ -3623,27 +3651,12 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a outvp, ap->a_outoffp, &len2, ap->a_flags, &inattrflag, &innfsva, &outattrflag, &outnfsva, ap->a_incred, consecutive, &must_commit); - if (inattrflag != 0) { + if (inattrflag != 0) ret = nfscl_loadattrcache(&invp, &innfsva, NULL, NULL, 0, 1); - if (error == 0 && ret != 0) - error = ret; - } - if (outattrflag != 0) { - ret = nfscl_loadattrcache(&outvp, &outnfsva, NULL, NULL, - 1, 1); - if (error == 0 && ret != 0) - error = ret; - } - if (error == 0 && len2 == 0) { - /* - * Some Linux NFSv4.2 servers can reply NFS_OK, but - * with a copied length (wr_count) == 0 when the - * offset + len is past EOF. (RFC-7862 requires a - * reply of NFS4ERR_INVAL for this case.) - */ - error = NFSERR_INVAL; - } + if (outattrflag != 0) + ret2 = nfscl_loadattrcache(&outvp, &outnfsva, NULL, + NULL, 1, 1); if (error == 0) { if (consecutive == false) { if (len2 == len) { @@ -3654,10 +3667,24 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a } else error = NFSERR_OFFLOADNOREQS; } - len -= len2; + /* + * If the Copy returns a length == 0, it hit the + * EOF on the input file. + */ + if (len2 == 0) { + *ap->a_lenp = copiedlen; + len = 0; + } else { + len -= len2; + copiedlen += len2; + } if (len == 0 && must_commit && error == 0) error = ncl_commit(outvp, outoff, *ap->a_lenp, ap->a_outcred, curthread); + if (error == 0 && ret != 0) + error = ret; + if (error == 0 && ret2 != 0) + error = ret2; } else if (error == NFSERR_OFFLOADNOREQS && consecutive) { /* * Try consecutive == false, which is ok only if all Modified: projects/nfsv42/sys/fs/nfsclient/nfsmount.h ============================================================================== --- projects/nfsv42/sys/fs/nfsclient/nfsmount.h Wed Oct 23 01:11:25 2019 (r353909) +++ projects/nfsv42/sys/fs/nfsclient/nfsmount.h Wed Oct 23 01:29:09 2019 (r353910) @@ -111,6 +111,7 @@ struct nfsmount { #define NFSMNTP_SEEK 0x00000020 #define NFSMNTP_SEEKTESTED 0x00000040 #define NFSMNTP_NOXATTR 0x00000080 +#define NFSMNTP_NOADVISE 0x00000100 #define NFSMNT_DIRPATH(m) (&((m)->nm_name[(m)->nm_krbnamelen + 1])) #define NFSMNT_SRVKRBNAME(m) \ From owner-svn-src-projects@freebsd.org Wed Oct 23 03:15:28 2019 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 8C17416C91D for ; Wed, 23 Oct 2019 03:15:28 +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) server-signature RSA-PSS (4096 bits) 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 46yb9D38xtz4Z8k; Wed, 23 Oct 2019 03:15:28 +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 504C61E435; Wed, 23 Oct 2019 03:15:28 +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 x9N3FSNb052161; Wed, 23 Oct 2019 03:15:28 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9N3FSBq052160; Wed, 23 Oct 2019 03:15:28 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201910230315.x9N3FSBq052160@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 23 Oct 2019 03:15:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r353913 - projects/nfsv42/sys/fs/nfsclient X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/nfsv42/sys/fs/nfsclient X-SVN-Commit-Revision: 353913 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.29 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: Wed, 23 Oct 2019 03:15:28 -0000 Author: rmacklem Date: Wed Oct 23 03:15:27 2019 New Revision: 353913 URL: https://svnweb.freebsd.org/changeset/base/353913 Log: Fix typo in comment. Modified: projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c Modified: projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c Wed Oct 23 02:15:15 2019 (r353912) +++ projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c Wed Oct 23 03:15:27 2019 (r353913) @@ -3628,7 +3628,7 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a * Clip "len" at va_size so that RFC compliant servers * will not reply NFSERR_INVAL. * Setting "len == 0" for the RPC would be preferred, - * but some Linux servers do not support that, + * but some Linux servers do not support that. */ if (inoff >= vap->va_size) *ap->a_lenp = len = 0; From owner-svn-src-projects@freebsd.org Thu Oct 24 02:25:34 2019 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 A8BF917191C for ; Thu, 24 Oct 2019 02:25:34 +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) server-signature RSA-PSS (4096 bits) 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 46zB1B418lz4776; Thu, 24 Oct 2019 02:25:34 +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 6CB9373CF; Thu, 24 Oct 2019 02:25:34 +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 x9O2PYHL081365; Thu, 24 Oct 2019 02:25:34 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2PYB5081362; Thu, 24 Oct 2019 02:25:34 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201910240225.x9O2PYB5081362@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Thu, 24 Oct 2019 02:25:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r353970 - projects/nfsv42/sys/fs/nfsclient X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/nfsv42/sys/fs/nfsclient X-SVN-Commit-Revision: 353970 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.29 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, 24 Oct 2019 02:25:34 -0000 Author: rmacklem Date: Thu Oct 24 02:25:33 2019 New Revision: 353970 URL: https://svnweb.freebsd.org/changeset/base/353970 Log: Add a flag to disable client side Allocate when the server replies NFSERR_NOTSUPP. If the server replies NFSERR_NOTSUPP for an Allocate operation, set a flag so that the client does not try Allocate on the mount again. Also, add a ncl_flush() call before the Allocate operation to ensure that additional storage on top of all writes is allocated. Modified: projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c projects/nfsv42/sys/fs/nfsclient/nfsmount.h Modified: projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c Thu Oct 24 02:25:30 2019 (r353969) +++ projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c Thu Oct 24 02:25:33 2019 (r353970) @@ -3507,15 +3507,30 @@ nfs_allocate(struct vop_allocate_args *ap) attrflag = 0; nmp = VFSTONFS(vp->v_mount); - if (NFSHASNFSV4(nmp) && nmp->nm_minorvers >= NFSV42_MINORVERSION) { - error = nfsrpc_allocate(vp, *ap->a_offset, *ap->a_len, &nfsva, - &attrflag, td->td_ucred, td, NULL); + mtx_lock(&nmp->nm_mtx); + if (NFSHASNFSV4(nmp) && nmp->nm_minorvers >= NFSV42_MINORVERSION && + (nmp->nm_privflag & NFSMNTP_NOALLOCATE) == 0) { + mtx_unlock(&nmp->nm_mtx); + /* + * Flush first to ensure that the allocate adds to the + * file's allocation on the server. + */ + error = ncl_flush(vp, MNT_WAIT, td, 1, 0); + if (error == 0) + error = nfsrpc_allocate(vp, *ap->a_offset, *ap->a_len, + &nfsva, &attrflag, td->td_ucred, td, NULL); if (error == 0) { *ap->a_offset += *ap->a_len; *ap->a_len = 0; + } else if (error == NFSERR_NOTSUPP) { + mtx_lock(&nmp->nm_mtx); + nmp->nm_privflag |= NFSMNTP_NOALLOCATE; + mtx_unlock(&nmp->nm_mtx); } - } else + } else { + mtx_unlock(&nmp->nm_mtx); error = EIO; + } /* * If the NFS server cannot perform the Allocate operation, just call * vop_stdallocate() to perform it. Modified: projects/nfsv42/sys/fs/nfsclient/nfsmount.h ============================================================================== --- projects/nfsv42/sys/fs/nfsclient/nfsmount.h Thu Oct 24 02:25:30 2019 (r353969) +++ projects/nfsv42/sys/fs/nfsclient/nfsmount.h Thu Oct 24 02:25:33 2019 (r353970) @@ -112,6 +112,7 @@ struct nfsmount { #define NFSMNTP_SEEKTESTED 0x00000040 #define NFSMNTP_NOXATTR 0x00000080 #define NFSMNTP_NOADVISE 0x00000100 +#define NFSMNTP_NOALLOCATE 0x00000200 #define NFSMNT_DIRPATH(m) (&((m)->nm_name[(m)->nm_krbnamelen + 1])) #define NFSMNT_SRVKRBNAME(m) \ From owner-svn-src-projects@freebsd.org Fri Oct 25 04:44:17 2019 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 E0AD2165F9A for ; Fri, 25 Oct 2019 04:44:17 +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) server-signature RSA-PSS (4096 bits) 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 46zs2n5dhLz43DN; Fri, 25 Oct 2019 04:44:17 +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 A45B721378; Fri, 25 Oct 2019 04:44:17 +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 x9P4iHSC043332; Fri, 25 Oct 2019 04:44:17 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9P4iH0Y043331; Fri, 25 Oct 2019 04:44:17 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201910250444.x9P4iH0Y043331@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 25 Oct 2019 04:44:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r354061 - projects/nfsv42/sys/fs/nfsserver X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/nfsv42/sys/fs/nfsserver X-SVN-Commit-Revision: 354061 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.29 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: Fri, 25 Oct 2019 04:44:17 -0000 Author: rmacklem Date: Fri Oct 25 04:44:17 2019 New Revision: 354061 URL: https://svnweb.freebsd.org/changeset/base/354061 Log: Return the correct error for Seek at EOF. The Linux NFSv4.2 client expects an NFSERR_NXIO error to be returned when a NFS4_CONTENT_DATA request with sa_offset == file_size is done for Seek. (This is not actually what RFC-7862 says is the correct reply for this operation request, so it is only done when vfs.nfsd.linux42server is set.) Anyhow, without this patch the code erroeously returned NFSERR_INVAL. Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Fri Oct 25 01:10:08 2019 (r354060) +++ projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Fri Oct 25 04:44:17 2019 (r354061) @@ -5478,7 +5478,7 @@ nfsrvd_seek(struct nfsrv_descript *nd, __unused int is vrele(vp); if (nd->nd_repstat == 0 && eof && content == NFSV4CONTENT_DATA && nfsrv_linux42server != 0) - nd->nd_repstat = NFSERR_INVAL; + nd->nd_repstat = NFSERR_NXIO; if (nd->nd_repstat == 0) { NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED + NFSX_HYPER); if (eof)