Lines Matching refs:l
45 static uint16_t *zap_leaf_rehash_entry(zap_leaf_t *l, struct zap_leaf_entry *le,
50 #define LEAF_HASH(l, h) \ argument
51 ((ZAP_LEAF_HASH_NUMENTRIES(l)-1) & \
53 (64 - ZAP_LEAF_HASH_SHIFT(l) - zap_leaf_phys(l)->l_hdr.lh_prefix_len)))
55 #define LEAF_HASH_ENTPTR(l, h) (&zap_leaf_phys(l)->l_hash[LEAF_HASH(l, h)]) argument
99 zap_leaf_t l; in zap_leaf_byteswap() local
103 l.l_bs = highbit64(size) - 1; in zap_leaf_byteswap()
104 l.l_dbuf = &l_dbuf; in zap_leaf_byteswap()
114 for (uint_t i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(&l); i++) in zap_leaf_byteswap()
117 for (uint_t i = 0; i < ZAP_LEAF_NUMCHUNKS(&l); i++) { in zap_leaf_byteswap()
118 zap_leaf_chunk_t *lc = &ZAP_LEAF_CHUNK(&l, i); in zap_leaf_byteswap()
152 zap_leaf_init(zap_leaf_t *l, boolean_t sort) in zap_leaf_init() argument
154 l->l_bs = highbit64(l->l_dbuf->db_size) - 1; in zap_leaf_init()
155 memset(&zap_leaf_phys(l)->l_hdr, 0, in zap_leaf_init()
157 memset(zap_leaf_phys(l)->l_hash, CHAIN_END, in zap_leaf_init()
158 2*ZAP_LEAF_HASH_NUMENTRIES(l)); in zap_leaf_init()
159 for (uint_t i = 0; i < ZAP_LEAF_NUMCHUNKS(l); i++) { in zap_leaf_init()
160 ZAP_LEAF_CHUNK(l, i).l_free.lf_type = ZAP_CHUNK_FREE; in zap_leaf_init()
161 ZAP_LEAF_CHUNK(l, i).l_free.lf_next = i+1; in zap_leaf_init()
163 ZAP_LEAF_CHUNK(l, ZAP_LEAF_NUMCHUNKS(l)-1).l_free.lf_next = CHAIN_END; in zap_leaf_init()
164 zap_leaf_phys(l)->l_hdr.lh_block_type = ZBT_LEAF; in zap_leaf_init()
165 zap_leaf_phys(l)->l_hdr.lh_magic = ZAP_LEAF_MAGIC; in zap_leaf_init()
166 zap_leaf_phys(l)->l_hdr.lh_nfree = ZAP_LEAF_NUMCHUNKS(l); in zap_leaf_init()
168 zap_leaf_phys(l)->l_hdr.lh_flags |= ZLF_ENTRIES_CDSORTED; in zap_leaf_init()
176 zap_leaf_chunk_alloc(zap_leaf_t *l) in zap_leaf_chunk_alloc() argument
178 ASSERT(zap_leaf_phys(l)->l_hdr.lh_nfree > 0); in zap_leaf_chunk_alloc()
180 uint_t chunk = zap_leaf_phys(l)->l_hdr.lh_freelist; in zap_leaf_chunk_alloc()
181 ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); in zap_leaf_chunk_alloc()
182 ASSERT3U(ZAP_LEAF_CHUNK(l, chunk).l_free.lf_type, ==, ZAP_CHUNK_FREE); in zap_leaf_chunk_alloc()
184 zap_leaf_phys(l)->l_hdr.lh_freelist = in zap_leaf_chunk_alloc()
185 ZAP_LEAF_CHUNK(l, chunk).l_free.lf_next; in zap_leaf_chunk_alloc()
187 zap_leaf_phys(l)->l_hdr.lh_nfree--; in zap_leaf_chunk_alloc()
193 zap_leaf_chunk_free(zap_leaf_t *l, uint16_t chunk) in zap_leaf_chunk_free() argument
195 struct zap_leaf_free *zlf = &ZAP_LEAF_CHUNK(l, chunk).l_free; in zap_leaf_chunk_free()
196 ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_nfree, <, ZAP_LEAF_NUMCHUNKS(l)); in zap_leaf_chunk_free()
197 ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); in zap_leaf_chunk_free()
201 zlf->lf_next = zap_leaf_phys(l)->l_hdr.lh_freelist; in zap_leaf_chunk_free()
203 zap_leaf_phys(l)->l_hdr.lh_freelist = chunk; in zap_leaf_chunk_free()
205 zap_leaf_phys(l)->l_hdr.lh_nfree++; in zap_leaf_chunk_free()
213 zap_leaf_array_create(zap_leaf_t *l, const char *buf, in zap_leaf_array_create() argument
228 uint16_t chunk = zap_leaf_chunk_alloc(l); in zap_leaf_array_create()
229 struct zap_leaf_array *la = &ZAP_LEAF_CHUNK(l, chunk).l_array; in zap_leaf_array_create()
256 zap_leaf_array_copy(zap_leaf_t *l, uint16_t chunk, zap_leaf_t *nl) in zap_leaf_array_copy() argument
262 ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); in zap_leaf_array_copy()
266 &ZAP_LEAF_CHUNK(l, chunk).l_array; in zap_leaf_array_copy()
286 zap_leaf_array_free(zap_leaf_t *l, uint16_t chunk) in zap_leaf_array_free() argument
288 struct zap_leaf_header *hdr = &zap_leaf_phys(l)->l_hdr; in zap_leaf_array_free()
293 ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); in zap_leaf_array_free()
294 zap_leaf_chunk_t *c = &ZAP_LEAF_CHUNK(l, chunk); in zap_leaf_array_free()
304 ASSERT3U(hdr->lh_nfree, <, ZAP_LEAF_NUMCHUNKS(l)); in zap_leaf_array_free()
313 zap_leaf_array_read(zap_leaf_t *l, uint16_t chunk, in zap_leaf_array_read() argument
326 struct zap_leaf_array *la = &ZAP_LEAF_CHUNK(l, chunk).l_array; in zap_leaf_array_read()
342 &ZAP_LEAF_CHUNK(l, chunk).l_array; in zap_leaf_array_read()
351 struct zap_leaf_array *la = &ZAP_LEAF_CHUNK(l, chunk).l_array; in zap_leaf_array_read()
353 ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); in zap_leaf_array_read()
371 zap_leaf_array_match(zap_leaf_t *l, zap_name_t *zn, in zap_leaf_array_match() argument
381 zap_leaf_array_read(l, chunk, sizeof (*thiskey), array_numints, in zap_leaf_array_match()
393 zap_leaf_array_read(l, chunk, sizeof (char), array_numints, in zap_leaf_array_match()
408 struct zap_leaf_array *la = &ZAP_LEAF_CHUNK(l, chunk).l_array; in zap_leaf_array_match()
410 ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); in zap_leaf_array_match()
425 zap_leaf_lookup(zap_leaf_t *l, zap_name_t *zn, zap_entry_handle_t *zeh) in zap_leaf_lookup() argument
429 ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC); in zap_leaf_lookup()
431 for (uint16_t *chunkp = LEAF_HASH_ENTPTR(l, zn->zn_hash); in zap_leaf_lookup()
434 le = ZAP_LEAF_ENTRY(l, chunk); in zap_leaf_lookup()
436 ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); in zap_leaf_lookup()
448 (zap_leaf_phys(l)->l_hdr.lh_flags & ZLF_ENTRIES_CDSORTED)); in zap_leaf_lookup()
449 if (zap_leaf_array_match(l, zn, le->le_name_chunk, in zap_leaf_lookup()
456 zeh->zeh_leaf = l; in zap_leaf_lookup()
469 zap_leaf_lookup_closest(zap_leaf_t *l, in zap_leaf_lookup_closest() argument
474 uint16_t bestlh = ZAP_LEAF_HASH_NUMENTRIES(l)-1; in zap_leaf_lookup_closest()
477 ASSERT3U(zap_leaf_phys(l)->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC); in zap_leaf_lookup_closest()
479 for (uint16_t lh = LEAF_HASH(l, h); lh <= bestlh; lh++) { in zap_leaf_lookup_closest()
480 for (uint16_t chunk = zap_leaf_phys(l)->l_hash[lh]; in zap_leaf_lookup_closest()
482 le = ZAP_LEAF_ENTRY(l, chunk); in zap_leaf_lookup_closest()
484 ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); in zap_leaf_lookup_closest()
500 zeh->zeh_leaf = l; in zap_leaf_lookup_closest()
553 zap_leaf_t *l = zeh->zeh_leaf; in zap_entry_update() local
554 struct zap_leaf_entry *le = ZAP_LEAF_ENTRY(l, *zeh->zeh_chunkp); in zap_entry_update()
559 if ((int)zap_leaf_phys(l)->l_hdr.lh_nfree < delta_chunks) in zap_entry_update()
562 zap_leaf_array_free(l, le->le_value_chunk); in zap_entry_update()
564 zap_leaf_array_create(l, buf, integer_size, num_integers); in zap_entry_update()
573 zap_leaf_t *l = zeh->zeh_leaf; in zap_entry_remove() local
578 struct zap_leaf_entry *le = ZAP_LEAF_ENTRY(l, entry_chunk); in zap_entry_remove()
584 zap_leaf_array_free(l, le->le_value_chunk); in zap_entry_remove()
585 zap_leaf_array_free(l, le->le_name_chunk); in zap_entry_remove()
586 zap_leaf_chunk_free(l, entry_chunk); in zap_entry_remove()
588 zap_leaf_phys(l)->l_hdr.lh_nentries--; in zap_entry_remove()
592 zap_entry_create(zap_leaf_t *l, zap_name_t *zn, uint32_t cd, in zap_entry_create() argument
604 if (numchunks > ZAP_LEAF_NUMCHUNKS(l)) in zap_entry_create()
609 if (zap_leaf_phys(l)->l_hdr.lh_flags & ZLF_ENTRIES_CDSORTED) { in zap_entry_create()
612 for (chunk = *LEAF_HASH_ENTPTR(l, h); in zap_entry_create()
614 le = ZAP_LEAF_ENTRY(l, chunk); in zap_entry_create()
625 for (chunk = *LEAF_HASH_ENTPTR(l, h); in zap_entry_create()
627 le = ZAP_LEAF_ENTRY(l, chunk); in zap_entry_create()
645 if (zap_leaf_phys(l)->l_hdr.lh_nfree < numchunks) in zap_entry_create()
649 chunk = zap_leaf_chunk_alloc(l); in zap_entry_create()
650 le = ZAP_LEAF_ENTRY(l, chunk); in zap_entry_create()
652 le->le_name_chunk = zap_leaf_array_create(l, zn->zn_key_orig, in zap_entry_create()
656 zap_leaf_array_create(l, buf, integer_size, num_integers); in zap_entry_create()
664 uint16_t *chunkp = zap_leaf_rehash_entry(l, le, chunk); in zap_entry_create()
666 zap_leaf_phys(l)->l_hdr.lh_nentries++; in zap_entry_create()
668 zeh->zeh_leaf = l; in zap_entry_create()
727 zap_leaf_rehash_entry(zap_leaf_t *l, struct zap_leaf_entry *le, uint16_t entry) in zap_leaf_rehash_entry() argument
737 for (chunkp = LEAF_HASH_ENTPTR(l, le->le_hash); in zap_leaf_rehash_entry()
739 le2 = ZAP_LEAF_ENTRY(l, *chunkp); in zap_leaf_rehash_entry()
750 zap_leaf_transfer_entry(zap_leaf_t *l, uint_t entry, zap_leaf_t *nl) in zap_leaf_transfer_entry() argument
752 struct zap_leaf_entry *le = ZAP_LEAF_ENTRY(l, entry); in zap_leaf_transfer_entry()
761 nle->le_name_chunk = zap_leaf_array_copy(l, le->le_name_chunk, nl); in zap_leaf_transfer_entry()
762 nle->le_value_chunk = zap_leaf_array_copy(l, le->le_value_chunk, nl); in zap_leaf_transfer_entry()
765 zap_leaf_array_free(l, le->le_value_chunk); in zap_leaf_transfer_entry()
766 zap_leaf_array_free(l, le->le_name_chunk); in zap_leaf_transfer_entry()
767 zap_leaf_chunk_free(l, entry); in zap_leaf_transfer_entry()
769 zap_leaf_phys(l)->l_hdr.lh_nentries--; in zap_leaf_transfer_entry()
777 zap_leaf_split(zap_leaf_t *l, zap_leaf_t *nl, boolean_t sort) in zap_leaf_split() argument
779 uint_t bit = 64 - 1 - zap_leaf_phys(l)->l_hdr.lh_prefix_len; in zap_leaf_split()
782 zap_leaf_phys(l)->l_hdr.lh_prefix <<= 1; in zap_leaf_split()
783 zap_leaf_phys(l)->l_hdr.lh_prefix_len++; in zap_leaf_split()
785 zap_leaf_phys(l)->l_hdr.lh_prefix | 1; in zap_leaf_split()
787 zap_leaf_phys(l)->l_hdr.lh_prefix_len; in zap_leaf_split()
790 memset(zap_leaf_phys(l)->l_hash, CHAIN_END, in zap_leaf_split()
791 2*ZAP_LEAF_HASH_NUMENTRIES(l)); in zap_leaf_split()
794 zap_leaf_phys(l)->l_hdr.lh_flags |= ZLF_ENTRIES_CDSORTED; in zap_leaf_split()
805 for (uint_t i = 0; i < ZAP_LEAF_NUMCHUNKS(l); i++) { in zap_leaf_split()
806 struct zap_leaf_entry *le = ZAP_LEAF_ENTRY(l, i); in zap_leaf_split()
811 zap_leaf_transfer_entry(l, i, nl); in zap_leaf_split()
813 (void) zap_leaf_rehash_entry(l, le, i); in zap_leaf_split()
818 zap_leaf_stats(zap_t *zap, zap_leaf_t *l, zap_stats_t *zs) in zap_leaf_stats() argument
821 zap_leaf_phys(l)->l_hdr.lh_prefix_len; in zap_leaf_stats()
826 n = zap_leaf_phys(l)->l_hdr.lh_nentries/5; in zap_leaf_stats()
831 zap_leaf_phys(l)->l_hdr.lh_nfree * (ZAP_LEAF_ARRAY_BYTES+1))*10 / in zap_leaf_stats()
836 for (uint_t i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(l); i++) { in zap_leaf_stats()
838 uint_t chunk = zap_leaf_phys(l)->l_hash[i]; in zap_leaf_stats()
842 ZAP_LEAF_ENTRY(l, chunk); in zap_leaf_stats()