kernel -- vm locking: Add vm object locking to vm_object_referenced.
authorVenkatesh Srinivas <me@endeavour.zapto.org>
Wed, 16 Feb 2011 05:04:35 +0000 (21:04 -0800)
committerVenkatesh Srinivas <me@endeavour.zapto.org>
Wed, 16 Feb 2011 05:04:35 +0000 (21:04 -0800)
sys/vm/vm_object.c

index da31ba6..9eeea98 100644 (file)
@@ -246,15 +246,9 @@ vm_object_allocate(objtype_t type, vm_pindex_t size)
 void
 vm_object_reference(vm_object_t object)
 {
-       if (object) {
-               lwkt_gettoken(&vmobj_token);
-               object->ref_count++;
-               if (object->type == OBJT_VNODE) {
-                       vref(object->handle);
-                       /* XXX what if the vnode is being destroyed? */
-               }
-               lwkt_reltoken(&vmobj_token);
-       }
+       lwkt_gettoken(&vmobj_token);
+       vm_object_reference_locked(object);
+       lwkt_reltoken(&vmobj_token);
 }
 
 void
@@ -262,11 +256,13 @@ vm_object_reference_locked(vm_object_t object)
 {
        if (object) {
                ASSERT_LWKT_TOKEN_HELD(&vmobj_token);
+               vm_object_lock(object);
                object->ref_count++;
                if (object->type == OBJT_VNODE) {
                        vref(object->handle);
                        /* XXX what if the vnode is being destroyed? */
                }
+               vm_object_unlock(object);
        }
 }