zap_leaf.c (247187) | zap_leaf.c (249195) |
---|---|
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) 2013 by Delphix. All rights reserved. |
|
23 */ 24 25/* 26 * The 512-byte leaf is broken into 32 16-byte chunks. 27 * chunk number n means l_chunk[n], even though the header precedes it. 28 * the names are stored null-terminated. 29 */ 30 --- 398 unchanged lines hidden (view full) --- 429 * NB: we could of course do this in one pass, but that would be 430 * a pain. We'll see if MT_BEST is even used much. 431 */ 432 if (zn->zn_matchtype == MT_BEST) { 433 zn->zn_matchtype = MT_FIRST; 434 goto again; 435 } 436 | 24 */ 25 26/* 27 * The 512-byte leaf is broken into 32 16-byte chunks. 28 * chunk number n means l_chunk[n], even though the header precedes it. 29 * the names are stored null-terminated. 30 */ 31 --- 398 unchanged lines hidden (view full) --- 430 * NB: we could of course do this in one pass, but that would be 431 * a pain. We'll see if MT_BEST is even used much. 432 */ 433 if (zn->zn_matchtype == MT_BEST) { 434 zn->zn_matchtype = MT_FIRST; 435 goto again; 436 } 437 |
437 return (ENOENT); | 438 return (SET_ERROR(ENOENT)); |
438} 439 440/* Return (h1,cd1 >= h2,cd2) */ 441#define HCD_GTEQ(h1, cd1, h2, cd2) \ 442 ((h1 > h2) ? TRUE : ((h1 == h2 && cd1 >= cd2) ? TRUE : FALSE)) 443 444int 445zap_leaf_lookup_closest(zap_leaf_t *l, --- 41 unchanged lines hidden (view full) --- 487zap_entry_read(const zap_entry_handle_t *zeh, 488 uint8_t integer_size, uint64_t num_integers, void *buf) 489{ 490 struct zap_leaf_entry *le = 491 ZAP_LEAF_ENTRY(zeh->zeh_leaf, *zeh->zeh_chunkp); 492 ASSERT3U(le->le_type, ==, ZAP_CHUNK_ENTRY); 493 494 if (le->le_value_intlen > integer_size) | 439} 440 441/* Return (h1,cd1 >= h2,cd2) */ 442#define HCD_GTEQ(h1, cd1, h2, cd2) \ 443 ((h1 > h2) ? TRUE : ((h1 == h2 && cd1 >= cd2) ? TRUE : FALSE)) 444 445int 446zap_leaf_lookup_closest(zap_leaf_t *l, --- 41 unchanged lines hidden (view full) --- 488zap_entry_read(const zap_entry_handle_t *zeh, 489 uint8_t integer_size, uint64_t num_integers, void *buf) 490{ 491 struct zap_leaf_entry *le = 492 ZAP_LEAF_ENTRY(zeh->zeh_leaf, *zeh->zeh_chunkp); 493 ASSERT3U(le->le_type, ==, ZAP_CHUNK_ENTRY); 494 495 if (le->le_value_intlen > integer_size) |
495 return (EINVAL); | 496 return (SET_ERROR(EINVAL)); |
496 497 zap_leaf_array_read(zeh->zeh_leaf, le->le_value_chunk, 498 le->le_value_intlen, le->le_value_numints, 499 integer_size, num_integers, buf); 500 501 if (zeh->zeh_num_integers > num_integers) | 497 498 zap_leaf_array_read(zeh->zeh_leaf, le->le_value_chunk, 499 le->le_value_intlen, le->le_value_numints, 500 integer_size, num_integers, buf); 501 502 if (zeh->zeh_num_integers > num_integers) |
502 return (EOVERFLOW); | 503 return (SET_ERROR(EOVERFLOW)); |
503 return (0); 504 505} 506 507int 508zap_entry_read_name(zap_t *zap, const zap_entry_handle_t *zeh, uint16_t buflen, 509 char *buf) 510{ --- 4 unchanged lines hidden (view full) --- 515 if (zap_getflags(zap) & ZAP_FLAG_UINT64_KEY) { 516 zap_leaf_array_read(zeh->zeh_leaf, le->le_name_chunk, 8, 517 le->le_name_numints, 8, buflen / 8, buf); 518 } else { 519 zap_leaf_array_read(zeh->zeh_leaf, le->le_name_chunk, 1, 520 le->le_name_numints, 1, buflen, buf); 521 } 522 if (le->le_name_numints > buflen) | 504 return (0); 505 506} 507 508int 509zap_entry_read_name(zap_t *zap, const zap_entry_handle_t *zeh, uint16_t buflen, 510 char *buf) 511{ --- 4 unchanged lines hidden (view full) --- 516 if (zap_getflags(zap) & ZAP_FLAG_UINT64_KEY) { 517 zap_leaf_array_read(zeh->zeh_leaf, le->le_name_chunk, 8, 518 le->le_name_numints, 8, buflen / 8, buf); 519 } else { 520 zap_leaf_array_read(zeh->zeh_leaf, le->le_name_chunk, 1, 521 le->le_name_numints, 1, buflen, buf); 522 } 523 if (le->le_name_numints > buflen) |
523 return (EOVERFLOW); | 524 return (SET_ERROR(EOVERFLOW)); |
524 return (0); 525} 526 527int 528zap_entry_update(zap_entry_handle_t *zeh, 529 uint8_t integer_size, uint64_t num_integers, const void *buf) 530{ 531 int delta_chunks; 532 zap_leaf_t *l = zeh->zeh_leaf; 533 struct zap_leaf_entry *le = ZAP_LEAF_ENTRY(l, *zeh->zeh_chunkp); 534 535 delta_chunks = ZAP_LEAF_ARRAY_NCHUNKS(num_integers * integer_size) - 536 ZAP_LEAF_ARRAY_NCHUNKS(le->le_value_numints * le->le_value_intlen); 537 538 if ((int)l->l_phys->l_hdr.lh_nfree < delta_chunks) | 525 return (0); 526} 527 528int 529zap_entry_update(zap_entry_handle_t *zeh, 530 uint8_t integer_size, uint64_t num_integers, const void *buf) 531{ 532 int delta_chunks; 533 zap_leaf_t *l = zeh->zeh_leaf; 534 struct zap_leaf_entry *le = ZAP_LEAF_ENTRY(l, *zeh->zeh_chunkp); 535 536 delta_chunks = ZAP_LEAF_ARRAY_NCHUNKS(num_integers * integer_size) - 537 ZAP_LEAF_ARRAY_NCHUNKS(le->le_value_numints * le->le_value_intlen); 538 539 if ((int)l->l_phys->l_hdr.lh_nfree < delta_chunks) |
539 return (EAGAIN); | 540 return (SET_ERROR(EAGAIN)); |
540 541 zap_leaf_array_free(l, &le->le_value_chunk); 542 le->le_value_chunk = 543 zap_leaf_array_create(l, buf, integer_size, num_integers); 544 le->le_value_numints = num_integers; 545 le->le_value_intlen = integer_size; 546 return (0); 547} --- 73 unchanged lines hidden (view full) --- 621 /* 622 * We would run out of space in a block before we could 623 * store enough entries to run out of CD values. 624 */ 625 ASSERT3U(cd, <, zap_maxcd(zn->zn_zap)); 626 } 627 628 if (l->l_phys->l_hdr.lh_nfree < numchunks) | 541 542 zap_leaf_array_free(l, &le->le_value_chunk); 543 le->le_value_chunk = 544 zap_leaf_array_create(l, buf, integer_size, num_integers); 545 le->le_value_numints = num_integers; 546 le->le_value_intlen = integer_size; 547 return (0); 548} --- 73 unchanged lines hidden (view full) --- 622 /* 623 * We would run out of space in a block before we could 624 * store enough entries to run out of CD values. 625 */ 626 ASSERT3U(cd, <, zap_maxcd(zn->zn_zap)); 627 } 628 629 if (l->l_phys->l_hdr.lh_nfree < numchunks) |
629 return (EAGAIN); | 630 return (SET_ERROR(EAGAIN)); |
630 631 /* make the entry */ 632 chunk = zap_leaf_chunk_alloc(l); 633 le = ZAP_LEAF_ENTRY(l, chunk); 634 le->le_type = ZAP_CHUNK_ENTRY; 635 le->le_name_chunk = zap_leaf_array_create(l, zn->zn_key_orig, 636 zn->zn_key_intlen, zn->zn_key_orig_numints); 637 le->le_name_numints = zn->zn_key_orig_numints; --- 235 unchanged lines hidden --- | 631 632 /* make the entry */ 633 chunk = zap_leaf_chunk_alloc(l); 634 le = ZAP_LEAF_ENTRY(l, chunk); 635 le->le_type = ZAP_CHUNK_ENTRY; 636 le->le_name_chunk = zap_leaf_array_create(l, zn->zn_key_orig, 637 zn->zn_key_intlen, zn->zn_key_orig_numints); 638 le->le_name_numints = zn->zn_key_orig_numints; --- 235 unchanged lines hidden --- |