git: 6c23d1fbeaa4 - stable/13 - 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:54:58 UTC
The branch stable/13 has been updated by kib:

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

commit 6c23d1fbeaa44f1cc4695d0a53f31b3734446730
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:44:13 +0000

    vn_copy_file_range(): provide ENOSYS fallback to vn_generic_copy_file_range()
    
    (cherry picked from commit c5405d1c850765d04f74067ebb71f57e9a26b8ea)
---
 sys/fs/fuse/fuse_vnops.c       | 7 ++-----
 sys/fs/nfsclient/nfs_clvnops.c | 4 +---
 sys/kern/vfs_vnops.c           | 2 ++
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c
index 6871461d26f1..6de23cf71cf3 100644
--- a/sys/fs/fuse/fuse_vnops.c
+++ b/sys/fs/fuse/fuse_vnops.c
@@ -862,6 +862,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;
 
@@ -944,13 +945,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 3e9daad09706..02449e64e508 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -3813,9 +3813,7 @@ nfs_copy_file_range(struct vop_copy_file_range_args *ap)
 	/* NFSv4.2 Copy is not permitted for infile == outfile. */
 	if (invp == outvp) {
 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 e37518ebaaa1..e720ef151c9e 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -3099,6 +3099,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);