From nobody Thu Nov 23 04:02:34 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 4SbPZz0syKz51CY5; Thu, 23 Nov 2023 04:02:35 +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 4SbPZz0RqRz4QFk; Thu, 23 Nov 2023 04:02:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700712155; 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=YdwWJA46sbZD9mUhTflv2aFdctFEn/ox9NqjfA80Tb4=; b=ubZatDqktdt4vsf9siklHK/pc/fM8fGzRO0idwwoPNh+En6CDo2BPqILiyvK2XnAn6CNdd 9Vb3vSQ+kC7zPNkVsFjJerlSrSnjIeOhixYlNBt9Jk2dEjtFfCE6nJt6B/5a5HXlcVSeO/ 4DVigJ31CrOez5i/ONH86cIKDoRJn2IUntzo56It0lS14siEBxngLT/e6Zak+wQMmz4K6K 8rNjyzpizEPWFhSXooKueP3do2TZUkHVdL1MMYadLKD+qewtR8L4unk5Wv2Ugqao8g5FKm vTp1hXn+DJ0XpMorIQUtvnQP7JexVQ71n8dSpIg+oCj3IcCC+QlretRWzGRx+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700712155; 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=YdwWJA46sbZD9mUhTflv2aFdctFEn/ox9NqjfA80Tb4=; b=ofk8KMAeRjEEV7x65AfAtscuIVJknmn6+NDW/ymSXRaLHvl9XlfQwwFg2pOmvlihmM7WcP 0Rky4IAyGMNktWlh75J87TgKVg/mGS6kyVNj95bLtJi/GeFK6op99mT7J87XKiUmd6ee1s DPyfeQdECA590jC7DHoabDnO5Hj0pPXTMnRiutmC9dIi65kJPG8vNFDwUE5j2/uQEVRjAd cPQrogYxNZj3Bc9h91yNCCVnCCPPKFRJ1TE84ktXVOfvhvbS8G8ANurJ+90ircvP5BYmlj 3gnB8ldF504EzB8dK8Rq+/ilJ1BCS2wCKiJz/Etvg2wyVtNxPGWSCYbWNk1M0w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700712155; a=rsa-sha256; cv=none; b=wo03hEfY47URZeDFGDXMm13+p6zecKUnls+NkbXIPtMuwE/IWK7Pm6c3agwBJH7R67KRBn IjhyuYYYfk/93ez/bvoai7nw940b5zNVLwqgNjCP2z+YDjhhAfViZPrRiX6BF4jSnY93Fv RxCAwMvTwIGFImaXwv9y5IayJARxZ4WvyDzolZUUAZ6AY25SgXg5BceSPWv3F2nmSzUQJ/ rjGn6JFK1YZdfPUsf9s6fDH7EIpL8nj7VHj5JpZM7gC3YnCnK5bfU2HLIYs7fseh+utxyy SyKIQkoORkqTTSniLP9kELoRpp2LbDfTnH12DWMbfhIhkDtJDx1feWlPBzJgfQ== 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 4SbPZy6XHTzmfy; Thu, 23 Nov 2023 04:02:34 +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 3AN42YQh005511; Thu, 23 Nov 2023 04:02:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AN42YKS005508; Thu, 23 Nov 2023 04:02:34 GMT (envelope-from git) Date: Thu, 23 Nov 2023 04:02:34 GMT Message-Id: <202311230402.3AN42YKS005508@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 0f3bb3b9ee48 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 0f3bb3b9ee48ddd9dcc2079062f27758bfb4b940 Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0f3bb3b9ee48ddd9dcc2079062f27758bfb4b940 commit 0f3bb3b9ee48ddd9dcc2079062f27758bfb4b940 Author: Konstantin Belousov AuthorDate: 2023-11-14 22:48:47 +0000 Commit: Konstantin Belousov 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)