mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-30 12:04:07 +00:00
Remove a racy checks on resident and cached pages for
tmpfs_mapped{read, write}() functions: - tmpfs_mapped{read, write}() are only called within VOP_{READ, WRITE}(), which check before-hand to work only on valid VREG vnodes. Also the vnode is locked for the duration of the work, making vnode reclaiming impossible, during the operation. Hence, vobj can never be NULL. - Currently check on resident pages and cached pages without vm object lock held is racy and can do even more harm than good, as a page could be transitioning between these 2 pools and then be skipped entirely. Skip the checks as lookups on empty splay trees are very cheap. Discussed with: alc Tested by: flo MFC after: 2 weeks
This commit is contained in:
parent
3e3812572d
commit
5e60cb948e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=246603
@ -511,10 +511,6 @@ tmpfs_mappedread(vm_object_t vobj, vm_object_t tobj, size_t len, struct uio *uio
|
||||
offset = addr & PAGE_MASK;
|
||||
tlen = MIN(PAGE_SIZE - offset, len);
|
||||
|
||||
if ((vobj == NULL) ||
|
||||
(vobj->resident_page_count == 0 && vobj->cache == NULL))
|
||||
goto nocache;
|
||||
|
||||
VM_OBJECT_LOCK(vobj);
|
||||
lookupvpg:
|
||||
if (((m = vm_page_lookup(vobj, idx)) != NULL) &&
|
||||
@ -569,7 +565,6 @@ tmpfs_mappedread(vm_object_t vobj, vm_object_t tobj, size_t len, struct uio *uio
|
||||
return (error);
|
||||
}
|
||||
VM_OBJECT_UNLOCK(vobj);
|
||||
nocache:
|
||||
error = tmpfs_nocacheread(tobj, idx, offset, tlen, uio);
|
||||
|
||||
return (error);
|
||||
@ -639,12 +634,6 @@ tmpfs_mappedwrite(vm_object_t vobj, vm_object_t tobj, size_t len, struct uio *ui
|
||||
offset = addr & PAGE_MASK;
|
||||
tlen = MIN(PAGE_SIZE - offset, len);
|
||||
|
||||
if ((vobj == NULL) ||
|
||||
(vobj->resident_page_count == 0 && vobj->cache == NULL)) {
|
||||
vpg = NULL;
|
||||
goto nocache;
|
||||
}
|
||||
|
||||
VM_OBJECT_LOCK(vobj);
|
||||
lookupvpg:
|
||||
if (((vpg = vm_page_lookup(vobj, idx)) != NULL) &&
|
||||
@ -668,7 +657,6 @@ tmpfs_mappedwrite(vm_object_t vobj, vm_object_t tobj, size_t len, struct uio *ui
|
||||
VM_OBJECT_UNLOCK(vobj);
|
||||
vpg = NULL;
|
||||
}
|
||||
nocache:
|
||||
VM_OBJECT_LOCK(tobj);
|
||||
tpg = vm_page_grab(tobj, idx, VM_ALLOC_WIRED |
|
||||
VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
|
||||
|
Loading…
Reference in New Issue
Block a user