@@ -105,14 +105,8 @@ dsl_dataset_block_born(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx)
105
105
ASSERT (BP_GET_TYPE (bp ) != DMU_OT_NONE );
106
106
ASSERT (DMU_OT_IS_VALID (BP_GET_TYPE (bp )));
107
107
if (ds == NULL ) {
108
- /*
109
- * Account for the meta-objset space in its placeholder
110
- * dsl_dir.
111
- */
112
- ASSERT3U (compressed , = = , uncompressed ); /* it's all metadata */
113
- dsl_dir_diduse_space (tx -> tx_pool -> dp_mos_dir , DD_USED_HEAD ,
114
- used , compressed , uncompressed , tx );
115
- dsl_dir_dirty (tx -> tx_pool -> dp_mos_dir , tx );
108
+ dsl_pool_mos_diduse_space (tx -> tx_pool ,
109
+ used , compressed , uncompressed );
116
110
return ;
117
111
}
118
112
dmu_buf_will_dirty (ds -> ds_dbuf , tx );
@@ -150,15 +144,9 @@ dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx,
150
144
151
145
ASSERT (used > 0 );
152
146
if (ds == NULL ) {
153
- /*
154
- * Account for the meta-objset space in its placeholder
155
- * dataset.
156
- */
157
147
dsl_free (tx -> tx_pool , tx -> tx_txg , bp );
158
-
159
- dsl_dir_diduse_space (tx -> tx_pool -> dp_mos_dir , DD_USED_HEAD ,
160
- - used , - compressed , - uncompressed , tx );
161
- dsl_dir_dirty (tx -> tx_pool -> dp_mos_dir , tx );
148
+ dsl_pool_mos_diduse_space (tx -> tx_pool ,
149
+ - used , - compressed , - uncompressed );
162
150
return (used );
163
151
}
164
152
ASSERT3P (tx -> tx_pool , = = , ds -> ds_dir -> dd_pool );
@@ -1074,26 +1062,26 @@ dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_t defer)
1074
1062
dummy_ds -> ds_dir = dd ;
1075
1063
dummy_ds -> ds_object = ds -> ds_object ;
1076
1064
1077
- /*
1078
- * Check for errors and mark this ds as inconsistent, in
1079
- * case we crash while freeing the objects.
1080
- */
1081
- err = dsl_sync_task_do (dd -> dd_pool , dsl_dataset_destroy_begin_check ,
1082
- dsl_dataset_destroy_begin_sync , ds , NULL , 0 );
1083
- if (err )
1084
- goto out_free ;
1085
-
1086
- err = dmu_objset_from_ds (ds , & os );
1087
- if (err )
1088
- goto out_free ;
1089
-
1090
- /*
1091
- * If async destruction is not enabled try to remove all objects
1092
- * while in the open context so that there is less work to do in
1093
- * the syncing context.
1094
- */
1095
1065
if (!spa_feature_is_enabled (dsl_dataset_get_spa (ds ),
1096
1066
& spa_feature_table [SPA_FEATURE_ASYNC_DESTROY ])) {
1067
+ /*
1068
+ * Check for errors and mark this ds as inconsistent, in
1069
+ * case we crash while freeing the objects.
1070
+ */
1071
+ err = dsl_sync_task_do (dd -> dd_pool ,
1072
+ dsl_dataset_destroy_begin_check ,
1073
+ dsl_dataset_destroy_begin_sync , ds , NULL , 0 );
1074
+ if (err )
1075
+ goto out_free ;
1076
+
1077
+ err = dmu_objset_from_ds (ds , & os );
1078
+ if (err )
1079
+ goto out_free ;
1080
+
1081
+ /*
1082
+ * Remove all objects while in the open context so that
1083
+ * there is less work to do in the syncing context.
1084
+ */
1097
1085
for (obj = 0 ; err == 0 ; err = dmu_object_next (os , & obj , FALSE,
1098
1086
ds -> ds_phys -> ds_prev_snap_txg )) {
1099
1087
/*
@@ -1104,29 +1092,25 @@ dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_t defer)
1104
1092
}
1105
1093
if (err != ESRCH )
1106
1094
goto out_free ;
1107
- }
1108
1095
1109
- /*
1110
- * Only the ZIL knows how to free log blocks.
1111
- */
1112
- zil_destroy (dmu_objset_zil (os ), B_FALSE );
1113
-
1114
- /*
1115
- * Sync out all in-flight IO.
1116
- */
1117
- txg_wait_synced (dd -> dd_pool , 0 );
1096
+ /*
1097
+ * Sync out all in-flight IO.
1098
+ */
1099
+ txg_wait_synced (dd -> dd_pool , 0 );
1118
1100
1119
- /*
1120
- * If we managed to free all the objects in open
1121
- * context, the user space accounting should be zero.
1122
- */
1123
- if (ds -> ds_phys -> ds_bp .blk_fill == 0 &&
1124
- dmu_objset_userused_enabled (os )) {
1125
- ASSERTV (uint64_t count );
1126
- ASSERT (zap_count (os , DMU_USERUSED_OBJECT , & count ) != 0 ||
1127
- count == 0 );
1128
- ASSERT (zap_count (os , DMU_GROUPUSED_OBJECT , & count ) != 0 ||
1129
- count == 0 );
1101
+ /*
1102
+ * If we managed to free all the objects in open
1103
+ * context, the user space accounting should be zero.
1104
+ */
1105
+ if (ds -> ds_phys -> ds_bp .blk_fill == 0 &&
1106
+ dmu_objset_userused_enabled (os )) {
1107
+ ASSERTV (uint64_t count );
1108
+
1109
+ ASSERT (zap_count (os , DMU_USERUSED_OBJECT ,
1110
+ & count ) != 0 || count == 0 );
1111
+ ASSERT (zap_count (os , DMU_GROUPUSED_OBJECT ,
1112
+ & count ) != 0 || count == 0 );
1113
+ }
1130
1114
}
1131
1115
1132
1116
rw_enter (& dd -> dd_pool -> dp_config_rwlock , RW_READER );
@@ -1878,6 +1862,7 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
1878
1862
} else {
1879
1863
zfeature_info_t * async_destroy =
1880
1864
& spa_feature_table [SPA_FEATURE_ASYNC_DESTROY ];
1865
+ objset_t * os ;
1881
1866
1882
1867
/*
1883
1868
* There's no next snapshot, so this is a head dataset.
@@ -1889,6 +1874,8 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
1889
1874
dsl_deadlist_free (mos , ds -> ds_phys -> ds_deadlist_obj , tx );
1890
1875
ds -> ds_phys -> ds_deadlist_obj = 0 ;
1891
1876
1877
+ VERIFY3U (0 , = = , dmu_objset_from_ds (ds , & os ));
1878
+
1892
1879
if (!spa_feature_is_enabled (dp -> dp_spa , async_destroy )) {
1893
1880
err = old_synchronous_dataset_destroy (ds , tx );
1894
1881
} else {
@@ -1898,12 +1885,12 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
1898
1885
*/
1899
1886
uint64_t used , comp , uncomp ;
1900
1887
1901
- ASSERT (err == 0 || err == EBUSY );
1888
+ zil_destroy_sync (dmu_objset_zil (os ), tx );
1889
+
1902
1890
if (!spa_feature_is_active (dp -> dp_spa , async_destroy )) {
1903
1891
spa_feature_incr (dp -> dp_spa , async_destroy , tx );
1904
- dp -> dp_bptree_obj = bptree_alloc (
1905
- dp -> dp_meta_objset , tx );
1906
- VERIFY (zap_add (dp -> dp_meta_objset ,
1892
+ dp -> dp_bptree_obj = bptree_alloc (mos , tx );
1893
+ VERIFY (zap_add (mos ,
1907
1894
DMU_POOL_DIRECTORY_OBJECT ,
1908
1895
DMU_POOL_BPTREE_OBJ , sizeof (uint64_t ), 1 ,
1909
1896
& dp -> dp_bptree_obj , tx ) == 0 );
@@ -1916,7 +1903,7 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
1916
1903
ASSERT (!DS_UNIQUE_IS_ACCURATE (ds ) ||
1917
1904
ds -> ds_phys -> ds_unique_bytes == used );
1918
1905
1919
- bptree_add (dp -> dp_meta_objset , dp -> dp_bptree_obj ,
1906
+ bptree_add (mos , dp -> dp_bptree_obj ,
1920
1907
& ds -> ds_phys -> ds_bp , ds -> ds_phys -> ds_prev_snap_txg ,
1921
1908
used , comp , uncomp , tx );
1922
1909
dsl_dir_diduse_space (ds -> ds_dir , DD_USED_HEAD ,
@@ -2203,7 +2190,6 @@ dsl_dataset_sync(dsl_dataset_t *ds, zio_t *zio, dmu_tx_t *tx)
2203
2190
dmu_buf_will_dirty (ds -> ds_dbuf , tx );
2204
2191
ds -> ds_phys -> ds_fsid_guid = ds -> ds_fsid_guid ;
2205
2192
2206
- dsl_dir_dirty (ds -> ds_dir , tx );
2207
2193
dmu_objset_sync (ds -> ds_objset , zio , tx );
2208
2194
}
2209
2195
0 commit comments