From nobody Fri Jul 14 11:36: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 4R2Tvk69ZSz2tpZj; Fri, 14 Jul 2023 11:36:34 +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 4R2Tvk5c26z3hDp; Fri, 14 Jul 2023 11:36:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689334594; 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=exGAxTulREwecRQKeF3TP7ZqpI6zxp4ZFDpRCJgr5s0=; b=wIYHL3sj/UHQF9B+QH++xnt3jkjGdCve8agUDSO/tdhprse67nqDPo9Z2kvINTm6/ZR+Oi JGIpY9nf1gIsYSoF+6I5q52H5xTEIOiwukpBn8quI0M5+hF57greUaU8V8feht+tfsw/Eu 8bHK3M8Hhl9bCcgVx7Qh0p5Ng/P6+WAOBf45fg1AIIE1Dvl2uTCCna9xyfXSbddwnzwbGD UuCg8dh+7VsMgD11/m3yfmdtHaV3zCILz8LopmeUjtDtvD0NBEmZh7VAjSx055dYHVOhOI /vfBnwtJL/zxWl1QVAgv0LbD/p6jaDKJdmoHonR8Pk9HCfYQoKhiJgc9XlZYaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689334594; 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=exGAxTulREwecRQKeF3TP7ZqpI6zxp4ZFDpRCJgr5s0=; b=iD7boBDowrmRUFvzTkLyaHiomZFOVok+thLXCyyr1oIEemvuaNB+auY4njA13wffXESEdj ndsRUg9YB78z/hZaDBk3QwkDko9LLIjyuQqprwB1P7Gl3jzyZjOU6nWgnJFcFsC1BLtWzC CLdl27T0x/yh7Rd2wMKWdfckYIvbOJ2Q4NSM3Vai/RklW5znlECY1yoXvflKfNC0e4s3r2 WjG/WIJkHUfoLFLPsAm1a4IK67MmwgIiNIrdX+PI8J1anSDiy6iinALDcT/uz+Tteguc7Z Wh7lo3kZNsNX8uirC4qX+1q2cbkOqlhaB1VLJPA+rV0A0aiePqTczq6ALs1J3A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689334594; a=rsa-sha256; cv=none; b=X3cN+UZwu8btrmkyKz6KHP4al7WfTb8WoBgdFPhG/M9OT7zZTffR7i4DUw5reCNiGEnubc dr90nW9SKXcusPt6o4/BjK7O1yAb5uuyGbgDJLcHfFEAXItY9JGoC2ffqfFT3QGJZ3J3U8 Llh4flw6K6l6cDtOekaYfs4bYBkFqCciBorEnEyW07vw9Ac4IK2+jO3Bo+Y7VNj2oPGNB4 BCwdhE42hQAGWXplX2H8IY9zULIxQLPTAbFIYU9w6C7sQa2nYC4Lz3r0UXrLQx6AcZmT8R Ec64akauw2FTIPaH+s/yzJBq8KM6oYHdT/Vm9oDxCH+yzP0JkDsVGRVC/ogBUg== 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 4R2Tvk4gZlzGrR; Fri, 14 Jul 2023 11:36: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 36EBaYUK012902; Fri, 14 Jul 2023 11:36:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36EBaYRX012901; Fri, 14 Jul 2023 11:36:34 GMT (envelope-from git) Date: Fri, 14 Jul 2023 11:36:34 GMT Message-Id: <202307141136.36EBaYRX012901@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: f58378393fb0 - main - vn_lock_pair(): Support passing LK_NODDLKTREAT 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: f58378393fb00f1683bc15f1ae7cbb83e047b9fb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f58378393fb00f1683bc15f1ae7cbb83e047b9fb commit f58378393fb00f1683bc15f1ae7cbb83e047b9fb Author: Olivier Certner AuthorDate: 2023-07-09 17:12:52 +0000 Commit: Konstantin Belousov CommitDate: 2023-07-14 11:36:12 +0000 vn_lock_pair(): Support passing LK_NODDLKTREAT Since this function ultimately calls vn_lock() or VOP_LOCK1(), allows it to receive and pass this flag which is used in the lookup code and doesn't interfere with the function's operation. Reviewed by: kib, markj MFC after: 1 week Differential revision: https://reviews.freebsd.org/D40954 --- sys/kern/vfs_vnops.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 33cb3ebed60f..41a80da75a4f 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -4018,6 +4018,9 @@ vn_lock_pair_pause(const char *wmesg) * Both vnodes could be unlocked temporary (and reclaimed). * * If requesting shared locking, locked vnode lock must not be recursed. + * + * Only one of LK_SHARED and LK_EXCLUSIVE must be specified. + * LK_NODDLKTREAT can be optionally passed. */ void vn_lock_pair(struct vnode *vp1, bool vp1_locked, int lkflags1, @@ -4025,19 +4028,21 @@ vn_lock_pair(struct vnode *vp1, bool vp1_locked, int lkflags1, { int error; - MPASS(lkflags1 == LK_SHARED || lkflags1 == LK_EXCLUSIVE); - MPASS(lkflags2 == LK_SHARED || lkflags2 == LK_EXCLUSIVE); + MPASS((lkflags1 & LK_SHARED) != 0 ^ (lkflags1 & LK_EXCLUSIVE) != 0); + MPASS((lkflags1 & ~(LK_SHARED | LK_EXCLUSIVE | LK_NODDLKTREAT)) == 0); + MPASS((lkflags2 & LK_SHARED) != 0 ^ (lkflags2 & LK_EXCLUSIVE) != 0); + MPASS((lkflags2 & ~(LK_SHARED | LK_EXCLUSIVE | LK_NODDLKTREAT)) == 0); if (vp1 == NULL && vp2 == NULL) return; if (vp1 != NULL) { - if (lkflags1 == LK_SHARED && + if ((lkflags1 & LK_SHARED) != 0 && (vp1->v_vnlock->lock_object.lo_flags & LK_NOSHARE) != 0) - lkflags1 = LK_EXCLUSIVE; + lkflags1 = (lkflags1 & ~LK_SHARED) | LK_EXCLUSIVE; if (vp1_locked && VOP_ISLOCKED(vp1) != LK_EXCLUSIVE) { ASSERT_VOP_LOCKED(vp1, "vp1"); - if (lkflags1 == LK_EXCLUSIVE) { + if ((lkflags1 & LK_EXCLUSIVE) != 0) { VOP_UNLOCK(vp1); ASSERT_VOP_UNLOCKED(vp1, "vp1 shared recursed"); @@ -4050,12 +4055,12 @@ vn_lock_pair(struct vnode *vp1, bool vp1_locked, int lkflags1, } if (vp2 != NULL) { - if (lkflags2 == LK_SHARED && + if ((lkflags2 & LK_SHARED) != 0 && (vp2->v_vnlock->lock_object.lo_flags & LK_NOSHARE) != 0) - lkflags2 = LK_EXCLUSIVE; + lkflags2 = (lkflags2 & ~LK_SHARED) | LK_EXCLUSIVE; if (vp2_locked && VOP_ISLOCKED(vp2) != LK_EXCLUSIVE) { ASSERT_VOP_LOCKED(vp2, "vp2"); - if (lkflags2 == LK_EXCLUSIVE) { + if ((lkflags2 & LK_EXCLUSIVE) != 0) { VOP_UNLOCK(vp2); ASSERT_VOP_UNLOCKED(vp2, "vp2 shared recursed");