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

Function zap_open_leaf

freebsd/contrib/openzfs/module/zfs/zap.c:471–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471static zap_leaf_t *
472zap_open_leaf(uint64_t blkid, dmu_buf_t *db)
473{
474 ASSERT(blkid != 0);
475
476 zap_leaf_t *l = kmem_zalloc(sizeof (zap_leaf_t), KM_SLEEP);
477 rw_init(&l->l_rwlock, NULL, RW_DEFAULT, NULL);
478 rw_enter(&l->l_rwlock, RW_WRITER);
479 l->l_blkid = blkid;
480 l->l_bs = highbit64(db->db_size) - 1;
481 l->l_dbuf = db;
482
483 dmu_buf_init_user(&l->l_dbu, zap_leaf_evict_sync, NULL, &l->l_dbuf);
484 zap_leaf_t *winner = dmu_buf_set_user(db, &l->l_dbu);
485
486 rw_exit(&l->l_rwlock);
487 if (winner != NULL) {
488 /* someone else set it first */
489 zap_leaf_evict_sync(&l->l_dbu);
490 l = winner;
491 }
492
493 /*
494 * lhr_pad was previously used for the next leaf in the leaf
495 * chain. There should be no chained leafs (as we have removed
496 * support for them).
497 */
498 ASSERT0(zap_leaf_phys(l)->l_hdr.lh_pad1);
499
500 /*
501 * There should be more hash entries than there can be
502 * chunks to put in the hash table
503 */
504 ASSERT3U(ZAP_LEAF_HASH_NUMENTRIES(l), >, ZAP_LEAF_NUMCHUNKS(l) / 3);
505
506 /* The chunks should begin at the end of the hash table */
507 ASSERT3P(&ZAP_LEAF_CHUNK(l, 0), ==, (zap_leaf_chunk_t *)
508 &zap_leaf_phys(l)->l_hash[ZAP_LEAF_HASH_NUMENTRIES(l)]);
509
510 /* The chunks should end at the end of the block */
511 ASSERT3U((uintptr_t)&ZAP_LEAF_CHUNK(l, ZAP_LEAF_NUMCHUNKS(l)) -
512 (uintptr_t)zap_leaf_phys(l), ==, l->l_dbuf->db_size);
513
514 return (l);
515}
516
517static int
518zap_get_leaf_byblk(zap_t *zap, uint64_t blkid, dmu_tx_t *tx, krw_t lt,

Callers 1

zap_get_leaf_byblkFunction · 0.85

Calls 8

rw_initFunction · 0.85
rw_enterFunction · 0.85
dmu_buf_init_userFunction · 0.85
dmu_buf_set_userFunction · 0.85
rw_exitFunction · 0.85
zap_leaf_evict_syncFunction · 0.85
highbit64Function · 0.50
zap_leaf_physFunction · 0.50

Tested by

no test coverage detected