MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zap_leaf_split

Function zap_leaf_split

freebsd/contrib/openzfs/module/zfs/zap_leaf.c:767–806  ·  view source on GitHub ↗

* Transfer the entries whose hash prefix ends in 1 to the new leaf. */

Source from the content-addressed store, hash-verified

765 * Transfer the entries whose hash prefix ends in 1 to the new leaf.
766 */
767void
768zap_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
808void
809zap_leaf_stats(zap_t *zap, zap_leaf_t *l, zap_stats_t *zs)

Callers 1

zap_expand_leafFunction · 0.85

Calls 4

zap_memsetFunction · 0.85
zap_leaf_transfer_entryFunction · 0.85
zap_leaf_rehash_entryFunction · 0.85
zap_leaf_physFunction · 0.50

Tested by

no test coverage detected