2374 case ZFS_PROP_VERSION:
2375 {
2376 zfsvfs_t *zfsvfs;
2377
2378 if ((err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_TRUE)) != 0)
2379 break;
2380
2381 err = zfs_set_version(zfsvfs, intval);
2382 zfsvfs_rele(zfsvfs, FTAG);
2383
2384 if (err == 0 && intval >= ZPL_VERSION_USERSPACE) {
2385 zfs_cmd_t *zc;
2386
2387 zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
2388 (void) strcpy(zc->zc_name, dsname);
2389 (void) zfs_ioc_userspace_upgrade(zc);
2390 kmem_free(zc, sizeof (zfs_cmd_t));
2391 }
2392 break;
2393 }
2394 case ZFS_PROP_COMPRESSION:
2395 {
2396 if (intval == ZIO_COMPRESS_LZ4) {
2397 zfeature_info_t *feature =
2398 &spa_feature_table[SPA_FEATURE_LZ4_COMPRESS];
2399 spa_t *spa;
2400 dsl_pool_t *dp;
2401
2402 if ((err = spa_open(dsname, &spa, FTAG)) != 0)
2403 return (err);
2404
2405 dp = spa->spa_dsl_pool;
2406
2407 /*
2408 * Setting the LZ4 compression algorithm activates
2409 * the feature.
2410 */
2411 if (!spa_feature_is_active(spa, feature)) {
2412 if ((err = zfs_prop_activate_feature(dp,
2413 feature)) != 0) {
3632 }
3633
3634 if (issnap)
3635 return (EINVAL);
3636
3637 if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
3638 /*
3639 * dsl_prop_get_all_impl() returns properties in this
3640 * format.
3641 */
3642 nvlist_t *attrs;
3643 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
3644 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
3645 &pair) == 0);
3646 }
3647
3648 /*
3649 * Check that this value is valid for this pool version
3650 */
3651 switch (prop) {
3652 case ZFS_PROP_COMPRESSION:
3653 /*
3654 * If the user specified gzip compression, make sure
3655 * the SPA supports it. We ignore any errors here since
3656 * we'll catch them later.
3657 */
3658 if (nvpair_type(pair) == DATA_TYPE_UINT64 &&
3659 nvpair_value_uint64(pair, &intval) == 0) {
3660 if (intval >= ZIO_COMPRESS_GZIP_1 &&
3661 intval <= ZIO_COMPRESS_GZIP_9 &&
3662 zfs_earlier_version(dsname,
3663 SPA_VERSION_GZIP_COMPRESSION)) {
3664 return (ENOTSUP);
3665 }
3666
3667 if (intval == ZIO_COMPRESS_ZLE &&
3668 zfs_earlier_version(dsname,
3669 SPA_VERSION_ZLE_COMPRESSION))
3670 return (ENOTSUP);
3671
|
2374 case ZFS_PROP_VERSION:
2375 {
2376 zfsvfs_t *zfsvfs;
2377
2378 if ((err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_TRUE)) != 0)
2379 break;
2380
2381 err = zfs_set_version(zfsvfs, intval);
2382 zfsvfs_rele(zfsvfs, FTAG);
2383
2384 if (err == 0 && intval >= ZPL_VERSION_USERSPACE) {
2385 zfs_cmd_t *zc;
2386
2387 zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
2388 (void) strcpy(zc->zc_name, dsname);
2389 (void) zfs_ioc_userspace_upgrade(zc);
2390 kmem_free(zc, sizeof (zfs_cmd_t));
2391 }
2392 break;
2393 }
2394 case ZFS_PROP_CHECKSUM:
2395 {
2396 if (intval == ZIO_CHECKSUM_EDONR512_256) {
2397 zfeature_info_t *feature =
2398 &spa_feature_table[SPA_FEATURE_EDONR_CKSUM];
2399 spa_t *spa;
2400 dsl_pool_t *dp;
2401
2402 if ((err = spa_open(dsname, &spa, FTAG)) != 0)
2403 return (err);
2404
2405 dp = spa->spa_dsl_pool;
2406
2407 /*
2408 * Setting the Edon-R checksum algorithm activates
2409 * the feature.
2410 */
2411 if (!spa_feature_is_active(spa, feature)) {
2412 if ((err = zfs_prop_activate_feature(dp,
2413 feature)) != 0) {
2414 spa_close(spa, FTAG);
2415 return (err);
2416 }
2417 }
2418
2419 spa_close(spa, FTAG);
2420 }
2421 /*
2422 * We still want the default set action to be performed in the
2423 * caller, we only performed zfeature settings here.
2424 */
2425 err = -1;
2426 break;
2427 }
2428 case ZFS_PROP_COMPRESSION:
2429 {
2430 if (intval == ZIO_COMPRESS_LZ4) {
2431 zfeature_info_t *feature =
2432 &spa_feature_table[SPA_FEATURE_LZ4_COMPRESS];
2433 spa_t *spa;
2434 dsl_pool_t *dp;
2435
2436 if ((err = spa_open(dsname, &spa, FTAG)) != 0)
2437 return (err);
2438
2439 dp = spa->spa_dsl_pool;
2440
2441 /*
2442 * Setting the LZ4 compression algorithm activates
2443 * the feature.
2444 */
2445 if (!spa_feature_is_active(spa, feature)) {
2446 if ((err = zfs_prop_activate_feature(dp,
2447 feature)) != 0) {
3666 }
3667
3668 if (issnap)
3669 return (EINVAL);
3670
3671 if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
3672 /*
3673 * dsl_prop_get_all_impl() returns properties in this
3674 * format.
3675 */
3676 nvlist_t *attrs;
3677 VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
3678 VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
3679 &pair) == 0);
3680 }
3681
3682 /*
3683 * Check that this value is valid for this pool version
3684 */
3685 switch (prop) {
3686 case ZFS_PROP_CHECKSUM:
3687 if (nvpair_type(pair) == DATA_TYPE_UINT64 &&
3688 nvpair_value_uint64(pair, &intval) == 0) {
3689 if (intval == ZIO_CHECKSUM_EDONR512_256) {
3690 zfeature_info_t *feature =
3691 &spa_feature_table[SPA_FEATURE_EDONR_CKSUM];
3692 spa_t *spa;
3693
3694 if ((err = spa_open(dsname, &spa, FTAG)) != 0)
3695 return (err);
3696
3697 if (!spa_feature_is_enabled(spa, feature)) {
3698 spa_close(spa, FTAG);
3699 return (ENOTSUP);
3700 }
3701 spa_close(spa, FTAG);
3702 }
3703 }
3704 break;
3705 case ZFS_PROP_COMPRESSION:
3706 /*
3707 * If the user specified gzip compression, make sure
3708 * the SPA supports it. We ignore any errors here since
3709 * we'll catch them later.
3710 */
3711 if (nvpair_type(pair) == DATA_TYPE_UINT64 &&
3712 nvpair_value_uint64(pair, &intval) == 0) {
3713 if (intval >= ZIO_COMPRESS_GZIP_1 &&
3714 intval <= ZIO_COMPRESS_GZIP_9 &&
3715 zfs_earlier_version(dsname,
3716 SPA_VERSION_GZIP_COMPRESSION)) {
3717 return (ENOTSUP);
3718 }
3719
3720 if (intval == ZIO_COMPRESS_ZLE &&
3721 zfs_earlier_version(dsname,
3722 SPA_VERSION_ZLE_COMPRESSION))
3723 return (ENOTSUP);
3724
|