dnode.c revision b143e04be7f04fe2274dda9b7004bc95e860f761
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/zfs_context.h>
#include <sys/dmu_impl.h>
#include <sys/dmu_objset.h>
#include <sys/dsl_dataset.h>
#include <sys/dmu_zfetch.h>
static kmem_cache_t *dnode_cache;
static dnode_phys_t dnode_phys_zero;
int zfs_default_bs = SPA_MINBLOCKSHIFT;
/* ARGSUSED */
static int
{
int i;
for (i = 0; i < TXG_SIZE; i++) {
sizeof (free_range_t),
sizeof (dmu_buf_impl_t),
}
return (0);
}
/* ARGSUSED */
static void
{
int i;
for (i = 0; i < TXG_SIZE; i++) {
}
}
void
dnode_init(void)
{
sizeof (dnode_t),
}
void
dnode_fini(void)
{
}
#ifdef ZFS_DEBUG
void
{
int drop_struct_lock = FALSE;
if (!(zfs_flags & ZFS_DEBUG_DNODE_VERIFY))
return;
}
int i;
if (dn->dn_datablkshift) {
}
for (i = 0; i < TXG_SIZE; i++) {
}
}
}
if (drop_struct_lock)
}
#endif
void
{
int i;
return;
}
/*
* dn_nblkptr is only one byte, so it's OK to read it in either
* byte order. We can't read dn_bouslen.
*/
/*
* OK to check dn_bonuslen for zero, because it won't matter if
* we have the wrong byte order. This is necessary because the
* dnode dnode is smaller than a regular dnode.
*/
if (dnp->dn_bonuslen != 0) {
/*
* Note that the bonus length calculated here may be
* longer than the actual bonus buffer. This is because
* we always put the bonus buffer after the last block
* pointer (instead of packing it against the end of the
* dnode buffer).
*/
}
}
void
{
int i;
size >>= DNODE_SHIFT;
for (i = 0; i < size; i++) {
buf++;
}
}
static int
{
return (-1);
return (1);
else return (0);
}
static void
{
}
static dnode_t *
{
if (dnp->dn_datablkszsec)
return (dn);
}
static void
{
if (dn->dn_dirtyctx_firstset) {
}
}
}
void
{
int i;
if (blocksize == 0)
else if (blocksize > SPA_MAXBLOCKSIZE)
else
if (ibs == 0)
for (i = 0; i < TXG_SIZE; i++) {
}
dn->dn_dirtyctx = 0;
dn->dn_free_txg = 0;
if (dn->dn_dirtyctx_firstset) {
}
}
void
{
int i;
for (i = 0; i < TXG_SIZE; i++)
/* clean up any unreferenced dbufs */
(void) dnode_evict_dbufs(dn, 0);
/*
* XXX I should really have a generation number to tell if we
* need to do this...
*/
/* free all old data */
}
/* change blocksize */
/* change type */
/* change bonus size */
if (bonuslen == 0)
}
/* change bonus size and type */
}
void
{
/*
* Wait for final references to the dnode to clear. This can
* only happen if the arc is asyncronously evicting state that
* has a hold on this dnode while we are trying to evict this
* dnode.
*/
delay(1);
}
dnode_t *
{
return (dn);
}
static void
{
int i;
for (i = 0; i < epb; i++) {
int n;
continue;
#ifdef ZFS_DEBUG
/*
* If there are holds on this dnode, then there should
* be holds on the dnode's containing dbuf as well; thus
* it wouldn't be eligable for eviction and this function
* would not have been called.
*/
for (n = 0; n < TXG_SIZE; n++)
#endif
children_dnodes[i] = NULL;
}
}
/*
* errors:
* EINVAL - invalid object number.
* EIO - i/o error.
* succeeds even for free dnodes.
*/
int
{
int drop_struct_lock = FALSE;
int type;
return (EINVAL);
}
if (drop_struct_lock)
return (EIO);
if (err) {
return (err);
}
if (children_dnodes == NULL) {
KM_SLEEP);
}
}
}
}
if (dn->dn_free_txg ||
}
return (0);
}
/*
* Return held dnode if the object is allocated, NULL if not.
*/
int
{
}
void
{
}
void
{
/* NOTE: the DNODE_DNODE does not have a dn_dbuf */
}
void
{
return;
#ifdef ZFS_DEBUG
/* ASSERT(dn->dn_free_txg == 0 || dn->dn_free_txg >= txg); */
#endif
/*
* If we are already marked dirty, we're done.
*/
return;
}
} else {
}
/*
* The dnode maintains a hold on its containing dbuf as
* long as there are holds on it. Each instantiated child
* dbuf maintaines a hold on the dnode. When the last child
* drops its hold, the dnode will drop its hold on the
* containing dbuf. We add a "dirty hold" here so that the
* dnode will hang around after we finish processing its
* children.
*/
}
void
{
/* we should be the only holder... hopefully */
/* ASSERT3U(refcount_count(&dn->dn_holds), ==, 1); */
return;
}
/*
* If the dnode is already dirty, it needs to be moved from
* the dirty list to the free list.
*/
} else {
}
}
/*
* Try to change the block size for the indicated dnode. This can only
* succeed if there are no blocks allocated or dirty beyond first block
*/
int
{
if (size == 0)
if (size > SPA_MAXBLOCKSIZE)
else
ibs = 0;
return (0);
/* Check for any allocated blocks beyond the first */
goto fail;
goto fail;
}
}
goto fail;
/* obtain the old block */
}
if (ibs) {
}
if (db)
return (0);
fail:
return (ENOTSUP);
}
{
return (0);
else
}
void
{
int drop_struct_lock = FALSE;
int epbs, new_nlevels;
}
goto out;
/*
* Compute the number of levels necessary to support the new maxblkid.
*/
new_nlevels = 1;
new_nlevels++;
/* Dirty the left indirects. */
}
out:
if (drop_struct_lock)
}
void
{
/* clear this entire range */
/* clear the beginning of this range */
/* clear the end of this range */
/* clear a chunk out of this range */
}
/* there may be no overlap */
}
}
void
{
/* If the range is past the end of the file, this is a no-op */
goto out;
if (len == -1ULL) {
}
/*
* First, block align the region to free:
*/
} else {
/* Freeing the whole block; don't do any head. */
head = 0;
} else {
/* Freeing part of the block. */
}
}
/* zero out any partial block data at the start of the range */
if (head) {
/* don't dirty if it isn't on disk and isn't dirty */
if (db->db_dirtied ||
}
}
}
/* If the range was less than one block, we're done */
goto out;
/*
* They are freeing the whole block of a
* non-power-of-two blocksize file. Skip all the messy
* math.
*/
blkid = 0;
nblks = 1;
} else {
int tail;
/* If the remaining range is past end of file, we're done */
goto out;
tail = 0;
else
/* zero out any partial block data at the end of the range */
if (tail) {
/* don't dirty if not on disk and not dirty */
if (db->db_dirtied ||
}
}
}
/* If the range did not include a full block, we are done */
if (len == 0)
goto out;
/* dirty the left indirects */
}
/* dirty the right indirects */
}
/*
* Finally, add this range to the dnode range list, we
* will finish up this free operation in the syncing phase.
*/
if (trunc)
}
{
/* Add new range to dn_ranges */
}
out:
}
/* return TRUE if this blkid was freed in a recent txg, or FALSE if it wasn't */
{
int i;
if (blkid == DB_BONUS_BLKID)
return (FALSE);
/*
* If we're in the process of opening the pool, dp will not be
* set yet, but there shouldn't be anything dirty.
*/
return (FALSE);
if (dn->dn_free_txg)
return (TRUE);
/*
* If dn_datablkshift is not set, then there's only a single
* block, in which case there will never be a free range so it
* won't matter.
*/
for (i = 0; i < TXG_SIZE; i++) {
if (range_found) {
break;
}
if (range_found &&
break;
}
return (i < TXG_SIZE);
}
void
{
(longlong_t)delta);
if (delta > 0) {
} else {
}
} else {
}
}
/*
* Be conservative (ie. OK to write less than this or free more than
* this, but don't write more or free less).
*/
void
{
if (space > 0)
if (ds)
}
static int
{
dprintf("probing object %llu offset %llx level %d of %u\n",
error = 0;
} else {
if (error) {
return (error);
}
if (error) {
return (error);
}
}
if (lvl == 0) {
span = DNODE_SHIFT;
break;
}
if (i == blkfill)
} else {
minfill = 0;
if (hole)
maxfill--;
else
minfill++;
i < epb; i++) {
break;
}
if (i >= epb)
}
if (db)
return (error);
}
/*
* Find the next hole, data, or sparse region at or after *offset.
* The value 'blkfill' tells us how many items we expect to find
* in an L0 data block; this value is 1 for normal objects,
* DNODES_PER_BLOCK for the meta dnode, and some fraction of
* DNODES_PER_BLOCK when searching for sparse regions thereof.
* Examples:
*
* dnode_next_offset(dn, hole, offset, 1, 1);
* Used in dmu_offset_next().
*
* dnode_next_offset(mdn, hole, offset, 0, DNODES_PER_BLOCK);
* Used in dmu_object_next().
*
* dnode_next_offset(mdn, TRUE, offset, 2, DNODES_PER_BLOCK >> 2);
* Finds the next L2 meta-dnode bp that's at most 1/4 full.
* Used in dmu_object_alloc().
*/
int
{
int error = 0;
return (ESRCH);
}
if (dn->dn_datablkshift == 0) {
if (hole)
} else {
}
return (error);
}
break;
}
return (error);
}