* Transfer the entries whose hash prefix ends in 1 to the new leaf. */
| 765 | * Transfer the entries whose hash prefix ends in 1 to the new leaf. |
| 766 | */ |
| 767 | void |
| 768 | zap_leaf_split(zap_leaf_t *l, zap_leaf_t *nl, boolean_t sort) |
| 769 | { |
| 770 | int bit = 64 - 1 - zap_leaf_phys(l)->l_hdr.lh_prefix_len; |
| 771 | |
| 772 | /* set new prefix and prefix_len */ |
| 773 | zap_leaf_phys(l)->l_hdr.lh_prefix <<= 1; |
| 774 | zap_leaf_phys(l)->l_hdr.lh_prefix_len++; |
| 775 | zap_leaf_phys(nl)->l_hdr.lh_prefix = |
| 776 | zap_leaf_phys(l)->l_hdr.lh_prefix | 1; |
| 777 | zap_leaf_phys(nl)->l_hdr.lh_prefix_len = |
| 778 | zap_leaf_phys(l)->l_hdr.lh_prefix_len; |
| 779 | |
| 780 | /* break existing hash chains */ |
| 781 | zap_memset(zap_leaf_phys(l)->l_hash, CHAIN_END, |
| 782 | 2*ZAP_LEAF_HASH_NUMENTRIES(l)); |
| 783 | |
| 784 | if (sort) |
| 785 | zap_leaf_phys(l)->l_hdr.lh_flags |= ZLF_ENTRIES_CDSORTED; |
| 786 | |
| 787 | /* |
| 788 | * Transfer entries whose hash bit 'bit' is set to nl; rehash |
| 789 | * the remaining entries |
| 790 | * |
| 791 | * NB: We could find entries via the hashtable instead. That |
| 792 | * would be O(hashents+numents) rather than O(numblks+numents), |
| 793 | * but this accesses memory more sequentially, and when we're |
| 794 | * called, the block is usually pretty full. |
| 795 | */ |
| 796 | for (int i = 0; i < ZAP_LEAF_NUMCHUNKS(l); i++) { |
| 797 | struct zap_leaf_entry *le = ZAP_LEAF_ENTRY(l, i); |
| 798 | if (le->le_type != ZAP_CHUNK_ENTRY) |
| 799 | continue; |
| 800 | |
| 801 | if (le->le_hash & (1ULL << bit)) |
| 802 | zap_leaf_transfer_entry(l, i, nl); |
| 803 | else |
| 804 | (void) zap_leaf_rehash_entry(l, i); |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | void |
| 809 | zap_leaf_stats(zap_t *zap, zap_leaf_t *l, zap_stats_t *zs) |
no test coverage detected