svn commit: r353970 - projects/nfsv42/sys/fs/nfsclient
Rick Macklem
rmacklem at FreeBSD.org
Thu Oct 24 02:25:34 UTC 2019
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) \
More information about the svn-src-projects
mailing list