Deleted Added
full compact
zap_micro.c (321527) zap_micro.c (321545)
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

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

13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
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 */
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

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

13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
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
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
24 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
25 * Copyright (c) 2014 Integros [integros.com]
22/*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
25 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
26 * Copyright (c) 2014 Integros [integros.com]
27 * Copyright 2017 Nexenta Systems, Inc.
26 */
27
28#include <sys/zio.h>
29#include <sys/spa.h>
30#include <sys/dmu.h>
31#include <sys/zfs_context.h>
32#include <sys/zap.h>
33#include <sys/refcount.h>

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

128 * chosing the bucket.
129 */
130 h &= ~((1ULL << (64 - zap_hashbits(zap))) - 1);
131
132 return (h);
133}
134
135static int
28 */
29
30#include <sys/zio.h>
31#include <sys/spa.h>
32#include <sys/dmu.h>
33#include <sys/zfs_context.h>
34#include <sys/zap.h>
35#include <sys/refcount.h>

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

130 * chosing the bucket.
131 */
132 h &= ~((1ULL << (64 - zap_hashbits(zap))) - 1);
133
134 return (h);
135}
136
137static int
136zap_normalize(zap_t *zap, const char *name, char *namenorm)
138zap_normalize(zap_t *zap, const char *name, char *namenorm, int normflags)
137{
138 size_t inlen, outlen;
139 int err;
140
141 ASSERT(!(zap_getflags(zap) & ZAP_FLAG_UINT64_KEY));
142
143 inlen = strlen(name) + 1;
144 outlen = ZAP_MAXNAMELEN;
145
146 err = 0;
147 (void) u8_textprep_str((char *)name, &inlen, namenorm, &outlen,
139{
140 size_t inlen, outlen;
141 int err;
142
143 ASSERT(!(zap_getflags(zap) & ZAP_FLAG_UINT64_KEY));
144
145 inlen = strlen(name) + 1;
146 outlen = ZAP_MAXNAMELEN;
147
148 err = 0;
149 (void) u8_textprep_str((char *)name, &inlen, namenorm, &outlen,
148 zap->zap_normflags | U8_TEXTPREP_IGNORE_NULL |
149 U8_TEXTPREP_IGNORE_INVALID, U8_UNICODE_LATEST, &err);
150 normflags | U8_TEXTPREP_IGNORE_NULL | U8_TEXTPREP_IGNORE_INVALID,
151 U8_UNICODE_LATEST, &err);
150
151 return (err);
152}
153
154boolean_t
155zap_match(zap_name_t *zn, const char *matchname)
156{
157 ASSERT(!(zap_getflags(zn->zn_zap) & ZAP_FLAG_UINT64_KEY));
158
152
153 return (err);
154}
155
156boolean_t
157zap_match(zap_name_t *zn, const char *matchname)
158{
159 ASSERT(!(zap_getflags(zn->zn_zap) & ZAP_FLAG_UINT64_KEY));
160
159 if (zn->zn_matchtype == MT_FIRST) {
161 if (zn->zn_matchtype & MT_NORMALIZE) {
160 char norm[ZAP_MAXNAMELEN];
161
162 char norm[ZAP_MAXNAMELEN];
163
162 if (zap_normalize(zn->zn_zap, matchname, norm) != 0)
164 if (zap_normalize(zn->zn_zap, matchname, norm,
165 zn->zn_normflags) != 0)
163 return (B_FALSE);
164
165 return (strcmp(zn->zn_key_norm, norm) == 0);
166 } else {
166 return (B_FALSE);
167
168 return (strcmp(zn->zn_key_norm, norm) == 0);
169 } else {
167 /* MT_BEST or MT_EXACT */
168 return (strcmp(zn->zn_key_orig, matchname) == 0);
169 }
170}
171
172void
173zap_name_free(zap_name_t *zn)
174{
175 kmem_free(zn, sizeof (zap_name_t));

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

180{
181 zap_name_t *zn = kmem_alloc(sizeof (zap_name_t), KM_SLEEP);
182
183 zn->zn_zap = zap;
184 zn->zn_key_intlen = sizeof (*key);
185 zn->zn_key_orig = key;
186 zn->zn_key_orig_numints = strlen(zn->zn_key_orig) + 1;
187 zn->zn_matchtype = mt;
170 return (strcmp(zn->zn_key_orig, matchname) == 0);
171 }
172}
173
174void
175zap_name_free(zap_name_t *zn)
176{
177 kmem_free(zn, sizeof (zap_name_t));

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

182{
183 zap_name_t *zn = kmem_alloc(sizeof (zap_name_t), KM_SLEEP);
184
185 zn->zn_zap = zap;
186 zn->zn_key_intlen = sizeof (*key);
187 zn->zn_key_orig = key;
188 zn->zn_key_orig_numints = strlen(zn->zn_key_orig) + 1;
189 zn->zn_matchtype = mt;
190 zn->zn_normflags = zap->zap_normflags;
191
192 /*
193 * If we're dealing with a case sensitive lookup on a mixed or
194 * insensitive fs, remove U8_TEXTPREP_TOUPPER or the lookup
195 * will fold case to all caps overriding the lookup request.
196 */
197 if (mt & MT_MATCH_CASE)
198 zn->zn_normflags &= ~U8_TEXTPREP_TOUPPER;
199
188 if (zap->zap_normflags) {
200 if (zap->zap_normflags) {
189 if (zap_normalize(zap, key, zn->zn_normbuf) != 0) {
201 /*
202 * We *must* use zap_normflags because this normalization is
203 * what the hash is computed from.
204 */
205 if (zap_normalize(zap, key, zn->zn_normbuf,
206 zap->zap_normflags) != 0) {
190 zap_name_free(zn);
191 return (NULL);
192 }
193 zn->zn_key_norm = zn->zn_normbuf;
194 zn->zn_key_norm_numints = strlen(zn->zn_key_norm) + 1;
195 } else {
207 zap_name_free(zn);
208 return (NULL);
209 }
210 zn->zn_key_norm = zn->zn_normbuf;
211 zn->zn_key_norm_numints = strlen(zn->zn_key_norm) + 1;
212 } else {
196 if (mt != MT_EXACT) {
213 if (mt != 0) {
197 zap_name_free(zn);
198 return (NULL);
199 }
200 zn->zn_key_norm = zn->zn_key_orig;
201 zn->zn_key_norm_numints = zn->zn_key_orig_numints;
202 }
203
204 zn->zn_hash = zap_hash(zn);
214 zap_name_free(zn);
215 return (NULL);
216 }
217 zn->zn_key_norm = zn->zn_key_orig;
218 zn->zn_key_norm_numints = zn->zn_key_orig_numints;
219 }
220
221 zn->zn_hash = zap_hash(zn);
222
223 if (zap->zap_normflags != zn->zn_normflags) {
224 /*
225 * We *must* use zn_normflags because this normalization is
226 * what the matching is based on. (Not the hash!)
227 */
228 if (zap_normalize(zap, key, zn->zn_normbuf,
229 zn->zn_normflags) != 0) {
230 zap_name_free(zn);
231 return (NULL);
232 }
233 zn->zn_key_norm_numints = strlen(zn->zn_key_norm) + 1;
234 }
235
205 return (zn);
206}
207
208zap_name_t *
209zap_name_alloc_uint64(zap_t *zap, const uint64_t *key, int numints)
210{
211 zap_name_t *zn = kmem_alloc(sizeof (zap_name_t), KM_SLEEP);
212
213 ASSERT(zap->zap_normflags == 0);
214 zn->zn_zap = zap;
215 zn->zn_key_intlen = sizeof (*key);
216 zn->zn_key_orig = zn->zn_key_norm = key;
217 zn->zn_key_orig_numints = zn->zn_key_norm_numints = numints;
236 return (zn);
237}
238
239zap_name_t *
240zap_name_alloc_uint64(zap_t *zap, const uint64_t *key, int numints)
241{
242 zap_name_t *zn = kmem_alloc(sizeof (zap_name_t), KM_SLEEP);
243
244 ASSERT(zap->zap_normflags == 0);
245 zn->zn_zap = zap;
246 zn->zn_key_intlen = sizeof (*key);
247 zn->zn_key_orig = zn->zn_key_norm = key;
248 zn->zn_key_orig_numints = zn->zn_key_norm_numints = numints;
218 zn->zn_matchtype = MT_EXACT;
249 zn->zn_matchtype = 0;
219
220 zn->zn_hash = zap_hash(zn);
221 return (zn);
222}
223
224static void
225mzap_byteswap(mzap_phys_t *buf, size_t size)
226{

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

300 avl_tree_t *avl = &zn->zn_zap->zap_m.zap_avl;
301
302 ASSERT(zn->zn_zap->zap_ismicro);
303 ASSERT(RW_LOCK_HELD(&zn->zn_zap->zap_rwlock));
304
305 mze_tofind.mze_hash = zn->zn_hash;
306 mze_tofind.mze_cd = 0;
307
250
251 zn->zn_hash = zap_hash(zn);
252 return (zn);
253}
254
255static void
256mzap_byteswap(mzap_phys_t *buf, size_t size)
257{

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

331 avl_tree_t *avl = &zn->zn_zap->zap_m.zap_avl;
332
333 ASSERT(zn->zn_zap->zap_ismicro);
334 ASSERT(RW_LOCK_HELD(&zn->zn_zap->zap_rwlock));
335
336 mze_tofind.mze_hash = zn->zn_hash;
337 mze_tofind.mze_cd = 0;
338
308again:
309 mze = avl_find(avl, &mze_tofind, &idx);
310 if (mze == NULL)
311 mze = avl_nearest(avl, idx, AVL_AFTER);
312 for (; mze && mze->mze_hash == zn->zn_hash; mze = AVL_NEXT(avl, mze)) {
313 ASSERT3U(mze->mze_cd, ==, MZE_PHYS(zn->zn_zap, mze)->mze_cd);
314 if (zap_match(zn, MZE_PHYS(zn->zn_zap, mze)->mze_name))
315 return (mze);
316 }
339 mze = avl_find(avl, &mze_tofind, &idx);
340 if (mze == NULL)
341 mze = avl_nearest(avl, idx, AVL_AFTER);
342 for (; mze && mze->mze_hash == zn->zn_hash; mze = AVL_NEXT(avl, mze)) {
343 ASSERT3U(mze->mze_cd, ==, MZE_PHYS(zn->zn_zap, mze)->mze_cd);
344 if (zap_match(zn, MZE_PHYS(zn->zn_zap, mze)->mze_name))
345 return (mze);
346 }
317 if (zn->zn_matchtype == MT_BEST) {
318 zn->zn_matchtype = MT_FIRST;
319 goto again;
320 }
347
321 return (NULL);
322}
323
324static uint32_t
325mze_find_unused_cd(zap_t *zap, uint64_t hash)
326{
327 mzap_ent_t mze_tofind;
328 mzap_ent_t *mze;

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

417 sizeof (mzap_ent_t), offsetof(mzap_ent_t, mze_node));
418
419 for (i = 0; i < zap->zap_m.zap_num_chunks; i++) {
420 mzap_ent_phys_t *mze =
421 &zap_m_phys(zap)->mz_chunk[i];
422 if (mze->mze_name[0]) {
423 zap_name_t *zn;
424
348 return (NULL);
349}
350
351static uint32_t
352mze_find_unused_cd(zap_t *zap, uint64_t hash)
353{
354 mzap_ent_t mze_tofind;
355 mzap_ent_t *mze;

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

444 sizeof (mzap_ent_t), offsetof(mzap_ent_t, mze_node));
445
446 for (i = 0; i < zap->zap_m.zap_num_chunks; i++) {
447 mzap_ent_phys_t *mze =
448 &zap_m_phys(zap)->mz_chunk[i];
449 if (mze->mze_name[0]) {
450 zap_name_t *zn;
451
425 zn = zap_name_alloc(zap, mze->mze_name,
426 MT_EXACT);
452 zn = zap_name_alloc(zap, mze->mze_name, 0);
427 if (mze_insert(zap, i, zn->zn_hash) == 0)
428 zap->zap_m.zap_num_entries++;
429 else {
430 printf("ZFS WARNING: Duplicated ZAP "
431 "entry detected (%s).\n",
432 mze->mze_name);
433 }
434 zap_name_free(zn);

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

624
625 for (i = 0; i < nchunks; i++) {
626 mzap_ent_phys_t *mze = &mzp->mz_chunk[i];
627 zap_name_t *zn;
628 if (mze->mze_name[0] == 0)
629 continue;
630 dprintf("adding %s=%llu\n",
631 mze->mze_name, mze->mze_value);
453 if (mze_insert(zap, i, zn->zn_hash) == 0)
454 zap->zap_m.zap_num_entries++;
455 else {
456 printf("ZFS WARNING: Duplicated ZAP "
457 "entry detected (%s).\n",
458 mze->mze_name);
459 }
460 zap_name_free(zn);

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

650
651 for (i = 0; i < nchunks; i++) {
652 mzap_ent_phys_t *mze = &mzp->mz_chunk[i];
653 zap_name_t *zn;
654 if (mze->mze_name[0] == 0)
655 continue;
656 dprintf("adding %s=%llu\n",
657 mze->mze_name, mze->mze_value);
632 zn = zap_name_alloc(zap, mze->mze_name, MT_EXACT);
658 zn = zap_name_alloc(zap, mze->mze_name, 0);
633 err = fzap_add_cd(zn, 8, 1, &mze->mze_value, mze->mze_cd,
634 tag, tx);
635 zap = zn->zn_zap; /* fzap_add_cd() may change zap */
636 zap_name_free(zn);
637 if (err)
638 break;
639 }
640 zio_buf_free(mzp, sz);
641 *zapp = zap;
642 return (err);
643}
644
659 err = fzap_add_cd(zn, 8, 1, &mze->mze_value, mze->mze_cd,
660 tag, tx);
661 zap = zn->zn_zap; /* fzap_add_cd() may change zap */
662 zap_name_free(zn);
663 if (err)
664 break;
665 }
666 zio_buf_free(mzp, sz);
667 *zapp = zap;
668 return (err);
669}
670
671/*
672 * The "normflags" determine the behavior of the matchtype_t which is
673 * passed to zap_lookup_norm(). Names which have the same normalized
674 * version will be stored with the same hash value, and therefore we can
675 * perform normalization-insensitive lookups. We can be Unicode form-
676 * insensitive and/or case-insensitive. The following flags are valid for
677 * "normflags":
678 *
679 * U8_TEXTPREP_NFC
680 * U8_TEXTPREP_NFD
681 * U8_TEXTPREP_NFKC
682 * U8_TEXTPREP_NFKD
683 * U8_TEXTPREP_TOUPPER
684 *
685 * The *_NF* (Normalization Form) flags are mutually exclusive; at most one
686 * of them may be supplied.
687 */
645void
646mzap_create_impl(objset_t *os, uint64_t obj, int normflags, zap_flags_t flags,
647 dmu_tx_t *tx)
648{
649 dmu_buf_t *db;
650 mzap_phys_t *zp;
651
652 VERIFY(0 == dmu_buf_hold(os, obj, 0, FTAG, &db, DMU_READ_NO_PREFETCH));

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

795
796again:
797 for (other = avl_walk(&zap->zap_m.zap_avl, mze, direction);
798 other && other->mze_hash == mze->mze_hash;
799 other = avl_walk(&zap->zap_m.zap_avl, other, direction)) {
800
801 if (zn == NULL) {
802 zn = zap_name_alloc(zap, MZE_PHYS(zap, mze)->mze_name,
688void
689mzap_create_impl(objset_t *os, uint64_t obj, int normflags, zap_flags_t flags,
690 dmu_tx_t *tx)
691{
692 dmu_buf_t *db;
693 mzap_phys_t *zp;
694
695 VERIFY(0 == dmu_buf_hold(os, obj, 0, FTAG, &db, DMU_READ_NO_PREFETCH));

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

838
839again:
840 for (other = avl_walk(&zap->zap_m.zap_avl, mze, direction);
841 other && other->mze_hash == mze->mze_hash;
842 other = avl_walk(&zap->zap_m.zap_avl, other, direction)) {
843
844 if (zn == NULL) {
845 zn = zap_name_alloc(zap, MZE_PHYS(zap, mze)->mze_name,
803 MT_FIRST);
846 MT_NORMALIZE);
804 allocdzn = B_TRUE;
805 }
806 if (zap_match(zn, MZE_PHYS(zap, other)->mze_name)) {
807 if (allocdzn)
808 zap_name_free(zn);
809 return (B_TRUE);
810 }
811 }

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

824 * Routines for manipulating attributes.
825 */
826
827int
828zap_lookup(objset_t *os, uint64_t zapobj, const char *name,
829 uint64_t integer_size, uint64_t num_integers, void *buf)
830{
831 return (zap_lookup_norm(os, zapobj, name, integer_size,
847 allocdzn = B_TRUE;
848 }
849 if (zap_match(zn, MZE_PHYS(zap, other)->mze_name)) {
850 if (allocdzn)
851 zap_name_free(zn);
852 return (B_TRUE);
853 }
854 }

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

867 * Routines for manipulating attributes.
868 */
869
870int
871zap_lookup(objset_t *os, uint64_t zapobj, const char *name,
872 uint64_t integer_size, uint64_t num_integers, void *buf)
873{
874 return (zap_lookup_norm(os, zapobj, name, integer_size,
832 num_integers, buf, MT_EXACT, NULL, 0, NULL));
875 num_integers, buf, 0, NULL, 0, NULL));
833}
834
835static int
836zap_lookup_impl(zap_t *zap, const char *name,
837 uint64_t integer_size, uint64_t num_integers, void *buf,
838 matchtype_t mt, char *realname, int rn_len,
839 boolean_t *ncp)
840{

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

892 return (err);
893}
894
895int
896zap_lookup_by_dnode(dnode_t *dn, const char *name,
897 uint64_t integer_size, uint64_t num_integers, void *buf)
898{
899 return (zap_lookup_norm_by_dnode(dn, name, integer_size,
876}
877
878static int
879zap_lookup_impl(zap_t *zap, const char *name,
880 uint64_t integer_size, uint64_t num_integers, void *buf,
881 matchtype_t mt, char *realname, int rn_len,
882 boolean_t *ncp)
883{

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

935 return (err);
936}
937
938int
939zap_lookup_by_dnode(dnode_t *dn, const char *name,
940 uint64_t integer_size, uint64_t num_integers, void *buf)
941{
942 return (zap_lookup_norm_by_dnode(dn, name, integer_size,
900 num_integers, buf, MT_EXACT, NULL, 0, NULL));
943 num_integers, buf, 0, NULL, 0, NULL));
901}
902
903int
904zap_lookup_norm_by_dnode(dnode_t *dn, const char *name,
905 uint64_t integer_size, uint64_t num_integers, void *buf,
906 matchtype_t mt, char *realname, int rn_len,
907 boolean_t *ncp)
908{

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

965 zap_unlockdir(zap, FTAG);
966 return (err);
967}
968
969int
970zap_contains(objset_t *os, uint64_t zapobj, const char *name)
971{
972 int err = zap_lookup_norm(os, zapobj, name, 0,
944}
945
946int
947zap_lookup_norm_by_dnode(dnode_t *dn, const char *name,
948 uint64_t integer_size, uint64_t num_integers, void *buf,
949 matchtype_t mt, char *realname, int rn_len,
950 boolean_t *ncp)
951{

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

1008 zap_unlockdir(zap, FTAG);
1009 return (err);
1010}
1011
1012int
1013zap_contains(objset_t *os, uint64_t zapobj, const char *name)
1014{
1015 int err = zap_lookup_norm(os, zapobj, name, 0,
973 0, NULL, MT_EXACT, NULL, 0, NULL);
1016 0, NULL, 0, NULL, 0, NULL);
974 if (err == EOVERFLOW || err == EINVAL)
975 err = 0; /* found, but skipped reading the value */
976 return (err);
977}
978
979int
980zap_length(objset_t *os, uint64_t zapobj, const char *name,
981 uint64_t *integer_size, uint64_t *num_integers)
982{
983 zap_t *zap;
984 int err;
985 mzap_ent_t *mze;
986 zap_name_t *zn;
987
988 err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap);
989 if (err)
990 return (err);
1017 if (err == EOVERFLOW || err == EINVAL)
1018 err = 0; /* found, but skipped reading the value */
1019 return (err);
1020}
1021
1022int
1023zap_length(objset_t *os, uint64_t zapobj, const char *name,
1024 uint64_t *integer_size, uint64_t *num_integers)
1025{
1026 zap_t *zap;
1027 int err;
1028 mzap_ent_t *mze;
1029 zap_name_t *zn;
1030
1031 err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap);
1032 if (err)
1033 return (err);
991 zn = zap_name_alloc(zap, name, MT_EXACT);
1034 zn = zap_name_alloc(zap, name, 0);
992 if (zn == NULL) {
993 zap_unlockdir(zap, FTAG);
994 return (SET_ERROR(ENOTSUP));
995 }
996 if (!zap->zap_ismicro) {
997 err = fzap_length(zn, integer_size, num_integers);
998 } else {
999 mze = mze_find(zn);

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

1086 int err;
1087 mzap_ent_t *mze;
1088 const uint64_t *intval = val;
1089 zap_name_t *zn;
1090
1091 err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap);
1092 if (err)
1093 return (err);
1035 if (zn == NULL) {
1036 zap_unlockdir(zap, FTAG);
1037 return (SET_ERROR(ENOTSUP));
1038 }
1039 if (!zap->zap_ismicro) {
1040 err = fzap_length(zn, integer_size, num_integers);
1041 } else {
1042 mze = mze_find(zn);

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

1129 int err;
1130 mzap_ent_t *mze;
1131 const uint64_t *intval = val;
1132 zap_name_t *zn;
1133
1134 err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap);
1135 if (err)
1136 return (err);
1094 zn = zap_name_alloc(zap, key, MT_EXACT);
1137 zn = zap_name_alloc(zap, key, 0);
1095 if (zn == NULL) {
1096 zap_unlockdir(zap, FTAG);
1097 return (SET_ERROR(ENOTSUP));
1098 }
1099 if (!zap->zap_ismicro) {
1100 err = fzap_add(zn, integer_size, num_integers, val, FTAG, tx);
1101 zap = zn->zn_zap; /* fzap_add() may change zap */
1102 } else if (integer_size != 8 || num_integers != 1 ||

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

1165 */
1166 if (integer_size == 8 && num_integers == 1)
1167 (void) zap_lookup(os, zapobj, name, 8, 1, &oldval);
1168#endif
1169
1170 err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap);
1171 if (err)
1172 return (err);
1138 if (zn == NULL) {
1139 zap_unlockdir(zap, FTAG);
1140 return (SET_ERROR(ENOTSUP));
1141 }
1142 if (!zap->zap_ismicro) {
1143 err = fzap_add(zn, integer_size, num_integers, val, FTAG, tx);
1144 zap = zn->zn_zap; /* fzap_add() may change zap */
1145 } else if (integer_size != 8 || num_integers != 1 ||

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

1208 */
1209 if (integer_size == 8 && num_integers == 1)
1210 (void) zap_lookup(os, zapobj, name, 8, 1, &oldval);
1211#endif
1212
1213 err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap);
1214 if (err)
1215 return (err);
1173 zn = zap_name_alloc(zap, name, MT_EXACT);
1216 zn = zap_name_alloc(zap, name, 0);
1174 if (zn == NULL) {
1175 zap_unlockdir(zap, FTAG);
1176 return (SET_ERROR(ENOTSUP));
1177 }
1178 if (!zap->zap_ismicro) {
1179 err = fzap_update(zn, integer_size, num_integers, val,
1180 FTAG, tx);
1181 zap = zn->zn_zap; /* fzap_update() may change zap */

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

1228 if (zap != NULL) /* may be NULL if fzap_upgrade() failed */
1229 zap_unlockdir(zap, FTAG);
1230 return (err);
1231}
1232
1233int
1234zap_remove(objset_t *os, uint64_t zapobj, const char *name, dmu_tx_t *tx)
1235{
1217 if (zn == NULL) {
1218 zap_unlockdir(zap, FTAG);
1219 return (SET_ERROR(ENOTSUP));
1220 }
1221 if (!zap->zap_ismicro) {
1222 err = fzap_update(zn, integer_size, num_integers, val,
1223 FTAG, tx);
1224 zap = zn->zn_zap; /* fzap_update() may change zap */

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

1271 if (zap != NULL) /* may be NULL if fzap_upgrade() failed */
1272 zap_unlockdir(zap, FTAG);
1273 return (err);
1274}
1275
1276int
1277zap_remove(objset_t *os, uint64_t zapobj, const char *name, dmu_tx_t *tx)
1278{
1236 return (zap_remove_norm(os, zapobj, name, MT_EXACT, tx));
1279 return (zap_remove_norm(os, zapobj, name, 0, tx));
1237}
1238
1239int
1240zap_remove_norm(objset_t *os, uint64_t zapobj, const char *name,
1241 matchtype_t mt, dmu_tx_t *tx)
1242{
1243 zap_t *zap;
1244 int err;

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

1520 * and hence we do not want to trigger an upgrade.
1521 */
1522 err = zap_lockdir_by_dnode(dn, NULL, RW_READER, TRUE, FALSE,
1523 FTAG, &zap);
1524 if (err != 0)
1525 return (err);
1526
1527 if (!zap->zap_ismicro) {
1280}
1281
1282int
1283zap_remove_norm(objset_t *os, uint64_t zapobj, const char *name,
1284 matchtype_t mt, dmu_tx_t *tx)
1285{
1286 zap_t *zap;
1287 int err;

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

1563 * and hence we do not want to trigger an upgrade.
1564 */
1565 err = zap_lockdir_by_dnode(dn, NULL, RW_READER, TRUE, FALSE,
1566 FTAG, &zap);
1567 if (err != 0)
1568 return (err);
1569
1570 if (!zap->zap_ismicro) {
1528 zap_name_t *zn = zap_name_alloc(zap, name, MT_EXACT);
1571 zap_name_t *zn = zap_name_alloc(zap, name, 0);
1529 if (zn) {
1530 err = fzap_count_write(zn, add, towrite,
1531 tooverwrite);
1532 zap_name_free(zn);
1533 } else {
1534 /*
1535 * We treat this case as similar to (name == NULL)
1536 */

--- 36 unchanged lines hidden ---
1572 if (zn) {
1573 err = fzap_count_write(zn, add, towrite,
1574 tooverwrite);
1575 zap_name_free(zn);
1576 } else {
1577 /*
1578 * We treat this case as similar to (name == NULL)
1579 */

--- 36 unchanged lines hidden ---