zap.c revision 478ed9ada0b6efe1318150a700986aa47e6a926d
199767f8919635c4928607450d9e0abb932109ceToomas Soome * CDDL HEADER START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The contents of this file are subject to the terms of the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Common Development and Distribution License (the "License").
199767f8919635c4928607450d9e0abb932109ceToomas Soome * You may not use this file except in compliance with the License.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * See the License for the specific language governing permissions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * and limitations under the License.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * When distributing Covered Code, include this CDDL HEADER in each
199767f8919635c4928607450d9e0abb932109ceToomas Soome * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * If applicable, add the following below this CDDL HEADER, with the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * fields enclosed by brackets "[]" replaced with your own identifying
199767f8919635c4928607450d9e0abb932109ceToomas Soome * information: Portions Copyright [yyyy] [name of copyright owner]
199767f8919635c4928607450d9e0abb932109ceToomas Soome * CDDL HEADER END
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Use is subject to license terms.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This file contains the top half of the zfs directory structure
199767f8919635c4928607450d9e0abb932109ceToomas Soome * implementation. The bottom half is in zap_leaf.c.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The zdir is an extendable hash data structure. There is a table of
199767f8919635c4928607450d9e0abb932109ceToomas Soome * pointers to buckets (zap_t->zd_data->zd_leafs). The buckets are
199767f8919635c4928607450d9e0abb932109ceToomas Soome * each a constant size and hold a variable number of directory entries.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The buckets (aka "leaf nodes") are implemented in zap_leaf.c.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The pointer table holds a power of 2 number of pointers.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (1<<zap_t->zd_data->zd_phys->zd_prefix_len). The bucket pointed to
199767f8919635c4928607450d9e0abb932109ceToomas Soome * by the pointer at index i in the table holds entries whose hash value
199767f8919635c4928607450d9e0abb932109ceToomas Soome * has a zd_prefix_len - bit prefix
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);
int err;
return (EINVAL);
if (err)
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) {