| 2922 | static sa_attr_type_t *sa_attr_table = NULL; |
| 2923 | |
| 2924 | static int |
| 2925 | open_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 | |
| 2968 | static void |
| 2969 | close_objset(objset_t *os, void *tag) |
no test coverage detected