/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (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 * or http://www.opensolaris.org/os/licensing. * 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 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _SYS_ZAP_LEAF_H #define _SYS_ZAP_LEAF_H #pragma ident "%Z%%M% %I% %E% SMI" #ifdef __cplusplus extern "C" { #endif struct zap; #define ZAP_LEAF_MAGIC 0x2AB1EAF /* chunk size = 24 bytes */ #define ZAP_LEAF_NUMCHUNKS 5118 #define ZAP_LEAF_ARRAY_BYTES 21 #define ZAP_LEAF_HASH_SHIFT 12 #define ZAP_LEAF_HASH_NUMENTRIES (1 << ZAP_LEAF_HASH_SHIFT) #define ZAP_LLA_DATA_BYTES ((1 << ZAP_BLOCK_SHIFT) - 16) typedef enum zap_entry_type { ZAP_LEAF_FREE = 253, ZAP_LEAF_ENTRY = 252, ZAP_LEAF_ARRAY = 251, ZAP_LEAF_TYPE_MAX = 250 } zap_entry_type_t; /* * TAKE NOTE: * If zap_leaf_phys_t is modified, zap_leaf_byteswap() must be modified. */ typedef struct zap_leaf_phys { struct zap_leaf_header { uint64_t lhr_block_type; /* ZBT_LEAF */ uint64_t lhr_next; /* next block in leaf chain */ uint64_t lhr_prefix; uint32_t lhr_magic; /* ZAP_LEAF_MAGIC */ uint16_t lhr_nfree; /* number free chunks */ uint16_t lhr_nentries; /* number of entries */ uint16_t lhr_prefix_len; #define lh_block_type l_phys->l_hdr.lhr_block_type #define lh_magic l_phys->l_hdr.lhr_magic #define lh_next l_phys->l_hdr.lhr_next #define lh_prefix l_phys->l_hdr.lhr_prefix #define lh_nfree l_phys->l_hdr.lhr_nfree #define lh_prefix_len l_phys->l_hdr.lhr_prefix_len #define lh_nentries l_phys->l_hdr.lhr_nentries /* above is accessable to zap, below is zap_leaf private */ uint16_t lh_freelist; /* chunk head of free list */ uint8_t lh_pad2[12]; } l_hdr; /* 2 24-byte chunks */ uint16_t l_hash[ZAP_LEAF_HASH_NUMENTRIES]; /* 170 24-byte chunks plus 16 bytes leftover space */ union zap_leaf_chunk { struct zap_leaf_entry { uint8_t le_type; /* always ZAP_LEAF_ENTRY */ uint8_t le_int_size; /* size of ints */ uint16_t le_next; /* next entry in hash chain */ uint16_t le_name_chunk; /* first chunk of the name */ uint16_t le_name_length; /* bytes in name, incl null */ uint16_t le_value_chunk; /* first chunk of the value */ uint16_t le_value_length; /* value length in ints */ uint32_t le_cd; /* collision differentiator */ uint64_t le_hash; /* hash value of the name */ } l_entry; struct zap_leaf_array { uint8_t la_type; uint8_t la_array[ZAP_LEAF_ARRAY_BYTES]; uint16_t la_next; /* next blk or CHAIN_END */ } l_array; struct zap_leaf_free { uint8_t lf_type; /* always ZAP_LEAF_FREE */ uint8_t lf_pad[ZAP_LEAF_ARRAY_BYTES]; uint16_t lf_next; /* next in free list, or CHAIN_END */ } l_free; } l_chunk[ZAP_LEAF_NUMCHUNKS]; } zap_leaf_phys_t; typedef struct zap_leaf { krwlock_t l_rwlock; /* only used on head of chain */ uint64_t l_blkid; /* 1<