zap.c revision c5f9e43110e1fb316fc4297c2d150b3518b80bbe
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * CDDL HEADER START
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * The contents of this file are subject to the terms of the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Common Development and Distribution License (the "License").
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * You may not use this file except in compliance with the License.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * See the License for the specific language governing permissions
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * and limitations under the License.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * When distributing Covered Code, include this CDDL HEADER in each
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * If applicable, add the following below this CDDL HEADER, with the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * fields enclosed by brackets "[]" replaced with your own identifying
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * information: Portions Copyright [yyyy] [name of copyright owner]
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * CDDL HEADER END
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Use is subject to license terms.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster#pragma ident "%Z%%M% %I% %E% SMI"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * This file contains the top half of the zfs directory structure
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * implementation. The bottom half is in zap_leaf.c.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * The zdir is an extendable hash data structure. There is a table of
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * pointers to buckets (zap_t->zd_data->zd_leafs). The buckets are
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * each a constant size and hold a variable number of directory entries.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * The buckets (aka "leaf nodes") are implemented in zap_leaf.c.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * The pointer table holds a power of 2 number of pointers.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * (1<<zap_t->zd_data->zd_phys->zd_prefix_len). The bucket pointed to
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * by the pointer at index i in the table holds entries whose hash value
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * has a zd_prefix_len - bit prefix
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterint fzap_default_block_shift = 14; /* 16k blocksize */
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterstatic void zap_leaf_pageout(dmu_buf_t *db, void *vl);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterstatic uint64_t zap_allocate_blocks(zap_t *zap, int nblocks);
zap_leaf_t *l;
int err;
if (err)
return (err);
int err;
if (err)
return (err);
if (err) {
return (err);
int err;
if (err)
return (err);
return (err);
return (ENOSPC);
int err;
if (err)
return (err);
static uint64_t
return (newblk);
static zap_leaf_t *
void *winner;
static zap_leaf_t *
l = winner;
zap_leaf_t *l;
int err;
if (err)
return (err);
if (l == NULL)
*lp = l;
int err;
if (err != 0)
return (err);
return (err);
zap_put_leaf(l);
if (err)
return (err);
while (old_prefix_len ==
if (err)
return (err);
if (err)
return (err);
*lp = l;
if (err)
return (err);
zap_put_leaf(l);
*lp = l;
zap_put_leaf(l);
int err;
if (err)
return (E2BIG);
switch (integer_size) {
return (EINVAL);
return (E2BIG);
zap_leaf_t *l;
int err;
if (err != 0)
return (err);
if (err != 0)
return (err);
if (err == 0) {
if (ncp) {
zap_put_leaf(l);
return (err);
zap_leaf_t *l;
int err;
if (err != 0)
return (err);
if (err == 0) {
goto out;
goto out;
if (err == 0) {
if (err == 0)
goto retry;
out:
return (err);
if (err != 0)
return (err);
zap_leaf_t *l;
if (err != 0)
return (err);
if (err != 0)
return (err);
if (create) {
if (err == 0)
if (err == 0)
goto retry;
return (err);
zap_leaf_t *l;
int err;
if (err != 0)
return (err);
if (err != 0)
goto out;
if (integer_size)
if (num_integers)
out:
zap_put_leaf(l);
return (err);
zap_leaf_t *l;
int err;
if (err != 0)
return (err);
if (err == 0) {
zap_put_leaf(l);
return (err);
char *name)
int err;
if (mask == 0)
return (err);
zap_leaf_t *l;
if (err != 0)
return (err);
goto again;
if (err == 0) {
return (err);
int i, err;
for (i = 0; i < len; i++) {
zap_leaf_t *l;
if (err == 0) {
zap_put_leaf(l);
int err;
if (err == 0) {