From nobody Thu Nov 23 04:01:04 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 4SbPYD68SJz51CLZ; Thu, 23 Nov 2023 04:01:04 +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 4SbPYD5Zjhz4P8X; Thu, 23 Nov 2023 04:01:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700712064; 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=kJbKosrVjZM6/+786W7sn27/fpKfy8Mk2KGHbiNnWWE=; b=P3bezc10BznnWrI4QUPQBn5UP8nJwbopNUE67KuGLGlxPHKuJb0nJFYbRAtJimyvwYLFml GEG0yTyGJohW2Jq8IINWMOyiYj3TFVbhe4iifhDjXsO2ha/O+8oX4qF3pHqpghpWN7OOvx oIj6BqbCNqzl8TQDXaLvaBBHEhb7iPE62irUKAd7n97orbMTSzfqUS50kbWfY/yZRQwh+k PWirMkZ7BQ81R8qVqHfMEa8BV7i9WT8m9FNWiR9YY+J9Scn1oxRMAHrG501ximufcKLJvD B9SOh8TvIvZFoMa/YeUeb6jjiL71s/rZ5ARnPfw98iS4dKtjwXmE7JtaBSFDGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700712064; 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=kJbKosrVjZM6/+786W7sn27/fpKfy8Mk2KGHbiNnWWE=; b=QbhwdGI5JxMfZVBxCOAU4JIJQGT8S7OhLX0+qC3l9IluR3l012bFUANpJ13zMcJw3GQLjJ AnIJK0FUVYy3kPriVKN2GZuHlzaSZGZlEN7Mk3fFh5dStiwO9nngruUYYEHvS0C3Fg59X4 x0zjJu0KYiCPmUNw3PqWy5IlNiP1Sstzdg/mMD2wATsOoz+amomSUZuC8DDOt5Ot37kFnA qHuW4JmJjiBhFLiTXubLmidx9gvnLwktjy6nZnD45NxIWkBSeBfqWj5GYhu0s/vRrQYO0n 5RQptkHTEHvS3U8k5b2Hcen8oGZFJSNxYtnj+RKAqSwlpNQ2KZfNIMY7JIPMBg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700712064; a=rsa-sha256; cv=none; b=DkaUBmIFrIj8xUL0eqihuq/T+XP2hRxDdFgZLO0JQowene8k0D/Z5LqT+S7nj5mL9NT6Yk 7a1ULZvbA0ngOWIdW5AoNVKq+QOenSznx+xibZPv2PbQm7zDgkDZ9C/w5wJvmMD0DDKxuQ DdrIeqAGqBnAmoDCxvJyeCScBnZWOJgPs7wIHD3qte0ANWnWzwPZpSnfoQP/7yhaA/j9oM kPANjGbeatNPHTzhqvMzhSC/IYBawHOyyi7XJpgM5Q1CZZBzQTAot0T4YnboCDFmlzX78j b3Ss6CT3RmgGsTGyQwq1EV8TrV8zskcFFv1BGM1yOe/+qTV7Sj43FLEdyn4IUA== 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 4SbPYD4fbCzmpT; Thu, 23 Nov 2023 04:01:04 +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 3AN414gi098728; Thu, 23 Nov 2023 04:01:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AN414Tq098725; Thu, 23 Nov 2023 04:01:04 GMT (envelope-from git) Date: Thu, 23 Nov 2023 04:01:04 GMT Message-Id: <202311230401.3AN414Tq098725@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: 4603a50fa323 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 4603a50fa32346f838c1f304d755e1204f6ad59a Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4603a50fa32346f838c1f304d755e1204f6ad59a commit 4603a50fa32346f838c1f304d755e1204f6ad59a Author: Konstantin Belousov AuthorDate: 2023-11-14 22:48:47 +0000 Commit: Konstantin Belousov CommitDate: 2023-11-23 04:00:36 +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 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)