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/zfs_ioctl.c
          +++ new/usr/src/uts/common/fs/zfs/zfs_ioctl.c
↓ open down ↓ 234 lines elided ↑ open up ↑
 235  235  static int zfs_ioc_userspace_upgrade(zfs_cmd_t *zc);
 236  236  static int zfs_check_settable(const char *name, nvpair_t *property,
 237  237      cred_t *cr);
 238  238  static int zfs_check_clearable(char *dataset, nvlist_t *props,
 239  239      nvlist_t **errors);
 240  240  static int zfs_fill_zplprops_root(uint64_t, nvlist_t *, nvlist_t *,
 241  241      boolean_t *);
 242  242  int zfs_set_prop_nvlist(const char *, zprop_source_t, nvlist_t *, nvlist_t *);
 243  243  static int get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp);
 244  244  
 245      -static int zfs_prop_activate_feature(spa_t *spa, zfeature_info_t *feature);
      245 +static int zfs_prop_activate_feature(spa_t *spa, spa_feature_t feature);
 246  246  
 247  247  /* _NOTE(PRINTFLIKE(4)) - this is printf-like, but lint is too whiney */
 248  248  void
 249  249  __dprintf(const char *file, const char *func, int line, const char *fmt, ...)
 250  250  {
 251  251          const char *newfile;
 252  252          char buf[512];
 253  253          va_list adx;
 254  254  
 255  255          /*
↓ open down ↓ 2119 lines elided ↑ open up ↑
2375 2375                          zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
2376 2376                          (void) strcpy(zc->zc_name, dsname);
2377 2377                          (void) zfs_ioc_userspace_upgrade(zc);
2378 2378                          kmem_free(zc, sizeof (zfs_cmd_t));
2379 2379                  }
2380 2380                  break;
2381 2381          }
2382 2382          case ZFS_PROP_COMPRESSION:
2383 2383          {
2384 2384                  if (intval == ZIO_COMPRESS_LZ4) {
2385      -                        zfeature_info_t *feature =
2386      -                            &spa_feature_table[SPA_FEATURE_LZ4_COMPRESS];
2387 2385                          spa_t *spa;
2388 2386  
2389 2387                          if ((err = spa_open(dsname, &spa, FTAG)) != 0)
2390 2388                                  return (err);
2391 2389  
2392 2390                          /*
2393 2391                           * Setting the LZ4 compression algorithm activates
2394 2392                           * the feature.
2395 2393                           */
2396      -                        if (!spa_feature_is_active(spa, feature)) {
     2394 +                        if (!spa_feature_is_active(spa,
     2395 +                            SPA_FEATURE_LZ4_COMPRESS)) {
2397 2396                                  if ((err = zfs_prop_activate_feature(spa,
2398      -                                    feature)) != 0) {
     2397 +                                    SPA_FEATURE_LZ4_COMPRESS)) != 0) {
2399 2398                                          spa_close(spa, FTAG);
2400 2399                                          return (err);
2401 2400                                  }
2402 2401                          }
2403 2402  
2404 2403                          spa_close(spa, FTAG);
2405 2404                  }
2406 2405                  /*
2407 2406                   * We still want the default set action to be performed in the
2408 2407                   * caller, we only performed zfeature settings here.
↓ open down ↓ 1247 lines elided ↑ open up ↑
3656 3655                              SPA_VERSION_GZIP_COMPRESSION)) {
3657 3656                                  return (SET_ERROR(ENOTSUP));
3658 3657                          }
3659 3658  
3660 3659                          if (intval == ZIO_COMPRESS_ZLE &&
3661 3660                              zfs_earlier_version(dsname,
3662 3661                              SPA_VERSION_ZLE_COMPRESSION))
3663 3662                                  return (SET_ERROR(ENOTSUP));
3664 3663  
3665 3664                          if (intval == ZIO_COMPRESS_LZ4) {
3666      -                                zfeature_info_t *feature =
3667      -                                    &spa_feature_table[
3668      -                                    SPA_FEATURE_LZ4_COMPRESS];
3669 3665                                  spa_t *spa;
3670 3666  
3671 3667                                  if ((err = spa_open(dsname, &spa, FTAG)) != 0)
3672 3668                                          return (err);
3673 3669  
3674      -                                if (!spa_feature_is_enabled(spa, feature)) {
     3670 +                                if (!spa_feature_is_enabled(spa,
     3671 +                                    SPA_FEATURE_LZ4_COMPRESS)) {
3675 3672                                          spa_close(spa, FTAG);
3676 3673                                          return (SET_ERROR(ENOTSUP));
3677 3674                                  }
3678 3675                                  spa_close(spa, FTAG);
3679 3676                          }
3680 3677  
3681 3678                          /*
3682 3679                           * If this is a bootable dataset then
3683 3680                           * verify that the compression algorithm
3684 3681                           * is supported for booting. We must return
↓ open down ↓ 37 lines elided ↑ open up ↑
3722 3719  }
3723 3720  
3724 3721  /*
3725 3722   * Checks for a race condition to make sure we don't increment a feature flag
3726 3723   * multiple times.
3727 3724   */
3728 3725  static int
3729 3726  zfs_prop_activate_feature_check(void *arg, dmu_tx_t *tx)
3730 3727  {
3731 3728          spa_t *spa = dmu_tx_pool(tx)->dp_spa;
3732      -        zfeature_info_t *feature = arg;
     3729 +        spa_feature_t *featurep = arg;
3733 3730  
3734      -        if (!spa_feature_is_active(spa, feature))
     3731 +        if (!spa_feature_is_active(spa, *featurep))
3735 3732                  return (0);
3736 3733          else
3737 3734                  return (SET_ERROR(EBUSY));
3738 3735  }
3739 3736  
3740 3737  /*
3741 3738   * The callback invoked on feature activation in the sync task caused by
3742 3739   * zfs_prop_activate_feature.
3743 3740   */
3744 3741  static void
3745 3742  zfs_prop_activate_feature_sync(void *arg, dmu_tx_t *tx)
3746 3743  {
3747 3744          spa_t *spa = dmu_tx_pool(tx)->dp_spa;
3748      -        zfeature_info_t *feature = arg;
     3745 +        spa_feature_t *featurep = arg;
3749 3746  
3750      -        spa_feature_incr(spa, feature, tx);
     3747 +        spa_feature_incr(spa, *featurep, tx);
3751 3748  }
3752 3749  
3753 3750  /*
3754 3751   * Activates a feature on a pool in response to a property setting. This
3755 3752   * creates a new sync task which modifies the pool to reflect the feature
3756 3753   * as being active.
3757 3754   */
3758 3755  static int
3759      -zfs_prop_activate_feature(spa_t *spa, zfeature_info_t *feature)
     3756 +zfs_prop_activate_feature(spa_t *spa, spa_feature_t feature)
3760 3757  {
3761 3758          int err;
3762 3759  
3763 3760          /* EBUSY here indicates that the feature is already active */
3764 3761          err = dsl_sync_task(spa_name(spa),
3765 3762              zfs_prop_activate_feature_check, zfs_prop_activate_feature_sync,
3766      -            feature, 2);
     3763 +            &feature, 2);
3767 3764  
3768 3765          if (err != 0 && err != EBUSY)
3769 3766                  return (err);
3770 3767          else
3771 3768                  return (0);
3772 3769  }
3773 3770  
3774 3771  /*
3775 3772   * Removes properties from the given props list that fail permission checks
3776 3773   * needed to clear them and to restore them in case of a receive error. For each
↓ open down ↓ 2152 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX