Date: Sat, 22 May 2021 09:46:29 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: da0e85f9ebc9 - stable/13 - Implement vm_object_vnode() using vm_pager_getvp() Message-ID: <202105220946.14M9kTLr012453@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=da0e85f9ebc9c4f5b9b7ddf126248d7d781b74d7 commit da0e85f9ebc9c4f5b9b7ddf126248d7d781b74d7 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-05-01 01:08:28 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-05-22 09:38:29 +0000 Implement vm_object_vnode() using vm_pager_getvp() (cherry picked from commit a7c198a24b12b9e6d83d7718d8d16a5cef48d35f) --- 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 22205510ff94..b81f73e41d05 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -3164,14 +3164,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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105220946.14M9kTLr012453>