Author: kib
Date: Tue Apr  9 10:04:10 2013
New Revision: 249303
URL: http://svnweb.freebsd.org/changeset/base/249303

Log:
  Fix the assertions for the state of the object under the map entry
  with the MAP_ENTRY_VN_WRITECNT flag:
  - Move the assertion that verifies the state of the v_writecount and
    vnp.writecount, under the block where the object is locked.
  - Check that the object type is OBJT_VNODE before asserting.
  
  Reported by:  avg
  Reviewed by:  alc
  MFC after:    1 week

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==============================================================================
--- head/sys/vm/vm_map.c        Tue Apr  9 09:15:26 2013        (r249302)
+++ head/sys/vm/vm_map.c        Tue Apr  9 10:04:10 2013        (r249303)
@@ -3160,6 +3160,22 @@ vmspace_fork(struct vmspace *vm1, vm_oof
                                object->charge = old_entry->end - 
old_entry->start;
                                old_entry->cred = NULL;
                        }
+
+                       /*
+                        * Assert the correct state of the vnode
+                        * v_writecount while the object is locked, to
+                        * not relock it later for the assertion
+                        * correctness.
+                        */
+                       if (old_entry->eflags & MAP_ENTRY_VN_WRITECNT &&
+                           object->type == OBJT_VNODE) {
+                               KASSERT(((struct vnode *)object->handle)->
+                                   v_writecount > 0,
+                                   ("vmspace_fork: v_writecount %p", object));
+                               KASSERT(object->un_pager.vnp.writemappings > 0,
+                                   ("vmspace_fork: vnp.writecount %p",
+                                   object));
+                       }
                        VM_OBJECT_WUNLOCK(object);
 
                        /*
@@ -3171,12 +3187,6 @@ vmspace_fork(struct vmspace *vm1, vm_oof
                            MAP_ENTRY_IN_TRANSITION);
                        new_entry->wired_count = 0;
                        if (new_entry->eflags & MAP_ENTRY_VN_WRITECNT) {
-                               object = new_entry->object.vm_object;
-                               KASSERT(((struct vnode *)object->handle)->
-                                   v_writecount > 0,
-                                   ("vmspace_fork: v_writecount"));
-                               KASSERT(object->un_pager.vnp.writemappings > 0,
-                                   ("vmspace_fork: vnp.writecount"));
                                vnode_pager_update_writecount(object,
                                    new_entry->start, new_entry->end);
                        }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to