Print this page
3752 want more verifiable dbuf user eviction
Submitted by:   Justin Gibbs <justing@spectralogic.com>
Submitted by:   Will Andrews <willa@spectralogic.com>

@@ -41,16 +41,18 @@
 
 static uint64_t dsl_dir_space_towrite(dsl_dir_t *dd);
 
 /* ARGSUSED */
 static void
-dsl_dir_evict(dmu_buf_t *db, void *arg)
+dsl_dir_evict(dmu_buf_user_t *dbu)
 {
-        dsl_dir_t *dd = arg;
+        dsl_dir_t *dd = (dsl_dir_t *)dbu;
         dsl_pool_t *dp = dd->dd_pool;
         int t;
 
+        dd->dd_dbuf = NULL;
+
         for (t = 0; t < TXG_SIZE; t++) {
                 ASSERT(!txg_list_member(&dp->dp_dirty_dirs, dd, t));
                 ASSERT(dd->dd_tempreserved[t] == 0);
                 ASSERT(dd->dd_space_towrite[t] == 0);
         }

@@ -80,11 +82,11 @@
         ASSERT(dsl_pool_config_held(dp));
 
         err = dmu_bonus_hold(dp->dp_meta_objset, ddobj, tag, &dbuf);
         if (err != 0)
                 return (err);
-        dd = dmu_buf_get_user(dbuf);
+        dd = (dsl_dir_t *)dmu_buf_get_user(dbuf);
 #ifdef ZFS_DEBUG
         {
                 dmu_object_info_t doi;
                 dmu_object_info_from_db(dbuf, &doi);
                 ASSERT3U(doi.doi_type, ==, DMU_OT_DSL_DIR);

@@ -96,11 +98,10 @@
 
                 dd = kmem_zalloc(sizeof (dsl_dir_t), KM_SLEEP);
                 dd->dd_object = ddobj;
                 dd->dd_dbuf = dbuf;
                 dd->dd_pool = dp;
-                dd->dd_phys = dbuf->db_data;
                 mutex_init(&dd->dd_lock, NULL, MUTEX_DEFAULT, NULL);
 
                 list_create(&dd->dd_prop_cbs, sizeof (dsl_prop_cb_record_t),
                     offsetof(dsl_prop_cb_record_t, cbr_node));
 

@@ -149,12 +150,12 @@
                         dd->dd_origin_txg =
                             origin_phys->ds_creation_txg;
                         dmu_buf_rele(origin_bonus, FTAG);
                 }
 
-                winner = dmu_buf_set_user_ie(dbuf, dd, &dd->dd_phys,
-                    dsl_dir_evict);
+                dmu_buf_init_user(&dd->db_evict, dsl_dir_evict);
+                winner = (dsl_dir_t *)dmu_buf_set_user_ie(dbuf, &dd->db_evict);
                 if (winner) {
                         if (dd->dd_parent)
                                 dsl_dir_rele(dd->dd_parent, dd);
                         mutex_destroy(&dd->dd_lock);
                         kmem_free(dd, sizeof (dsl_dir_t));