rem: TRACE(("map_backing_store: aspace 0x%x, store 0x%x, *vaddr 0x%x, offset 0x%Lx, size %d, addr_type %d, wiring %d, lock %d, _region 0x%x, region_name '%s'\n",
add: TRACE(("map_backing_store: aspace %p, store %p, *vaddr %p, offset 0x%Lx, size %lu, addr_type %d, wiring %d, lock %d, _region %p, region_name '%s'\n",
context: map_backing_store(vm_address_space *aspace, vm_store *store, void **vaddr,	off_t offset, addr_t size, int addr_type, int wiring, int lock,	int mapping, vm_region **_region, const char *region_name){	vm_cache *cache;	vm_cache_ref *cache_ref;	vm_region *region;	vm_cache *nu_cache;	vm_cache_ref *nu_cache_ref = NULL;	vm_store *nu_store;	int err;	TRACE(("map_backing_store: aspace 0x%x, store 0x%x, *vaddr 0x%x, offset 0x%Lx, size %d, addr_type %d, wiring %d, lock %d, _region 0x%x, region_name '%s'\n",		aspace, store, *vaddr, offset, size, addr_type, wiring, lock, _region, region_name));	region = _vm_create_region_struct(aspace, region_name, wiring, lock);	if (!region)		return B_NO_MEMORY;	cache = store->cache;	cache_ref = cache->ref;	// if this is a private map, we need to create a new cache & store object	// pair to handle the private copies of pages as they are written to	if (mapping == REGION_PRIVATE_MAP) {		// create an anonymous store object		nu_store = vm_store_create_anonymous_noswap();		if (nu_store == NULL)			panic("map_backing_store: vm_create_store_anonymous_noswap returned NULL");		nu_cache = vm_cache_create(nu_store);		if (nu_cache == NULL)			panic("map_backing_store: vm_cache_create returned NULL");		nu_cache_ref = vm_cache_ref_create(nu_cache);		if (nu_cache_ref == NULL)			panic("map_backing_store: vm_cache_ref_create returned NULL");		nu_cache->temporary = 1;		nu_cache->scan_skip = cache->scan_skip;		nu_cache->source = cache;		// grab a ref to the cache object we're now linked to as a source		vm_cache_acquire_ref(cache_ref, true);		cache = nu_cache;		cache_ref = cache->ref;		store = nu_store;	}	mutex_lock(&cache_ref->lock);	// If we don't have enough committed space to cover through to the new end of region...	if (store->committed_size < offset + size) {		// try to commit more memory		off_t old_store_commitment = store->committed_size; // Note what we had		off_t commitment = (store->ops->commit)(store, offset + size); // Commit through to the new end		if (commitment < offset + size) { // Uh oh - didn't work			if (cache->temporary) { // If this is a temporary cache, Check to see if we ran out of space and return error.				int state = disable_interrupts();				acquire_spinlock(&max_commit_lock);				if (max_commit - old_store_commitment + commitment < offset + size) {					release_spinlock(&max_commit_lock);					restore_interrupts(state);					mutex_unlock(&cache_ref->lock);					err = ERR_VM_WOULD_OVERCOMMIT;					goto err1a;				}				max_commit += (commitment - old_store_commitment) - (offset + size - cache->virtual_size);				cache->virtual_size = offset + size;				release_spinlock(&max_commit_lock);				restore_interrupts(state);			} else {				mutex_unlock(&cache_ref->lock);				err = ENOMEM;				goto err1a;			}		}	}	mutex_unlock(&cache_ref->lock);	vm_cache_acquire_ref(cache_ref, true);	acquire_sem_etc(aspace->virtual_map.sem, WRITE_COUNT, 0, 0);	// check to see if this aspace has entered DELETE state	if (aspace->state == VM_ASPACE_STATE_DELETION) {		// okay, someone is trying to delete this aspace now, so we can't		// insert the region, so back out		err = ERR_VM_INVALID_ASPACE;		goto err1b;	}	err = insert_area(aspace, vaddr, addr_type, size, region);	if (err < B_OK)		goto err1b;	// attach the cache to the region	region->cache_ref = cache_ref;	region->cache_offset = offset;	// point the cache back to the region	vm_cache_insert_region(cache_ref, region);	// insert the region in the global region hash table	acquire_sem_etc(region_hash_sem, WRITE_COUNT, 0 ,0);	hash_insert(region_table, region);	release_sem_etc(region_hash_sem, WRITE_COUNT, 0);	// grab a ref to the aspace (the region holds this)	atomic_add(&aspace->ref_count, 1);	release_sem_etc(aspace->virtual_map.sem, WRITE_COUNT, 0);	*_region = region;	return B_NO_ERROR;err1b:	release_sem_etc(aspace->virtual_map.sem, WRITE_COUNT, 0);	vm_cache_release_ref(cache_ref);	goto err;err1a:	if (nu_cache_ref) {		// had never acquired it's initial ref, so acquire and then release it		// this should clean up all the objects it references		vm_cache_acquire_ref(cache_ref, true);		vm_cache_release_ref(cache_ref);	}err:	free(region->name);	free(region);	return err;}