mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-20 16:54:02 +00:00
In vm_map_entry_set_vnode_text(), tolerate tmpfs mappings for which
vnode is no longer resident. Mapping of tmpfs file does not bump use count on the vnode, because backing object has swap type. As result, even during normal operations, and of course on forced unmount, we might end up with text mapping from tmpfs node which has no vnode in memory. In this case, there is no v_writecount to clear (this was done during reclaim), and no reason to assert that the vnode is present. Restructure the code to silently ignore OBJ_SWAP objects with OBJ_TMPFS_NODE flag set, but OBJ_TMPFS flag clear. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
87e34f6cf4
commit
32d2014dde
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348701
|
@ -526,19 +526,31 @@ vm_map_entry_set_vnode_text(vm_map_entry_t entry, bool add)
|
|||
object = object1;
|
||||
}
|
||||
|
||||
/*
|
||||
* For OBJT_DEAD objects, v_writecount was handled in
|
||||
* vnode_pager_dealloc().
|
||||
*/
|
||||
if (object->type != OBJT_DEAD) {
|
||||
KASSERT(((object->flags & OBJ_TMPFS) == 0 &&
|
||||
object->type == OBJT_VNODE) ||
|
||||
((object->flags & OBJ_TMPFS) != 0 &&
|
||||
object->type == OBJT_SWAP),
|
||||
vp = NULL;
|
||||
if (object->type == OBJT_DEAD) {
|
||||
/*
|
||||
* For OBJT_DEAD objects, v_writecount was handled in
|
||||
* vnode_pager_dealloc().
|
||||
*/
|
||||
} else if (object->type == OBJT_VNODE) {
|
||||
vp = object->handle;
|
||||
} else if (object->type == OBJT_SWAP) {
|
||||
KASSERT((object->flags & OBJ_TMPFS_NODE) != 0,
|
||||
("vm_map_entry_set_vnode_text: swap and !TMPFS "
|
||||
"entry %p, object %p, add %d", entry, object, add));
|
||||
/*
|
||||
* Tmpfs VREG node, which was reclaimed, has
|
||||
* OBJ_TMPFS_NODE flag set, but not OBJ_TMPFS. In
|
||||
* this case there is no v_writecount to adjust.
|
||||
*/
|
||||
if ((object->flags & OBJ_TMPFS) != 0)
|
||||
vp = object->un_pager.swp.swp_tmpfs;
|
||||
} else {
|
||||
KASSERT(0,
|
||||
("vm_map_entry_set_vnode_text: wrong object type, "
|
||||
"entry %p, object %p, add %d", entry, object, add));
|
||||
vp = (object->flags & OBJ_TMPFS) == 0 ? object->handle :
|
||||
object->un_pager.swp.swp_tmpfs;
|
||||
}
|
||||
if (vp != NULL) {
|
||||
if (add)
|
||||
VOP_SET_TEXT_CHECKED(vp);
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue