+ if (update_cow || (flags & (MEMORY_OBJECT_DATA_PURGE | MEMORY_OBJECT_DATA_SYNC))) {
+ int collisions = 0;
+
+ while ((copy_object = object->copy) != VM_OBJECT_NULL) {
+ /*
+ * need to do a try here since we're swimming upstream
+ * against the normal lock ordering... however, we need
+ * to hold the object stable until we gain control of the
+ * copy object so we have to be careful how we approach this
+ */
+ if (vm_object_lock_try(copy_object)) {
+ /*
+ * we 'won' the lock on the copy object...
+ * no need to hold the object lock any longer...
+ * take a real reference on the copy object because
+ * we're going to call vm_fault_page on it which may
+ * under certain conditions drop the lock and the paging
+ * reference we're about to take... the reference
+ * will keep the copy object from going away if that happens
+ */
+ vm_object_unlock(object);
+ vm_object_reference_locked(copy_object);
+ break;
+ }
+ vm_object_unlock(object);
+
+ collisions++;
+ mutex_pause(collisions);