From nobody Thu Nov 16 20:11:49 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SWWQZ1TMBz513Hq; Thu, 16 Nov 2023 20:11:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SWWQZ0Yjyz3dt8; Thu, 16 Nov 2023 20:11:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700165510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YUwEJbxn7ttaty9UzVgjVrjD6k98SsZXaBRu8UODi0A=; b=nd7fwZ1zRunXBOiySHjrvZI10g2kViFPt0Jy0Eem5vso3Vm487XJemPm1qE6u9fkOFyPK3 HKfMscAKl4Iwm6uiumsSUTzWKKmyc9AHf5XyRRMxnJb5YK5VHefvg96Y4zOqd8iqPpk3i6 ++pZ2MldhVhla9TBBeM0iER++gkRVSzQJjrXMHI8zbZ0ZWfqPSVBKUZW/NcGHnfYSyScEc LInMSGbLGKpMJqUAO66CtfUZtTE6QPHSguXN5cMYWQ+F9grvP03f6Dlrv2NuGdUaQ5wRYN eZGOpsJzSmCmVYLGMcI+GkUsf0GmztZN9WA6w6cXqITXzz3nj3UAXb1R9ARBcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700165510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YUwEJbxn7ttaty9UzVgjVrjD6k98SsZXaBRu8UODi0A=; b=gvqDVDbOeOh7vKt9rEQ8maxOdWFrz5tFpDmP6XyBqc8FhVmLZ4vGDZAoURXM8PN83Ztb8D EK9GBEo6mkUD3XYUkuDsCSVa0UD3xN99C6rWoWGyKeu1I55+qnLAKRmycNWrUTj0Ow+7d8 FXPtTstUe9PiHm4TIhRn4/dag+PqFVwrDWSBkp6FK79m0wlb6+OFSLdOUyk8ahcrlufeA3 /IOVyZ0dfZx67ntAGSOubjWCOHyxZkhCEC8MTnzCm3dGyApLGeNnCn346foB3qOFtSuWr8 Ci+Gs+jF4nSO3TGJ5lPQqL+U6V3PXGx0339ORJHZiD0WvKjfY6yintRvpM2gmQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700165510; a=rsa-sha256; cv=none; b=LEL4k0C/d4UOAuXca7HQhMWLUdC+hxp+PQbf7mp1MaWhEsZZCPAdljCnbVJNOMocz1CvOs 8BP1r4OouZ9VStgRdviXg+v6vntxfEWNCOwR092QHYUeIUE2AGt+mQYs6dMy2f8ATQXnSJ zt/PiT6u/RDiHu5AK5f5uo5/J3mxJSq0+V9O+kzT5cdTiX3PyNP2xYHGElAlvvMatNDaqF sSONghuqVAF9CKHMMT2oxcsxr/fcfT2UJuKlDAgC2rK6WHwnsf+tVFgVNbvBJM+qSCKUES AMtIHXUPE9IaIPALAp3ucMicO8j3uUq7AetmxGxv3eSPNay7VOnd62hvmnB2bQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SWWQY6kSfz1Cjk; Thu, 16 Nov 2023 20:11:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AGKBnhG082624; Thu, 16 Nov 2023 20:11:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AGKBnLY082621; Thu, 16 Nov 2023 20:11:49 GMT (envelope-from git) Date: Thu, 16 Nov 2023 20:11:49 GMT Message-Id: <202311162011.3AGKBnLY082621@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 318c56714aa8 - main - fuse_vnop_copy_file_range(): use vn_lock_pair() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 318c56714aa8c170132ebe008f52904e0f119b5f Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=318c56714aa8c170132ebe008f52904e0f119b5f commit 318c56714aa8c170132ebe008f52904e0f119b5f Author: Konstantin Belousov AuthorDate: 2023-11-14 22:48:47 +0000 Commit: Konstantin Belousov CommitDate: 2023-11-16 20:10:30 +0000 fuse_vnop_copy_file_range(): use vn_lock_pair() Reviewed by: asomers, jah Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42625 --- 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 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)