Print this page
3752 want more verifiable dbuf user eviction
Submitted by: Justin Gibbs <justing@spectralogic.com>
Submitted by: Will Andrews <willa@spectralogic.com>
*** 43,53 ****
uint64_t
zap_getflags(zap_t *zap)
{
if (zap->zap_ismicro)
return (0);
! return (zap->zap_u.zap_fat.zap_phys->zap_flags);
}
int
zap_hashbits(zap_t *zap)
{
--- 43,53 ----
uint64_t
zap_getflags(zap_t *zap)
{
if (zap->zap_ismicro)
return (0);
! return (zap->zap_f_phys->zap_flags);
}
int
zap_hashbits(zap_t *zap)
{
*** 382,392 ****
/*
* Make sure that zap_ismicro is set before we let others see
* it, because zap_lockdir() checks zap_ismicro without the lock
* held.
*/
! winner = dmu_buf_set_user(db, zap, &zap->zap_m.zap_phys, zap_evict);
if (winner != NULL) {
rw_exit(&zap->zap_rwlock);
rw_destroy(&zap->zap_rwlock);
if (!zap->zap_ismicro)
--- 382,393 ----
/*
* Make sure that zap_ismicro is set before we let others see
* it, because zap_lockdir() checks zap_ismicro without the lock
* held.
*/
! dmu_buf_init_user(&zap->db_evict, zap_evict);
! winner = (zap_t *)dmu_buf_set_user(db, &zap->db_evict);
if (winner != NULL) {
rw_exit(&zap->zap_rwlock);
rw_destroy(&zap->zap_rwlock);
if (!zap->zap_ismicro)
*** 394,412 ****
kmem_free(zap, sizeof (zap_t));
return (winner);
}
if (zap->zap_ismicro) {
! zap->zap_salt = zap->zap_m.zap_phys->mz_salt;
! zap->zap_normflags = zap->zap_m.zap_phys->mz_normflags;
zap->zap_m.zap_num_chunks = db->db_size / MZAP_ENT_LEN - 1;
avl_create(&zap->zap_m.zap_avl, mze_compare,
sizeof (mzap_ent_t), offsetof(mzap_ent_t, mze_node));
for (i = 0; i < zap->zap_m.zap_num_chunks; i++) {
mzap_ent_phys_t *mze =
! &zap->zap_m.zap_phys->mz_chunk[i];
if (mze->mze_name[0]) {
zap_name_t *zn;
zap->zap_m.zap_num_entries++;
zn = zap_name_alloc(zap, mze->mze_name,
--- 395,413 ----
kmem_free(zap, sizeof (zap_t));
return (winner);
}
if (zap->zap_ismicro) {
! zap->zap_salt = zap->zap_m_phys->mz_salt;
! zap->zap_normflags = zap->zap_m_phys->mz_normflags;
zap->zap_m.zap_num_chunks = db->db_size / MZAP_ENT_LEN - 1;
avl_create(&zap->zap_m.zap_avl, mze_compare,
sizeof (mzap_ent_t), offsetof(mzap_ent_t, mze_node));
for (i = 0; i < zap->zap_m.zap_num_chunks; i++) {
mzap_ent_phys_t *mze =
! &zap->zap_m_phys->mz_chunk[i];
if (mze->mze_name[0]) {
zap_name_t *zn;
zap->zap_m.zap_num_entries++;
zn = zap_name_alloc(zap, mze->mze_name,
*** 414,443 ****
mze_insert(zap, i, zn->zn_hash);
zap_name_free(zn);
}
}
} else {
! zap->zap_salt = zap->zap_f.zap_phys->zap_salt;
! zap->zap_normflags = zap->zap_f.zap_phys->zap_normflags;
ASSERT3U(sizeof (struct zap_leaf_header), ==,
2*ZAP_LEAF_CHUNKSIZE);
/*
* The embedded pointer table should not overlap the
* other members.
*/
ASSERT3P(&ZAP_EMBEDDED_PTRTBL_ENT(zap, 0), >,
! &zap->zap_f.zap_phys->zap_salt);
/*
* The embedded pointer table should end at the end of
* the block
*/
ASSERT3U((uintptr_t)&ZAP_EMBEDDED_PTRTBL_ENT(zap,
1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap)) -
! (uintptr_t)zap->zap_f.zap_phys, ==,
zap->zap_dbuf->db_size);
}
rw_exit(&zap->zap_rwlock);
return (zap);
}
--- 415,444 ----
mze_insert(zap, i, zn->zn_hash);
zap_name_free(zn);
}
}
} else {
! zap->zap_salt = zap->zap_f_phys->zap_salt;
! zap->zap_normflags = zap->zap_f_phys->zap_normflags;
ASSERT3U(sizeof (struct zap_leaf_header), ==,
2*ZAP_LEAF_CHUNKSIZE);
/*
* The embedded pointer table should not overlap the
* other members.
*/
ASSERT3P(&ZAP_EMBEDDED_PTRTBL_ENT(zap, 0), >,
! &zap->zap_f_phys->zap_salt);
/*
* The embedded pointer table should end at the end of
* the block
*/
ASSERT3U((uintptr_t)&ZAP_EMBEDDED_PTRTBL_ENT(zap,
1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap)) -
! (uintptr_t)zap->zap_f_phys, ==,
zap->zap_dbuf->db_size);
}
rw_exit(&zap->zap_rwlock);
return (zap);
}
*** 463,473 ****
dmu_object_info_from_db(db, &doi);
ASSERT3U(DMU_OT_BYTESWAP(doi.doi_type), ==, DMU_BSWAP_ZAP);
}
#endif
! zap = dmu_buf_get_user(db);
if (zap == NULL)
zap = mzap_open(os, obj, db);
/*
* We're checking zap_ismicro without the lock held, in order to
--- 464,474 ----
dmu_object_info_from_db(db, &doi);
ASSERT3U(DMU_OT_BYTESWAP(doi.doi_type), ==, DMU_BSWAP_ZAP);
}
#endif
! zap = (zap_t *)dmu_buf_get_user(db);
if (zap == NULL)
zap = mzap_open(os, obj, db);
/*
* We're checking zap_ismicro without the lock held, in order to
*** 674,688 ****
*/
return (dmu_object_free(os, zapobj, tx));
}
- _NOTE(ARGSUSED(0))
void
! zap_evict(dmu_buf_t *db, void *vzap)
{
! zap_t *zap = vzap;
rw_destroy(&zap->zap_rwlock);
if (zap->zap_ismicro)
mze_destroy(zap);
--- 675,688 ----
*/
return (dmu_object_free(os, zapobj, tx));
}
void
! zap_evict(dmu_buf_user_t *dbu)
{
! zap_t *zap = (zap_t *)dbu;
rw_destroy(&zap->zap_rwlock);
if (zap->zap_ismicro)
mze_destroy(zap);
*** 936,957 ****
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock));
#ifdef ZFS_DEBUG
for (i = 0; i < zap->zap_m.zap_num_chunks; i++) {
! mzap_ent_phys_t *mze = &zap->zap_m.zap_phys->mz_chunk[i];
ASSERT(strcmp(zn->zn_key_orig, mze->mze_name) != 0);
}
#endif
cd = mze_find_unused_cd(zap, zn->zn_hash);
/* given the limited size of the microzap, this can't happen */
ASSERT(cd < zap_maxcd(zap));
again:
for (i = start; i < zap->zap_m.zap_num_chunks; i++) {
! mzap_ent_phys_t *mze = &zap->zap_m.zap_phys->mz_chunk[i];
if (mze->mze_name[0] == 0) {
mze->mze_value = value;
mze->mze_cd = cd;
(void) strcpy(mze->mze_name, zn->zn_key_orig);
zap->zap_m.zap_num_entries++;
--- 936,957 ----
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock));
#ifdef ZFS_DEBUG
for (i = 0; i < zap->zap_m.zap_num_chunks; i++) {
! mzap_ent_phys_t *mze = &zap->zap_m_phys->mz_chunk[i];
ASSERT(strcmp(zn->zn_key_orig, mze->mze_name) != 0);
}
#endif
cd = mze_find_unused_cd(zap, zn->zn_hash);
/* given the limited size of the microzap, this can't happen */
ASSERT(cd < zap_maxcd(zap));
again:
for (i = start; i < zap->zap_m.zap_num_chunks; i++) {
! mzap_ent_phys_t *mze = &zap->zap_m_phys->mz_chunk[i];
if (mze->mze_name[0] == 0) {
mze->mze_value = value;
mze->mze_cd = cd;
(void) strcpy(mze->mze_name, zn->zn_key_orig);
zap->zap_m.zap_num_entries++;
*** 1148,1158 ****
mze = mze_find(zn);
if (mze == NULL) {
err = SET_ERROR(ENOENT);
} else {
zap->zap_m.zap_num_entries--;
! bzero(&zap->zap_m.zap_phys->mz_chunk[mze->mze_chunkid],
sizeof (mzap_ent_phys_t));
mze_remove(zap, mze);
}
}
zap_name_free(zn);
--- 1148,1158 ----
mze = mze_find(zn);
if (mze == NULL) {
err = SET_ERROR(ENOENT);
} else {
zap->zap_m.zap_num_entries--;
! bzero(&zap->zap_m_phys->mz_chunk[mze->mze_chunkid],
sizeof (mzap_ent_phys_t));
mze_remove(zap, mze);
}
}
zap_name_free(zn);