git: c99f50351c73 - stable/14 - vn_copy_file_range(): provide ENOSYS fallback to vn_generic_copy_file_range()

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 05 Dec 2023 00:44:00 UTC
The branch stable/14 has been updated by kib:

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

commit c99f50351c7390dbd370f836361dfce0d738f566
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-11-18 08:59:19 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-12-05 00:43:27 +0000

    vn_copy_file_range(): provide ENOSYS fallback to vn_generic_copy_file_range()
    
    (cherry picked from commit c5405d1c850765d04f74067ebb71f57e9a26b8ea)
---
 sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c | 4 +---
 sys/fs/fuse/fuse_vnops.c                                 | 7 ++-----
 sys/fs/nfsclient/nfs_clvnops.c                           | 4 +---
 sys/kern/vfs_vnops.c                                     | 2 ++
 4 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c
index 05f28033be6a..3302f043620a 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c
@@ -6315,9 +6315,7 @@ bad_locked_fallback:
 bad_write_fallback:
 	if (mp != NULL)
 		vn_finished_write(mp);
-	error = vn_generic_copy_file_range(ap->a_invp, ap->a_inoffp,
-	    ap->a_outvp, ap->a_outoffp, ap->a_lenp, ap->a_flags,
-	    ap->a_incred, ap->a_outcred, ap->a_fsizetd);
+	error = ENOSYS;
 	return (error);
 }
 #endif
diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c
index b9e4e48e6dbd..9728afb66654 100644
--- a/sys/fs/fuse/fuse_vnops.c
+++ b/sys/fs/fuse/fuse_vnops.c
@@ -861,6 +861,7 @@ fuse_vnop_copy_file_range(struct vop_copy_file_range_args *ap)
 	pid_t pid;
 	int err;
 
+	err = ENOSYS;
 	if (mp == NULL || mp != vnode_mount(outvp))
 		goto fallback;
 
@@ -943,13 +944,9 @@ unlock:
 		VOP_UNLOCK(invp);
 	VOP_UNLOCK(outvp);
 
-	if (err == ENOSYS) {
+	if (err == ENOSYS)
 		fsess_set_notimpl(mp, FUSE_COPY_FILE_RANGE);
 fallback:
-		err = vn_generic_copy_file_range(ap->a_invp, ap->a_inoffp,
-		    ap->a_outvp, ap->a_outoffp, ap->a_lenp, ap->a_flags,
-		    ap->a_incred, ap->a_outcred, ap->a_fsizetd);
-	}
 
 	/*
 	 * No need to call vn_rlimit_fsizex_res before return, since the uio is
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 63cb9eaec7b7..cfb5e90739a4 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -3888,9 +3888,7 @@ nfs_copy_file_range(struct vop_copy_file_range_args *ap)
 	 */
 	if (invp == outvp || invp->v_mount != outvp->v_mount) {
 generic_copy:
-		return (vn_generic_copy_file_range(invp, ap->a_inoffp,
-		    outvp, ap->a_outoffp, ap->a_lenp, ap->a_flags,
-		    ap->a_incred, ap->a_outcred, ap->a_fsizetd));
+		return (ENOSYS);
 	}
 
 	/* Lock both vnodes, avoiding risk of deadlock. */
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 6e8a6b23eec6..e6a4b074b4e5 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -3144,6 +3144,8 @@ vn_copy_file_range(struct vnode *invp, off_t *inoffp, struct vnode *outvp,
 		error = VOP_COPY_FILE_RANGE(invpl, inoffp, outvpl, outoffp,
 		    lenp, flags, incred, outcred, fsize_td);
 	else
+		error = ENOSYS;
+	if (error == ENOSYS)
 		error = vn_generic_copy_file_range(invpl, inoffp, outvpl,
 		    outoffp, lenp, flags, incred, outcred, fsize_td);
 	vfs_unbusy(outmp);