space_map.c revision a2cdcdd260232b58202b11a9bfc0103c9449ed52
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
#include <sys/dsl_pool.h>
#include <sys/space_map.h>
#include <sys/refcount.h>
#include <sys/zfeature.h>
/*
* The data for a given space map can be kept on blocks of any size.
* Larger blocks entail fewer i/o operations, but they also cause the
* DMU to keep more data in-core, and also to waste more i/o bandwidth
* when only a few blocks have changed since the last transaction group.
*/
/*
* Load the space map disk into the specified range tree. Segments of maptype
* are added to the range tree, other segment types are removed.
*
* Note: space_map_load() will drop sm_lock across dmu_read() calls.
* The caller must be OK with this.
*/
int
{
int error = 0;
}
}
dprintf("object=%llu offset=%llx size=%llx\n",
if (error != 0)
break;
if (SM_DEBUG_DECODE(e)) /* Skip debug entries */
continue;
if (SM_TYPE_DECODE(e) == maptype) {
} else {
}
}
}
if (error == 0)
else
return (error);
}
void
{
return;
}
{
/*
* Verify that the in-core range tree does not have any
* ranges smaller than our sm_shift size.
*/
if (rt->rt_histogram[i] != 0)
return (B_FALSE);
}
return (B_TRUE);
}
void
{
int idx = 0;
return;
/*
* Transfer the content of the range tree histogram to the space
* map histogram. The space map histogram contains 32 buckets ranging
* between 2^sm_shift to 2^(32+sm_shift-1). The range tree,
* however, can represent ranges from 2^0 to 2^63. Since the space
* map only cares about allocatable blocks (minimum of sm_shift) we
* can safely ignore all ranges in the range tree smaller than sm_shift.
*/
/*
* Since the largest histogram bucket in the space map is
* 2^(32+sm_shift-1), we need to normalize the values in
* the range tree for any bucket larger than that size. For
* example given an sm_shift of 9, ranges larger than 2^40
* would get normalized as if they were 1TB ranges. Assume
* the range tree had a count of 5 in the 2^44 (16TB) bucket,
* the calculation below would normalize this to 5 * 2^4 (16).
*/
/*
* Increment the space map's index as long as we haven't
* reached the maximum bucket size. Accumulate all ranges
* larger than the max bucket size into the last bucket.
*/
idx++;
}
}
}
{
/*
* All space_maps always have a debug entry so account for it here.
*/
entries = 1;
/*
* Traverse the range tree and calculate the number of space map
* entries that would be required to write out the range tree.
*/
}
return (entries);
}
/*
* Note: space_map_write() will drop sm_lock across dmu_write() calls.
*/
void
{
/*
* This field is no longer necessary since the in-core space map
* now contains the object number but is maintained for backwards
* compatibility.
*/
if (range_tree_space(rt) == 0) {
return;
}
else
total = 0;
while (size != 0) {
if (entry == entry_map_end) {
}
}
}
}
/*
* Ensure that the space_map's accounting wasn't changed
* while we were in the middle of writing it out.
*/
}
static int
{
int error;
if (error)
return (error);
return (0);
}
int
{
int error;
if (error != 0) {
return (error);
}
return (0);
}
void
{
return;
}
void
{
/*
* If the space map has the wrong bonus size (because
* SPA_FEATURE_SPACEMAP_HISTOGRAM has recently been enabled), or
* the wrong block size (because space_map_blksz has changed),
* free and re-allocate its object with the updated sizes.
*
* Otherwise, just truncate the current object.
*/
zfs_dbgmsg("txg %llu, spa %s, reallocating: "
} else {
/*
* If the spacemap is reallocated, its histogram
* will be reset. Do the same in the common case so that
* bugs related to the uncommon case do not go unnoticed.
*/
}
}
/*
* Update the in-core space_map allocation and length values.
*/
void
{
return;
}
{
int bonuslen;
bonuslen = sizeof (space_map_phys_t);
} else {
}
return (object);
}
void
{
return;
}
}
}
{
}
/*
* Returns the already synced, on-disk allocated space.
*/
{
}
/*
* Returns the already synced, on-disk length;
*/
{
}
/*
* Returns the allocated space that is currently syncing.
*/
{
return (0);
}