Include path for tmpfs objects in vm.objects sysctl

This applies the fix in r283924 to the vm.objects sysctl
added by r283624 so the output will include the vnode
information (i.e. path) for tmpfs objects.

Reviewed by:	kib, dab
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D2724
This commit is contained in:
Eric van Gyzen 2018-11-30 04:59:43 +00:00
parent 0951bd362c
commit 5e38e3f5eb
3 changed files with 46 additions and 106 deletions

View File

@ -2219,43 +2219,11 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS)
freepath = NULL;
fullpath = "";
if (lobj) {
vp = NULL;
switch (lobj->type) {
case OBJT_DEFAULT:
kve->kve_type = KVME_TYPE_DEFAULT;
break;
case OBJT_VNODE:
kve->kve_type = KVME_TYPE_VNODE;
vp = lobj->handle;
vref(vp);
break;
case OBJT_SWAP:
if ((lobj->flags & OBJ_TMPFS_NODE) != 0) {
kve->kve_type = KVME_TYPE_VNODE;
if ((lobj->flags & OBJ_TMPFS) != 0) {
vp = lobj->un_pager.swp.swp_tmpfs;
vref(vp);
}
} else {
kve->kve_type = KVME_TYPE_SWAP;
}
break;
case OBJT_DEVICE:
kve->kve_type = KVME_TYPE_DEVICE;
break;
case OBJT_PHYS:
kve->kve_type = KVME_TYPE_PHYS;
break;
case OBJT_DEAD:
kve->kve_type = KVME_TYPE_DEAD;
break;
case OBJT_SG:
kve->kve_type = KVME_TYPE_SG;
break;
default:
kve->kve_type = vm_object_kvme_type(lobj, &vp);
if (kve->kve_type == KVME_TYPE_MGTDEVICE)
kve->kve_type = KVME_TYPE_UNKNOWN;
break;
}
if (vp != NULL)
vref(vp);
if (lobj != obj)
VM_OBJECT_RUNLOCK(lobj);
@ -2463,46 +2431,9 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, int flags)
freepath = NULL;
fullpath = "";
if (lobj != NULL) {
vp = NULL;
switch (lobj->type) {
case OBJT_DEFAULT:
kve->kve_type = KVME_TYPE_DEFAULT;
break;
case OBJT_VNODE:
kve->kve_type = KVME_TYPE_VNODE;
vp = lobj->handle;
kve->kve_type = vm_object_kvme_type(lobj, &vp);
if (vp != NULL)
vref(vp);
break;
case OBJT_SWAP:
if ((lobj->flags & OBJ_TMPFS_NODE) != 0) {
kve->kve_type = KVME_TYPE_VNODE;
if ((lobj->flags & OBJ_TMPFS) != 0) {
vp = lobj->un_pager.swp.swp_tmpfs;
vref(vp);
}
} else {
kve->kve_type = KVME_TYPE_SWAP;
}
break;
case OBJT_DEVICE:
kve->kve_type = KVME_TYPE_DEVICE;
break;
case OBJT_PHYS:
kve->kve_type = KVME_TYPE_PHYS;
break;
case OBJT_DEAD:
kve->kve_type = KVME_TYPE_DEAD;
break;
case OBJT_SG:
kve->kve_type = KVME_TYPE_SG;
break;
case OBJT_MGTDEVICE:
kve->kve_type = KVME_TYPE_MGTDEVICE;
break;
default:
kve->kve_type = KVME_TYPE_UNKNOWN;
break;
}
if (lobj != obj)
VM_OBJECT_RUNLOCK(lobj);

View File

@ -2330,6 +2330,41 @@ vm_object_vnode(vm_object_t object)
return (vp);
}
/*
* Return the kvme type of the given object.
* If vpp is not NULL, set it to the object's vm_object_vnode() or NULL.
*/
int
vm_object_kvme_type(vm_object_t object, struct vnode **vpp)
{
VM_OBJECT_ASSERT_LOCKED(object);
if (vpp != NULL)
*vpp = vm_object_vnode(object);
switch (object->type) {
case OBJT_DEFAULT:
return (KVME_TYPE_DEFAULT);
case OBJT_VNODE:
return (KVME_TYPE_VNODE);
case OBJT_SWAP:
if ((object->flags & OBJ_TMPFS_NODE) != 0)
return (KVME_TYPE_VNODE);
return (KVME_TYPE_SWAP);
case OBJT_DEVICE:
return (KVME_TYPE_DEVICE);
case OBJT_PHYS:
return (KVME_TYPE_PHYS);
case OBJT_DEAD:
return (KVME_TYPE_DEAD);
case OBJT_SG:
return (KVME_TYPE_SG);
case OBJT_MGTDEVICE:
return (KVME_TYPE_MGTDEVICE);
default:
return (KVME_TYPE_UNKNOWN);
}
}
static int
sysctl_vm_object_list(SYSCTL_HANDLER_ARGS)
{
@ -2404,38 +2439,9 @@ sysctl_vm_object_list(SYSCTL_HANDLER_ARGS)
kvo->kvo_vn_fsid_freebsd11 = 0;
freepath = NULL;
fullpath = "";
vp = NULL;
switch (obj->type) {
case OBJT_DEFAULT:
kvo->kvo_type = KVME_TYPE_DEFAULT;
break;
case OBJT_VNODE:
kvo->kvo_type = KVME_TYPE_VNODE;
vp = obj->handle;
kvo->kvo_type = vm_object_kvme_type(obj, &vp);
if (vp != NULL)
vref(vp);
break;
case OBJT_SWAP:
kvo->kvo_type = KVME_TYPE_SWAP;
break;
case OBJT_DEVICE:
kvo->kvo_type = KVME_TYPE_DEVICE;
break;
case OBJT_PHYS:
kvo->kvo_type = KVME_TYPE_PHYS;
break;
case OBJT_DEAD:
kvo->kvo_type = KVME_TYPE_DEAD;
break;
case OBJT_SG:
kvo->kvo_type = KVME_TYPE_SG;
break;
case OBJT_MGTDEVICE:
kvo->kvo_type = KVME_TYPE_MGTDEVICE;
break;
default:
kvo->kvo_type = KVME_TYPE_UNKNOWN;
break;
}
VM_OBJECT_RUNLOCK(obj);
if (vp != NULL) {
vn_fullpath(curthread, vp, &fullpath, &freepath);

View File

@ -263,6 +263,8 @@ extern struct vm_object kernel_object_store;
#define VM_OBJECT_WUNLOCK(object) \
rw_wunlock(&(object)->lock)
struct vnode;
/*
* The object must be locked or thread private.
*/
@ -328,6 +330,7 @@ void vm_object_destroy (vm_object_t);
void vm_object_terminate (vm_object_t);
void vm_object_set_writeable_dirty (vm_object_t);
void vm_object_init (void);
int vm_object_kvme_type(vm_object_t object, struct vnode **vpp);
void vm_object_madvise(vm_object_t, vm_pindex_t, vm_pindex_t, int);
boolean_t vm_object_page_clean(vm_object_t object, vm_ooffset_t start,
vm_ooffset_t end, int flags);