Print this page
4171 clean up spa_feature_*() interfaces
4172 implement extensible_dataset feature for use by other zpool features
Reviewed by: Max Grossman <max.grossman@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>


 335 }
 336 
 337 int
 338 dsl_dataset_hold_obj(dsl_pool_t *dp, uint64_t dsobj, void *tag,
 339     dsl_dataset_t **dsp)
 340 {
 341         objset_t *mos = dp->dp_meta_objset;
 342         dmu_buf_t *dbuf;
 343         dsl_dataset_t *ds;
 344         int err;
 345         dmu_object_info_t doi;
 346 
 347         ASSERT(dsl_pool_config_held(dp));
 348 
 349         err = dmu_bonus_hold(mos, dsobj, tag, &dbuf);
 350         if (err != 0)
 351                 return (err);
 352 
 353         /* Make sure dsobj has the correct object type. */
 354         dmu_object_info_from_db(dbuf, &doi);
 355         if (doi.doi_type != DMU_OT_DSL_DATASET) {
 356                 dmu_buf_rele(dbuf, tag);
 357                 return (SET_ERROR(EINVAL));
 358         }
 359 
 360         ds = dmu_buf_get_user(dbuf);
 361         if (ds == NULL) {
 362                 dsl_dataset_t *winner = NULL;
 363 
 364                 ds = kmem_zalloc(sizeof (dsl_dataset_t), KM_SLEEP);
 365                 ds->ds_dbuf = dbuf;
 366                 ds->ds_object = dsobj;
 367                 ds->ds_phys = dbuf->db_data;
 368 
 369                 mutex_init(&ds->ds_lock, NULL, MUTEX_DEFAULT, NULL);
 370                 mutex_init(&ds->ds_opening_lock, NULL, MUTEX_DEFAULT, NULL);
 371                 mutex_init(&ds->ds_sendstream_lock, NULL, MUTEX_DEFAULT, NULL);
 372                 refcount_create(&ds->ds_longholds);
 373 
 374                 bplist_create(&ds->ds_pending_deadlist);
 375                 dsl_deadlist_open(&ds->ds_deadlist,


2954 
2955         if (earlier->ds_phys->ds_creation_txg >=
2956             later->ds_phys->ds_creation_txg)
2957                 return (B_FALSE);
2958 
2959         if (later->ds_dir == earlier->ds_dir)
2960                 return (B_TRUE);
2961         if (!dsl_dir_is_clone(later->ds_dir))
2962                 return (B_FALSE);
2963 
2964         if (later->ds_dir->dd_phys->dd_origin_obj == earlier->ds_object)
2965                 return (B_TRUE);
2966         dsl_dataset_t *origin;
2967         error = dsl_dataset_hold_obj(dp,
2968             later->ds_dir->dd_phys->dd_origin_obj, FTAG, &origin);
2969         if (error != 0)
2970                 return (B_FALSE);
2971         ret = dsl_dataset_is_before(origin, earlier);
2972         dsl_dataset_rele(origin, FTAG);
2973         return (ret);








2974 }


 335 }
 336 
 337 int
 338 dsl_dataset_hold_obj(dsl_pool_t *dp, uint64_t dsobj, void *tag,
 339     dsl_dataset_t **dsp)
 340 {
 341         objset_t *mos = dp->dp_meta_objset;
 342         dmu_buf_t *dbuf;
 343         dsl_dataset_t *ds;
 344         int err;
 345         dmu_object_info_t doi;
 346 
 347         ASSERT(dsl_pool_config_held(dp));
 348 
 349         err = dmu_bonus_hold(mos, dsobj, tag, &dbuf);
 350         if (err != 0)
 351                 return (err);
 352 
 353         /* Make sure dsobj has the correct object type. */
 354         dmu_object_info_from_db(dbuf, &doi);
 355         if (doi.doi_bonus_type != DMU_OT_DSL_DATASET) {
 356                 dmu_buf_rele(dbuf, tag);
 357                 return (SET_ERROR(EINVAL));
 358         }
 359 
 360         ds = dmu_buf_get_user(dbuf);
 361         if (ds == NULL) {
 362                 dsl_dataset_t *winner = NULL;
 363 
 364                 ds = kmem_zalloc(sizeof (dsl_dataset_t), KM_SLEEP);
 365                 ds->ds_dbuf = dbuf;
 366                 ds->ds_object = dsobj;
 367                 ds->ds_phys = dbuf->db_data;
 368 
 369                 mutex_init(&ds->ds_lock, NULL, MUTEX_DEFAULT, NULL);
 370                 mutex_init(&ds->ds_opening_lock, NULL, MUTEX_DEFAULT, NULL);
 371                 mutex_init(&ds->ds_sendstream_lock, NULL, MUTEX_DEFAULT, NULL);
 372                 refcount_create(&ds->ds_longholds);
 373 
 374                 bplist_create(&ds->ds_pending_deadlist);
 375                 dsl_deadlist_open(&ds->ds_deadlist,


2954 
2955         if (earlier->ds_phys->ds_creation_txg >=
2956             later->ds_phys->ds_creation_txg)
2957                 return (B_FALSE);
2958 
2959         if (later->ds_dir == earlier->ds_dir)
2960                 return (B_TRUE);
2961         if (!dsl_dir_is_clone(later->ds_dir))
2962                 return (B_FALSE);
2963 
2964         if (later->ds_dir->dd_phys->dd_origin_obj == earlier->ds_object)
2965                 return (B_TRUE);
2966         dsl_dataset_t *origin;
2967         error = dsl_dataset_hold_obj(dp,
2968             later->ds_dir->dd_phys->dd_origin_obj, FTAG, &origin);
2969         if (error != 0)
2970                 return (B_FALSE);
2971         ret = dsl_dataset_is_before(origin, earlier);
2972         dsl_dataset_rele(origin, FTAG);
2973         return (ret);
2974 }
2975 
2976 
2977 void
2978 dsl_dataset_zapify(dsl_dataset_t *ds, dmu_tx_t *tx)
2979 {
2980         objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset;
2981         dmu_object_zapify(mos, ds->ds_object, DMU_OT_DSL_DATASET, tx);
2982 }