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

Function dmu_objset_create_sync

freebsd/contrib/openzfs/module/zfs/dmu_objset.c:1189–1276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1187}
1188
1189static void
1190dmu_objset_create_sync(void *arg, dmu_tx_t *tx)
1191{
1192 dmu_objset_create_arg_t *doca = arg;
1193 dsl_pool_t *dp = dmu_tx_pool(tx);
1194 spa_t *spa = dp->dp_spa;
1195 dsl_dir_t *pdd;
1196 const char *tail;
1197 dsl_dataset_t *ds;
1198 uint64_t obj;
1199 blkptr_t *bp;
1200 objset_t *os;
1201 zio_t *rzio;
1202
1203 VERIFY0(dsl_dir_hold(dp, doca->doca_name, FTAG, &pdd, &tail));
1204
1205 obj = dsl_dataset_create_sync(pdd, tail, NULL, doca->doca_flags,
1206 doca->doca_cred, doca->doca_dcp, tx);
1207
1208 VERIFY0(dsl_dataset_hold_obj_flags(pdd->dd_pool, obj,
1209 DS_HOLD_FLAG_DECRYPT, FTAG, &ds));
1210 rrw_enter(&ds->ds_bp_rwlock, RW_READER, FTAG);
1211 bp = dsl_dataset_get_blkptr(ds);
1212 os = dmu_objset_create_impl(spa, ds, bp, doca->doca_type, tx);
1213 rrw_exit(&ds->ds_bp_rwlock, FTAG);
1214
1215 if (doca->doca_userfunc != NULL) {
1216 doca->doca_userfunc(os, doca->doca_userarg,
1217 doca->doca_cred, tx);
1218 }
1219
1220 /*
1221 * The doca_userfunc() may write out some data that needs to be
1222 * encrypted if the dataset is encrypted (specifically the root
1223 * directory). This data must be written out before the encryption
1224 * key mapping is removed by dsl_dataset_rele_flags(). Force the
1225 * I/O to occur immediately by invoking the relevant sections of
1226 * dsl_pool_sync().
1227 */
1228 if (os->os_encrypted) {
1229 dsl_dataset_t *tmpds = NULL;
1230 boolean_t need_sync_done = B_FALSE;
1231
1232 mutex_enter(&ds->ds_lock);
1233 ds->ds_owner = FTAG;
1234 mutex_exit(&ds->ds_lock);
1235
1236 rzio = zio_root(spa, NULL, NULL, ZIO_FLAG_MUSTSUCCEED);
1237 tmpds = txg_list_remove_this(&dp->dp_dirty_datasets, ds,
1238 tx->tx_txg);
1239 if (tmpds != NULL) {
1240 dsl_dataset_sync(ds, rzio, tx);
1241 need_sync_done = B_TRUE;
1242 }
1243 VERIFY0(zio_wait(rzio));
1244
1245 dmu_objset_sync_done(os, tx);
1246 taskq_wait(dp->dp_sync_taskq);

Callers

nothing calls this directly

Calls 15

dmu_tx_poolFunction · 0.85
dsl_dir_holdFunction · 0.85
dsl_dataset_create_syncFunction · 0.85
rrw_enterFunction · 0.85
dsl_dataset_get_blkptrFunction · 0.85
dmu_objset_create_implFunction · 0.85
rrw_exitFunction · 0.85
mutex_enterFunction · 0.85
mutex_exitFunction · 0.85
zio_rootFunction · 0.85
txg_list_remove_thisFunction · 0.85

Tested by

no test coverage detected