git: 0f3bb3b9ee48 - stable/13 - fuse_vnop_copy_file_range(): use vn_lock_pair()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 23 Nov 2023 04:02:34 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0f3bb3b9ee48ddd9dcc2079062f27758bfb4b940 commit 0f3bb3b9ee48ddd9dcc2079062f27758bfb4b940 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-11-14 22:48:47 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-11-23 04:02:00 +0000 fuse_vnop_copy_file_range(): use vn_lock_pair() (cherry picked from commit 318c56714aa8c170132ebe008f52904e0f119b5f) --- sys/fs/fuse/fuse_vnops.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index 988e7aa3278e..0b683a7c63bd 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -880,23 +880,11 @@ fuse_vnop_copy_file_range(struct vop_copy_file_range_args *ap) td = ap->a_fsizetd; pid = td->td_proc->p_pid; - /* Lock both vnodes, avoiding risk of deadlock. */ - do { - err = vn_lock(outvp, LK_EXCLUSIVE); - if (invp == outvp) - break; - if (err == 0) { - err = vn_lock(invp, LK_SHARED | LK_NOWAIT); - if (err == 0) - break; - VOP_UNLOCK(outvp); - err = vn_lock(invp, LK_SHARED); - if (err == 0) - VOP_UNLOCK(invp); - } - } while (err == 0); - if (err != 0) - return (err); + vn_lock_pair(invp, false, LK_SHARED, outvp, false, LK_EXCLUSIVE); + if (invp->v_data == NULL || outvp->v_data == NULL) { + err = EBADF; + goto unlock; + } err = fuse_filehandle_getrw(invp, FREAD, &infufh, incred, pid); if (err)