From nobody Wed Apr 26 00:01:00 2023 X-Original-To: dev-commits-src-main@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 4Q5fCd1dh6z46w7v; Wed, 26 Apr 2023 00:01:01 +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 4Q5fCd1BsLz3wQ8; Wed, 26 Apr 2023 00:01:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682467261; 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=XUhpovXqZJBiNh3RhxI6ckiHdNpkEbmavnVUhYxsUcM=; b=SfIEGnek3FyGUsUjUVbMvVxSI0khxve10hQv5TrsroHtUvRXtDqj0nzA70xSCLOWqqDp2d wupH6GLkwdpHDy6CxWy5DCynYb5FybkeJ318fFxqB3xTF7+LLarp89qrNhv3eCVNeyn/pH qNdRMJOwVHo7YR4d1htRcXgrViLFVrQ5GTrqzRGTMG6fb1eTRBIokmFCQ17P8WCWXxvC4n x9PsGxmRQqKczVMfPiHddYT1Lz7WLEcmodDddbTJQjRbsQBwmmjZa9s3GfIRBOhO95BXYG 7l/g/id5lNnDiYzBxzaz2NbVXnlgmUd0u7FrrD49DNi+hMgbhJlRvpdtudwecQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682467261; 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=XUhpovXqZJBiNh3RhxI6ckiHdNpkEbmavnVUhYxsUcM=; b=LvoIkfowDnlJJgGIYu/edQmgsj2CZZSe3BqWOyl0Meoafz3L1ZtKRx6Ego77OcQHG1J6Oe 6FpzT7+iX8PqzI6rWS5YLLTUVt/PfWUOYCiazRhTk8l/I3RJUXqPWfMllkiVDxXFjY5rEv TOunKkoTt2Obzyw81F4Uzb3DvDaAoXskFsCwBnBVm9vypd34s+sVkhbfAHzsHE/wH2IPdb HDO9QB41ZnMUf5rM4QW3VvGayx4pi4ZGhP0ahm1/VQL0jSnQKTL2ElyOpJlRczQhY5kbvK 61IeMcNttkUKoAAePtsAGWwivU/U36EBJE4dR1oe0TZWotIxelMNkKVkh1o3NQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682467261; a=rsa-sha256; cv=none; b=SRKjVsHM0qQ6nur4xW1LNrwdY0EJyFGQpnKsftcCwzcvmRnMIELhRId9eeBk3/yizJdVEF UP7TaJ61fJtdW5sVXDXbIiG03PR8NdPv8lAsgJuE3gwR8WmuIuvGD/usFt34BZSXEbJHwa jWDer6GZvu/EmFNGLfeSGBzxIrIVQnseAD+CYdl9niNuj22Hzwkl3El0xPqtGNu+drwDKh a19lSwqhCE+3Fah/vf71xxkJlfHC3el4veofOpko9r5EK+jPESq/f296TEDTqfpWaTHr2x tTC11fBL9IxFQzREYRCn4qp0EGgnGCttZkJxoJIorh73k6wQ8YTTCy7g9XYCrw== 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 4Q5fCd0Hm4z1Rlp; Wed, 26 Apr 2023 00:01:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33Q0102k084246; Wed, 26 Apr 2023 00:01:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33Q010Hl084245; Wed, 26 Apr 2023 00:01:00 GMT (envelope-from git) Date: Wed, 26 Apr 2023 00:01:00 GMT Message-Id: <202304260001.33Q010Hl084245@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: 37e6036b26cd - main - VOP_CLOSE(): MNTK_EXTENDED_SHARED filesystems do not need excl lock List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 37e6036b26cdd2942344b6c69f9a10764c6209ba Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=37e6036b26cdd2942344b6c69f9a10764c6209ba commit 37e6036b26cdd2942344b6c69f9a10764c6209ba Author: Konstantin Belousov AuthorDate: 2023-04-24 22:43:32 +0000 Commit: Konstantin Belousov CommitDate: 2023-04-25 22:39:25 +0000 VOP_CLOSE(): MNTK_EXTENDED_SHARED filesystems do not need excl lock All in-tree implementations of VOP_CLOSE() for filesystems proclaiming MNTK_EXTENDED_SHARED, are fine with the shared lock for the closed vnode. I checked the following implementations: ffs ext2 ufs null tmpfs devfs fdescfs cd9660 zfs It seems that initial addition of FWRITE check was due to necessity of handling the VV_TEXT vnode vflag. Since VOP_ADD_WRITECOUNT() only requires shared lock, we can relax the locking requirement there. Reviewed by: markj, Olivier Certner Tested by: Olivier Certner Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D39784 --- sys/kern/vfs_vnops.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index e42d17ec2478..581d620e348e 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -483,7 +483,7 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred, * If there is no fp, due to kernel-mode open, * we can call VOP_CLOSE() now. */ - if ((vp->v_type == VFIFO || (fmode & FWRITE) != 0 || + if ((vp->v_type == VFIFO || !MNT_EXTENDED_SHARED(vp->v_mount)) && VOP_ISLOCKED(vp) != LK_EXCLUSIVE) vn_lock(vp, LK_UPGRADE | LK_RETRY); @@ -528,11 +528,8 @@ vn_close1(struct vnode *vp, int flags, struct ucred *file_cred, struct mount *mp; int error, lock_flags; - if (vp->v_type != VFIFO && (flags & FWRITE) == 0 && - MNT_EXTENDED_SHARED(vp->v_mount)) - lock_flags = LK_SHARED; - else - lock_flags = LK_EXCLUSIVE; + lock_flags = vp->v_type != VFIFO && MNT_EXTENDED_SHARED(vp->v_mount) ? + LK_SHARED : LK_EXCLUSIVE; vn_start_write(vp, &mp, V_WAIT); vn_lock(vp, lock_flags | LK_RETRY);