| 1271 | } |
| 1272 | |
| 1273 | uint64_t |
| 1274 | dsl_dataset_create_sync(dsl_dir_t *pdd, const char *lastname, |
| 1275 | dsl_dataset_t *origin, uint64_t flags, cred_t *cr, |
| 1276 | dsl_crypto_params_t *dcp, dmu_tx_t *tx) |
| 1277 | { |
| 1278 | dsl_pool_t *dp = pdd->dd_pool; |
| 1279 | uint64_t dsobj, ddobj; |
| 1280 | dsl_dir_t *dd; |
| 1281 | |
| 1282 | ASSERT(dmu_tx_is_syncing(tx)); |
| 1283 | ASSERT(lastname[0] != '@'); |
| 1284 | /* |
| 1285 | * Filesystems will eventually have their origin set to dp_origin_snap, |
| 1286 | * but that's taken care of in dsl_dataset_create_sync_dd. When |
| 1287 | * creating a filesystem, this function is called with origin equal to |
| 1288 | * NULL. |
| 1289 | */ |
| 1290 | if (origin != NULL) |
| 1291 | ASSERT3P(origin, !=, dp->dp_origin_snap); |
| 1292 | |
| 1293 | ddobj = dsl_dir_create_sync(dp, pdd, lastname, tx); |
| 1294 | VERIFY0(dsl_dir_hold_obj(dp, ddobj, lastname, FTAG, &dd)); |
| 1295 | |
| 1296 | dsobj = dsl_dataset_create_sync_dd(dd, origin, dcp, |
| 1297 | flags & ~DS_CREATE_FLAG_NODIRTY, tx); |
| 1298 | |
| 1299 | dsl_deleg_set_create_perms(dd, tx, cr); |
| 1300 | |
| 1301 | /* |
| 1302 | * If we are creating a clone and the livelist feature is enabled, |
| 1303 | * add the entry DD_FIELD_LIVELIST to ZAP. |
| 1304 | */ |
| 1305 | if (origin != NULL && |
| 1306 | spa_feature_is_enabled(dp->dp_spa, SPA_FEATURE_LIVELIST)) { |
| 1307 | objset_t *mos = dd->dd_pool->dp_meta_objset; |
| 1308 | dsl_dir_zapify(dd, tx); |
| 1309 | uint64_t obj = dsl_deadlist_alloc(mos, tx); |
| 1310 | VERIFY0(zap_add(mos, dd->dd_object, DD_FIELD_LIVELIST, |
| 1311 | sizeof (uint64_t), 1, &obj, tx)); |
| 1312 | spa_feature_incr(dp->dp_spa, SPA_FEATURE_LIVELIST, tx); |
| 1313 | } |
| 1314 | |
| 1315 | /* |
| 1316 | * Since we're creating a new node we know it's a leaf, so we can |
| 1317 | * initialize the counts if the limit feature is active. |
| 1318 | */ |
| 1319 | if (spa_feature_is_active(dp->dp_spa, SPA_FEATURE_FS_SS_LIMIT)) { |
| 1320 | uint64_t cnt = 0; |
| 1321 | objset_t *os = dd->dd_pool->dp_meta_objset; |
| 1322 | |
| 1323 | dsl_dir_zapify(dd, tx); |
| 1324 | VERIFY0(zap_add(os, dd->dd_object, DD_FIELD_FILESYSTEM_COUNT, |
| 1325 | sizeof (cnt), 1, &cnt, tx)); |
| 1326 | VERIFY0(zap_add(os, dd->dd_object, DD_FIELD_SNAPSHOT_COUNT, |
| 1327 | sizeof (cnt), 1, &cnt, tx)); |
| 1328 | } |
| 1329 | |
| 1330 | dsl_dir_rele(dd, FTAG); |
no test coverage detected