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

Function dmu_objset_open_impl

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

* Instantiates the objset_t in-memory structure corresponding to the * objset_phys_t that's pointed to by the specified blkptr_t. */

Source from the content-addressed store, hash-verified

408 * objset_phys_t that's pointed to by the specified blkptr_t.
409 */
410int
411dmu_objset_open_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
412 objset_t **osp)
413{
414 objset_t *os;
415 int i, err;
416
417 ASSERT(ds == NULL || MUTEX_HELD(&ds->ds_opening_lock));
418 ASSERT(!BP_IS_REDACTED(bp));
419
420 /*
421 * We need the pool config lock to get properties.
422 */
423 ASSERT(ds == NULL || dsl_pool_config_held(ds->ds_dir->dd_pool));
424
425 /*
426 * The $ORIGIN dataset (if it exists) doesn't have an associated
427 * objset, so there's no reason to open it. The $ORIGIN dataset
428 * will not exist on pools older than SPA_VERSION_ORIGIN.
429 */
430 if (ds != NULL && spa_get_dsl(spa) != NULL &&
431 spa_get_dsl(spa)->dp_origin_snap != NULL) {
432 ASSERT3P(ds->ds_dir, !=,
433 spa_get_dsl(spa)->dp_origin_snap->ds_dir);
434 }
435
436 os = kmem_zalloc(sizeof (objset_t), KM_SLEEP);
437 os->os_dsl_dataset = ds;
438 os->os_spa = spa;
439 os->os_rootbp = bp;
440 if (!BP_IS_HOLE(os->os_rootbp)) {
441 arc_flags_t aflags = ARC_FLAG_WAIT;
442 zbookmark_phys_t zb;
443 int size;
444 enum zio_flag zio_flags = ZIO_FLAG_CANFAIL;
445 SET_BOOKMARK(&zb, ds ? ds->ds_object : DMU_META_OBJSET,
446 ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID);
447
448 if (DMU_OS_IS_L2CACHEABLE(os))
449 aflags |= ARC_FLAG_L2CACHE;
450
451 if (ds != NULL && ds->ds_dir->dd_crypto_obj != 0) {
452 ASSERT3U(BP_GET_COMPRESS(bp), ==, ZIO_COMPRESS_OFF);
453 ASSERT(BP_IS_AUTHENTICATED(bp));
454 zio_flags |= ZIO_FLAG_RAW;
455 }
456
457 dprintf_bp(os->os_rootbp, "reading %s", "");
458 err = arc_read(NULL, spa, os->os_rootbp,
459 arc_getbuf_func, &os->os_phys_buf,
460 ZIO_PRIORITY_SYNC_READ, zio_flags, &aflags, &zb);
461 if (err != 0) {
462 kmem_free(os, sizeof (objset_t));
463 /* convert checksum errors into IO errors */
464 if (err == ECKSUM)
465 err = SET_ERROR(EIO);
466 return (err);
467 }

Callers 3

dsl_pool_initFunction · 0.85
dmu_objset_from_dsFunction · 0.85

Calls 15

dsl_pool_config_heldFunction · 0.85
spa_get_dslFunction · 0.85
arc_readFunction · 0.85
spa_versionFunction · 0.85
spa_feature_is_enabledFunction · 0.85
arc_buf_sizeFunction · 0.85
arc_alloc_bufFunction · 0.85
bzeroFunction · 0.85
arc_buf_destroyFunction · 0.85
dsl_prop_registerFunction · 0.85
zfs_prop_to_nameFunction · 0.85
spa_max_replicationFunction · 0.85

Tested by

no test coverage detected