From 010cf3b9e3f74791c3d1c892f7735cf49a15da6c Mon Sep 17 00:00:00 2001 From: David Greenman Date: Thu, 5 Jan 1995 04:30:40 +0000 Subject: [PATCH] Make sure that the object being collapsed doesn't go away on us...by gaining extra references to it. Submitted by: John Dyson Obtained from: --- sys/vm/vm_object.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 3d084cc5cfa..f529ad20d0b 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_object.c,v 1.12 1994/12/11 01:36:53 davidg Exp $ + * $Id: vm_object.c,v 1.13 1994/12/23 05:00:19 davidg Exp $ */ /* @@ -251,8 +251,13 @@ vm_object_deallocate(object) */ vm_object_lock(object); if (--(object->ref_count) != 0) { - if( object->ref_count == 1) - vm_object_rcollapse(object->reverse_shadow_head.tqh_first, object); + if( object->ref_count == 1) { + if( object->reverse_shadow_head.tqh_first) { + ++object->reverse_shadow_head.tqh_first->ref_count; + vm_object_rcollapse(object->reverse_shadow_head.tqh_first, object); + vm_object_deallocate(object->reverse_shadow_head.tqh_first); + } + } vm_object_unlock(object); /* @@ -1162,6 +1167,7 @@ vm_object_rcollapse(object, sobject) if (backing_object->ref_count != 1) return; + backing_object->ref_count += 2; s = splbio(); while( backing_object->paging_in_progress) { tsleep( backing_object, PVM, "rcolow", 0); @@ -1201,6 +1207,7 @@ vm_object_rcollapse(object, sobject) } p = next; } + backing_object->ref_count -= 2; } /* @@ -1228,6 +1235,8 @@ vm_object_qcollapse(object) if (backing_object->ref_count != 1) return; + backing_object->ref_count += 2; + backing_offset = object->shadow_offset; size = object->size; p = backing_object->memq.tqh_first; @@ -1266,6 +1275,7 @@ vm_object_qcollapse(object) } p = next; } + backing_object->ref_count -= 2; } boolean_t vm_object_collapse_allowed = TRUE;