From owner-dev-commits-src-main@freebsd.org Fri May 7 14:08:25 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 2AF2962F1B0; Fri, 7 May 2021 14:08:25 +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 4FcC3D6L2nz4f14; Fri, 7 May 2021 14:08:24 +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 96A194C15; Fri, 7 May 2021 14:08:24 +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 147E8OK0020272; Fri, 7 May 2021 14:08:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 147E8O59020271; Fri, 7 May 2021 14:08:24 GMT (envelope-from git) Date: Fri, 7 May 2021 14:08:24 GMT Message-Id: <202105071408.147E8O59020271@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: a7c198a24b12 - main - Implement vm_object_vnode() using vm_pager_getvp() 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: a7c198a24b12b9e6d83d7718d8d16a5cef48d35f 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, 07 May 2021 14:08:25 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a7c198a24b12b9e6d83d7718d8d16a5cef48d35f commit a7c198a24b12b9e6d83d7718d8d16a5cef48d35f Author: Konstantin Belousov AuthorDate: 2021-05-01 01:08:28 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-07 14:08:03 +0000 Implement vm_object_vnode() using vm_pager_getvp() Allow vp_heldp argument to be NULL, in which case the returned vnode is not held for tmpfs swap objects. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30070 --- sys/vm/swap_pager.c | 14 ++++++++++---- sys/vm/vm_object.c | 11 +---------- sys/vm/vm_pager.h | 9 +++------ 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index f09a6ffc80dc..ec37a26d523d 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -3160,14 +3160,20 @@ swap_pager_getvp(vm_object_t object, struct vnode **vpp, bool *vp_heldp) * OBJ_TMPFS_NODE flag set, but not OBJ_TMPFS. In * this case there is no v_writecount to adjust. */ - VM_OBJECT_RLOCK(object); + if (vp_heldp != NULL) + VM_OBJECT_RLOCK(object); + else + VM_OBJECT_ASSERT_LOCKED(object); if ((object->flags & OBJ_TMPFS) != 0) { vp = object->un_pager.swp.swp_tmpfs; if (vp != NULL) { - vhold(vp); *vpp = vp; - *vp_heldp = true; + if (vp_heldp != NULL) { + vhold(vp); + *vp_heldp = true; + } } } - VM_OBJECT_RUNLOCK(object); + if (vp_heldp != NULL) + VM_OBJECT_RUNLOCK(object); } diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 7b380608cdf4..bbcbad41f10c 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2429,16 +2429,7 @@ vm_object_vnode(vm_object_t object) struct vnode *vp; VM_OBJECT_ASSERT_LOCKED(object); - if (object->type == OBJT_VNODE) { - vp = object->handle; - KASSERT(vp != NULL, ("%s: OBJT_VNODE has no vnode", __func__)); - } else if (object->type == OBJT_SWAP && - (object->flags & OBJ_TMPFS) != 0) { - vp = object->un_pager.swp.swp_tmpfs; - KASSERT(vp != NULL, ("%s: OBJT_TMPFS has no vnode", __func__)); - } else { - vp = NULL; - } + vm_pager_getvp(object, &vp, NULL); return (vp); } diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h index 6a35c066bea6..507123adb454 100644 --- a/sys/vm/vm_pager.h +++ b/sys/vm/vm_pager.h @@ -229,14 +229,11 @@ vm_pager_getvp(vm_object_t object, struct vnode **vpp, bool *vp_heldp) pgo_getvp_t *method; *vpp = NULL; - *vp_heldp = false; + if (vp_heldp != NULL) + *vp_heldp = false; method = pagertab[object->type]->pgo_getvp; - if (method != NULL) { + if (method != NULL) method(object, vpp, vp_heldp); - } else { - KASSERT(0, - ("vm_pager_getvp: wrong object type obj %p", object)); - } } static __inline void