diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2023-11-14 22:48:47 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2023-11-16 20:10:30 +0000 |
commit | 318c56714aa8c170132ebe008f52904e0f119b5f (patch) | |
tree | 18a13a62433ff6a7d3d44a1746eba712875f26cd | |
parent | 884eeff20ce91ff9fd5cd0a1766e094dcb15b463 (diff) | |
download | src-318c56714aa8c170132ebe008f52904e0f119b5f.tar.gz src-318c56714aa8c170132ebe008f52904e0f119b5f.zip |
-rw-r--r-- | sys/fs/fuse/fuse_vnops.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index 3249e5988801..aead188276ec 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -879,23 +879,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) |