From nobody Mon Mar 4 18:51:45 2024 X-Original-To: dev-commits-src-branches@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 4TpSTs5PGlz5D5tS; Mon, 4 Mar 2024 18:51:45 +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 4TpSTs4r0Hz4bnJ; Mon, 4 Mar 2024 18:51:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709578305; 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=8/YkbO/LkohPs9H/9uGzasKKoC73HQJlvKzZMHB7fm8=; b=i7JAbeK0zqDRMpac2baFxoECYBQ2TNgc0HKRDiaZcVTBynvCPCRV1SCoLjROHu41enseRS Z/sp3TnONEnSvcUWwOilXMgrmEgG2JaUDIQIEagqdSUDEXJexVVPEaoBMxbPvmS+gQOCPz rLhufBR0ZoymXcyduMJN95AiZv1Ms6/NKU0/OjptLbIcOHrkyVPnQsRkEd3/jBFLb0knAB A1+hOIVK2Nf1JYfkuPj7GV3vZC6mvBk1D+0CYZ8/1GqJF63TmE/BjSAK+X850uYGAFoT03 bAU+/TCtNRglpDQZsUZKmolLCrHZDdEGEyysHKvDfxjbTGHf38Rvd1Vhwmpm5g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709578305; a=rsa-sha256; cv=none; b=bC6oM/YGkKfPp2U99Vt9R+wzr2tnmbzcwsqTauC3jgJ3QruRhIrVY9zVUoShiEtRHp3hRk 09BSmWZIb3m8eqh4jX5l5Q8UBGY1Z3jdBlpNiHEuvrLGJ8lgZ05qb+yiBSdub5mnsSVpZb Dmh5pmFO5HZQ0PSuDtRM7y9ulztwqRKDW0EcrnfCXMrsw2fWjcqINfCwFXWhu1ettG7w1w FpNvaHnXTT7SNHCxAr+VKaWjHRP9u9mbsrKkUzPWBSFGYZxNZ2sn8u6ePtoXR9K71lofAT ZHvJQrKIBnOPSizYaYCl5rNe5FP3LJdop3ayn146jvysGZxUq81HFfDL7jdtXw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709578305; 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=8/YkbO/LkohPs9H/9uGzasKKoC73HQJlvKzZMHB7fm8=; b=DerfejhZbX7WWvDcGtzX1hlLcevIzJhpYWCZI/AxMAy384SKPIzXKDmz9W0rUzhIPhpbte ln2i8i7ltWSLdx46xN1+aGxer+4CH9Do5Ixytn9Cw8sllCX2AWhMGiukjjithzbmDmL2qB QZsFDdUXouS7OmOvnPMrFVmDxRdFDSxvAIO9f0m7+0V52GLhrtsM9zTtICHaoMLS250fK/ 9z8SgbcSfSdneWISJn0LciMt2zDjCCiI6BHPR7KQq9sfYBhBrUf6xI6ny+rEObtuQmMaTT QfND6ZKIeZjtVYNwfIXIoYwo1ad57PpMGW6MOU63+tYphzYyt+Zik+/eDVeyNA== 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 4TpSTs4Qv0zYmJ; Mon, 4 Mar 2024 18:51:45 +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 424Ipjmr009577; Mon, 4 Mar 2024 18:51:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 424Ipj0g009574; Mon, 4 Mar 2024 18:51:45 GMT (envelope-from git) Date: Mon, 4 Mar 2024 18:51:45 GMT Message-Id: <202403041851.424Ipj0g009574@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Jason A. Harmening" Subject: git: d0bb255d1fcb - stable/14 - VFS: update VOP_FSYNC() debug check to reflect actual locking policy List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jah X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: d0bb255d1fcbf4baff4cc43df684deb2ecd2f96d Auto-Submitted: auto-generated The branch stable/14 has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=d0bb255d1fcbf4baff4cc43df684deb2ecd2f96d commit d0bb255d1fcbf4baff4cc43df684deb2ecd2f96d Author: Jason A. Harmening AuthorDate: 2023-12-26 02:02:25 +0000 Commit: Jason A. Harmening CommitDate: 2024-03-04 18:30:27 +0000 VFS: update VOP_FSYNC() debug check to reflect actual locking policy Shared vs. exclusive locking is determined not by MNT_EXTENDED_SHARED but by MNT_SHARED_WRITES (although there are several places that ignore this and simply always use an exclusive lock). Also add a comment on the possible difference between VOP_GETWRITEMOUNT(vp) and vp->v_mount on this path. Found by local testing of unionfs atop ZFS with DEBUG_VFS_LOCKS. Reviewed by: kib, olce Differential Revision: https://reviews.freebsd.org/D43816 (cherry picked from commit 9530182e371dee382b76d8594f65633a304b396f) --- sys/kern/vfs_subr.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index b9e92b5b9812..d1c17dca37d4 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -5845,7 +5845,22 @@ vop_fsync_debugprepost(struct vnode *vp, const char *name) { if (vp->v_type == VCHR) ; - else if (MNT_EXTENDED_SHARED(vp->v_mount)) + /* + * The shared vs. exclusive locking policy for fsync() + * is actually determined by vp's write mount as indicated + * by VOP_GETWRITEMOUNT(), which for stacked filesystems + * may not be the same as vp->v_mount. However, if the + * underlying filesystem which really handles the fsync() + * supports shared locking, the stacked filesystem must also + * be prepared for its VOP_FSYNC() operation to be called + * with only a shared lock. On the other hand, if the + * stacked filesystem claims support for shared write + * locking but the underlying filesystem does not, and the + * caller incorrectly uses a shared lock, this condition + * should still be caught when the stacked filesystem + * invokes VOP_FSYNC() on the underlying filesystem. + */ + else if (MNT_SHARED_WRITES(vp->v_mount)) ASSERT_VOP_LOCKED(vp, name); else ASSERT_VOP_ELOCKED(vp, name);