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) \