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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/dsl_destroy.c
          +++ new/usr/src/uts/common/fs/zfs/dsl_destroy.c
↓ open down ↓ 30 lines elided ↑ open up ↑
  31   31  #include <sys/dmu_tx.h>
  32   32  #include <sys/dsl_pool.h>
  33   33  #include <sys/dsl_dir.h>
  34   34  #include <sys/dmu_traverse.h>
  35   35  #include <sys/dsl_scan.h>
  36   36  #include <sys/dmu_objset.h>
  37   37  #include <sys/zap.h>
  38   38  #include <sys/zfeature.h>
  39   39  #include <sys/zfs_ioctl.h>
  40   40  #include <sys/dsl_deleg.h>
       41 +#include <sys/dmu_impl.h>
  41   42  
  42   43  typedef struct dmu_snapshots_destroy_arg {
  43   44          nvlist_t *dsda_snaps;
  44   45          nvlist_t *dsda_successful_snaps;
  45   46          boolean_t dsda_defer;
  46   47          nvlist_t *dsda_errlist;
  47   48  } dmu_snapshots_destroy_arg_t;
  48   49  
  49   50  int
  50   51  dsl_destroy_snapshot_check_impl(dsl_dataset_t *ds, boolean_t defer)
↓ open down ↓ 390 lines elided ↑ open up ↑
 441  442                      ds->ds_phys->ds_next_clones_obj, &count) && count == 0);
 442  443                  VERIFY0(dmu_object_free(mos,
 443  444                      ds->ds_phys->ds_next_clones_obj, tx));
 444  445          }
 445  446          if (ds->ds_phys->ds_props_obj != 0)
 446  447                  VERIFY0(zap_destroy(mos, ds->ds_phys->ds_props_obj, tx));
 447  448          if (ds->ds_phys->ds_userrefs_obj != 0)
 448  449                  VERIFY0(zap_destroy(mos, ds->ds_phys->ds_userrefs_obj, tx));
 449  450          dsl_dir_rele(ds->ds_dir, ds);
 450  451          ds->ds_dir = NULL;
 451      -        VERIFY0(dmu_object_free(mos, obj, tx));
      452 +        dmu_object_free_zapified(mos, obj, tx);
 452  453  }
 453  454  
 454  455  static void
 455  456  dsl_destroy_snapshot_sync(void *arg, dmu_tx_t *tx)
 456  457  {
 457  458          dmu_snapshots_destroy_arg_t *dsda = arg;
 458  459          dsl_pool_t *dp = dmu_tx_pool(tx);
 459  460          nvpair_t *pair;
 460  461  
 461  462          for (pair = nvlist_next_nvpair(dsda->dsda_successful_snaps, NULL);
↓ open down ↓ 202 lines elided ↑ open up ↑
 664  665          for (t = 0; t < DD_USED_NUM; t++)
 665  666                  ASSERT0(dd->dd_phys->dd_used_breakdown[t]);
 666  667  
 667  668          VERIFY0(zap_destroy(mos, dd->dd_phys->dd_child_dir_zapobj, tx));
 668  669          VERIFY0(zap_destroy(mos, dd->dd_phys->dd_props_zapobj, tx));
 669  670          VERIFY0(dsl_deleg_destroy(mos, dd->dd_phys->dd_deleg_zapobj, tx));
 670  671          VERIFY0(zap_remove(mos,
 671  672              dd->dd_parent->dd_phys->dd_child_dir_zapobj, dd->dd_myname, tx));
 672  673  
 673  674          dsl_dir_rele(dd, FTAG);
 674      -        VERIFY0(dmu_object_free(mos, ddobj, tx));
      675 +        dmu_object_free_zapified(mos, ddobj, tx);
 675  676  }
 676  677  
 677  678  void
 678  679  dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx)
 679  680  {
 680  681          dsl_pool_t *dp = dmu_tx_pool(tx);
 681  682          objset_t *mos = dp->dp_meta_objset;
 682  683          uint64_t obj, ddobj, prevobj = 0;
 683  684          boolean_t rmorigin;
 684  685  
↓ open down ↓ 32 lines elided ↑ open up ↑
 717  718                  dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx);
 718  719                  if (ds->ds_prev->ds_phys->ds_next_clones_obj != 0) {
 719  720                          dsl_dataset_remove_from_next_clones(ds->ds_prev,
 720  721                              obj, tx);
 721  722                  }
 722  723  
 723  724                  ASSERT3U(ds->ds_prev->ds_phys->ds_num_children, >, 1);
 724  725                  ds->ds_prev->ds_phys->ds_num_children--;
 725  726          }
 726  727  
 727      -        zfeature_info_t *async_destroy =
 728      -            &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY];
 729      -        objset_t *os;
 730      -
 731  728          /*
 732  729           * Destroy the deadlist.  Unless it's a clone, the
 733  730           * deadlist should be empty.  (If it's a clone, it's
 734  731           * safe to ignore the deadlist contents.)
 735  732           */
 736  733          dsl_deadlist_close(&ds->ds_deadlist);
 737  734          dsl_deadlist_free(mos, ds->ds_phys->ds_deadlist_obj, tx);
 738  735          dmu_buf_will_dirty(ds->ds_dbuf, tx);
 739  736          ds->ds_phys->ds_deadlist_obj = 0;
 740  737  
      738 +        objset_t *os;
 741  739          VERIFY0(dmu_objset_from_ds(ds, &os));
 742  740  
 743      -        if (!spa_feature_is_enabled(dp->dp_spa, async_destroy)) {
      741 +        if (!spa_feature_is_enabled(dp->dp_spa, SPA_FEATURE_ASYNC_DESTROY)) {
 744  742                  old_synchronous_dataset_destroy(ds, tx);
 745  743          } else {
 746  744                  /*
 747  745                   * Move the bptree into the pool's list of trees to
 748  746                   * clean up and update space accounting information.
 749  747                   */
 750  748                  uint64_t used, comp, uncomp;
 751  749  
 752  750                  zil_destroy_sync(dmu_objset_zil(os), tx);
 753  751  
 754      -                if (!spa_feature_is_active(dp->dp_spa, async_destroy)) {
      752 +                if (!spa_feature_is_active(dp->dp_spa,
      753 +                    SPA_FEATURE_ASYNC_DESTROY)) {
 755  754                          dsl_scan_t *scn = dp->dp_scan;
 756      -
 757      -                        spa_feature_incr(dp->dp_spa, async_destroy, tx);
      755 +                        spa_feature_incr(dp->dp_spa, SPA_FEATURE_ASYNC_DESTROY,
      756 +                            tx);
 758  757                          dp->dp_bptree_obj = bptree_alloc(mos, tx);
 759  758                          VERIFY0(zap_add(mos,
 760  759                              DMU_POOL_DIRECTORY_OBJECT,
 761  760                              DMU_POOL_BPTREE_OBJ, sizeof (uint64_t), 1,
 762  761                              &dp->dp_bptree_obj, tx));
 763  762                          ASSERT(!scn->scn_async_destroying);
 764  763                          scn->scn_async_destroying = B_TRUE;
 765  764                  }
 766  765  
 767  766                  used = ds->ds_dir->dd_phys->dd_used_bytes;
↓ open down ↓ 39 lines elided ↑ open up ↑
 807  806          ASSERT(ds->ds_phys->ds_snapnames_zapobj != 0);
 808  807          VERIFY0(zap_destroy(mos, ds->ds_phys->ds_snapnames_zapobj, tx));
 809  808  
 810  809          spa_prop_clear_bootfs(dp->dp_spa, ds->ds_object, tx);
 811  810  
 812  811          ASSERT0(ds->ds_phys->ds_next_clones_obj);
 813  812          ASSERT0(ds->ds_phys->ds_props_obj);
 814  813          ASSERT0(ds->ds_phys->ds_userrefs_obj);
 815  814          dsl_dir_rele(ds->ds_dir, ds);
 816  815          ds->ds_dir = NULL;
 817      -        VERIFY0(dmu_object_free(mos, obj, tx));
      816 +        dmu_object_free_zapified(mos, obj, tx);
 818  817  
 819  818          dsl_dir_destroy_sync(ddobj, tx);
 820  819  
 821  820          if (rmorigin) {
 822  821                  dsl_dataset_t *prev;
 823  822                  VERIFY0(dsl_dataset_hold_obj(dp, prevobj, FTAG, &prev));
 824  823                  dsl_destroy_snapshot_sync_impl(prev, B_FALSE, tx);
 825  824                  dsl_dataset_rele(prev, FTAG);
 826  825          }
 827  826  }
↓ open down ↓ 35 lines elided ↑ open up ↑
 863  862          spa_t *spa;
 864  863          boolean_t isenabled;
 865  864  
 866  865  #ifdef _KERNEL
 867  866          zfs_destroy_unmount_origin(name);
 868  867  #endif
 869  868  
 870  869          error = spa_open(name, &spa, FTAG);
 871  870          if (error != 0)
 872  871                  return (error);
 873      -        isenabled = spa_feature_is_enabled(spa,
 874      -            &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY]);
      872 +        isenabled = spa_feature_is_enabled(spa, SPA_FEATURE_ASYNC_DESTROY);
 875  873          spa_close(spa, FTAG);
 876  874  
 877  875          ddha.ddha_name = name;
 878  876  
 879  877          if (!isenabled) {
 880  878                  objset_t *os;
 881  879  
 882  880                  error = dsl_sync_task(name, dsl_destroy_head_check,
 883  881                      dsl_destroy_head_begin_sync, &ddha, 0);
 884  882                  if (error != 0)
↓ open down ↓ 45 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX