Deleted Added
full compact
zap.c (225736) zap.c (243674)
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.
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.
23 */
24
25/*
26 * This file contains the top half of the zfs directory structure
27 * implementation. The bottom half is in zap_leaf.c.
28 *
29 * The zdir is an extendable hash data structure. There is a table of
30 * pointers to buckets (zap_t->zd_data->zd_leafs). The buckets are

--- 125 unchanged lines hidden (view full) ---

156 ASSERT(tbl->zt_blk != 0);
157 ASSERT(tbl->zt_numblks > 0);
158
159 if (tbl->zt_nextblk != 0) {
160 newblk = tbl->zt_nextblk;
161 } else {
162 newblk = zap_allocate_blocks(zap, tbl->zt_numblks * 2);
163 tbl->zt_nextblk = newblk;
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;
164 ASSERT3U(tbl->zt_blks_copied, ==, 0);
165 ASSERT0(tbl->zt_blks_copied);
165 dmu_prefetch(zap->zap_objset, zap->zap_object,
166 tbl->zt_blk << bs, tbl->zt_numblks << bs);
167 }
168
169 /*
170 * Copy the ptrtbl from the old to new location.
171 */
172

--- 160 unchanged lines hidden (view full) ---

333 * block, which will double the size of the ptrtbl.
334 */
335 uint64_t newblk;
336 dmu_buf_t *db_new;
337 int err;
338
339 ASSERT3U(zap->zap_f.zap_phys->zap_ptrtbl.zt_shift, ==,
340 ZAP_EMBEDDED_PTRTBL_SHIFT(zap));
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));
341 ASSERT3U(zap->zap_f.zap_phys->zap_ptrtbl.zt_blk, ==, 0);
342 ASSERT0(zap->zap_f.zap_phys->zap_ptrtbl.zt_blk);
342
343 newblk = zap_allocate_blocks(zap, 1);
344 err = dmu_buf_hold(zap->zap_objset, zap->zap_object,
345 newblk << FZAP_BLOCK_SHIFT(zap), FTAG, &db_new,
346 DMU_READ_NO_PREFETCH);
347 if (err)
348 return (err);
349 dmu_buf_will_dirty(db_new, tx);

--- 119 unchanged lines hidden (view full) ---

469 l = winner;
470 }
471
472 /*
473 * lhr_pad was previously used for the next leaf in the leaf
474 * chain. There should be no chained leafs (as we have removed
475 * support for them).
476 */
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 */
477 ASSERT3U(l->l_phys->l_hdr.lh_pad1, ==, 0);
478 ASSERT0(l->l_phys->l_hdr.lh_pad1);
478
479 /*
480 * There should be more hash entries than there can be
481 * chunks to put in the hash table
482 */
483 ASSERT3U(ZAP_LEAF_HASH_NUMENTRIES(l), >, ZAP_LEAF_NUMCHUNKS(l) / 3);
484
485 /* The chunks should begin at the end of the hash table */

--- 166 unchanged lines hidden (view full) ---

652 return (err);
653 ASSERT3U(blk, ==, l->l_blkid);
654 }
655
656 nl = zap_create_leaf(zap, tx);
657 zap_leaf_split(l, nl, zap->zap_normflags != 0);
658
659 /* set sibling pointers */
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 */
660 for (i = 0; i < (1ULL<<prefix_diff); i++) {
661 for (i = 0; i < (1ULL << prefix_diff); i++) {
661 err = zap_set_idx_to_blk(zap, sibling+i, nl->l_blkid, tx);
662 err = zap_set_idx_to_blk(zap, sibling+i, nl->l_blkid, tx);
662 ASSERT3U(err, ==, 0); /* we checked for i/o errors above */
663 ASSERT0(err); /* we checked for i/o errors above */
663 }
664
665 if (hash & (1ULL << (64 - l->l_phys->l_hdr.lh_prefix_len))) {
666 /* we want the sibling */
667 zap_put_leaf(l);
668 *lp = nl;
669 } else {
670 zap_put_leaf(nl);

--- 270 unchanged lines hidden (view full) ---

941 bs = FZAP_BLOCK_SHIFT(zap);
942 dmu_prefetch(zap->zap_objset, zap->zap_object, blk << bs, 1 << bs);
943}
944
945/*
946 * Helper functions for consumers.
947 */
948
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
949int
950zap_value_search(objset_t *os, uint64_t zapobj, uint64_t value, uint64_t mask,
951 char *name)
952{
953 zap_cursor_t zc;
954 zap_attribute_t *za;
955 int err;
956

--- 118 unchanged lines hidden (view full) ---

1075{
1076 char name[20];
1077
1078 (void) snprintf(name, sizeof (name), "%llx", (longlong_t)key);
1079 return (zap_add(os, obj, name, 8, 1, &value, tx));
1080}
1081
1082int
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
1083zap_lookup_int_key(objset_t *os, uint64_t obj, uint64_t key, uint64_t *valuep)
1084{
1085 char name[20];
1086
1087 (void) snprintf(name, sizeof (name), "%llx", (longlong_t)key);
1088 return (zap_lookup(os, obj, name, 8, 1, valuep));
1089}
1090

--- 264 unchanged lines hidden ---
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 ---