Print this page
4185 New hash algorithm support

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 ↓ 171 lines elided ↑ open up ↑
 172  172  #include <sys/zfs_dir.h>
 173  173  #include <sys/zfs_onexit.h>
 174  174  #include <sys/zvol.h>
 175  175  #include <sys/dsl_scan.h>
 176  176  #include <sharefs/share.h>
 177  177  #include <sys/dmu_objset.h>
 178  178  #include <sys/dmu_send.h>
 179  179  #include <sys/dsl_destroy.h>
 180  180  #include <sys/dsl_userhold.h>
 181  181  #include <sys/zfeature.h>
      182 +#include <sys/zio_checksum.h>
 182  183  
 183  184  #include "zfs_namecheck.h"
 184  185  #include "zfs_prop.h"
 185  186  #include "zfs_deleg.h"
 186  187  #include "zfs_comutil.h"
 187  188  
 188  189  extern struct modlfs zfs_modlfs;
 189  190  
 190  191  extern void zfs_init(void);
 191  192  extern void zfs_fini(void);
↓ open down ↓ 2211 lines elided ↑ open up ↑
2403 2404  
2404 2405                          spa_close(spa, FTAG);
2405 2406                  }
2406 2407                  /*
2407 2408                   * We still want the default set action to be performed in the
2408 2409                   * caller, we only performed zfeature settings here.
2409 2410                   */
2410 2411                  err = -1;
2411 2412                  break;
2412 2413          }
     2414 +        case ZFS_PROP_CHECKSUM:
     2415 +        case ZFS_PROP_DEDUP:
     2416 +        {
     2417 +                zfeature_info_t *feature = NULL;
     2418 +                spa_t           *spa;
2413 2419  
     2420 +                if (intval == ZIO_CHECKSUM_SHA512)
     2421 +                        feature = &spa_feature_table[SPA_FEATURE_SHA512];
     2422 +                else if (intval == ZIO_CHECKSUM_SKEIN)
     2423 +                        feature = &spa_feature_table[SPA_FEATURE_SKEIN];
     2424 +                else if (intval == ZIO_CHECKSUM_EDONR)
     2425 +                        feature = &spa_feature_table[SPA_FEATURE_EDONR];
     2426 +                if (feature == NULL) {
     2427 +                        /* No features need to be activated for this cksum */
     2428 +                        err = -1;
     2429 +                        break;
     2430 +                }
     2431 +                if ((err = spa_open(dsname, &spa, FTAG)) != 0)
     2432 +                        return (err);
     2433 +                if (!spa_feature_is_active(spa, feature)) {
     2434 +                        /* Salted checksums must store the salt in the MOS */
     2435 +                        if (zio_checksum_table[intval].ci_salted)
     2436 +                                err = spa_activate_salted_cksum(spa, feature);
     2437 +                        else
     2438 +                                err = zfs_prop_activate_feature(spa, feature);
     2439 +                }
     2440 +                spa_close(spa, FTAG);
     2441 +                if (err == 0) {
     2442 +                        /*
     2443 +                         * We want the default set action to be performed in
     2444 +                         * the caller, we only perform feature checks here.
     2445 +                         */
     2446 +                        err = -1;
     2447 +                }
     2448 +                break;
     2449 +        }
     2450 +
2414 2451          default:
2415 2452                  err = -1;
2416 2453          }
2417 2454  
2418 2455          return (err);
2419 2456  }
2420 2457  
2421 2458  /*
2422 2459   * This function is best effort. If it fails to set any of the given properties,
2423 2460   * it continues to set as many as it can and returns the last error
↓ open down ↓ 1266 lines elided ↑ open up ↑
3690 3727                                  return (SET_ERROR(ERANGE));
3691 3728                          }
3692 3729                  }
3693 3730                  break;
3694 3731  
3695 3732          case ZFS_PROP_COPIES:
3696 3733                  if (zfs_earlier_version(dsname, SPA_VERSION_DITTO_BLOCKS))
3697 3734                          return (SET_ERROR(ENOTSUP));
3698 3735                  break;
3699 3736  
3700      -        case ZFS_PROP_DEDUP:
3701      -                if (zfs_earlier_version(dsname, SPA_VERSION_DEDUP))
3702      -                        return (SET_ERROR(ENOTSUP));
3703      -                break;
3704      -
3705 3737          case ZFS_PROP_SHARESMB:
3706 3738                  if (zpl_earlier_version(dsname, ZPL_VERSION_FUID))
3707 3739                          return (SET_ERROR(ENOTSUP));
3708 3740                  break;
3709 3741  
3710 3742          case ZFS_PROP_ACLINHERIT:
3711 3743                  if (nvpair_type(pair) == DATA_TYPE_UINT64 &&
3712 3744                      nvpair_value_uint64(pair, &intval) == 0) {
3713 3745                          if (intval == ZFS_ACL_PASSTHROUGH_X &&
3714 3746                              zfs_earlier_version(dsname,
3715 3747                              SPA_VERSION_PASSTHROUGH_X))
3716 3748                                  return (SET_ERROR(ENOTSUP));
3717 3749                  }
3718 3750                  break;
     3751 +
     3752 +        case ZFS_PROP_CHECKSUM:
     3753 +        case ZFS_PROP_DEDUP: {
     3754 +                zfeature_info_t *feature = NULL;
     3755 +
     3756 +                /* dedup feature version checks */
     3757 +                if (prop == ZFS_PROP_DEDUP &&
     3758 +                    zfs_earlier_version(dsname, SPA_VERSION_DEDUP))
     3759 +                        return (SET_ERROR(ENOTSUP));
     3760 +
     3761 +                if (nvpair_value_uint64(pair, &intval) != 0)
     3762 +                        return (SET_ERROR(EINVAL));
     3763 +
     3764 +                /* check prop value is enabled in features */
     3765 +                if (intval == ZIO_CHECKSUM_SHA512)
     3766 +                        feature = &spa_feature_table[SPA_FEATURE_SHA512];
     3767 +                else if (intval == ZIO_CHECKSUM_SKEIN)
     3768 +                        feature = &spa_feature_table[SPA_FEATURE_SKEIN];
     3769 +                else if (intval == ZIO_CHECKSUM_EDONR)
     3770 +                        feature = &spa_feature_table[SPA_FEATURE_EDONR];
     3771 +
     3772 +                if (feature != NULL) {
     3773 +                        spa_t *spa;
     3774 +
     3775 +                        if ((err = spa_open(dsname, &spa, FTAG)) != 0)
     3776 +                                return (err);
     3777 +                        /*
     3778 +                         * Salted checksums are not supported on root pools.
     3779 +                         */
     3780 +                        if (spa_bootfs(spa) != 0 &&
     3781 +                            intval < ZIO_CHECKSUM_FUNCTIONS &&
     3782 +                            zio_checksum_table[intval].ci_salted != 0) {
     3783 +                                spa_close(spa, FTAG);
     3784 +                                return (SET_ERROR(ERANGE));
     3785 +                        }
     3786 +                        if (!spa_feature_is_enabled(spa, feature)) {
     3787 +                                spa_close(spa, FTAG);
     3788 +                                return (SET_ERROR(ENOTSUP));
     3789 +                        }
     3790 +                        spa_close(spa, FTAG);
     3791 +                }
     3792 +                break;
3719 3793          }
     3794 +        }
3720 3795  
3721 3796          return (zfs_secpolicy_setprop(dsname, prop, pair, CRED()));
3722 3797  }
3723 3798  
3724 3799  /*
3725 3800   * Checks for a race condition to make sure we don't increment a feature flag
3726 3801   * multiple times.
3727 3802   */
3728 3803  static int
3729 3804  zfs_prop_activate_feature_check(void *arg, dmu_tx_t *tx)
↓ open down ↓ 2199 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX