svn commit: r348701 - head/sys/vm
Konstantin Belousov
kib at FreeBSD.org
Wed Jun 5 20:21:18 UTC 2019
Author: kib
Date: Wed Jun 5 20:21:17 2019
New Revision: 348701
URL: https://svnweb.freebsd.org/changeset/base/348701
Log:
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
Modified:
head/sys/vm/vm_map.c
Modified: head/sys/vm/vm_map.c
==============================================================================
--- head/sys/vm/vm_map.c Wed Jun 5 20:18:56 2019 (r348700)
+++ head/sys/vm/vm_map.c Wed Jun 5 20:21:17 2019 (r348701)
@@ -526,19 +526,31 @@ vm_map_entry_set_vnode_text(vm_map_entry_t entry, bool
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
More information about the svn-src-head
mailing list