1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2012 by Delphix. All rights reserved. |
24 */ 25 26/* 27 * This file contains the top half of the zfs directory structure 28 * implementation. The bottom half is in zap_leaf.c. 29 * 30 * The zdir is an extendable hash data structure. There is a table of 31 * pointers to buckets (zap_t->zd_data->zd_leafs). The buckets are --- 125 unchanged lines hidden (view full) --- 157 ASSERT(tbl->zt_blk != 0); 158 ASSERT(tbl->zt_numblks > 0); 159 160 if (tbl->zt_nextblk != 0) { 161 newblk = tbl->zt_nextblk; 162 } else { 163 newblk = zap_allocate_blocks(zap, tbl->zt_numblks * 2); 164 tbl->zt_nextblk = newblk; |
165 ASSERT0(tbl->zt_blks_copied); |
166 dmu_prefetch(zap->zap_objset, zap->zap_object, 167 tbl->zt_blk << bs, tbl->zt_numblks << bs); 168 } 169 170 /* 171 * Copy the ptrtbl from the old to new location. 172 */ 173 --- 160 unchanged lines hidden (view full) --- 334 * block, which will double the size of the ptrtbl. 335 */ 336 uint64_t newblk; 337 dmu_buf_t *db_new; 338 int err; 339 340 ASSERT3U(zap->zap_f.zap_phys->zap_ptrtbl.zt_shift, ==, 341 ZAP_EMBEDDED_PTRTBL_SHIFT(zap)); |
342 ASSERT0(zap->zap_f.zap_phys->zap_ptrtbl.zt_blk); |
343 344 newblk = zap_allocate_blocks(zap, 1); 345 err = dmu_buf_hold(zap->zap_objset, zap->zap_object, 346 newblk << FZAP_BLOCK_SHIFT(zap), FTAG, &db_new, 347 DMU_READ_NO_PREFETCH); 348 if (err) 349 return (err); 350 dmu_buf_will_dirty(db_new, tx); --- 119 unchanged lines hidden (view full) --- 470 l = winner; 471 } 472 473 /* 474 * lhr_pad was previously used for the next leaf in the leaf 475 * chain. There should be no chained leafs (as we have removed 476 * support for them). 477 */ |
478 ASSERT0(l->l_phys->l_hdr.lh_pad1); |
479 480 /* 481 * There should be more hash entries than there can be 482 * chunks to put in the hash table 483 */ 484 ASSERT3U(ZAP_LEAF_HASH_NUMENTRIES(l), >, ZAP_LEAF_NUMCHUNKS(l) / 3); 485 486 /* The chunks should begin at the end of the hash table */ --- 166 unchanged lines hidden (view full) --- 653 return (err); 654 ASSERT3U(blk, ==, l->l_blkid); 655 } 656 657 nl = zap_create_leaf(zap, tx); 658 zap_leaf_split(l, nl, zap->zap_normflags != 0); 659 660 /* set sibling pointers */ |
661 for (i = 0; i < (1ULL << prefix_diff); i++) { |
662 err = zap_set_idx_to_blk(zap, sibling+i, nl->l_blkid, tx); |
663 ASSERT0(err); /* we checked for i/o errors above */ |
664 } 665 666 if (hash & (1ULL << (64 - l->l_phys->l_hdr.lh_prefix_len))) { 667 /* we want the sibling */ 668 zap_put_leaf(l); 669 *lp = nl; 670 } else { 671 zap_put_leaf(nl); --- 270 unchanged lines hidden (view full) --- 942 bs = FZAP_BLOCK_SHIFT(zap); 943 dmu_prefetch(zap->zap_objset, zap->zap_object, blk << bs, 1 << bs); 944} 945 946/* 947 * Helper functions for consumers. 948 */ 949 |
950uint64_t 951zap_create_link(objset_t *os, dmu_object_type_t ot, uint64_t parent_obj, 952 const char *name, dmu_tx_t *tx) 953{ 954 uint64_t new_obj; 955 956 VERIFY((new_obj = zap_create(os, ot, DMU_OT_NONE, 0, tx)) > 0); 957 VERIFY(zap_add(os, parent_obj, name, sizeof (uint64_t), 1, &new_obj, 958 tx) == 0); 959 960 return (new_obj); 961} 962 |
963int 964zap_value_search(objset_t *os, uint64_t zapobj, uint64_t value, uint64_t mask, 965 char *name) 966{ 967 zap_cursor_t zc; 968 zap_attribute_t *za; 969 int err; 970 --- 118 unchanged lines hidden (view full) --- 1089{ 1090 char name[20]; 1091 1092 (void) snprintf(name, sizeof (name), "%llx", (longlong_t)key); 1093 return (zap_add(os, obj, name, 8, 1, &value, tx)); 1094} 1095 1096int |
1097zap_update_int_key(objset_t *os, uint64_t obj, 1098 uint64_t key, uint64_t value, dmu_tx_t *tx) 1099{ 1100 char name[20]; 1101 1102 (void) snprintf(name, sizeof (name), "%llx", (longlong_t)key); 1103 return (zap_update(os, obj, name, 8, 1, &value, tx)); 1104} 1105 1106int |
1107zap_lookup_int_key(objset_t *os, uint64_t obj, uint64_t key, uint64_t *valuep) 1108{ 1109 char name[20]; 1110 1111 (void) snprintf(name, sizeof (name), "%llx", (longlong_t)key); 1112 return (zap_lookup(os, obj, name, 8, 1, valuep)); 1113} 1114 --- 264 unchanged lines hidden --- |