Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Oct 2021 21:31:10 GMT
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 235891a1273d - main - nfscl: Fix NFS VOP_ALLOCATE for mounts without Allocate support
Message-ID:  <202110102131.19ALVAYb076011@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=235891a1273d99b86784f935d2d6c554ce189559

commit 235891a1273d99b86784f935d2d6c554ce189559
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-10-10 21:27:52 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-10-10 21:27:52 +0000

    nfscl: Fix NFS VOP_ALLOCATE for mounts without Allocate support
    
    Without this patch, nfs_allocate() fell back on using vop_stdallocate()
    for NFS mounts without Allocate operation support.  This was incorrect,
    since some file systems, such as ZFS, cannot do allocate via
    vop_stdallocate(), which uses writes to try and allocate blocks.
    
    Also, fix nfs_allocate() to return EINVAL when mounts cannot do Allocate,
    since that is the correct error for posix_fallocate(2).
    Note that Allocate is only supported by some NFSv4.2 servers.
    
    MFC after:      2 weeks
---
 sys/fs/nfsclient/nfs_clvnops.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 0b60100d1fc9..3e444780eb24 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -3671,17 +3671,12 @@ nfs_allocate(struct vop_allocate_args *ap)
 			mtx_lock(&nmp->nm_mtx);
 			nmp->nm_privflag |= NFSMNTP_NOALLOCATE;
 			mtx_unlock(&nmp->nm_mtx);
+			error = EINVAL;
 		}
 	} else {
 		mtx_unlock(&nmp->nm_mtx);
-		error = EIO;
+		error = EINVAL;
 	}
-	/*
-	 * If the NFS server cannot perform the Allocate operation, just call
-	 * vop_stdallocate() to perform it.
-	 */
-	if (error != 0)
-		error = vop_stdallocate(ap);
 	if (attrflag != 0) {
 		ret = nfscl_loadattrcache(&vp, &nfsva, NULL, NULL, 0, 1);
 		if (error == 0 && ret != 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110102131.19ALVAYb076011>