Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Show First 20 Lines • Show All 2,147 Lines • ▼ Show 20 Lines | if (error != 0) | ||||
return (error); | return (error); | ||||
error = spa_vdev_setfru(spa, guid, fru); | error = spa_vdev_setfru(spa, guid, fru); | ||||
spa_close(spa, FTAG); | spa_close(spa, FTAG); | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
get_prop_uint64(nvlist_t *nv, const char *prop, nvlist_t **nvp, | |||||
uint64_t *val) | |||||
{ | |||||
int err = 0; | |||||
nvlist_t *subnv; | |||||
nvpair_t *pair; | |||||
nvpair_t *propval; | |||||
if (nvlist_lookup_nvpair(nv, prop, &pair) != 0) | |||||
return (EINVAL); | |||||
/* decode the property value */ | |||||
propval = pair; | |||||
if (nvpair_type(pair) == DATA_TYPE_NVLIST) { | |||||
subnv = fnvpair_value_nvlist(pair); | |||||
if (nvp != NULL) | |||||
*nvp = subnv; | |||||
if (nvlist_lookup_nvpair(subnv, ZPROP_VALUE, &propval) != 0) | |||||
err = EINVAL; | |||||
} | |||||
if (nvpair_type(propval) == DATA_TYPE_UINT64) { | |||||
*val = fnvpair_value_uint64(propval); | |||||
} | |||||
return (err); | |||||
} | |||||
static int | |||||
zfs_ioc_objset_stats_impl(zfs_cmd_t *zc, objset_t *os) | zfs_ioc_objset_stats_impl(zfs_cmd_t *zc, objset_t *os) | ||||
{ | { | ||||
int error = 0; | int error = 0; | ||||
nvlist_t *nv; | nvlist_t *nv; | ||||
dmu_objset_fast_stat(os, &zc->zc_objset_stats); | dmu_objset_fast_stat(os, &zc->zc_objset_stats); | ||||
if (zc->zc_nvlist_dst != 0 && | if (zc->zc_nvlist_dst != 0 && | ||||
(error = dsl_prop_get_all(os, &nv)) == 0) { | (error = dsl_prop_get_all(os, &nv)) == 0) { | ||||
dmu_objset_stats(os, nv); | dmu_objset_stats(os, nv); | ||||
/* | /* | ||||
* NB: zvol_get_stats() will read the objset contents, | * NB: zvol_get_stats() will read the objset contents, | ||||
* which we aren't supposed to do with a | * which we aren't supposed to do with a | ||||
* DS_MODE_USER hold, because it could be | * DS_MODE_USER hold, because it could be | ||||
* inconsistent. So this is a bit of a workaround... | * inconsistent. So this is a bit of a workaround... | ||||
* XXX reading with out owning | * XXX reading with out owning | ||||
*/ | */ | ||||
if (!zc->zc_objset_stats.dds_inconsistent && | if (!zc->zc_objset_stats.dds_inconsistent && | ||||
dmu_objset_type(os) == DMU_OST_ZVOL) { | dmu_objset_type(os) == DMU_OST_ZVOL) { | ||||
error = zvol_get_stats(os, nv); | error = zvol_get_stats(os, nv); | ||||
if (error == EIO) | if (error == EIO) | ||||
return (error); | return (error); | ||||
VERIFY0(error); | VERIFY0(error); | ||||
} | } | ||||
/* | |||||
* ZSTD stores the compression level in a separate hidden | |||||
* property to avoid using up a large chunk of space in the | |||||
* on-disk compression algorithm enum. We need to swap things | |||||
* back around when the property is read. | |||||
*/ | |||||
nvlist_t *cnv; | |||||
uint64_t compval, levelval; | |||||
if (get_prop_uint64(nv, "compression", &cnv, &compval) != 0) | |||||
error = EINVAL; | |||||
if (error == 0 && compval == ZIO_COMPRESS_ZSTD && | |||||
get_prop_uint64(nv, "zstd_compress_level", NULL, | |||||
&levelval) == 0) { | |||||
if (levelval == ZIO_ZSTDLVL_DEFAULT) | |||||
levelval = 0; | |||||
fnvlist_remove(cnv, ZPROP_VALUE); | |||||
fnvlist_add_uint64(cnv, ZPROP_VALUE, | |||||
compval | (levelval << SPA_COMPRESSBITS)); | |||||
} | |||||
error = put_nvlist(zc, nv); | error = put_nvlist(zc, nv); | ||||
nvlist_free(nv); | nvlist_free(nv); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 383 Lines • ▼ Show 20 Lines | if (err == 0 && intval >= ZPL_VERSION_USERSPACE) { | ||||
zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP); | zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP); | ||||
(void) strcpy(zc->zc_name, dsname); | (void) strcpy(zc->zc_name, dsname); | ||||
(void) zfs_ioc_userspace_upgrade(zc); | (void) zfs_ioc_userspace_upgrade(zc); | ||||
kmem_free(zc, sizeof (zfs_cmd_t)); | kmem_free(zc, sizeof (zfs_cmd_t)); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
case ZFS_PROP_COMPRESSION: | |||||
/* Special handling is only required for ZSTD */ | |||||
if (intval & SPA_COMPRESSMASK != ZIO_COMPRESS_ZSTD) { | |||||
err = -1; | |||||
break; | |||||
} | |||||
/* | |||||
* Store the ZSTD compression level separate from the compress | |||||
* property in its own hidden property. | |||||
*/ | |||||
uint64_t levelval; | |||||
if (intval == ZIO_COMPRESS_ZSTD) { | |||||
levelval = ZIO_ZSTDLVL_DEFAULT; | |||||
} else { | |||||
levelval = (intval & ~SPA_COMPRESSMASK) | |||||
>> SPA_COMPRESSBITS; | |||||
} | |||||
err = dsl_prop_set_int(dsname, "zstd_compress_level", source, | |||||
levelval); | |||||
if (err == 0) { | |||||
/* Store the compression algorithm normally */ | |||||
err = dsl_prop_set_int(dsname, propname, source, | |||||
intval & SPA_COMPRESSMASK); | |||||
} | |||||
break; | |||||
default: | default: | ||||
err = -1; | err = -1; | ||||
} | } | ||||
return (err); | return (err); | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 1,483 Lines • ▼ Show 20 Lines | if (nvpair_value_uint64(pair, &intval) == 0) { | ||||
if (intval == ZIO_COMPRESS_LZ4) { | if (intval == ZIO_COMPRESS_LZ4) { | ||||
spa_t *spa; | spa_t *spa; | ||||
if ((err = spa_open(dsname, &spa, FTAG)) != 0) | if ((err = spa_open(dsname, &spa, FTAG)) != 0) | ||||
return (err); | return (err); | ||||
if (!spa_feature_is_enabled(spa, | if (!spa_feature_is_enabled(spa, | ||||
SPA_FEATURE_LZ4_COMPRESS)) { | SPA_FEATURE_LZ4_COMPRESS)) { | ||||
spa_close(spa, FTAG); | |||||
return (SET_ERROR(ENOTSUP)); | |||||
} | |||||
spa_close(spa, FTAG); | |||||
} | |||||
if (intval == ZIO_COMPRESS_ZSTD) { | |||||
spa_t *spa; | |||||
if ((err = spa_open(dsname, &spa, FTAG)) != 0) | |||||
return (err); | |||||
if (!spa_feature_is_enabled(spa, | |||||
SPA_FEATURE_ZSTD_COMPRESS)) { | |||||
spa_close(spa, FTAG); | spa_close(spa, FTAG); | ||||
return (SET_ERROR(ENOTSUP)); | return (SET_ERROR(ENOTSUP)); | ||||
} | } | ||||
spa_close(spa, FTAG); | spa_close(spa, FTAG); | ||||
} | } | ||||
/* | /* | ||||
* If this is a bootable dataset then | * If this is a bootable dataset then | ||||
▲ Show 20 Lines • Show All 2,975 Lines • Show Last 20 Lines |