From owner-dev-commits-src-main@freebsd.org Fri Feb 12 01:07:14 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 43C4653D35A; Fri, 12 Feb 2021 01:07:14 +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 4DcFhb3X3pz3NQN; Fri, 12 Feb 2021 01:07:11 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4D5731AFD0; Fri, 12 Feb 2021 01:07:10 +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 11C17AtQ070554; Fri, 12 Feb 2021 01:07:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11C17Ark070553; Fri, 12 Feb 2021 01:07:10 GMT (envelope-from git) Date: Fri, 12 Feb 2021 01:07:10 GMT Message-Id: <202102120107.11C17Ark070553@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: 49c117c19376 - main - Add VOP_VPUT_PAIR() with trivial default implementation. 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: 49c117c193768b10f5fb1c5e4d6b88300cfbcdd6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Feb 2021 01:07:14 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=49c117c193768b10f5fb1c5e4d6b88300cfbcdd6 commit 49c117c193768b10f5fb1c5e4d6b88300cfbcdd6 Author: Konstantin Belousov AuthorDate: 2021-01-28 22:30:53 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-12 01:02:20 +0000 Add VOP_VPUT_PAIR() with trivial default implementation. The VOP is intended to be used in situations where VFS has two referenced locked vnodes, typically a directory vnode dvp and a vnode vp that is linked from the directory, and at least dvp is vput(9)ed. The child vnode can be also vput-ed, but optionally left referenced and locked. There, at least UFS may need to do some actions with dvp which cannot be done while vp is also locked, so its lock might be dropped temporary. For instance, in some cases UFS needs to sync dvp to avoid filesystem state that is currently not handled by either kernel nor fsck. Having such VOP provides the neccessary context for filesystem which can do correct locking and handle potential reclamation of vp after relock. Trivial implementation does vput(dvp) and optionally vput(vp). Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation --- sys/kern/vfs_default.c | 15 +++++++++++++++ sys/kern/vnode_if.src | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 4b96d9522ce3..382fbb2d9ace 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -92,6 +92,7 @@ static int vop_stdfdatasync(struct vop_fdatasync_args *ap); static int vop_stdgetpages_async(struct vop_getpages_async_args *ap); static int vop_stdread_pgcache(struct vop_read_pgcache_args *ap); static int vop_stdstat(struct vop_stat_args *ap); +static int vop_stdvput_pair(struct vop_vput_pair_args *ap); /* * This vnode table stores what we want to do if the filesystem doesn't @@ -151,6 +152,7 @@ struct vop_vector default_vnodeops = { .vop_unset_text = vop_stdunset_text, .vop_add_writecount = vop_stdadd_writecount, .vop_copy_file_range = vop_stdcopy_file_range, + .vop_vput_pair = vop_stdvput_pair, }; VFS_VOP_VECTOR_REGISTER(default_vnodeops); @@ -1592,3 +1594,16 @@ vop_stdread_pgcache(struct vop_read_pgcache_args *ap __unused) { return (EJUSTRETURN); } + +static int +vop_stdvput_pair(struct vop_vput_pair_args *ap) +{ + struct vnode *dvp, *vp, **vpp; + + dvp = ap->a_dvp; + vpp = ap->a_vpp; + vput(dvp); + if (vpp != NULL && ap->a_unlock_vp && (vp = *vpp) != NULL) + vput(vp); + return (0); +} diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 5d15d4a0c863..b506237f385d 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -792,6 +792,15 @@ vop_copy_file_range { }; +%% vput_pair dvp E - - + +vop_vput_pair { + IN struct vnode *dvp; + INOUT struct vnode **vpp; + IN bool unlock_vp; +}; + + # The VOPs below are spares at the end of the table to allow new VOPs to be # added in stable branches without breaking the KBI. New VOPs in HEAD should # be added above these spares. When merging a new VOP to a stable branch,