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

Function open_objset

freebsd/contrib/openzfs/cmd/zdb/zdb.c:2924–2966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2922static sa_attr_type_t *sa_attr_table = NULL;
2923
2924static int
2925open_objset(const char *path, void *tag, objset_t **osp)
2926{
2927 int err;
2928 uint64_t sa_attrs = 0;
2929 uint64_t version = 0;
2930
2931 VERIFY3P(sa_os, ==, NULL);
2932 /*
2933 * We can't own an objset if it's redacted. Therefore, we do this
2934 * dance: hold the objset, then acquire a long hold on its dataset, then
2935 * release the pool (which is held as part of holding the objset).
2936 */
2937 err = dmu_objset_hold(path, tag, osp);
2938 if (err != 0) {
2939 (void) fprintf(stderr, "failed to hold dataset '%s': %s\n",
2940 path, strerror(err));
2941 return (err);
2942 }
2943 dsl_dataset_long_hold(dmu_objset_ds(*osp), tag);
2944 dsl_pool_rele(dmu_objset_pool(*osp), tag);
2945
2946 if (dmu_objset_type(*osp) == DMU_OST_ZFS && !(*osp)->os_encrypted) {
2947 (void) zap_lookup(*osp, MASTER_NODE_OBJ, ZPL_VERSION_STR,
2948 8, 1, &version);
2949 if (version >= ZPL_VERSION_SA) {
2950 (void) zap_lookup(*osp, MASTER_NODE_OBJ, ZFS_SA_ATTRS,
2951 8, 1, &sa_attrs);
2952 }
2953 err = sa_setup(*osp, sa_attrs, zfs_attr_table, ZPL_END,
2954 &sa_attr_table);
2955 if (err != 0) {
2956 (void) fprintf(stderr, "sa_setup failed: %s\n",
2957 strerror(err));
2958 dsl_dataset_long_rele(dmu_objset_ds(*osp), tag);
2959 dsl_dataset_rele(dmu_objset_ds(*osp), tag);
2960 *osp = NULL;
2961 }
2962 }
2963 sa_os = *osp;
2964
2965 return (0);
2966}
2967
2968static void
2969close_objset(objset_t *os, void *tag)

Callers 3

dump_pathFunction · 0.85
dump_one_objsetFunction · 0.85
mainFunction · 0.85

Calls 10

dmu_objset_holdFunction · 0.85
dsl_dataset_long_holdFunction · 0.85
dmu_objset_dsFunction · 0.85
dsl_pool_releFunction · 0.85
dmu_objset_poolFunction · 0.85
zap_lookupFunction · 0.85
sa_setupFunction · 0.85
dsl_dataset_long_releFunction · 0.85
dsl_dataset_releFunction · 0.85
dmu_objset_typeEnum · 0.50

Tested by

no test coverage detected