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/space_map.c
          +++ new/usr/src/uts/common/fs/zfs/space_map.c
↓ open down ↓ 466 lines elided ↑ open up ↑
 467  467  
 468  468          sm->sm_object = space_map_alloc(sm->sm_os, tx);
 469  469          VERIFY0(space_map_open_impl(sm));
 470  470  }
 471  471  
 472  472  void
 473  473  space_map_truncate(space_map_t *sm, dmu_tx_t *tx)
 474  474  {
 475  475          objset_t *os = sm->sm_os;
 476  476          spa_t *spa = dmu_objset_spa(os);
 477      -        zfeature_info_t *space_map_histogram =
 478      -            &spa_feature_table[SPA_FEATURE_SPACEMAP_HISTOGRAM];
 479  477          dmu_object_info_t doi;
 480  478          int bonuslen;
 481  479  
 482  480          ASSERT(dsl_pool_sync_context(dmu_objset_pool(os)));
 483  481          ASSERT(dmu_tx_is_syncing(tx));
 484  482  
 485  483          VERIFY0(dmu_free_range(os, space_map_object(sm), 0, -1ULL, tx));
 486  484          dmu_object_info_from_db(sm->sm_dbuf, &doi);
 487  485  
 488      -        if (spa_feature_is_enabled(spa, space_map_histogram)) {
      486 +        if (spa_feature_is_enabled(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM)) {
 489  487                  bonuslen = sizeof (space_map_phys_t);
 490  488                  ASSERT3U(bonuslen, <=, dmu_bonus_max());
 491  489          } else {
 492  490                  bonuslen = SPACE_MAP_SIZE_V0;
 493  491          }
 494  492  
 495  493          if (bonuslen != doi.doi_bonus_size ||
 496  494              doi.doi_data_block_size != SPACE_MAP_INITIAL_BLOCKSIZE) {
 497  495                  zfs_dbgmsg("txg %llu, spa %s, reallocating: "
 498  496                      "old bonus %u, old blocksz %u", dmu_tx_get_txg(tx),
↓ open down ↓ 19 lines elided ↑ open up ↑
 518  516          ASSERT(MUTEX_HELD(sm->sm_lock));
 519  517  
 520  518          sm->sm_alloc = sm->sm_phys->smp_alloc;
 521  519          sm->sm_length = sm->sm_phys->smp_objsize;
 522  520  }
 523  521  
 524  522  uint64_t
 525  523  space_map_alloc(objset_t *os, dmu_tx_t *tx)
 526  524  {
 527  525          spa_t *spa = dmu_objset_spa(os);
 528      -        zfeature_info_t *space_map_histogram =
 529      -            &spa_feature_table[SPA_FEATURE_SPACEMAP_HISTOGRAM];
 530  526          uint64_t object;
 531  527          int bonuslen;
 532  528  
 533      -        if (spa_feature_is_enabled(spa, space_map_histogram)) {
 534      -                spa_feature_incr(spa, space_map_histogram, tx);
      529 +        if (spa_feature_is_enabled(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM)) {
      530 +                spa_feature_incr(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM, tx);
 535  531                  bonuslen = sizeof (space_map_phys_t);
 536  532                  ASSERT3U(bonuslen, <=, dmu_bonus_max());
 537  533          } else {
 538  534                  bonuslen = SPACE_MAP_SIZE_V0;
 539  535          }
 540  536  
 541  537          object = dmu_object_alloc(os,
 542  538              DMU_OT_SPACE_MAP, SPACE_MAP_INITIAL_BLOCKSIZE,
 543  539              DMU_OT_SPACE_MAP_HEADER, bonuslen, tx);
 544  540  
 545  541          return (object);
 546  542  }
 547  543  
 548  544  void
 549  545  space_map_free(space_map_t *sm, dmu_tx_t *tx)
 550  546  {
 551  547          spa_t *spa;
 552      -        zfeature_info_t *space_map_histogram =
 553      -            &spa_feature_table[SPA_FEATURE_SPACEMAP_HISTOGRAM];
 554  548  
 555  549          if (sm == NULL)
 556  550                  return;
 557  551  
 558  552          spa = dmu_objset_spa(sm->sm_os);
 559      -        if (spa_feature_is_enabled(spa, space_map_histogram)) {
      553 +        if (spa_feature_is_enabled(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM)) {
 560  554                  dmu_object_info_t doi;
 561  555  
 562  556                  dmu_object_info_from_db(sm->sm_dbuf, &doi);
 563  557                  if (doi.doi_bonus_size != SPACE_MAP_SIZE_V0) {
 564      -                        VERIFY(spa_feature_is_active(spa, space_map_histogram));
 565      -                        spa_feature_decr(spa, space_map_histogram, tx);
      558 +                        VERIFY(spa_feature_is_active(spa,
      559 +                            SPA_FEATURE_SPACEMAP_HISTOGRAM));
      560 +                        spa_feature_decr(spa,
      561 +                            SPA_FEATURE_SPACEMAP_HISTOGRAM, tx);
 566  562                  }
 567  563          }
 568  564  
 569  565          VERIFY3U(dmu_object_free(sm->sm_os, space_map_object(sm), tx), ==, 0);
 570  566          sm->sm_object = 0;
 571  567  }
 572  568  
 573  569  uint64_t
 574  570  space_map_object(space_map_t *sm)
 575  571  {
↓ open down ↓ 32 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX