zap_leaf.c revision d5285cae913f4e01ffa0e6693a6d8ef1fbea30ba
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER START
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The contents of this file are subject to the terms of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Common Development and Distribution License (the "License").
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You may not use this file except in compliance with the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * See the License for the specific language governing permissions
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and limitations under the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * When distributing Covered Code, include this CDDL HEADER in each
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If applicable, add the following below this CDDL HEADER, with the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fields enclosed by brackets "[]" replaced with your own identifying
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information: Portions Copyright [yyyy] [name of copyright owner]
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER END
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The 512-byte leaf is broken into 32 16-byte chunks.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * chunk number n means l_chunk[n], even though the header precedes it.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the names are stored null-terminated.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic uint16_t *zap_leaf_rehash_entry(zap_leaf_t *l, uint16_t entry);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define CHAIN_END 0xffff /* end of the chunk chain */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* half the (current) minimum block size */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define LEAF_HASH(l, h) \
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ((h) >> (64 - ZAP_LEAF_HASH_SHIFT(l)-(l)->l_phys->l_hdr.lh_prefix_len)))
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#define LEAF_HASH_ENTPTR(l, h) (&(l)->l_phys->l_hash[LEAF_HASH(l, h)])
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor return (0xFEEDFACEDEADBEEFULL);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorzap_leaf_byteswap(zap_leaf_phys_t *buf, int size)
zap_leaf_t l;
for (i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(&l); i++)
for (i = 0; i < ZAP_LEAF_NUMCHUNKS(&l); i++) {
case ZAP_CHUNK_ENTRY:
case ZAP_CHUNK_FREE:
case ZAP_CHUNK_ARRAY:
for (i = 0; i < ZAP_LEAF_NUMCHUNKS(l); i++) {
if (sort)
static uint16_t
int chunk;
return (chunk);
static uint16_t
int byten = 0;
while (len > 0) {
for (i = 0; i < ZAP_LEAF_ARRAY_BYTES; i++) {
if (byten == 0)
byten = 0;
if (--len == 0)
return (chunk_head);
void *buf)
int byten = 0;
char *p = buf;
p += ZAP_LEAF_ARRAY_BYTES;
while (len > 0) {
byten++;
byten = 0;
len--;
if (len == 0)
p += buf_int_len;
static boolean_t
int bseen = 0;
KM_SLEEP);
return (match);
return (match);
return (B_FALSE);
goto again;
return (ENOENT);
return (EINVAL);
return (EOVERFLOW);
char *buf)
return (EOVERFLOW);
int delta_chunks;
return (EAGAIN);
int numchunks;
return (E2BIG);
cd = 0;
cd++;
return (EAGAIN);
* conflicts, in which case we don't need the concatenated/normalized
return (B_FALSE);
if (allocdzn)
return (B_TRUE);
if (allocdzn)
return (B_FALSE);
static uint16_t *
return (chunkp);
static uint16_t
return (new_chunk);
if (sort)
for (i = 0; i < ZAP_LEAF_NUMCHUNKS(l); i++) {
(void) zap_leaf_rehash_entry(l, i);
for (i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(l); i++) {
int nentries = 0;
nentries++;
n = nentries;