Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zcp_get.c
Show First 20 Lines • Show All 319 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
int error = 0; | int error = 0; | ||||
objset_t *os; | objset_t *os; | ||||
uint64_t numval; | uint64_t numval; | ||||
char *strval = kmem_alloc(ZAP_MAXVALUELEN, KM_SLEEP); | char *strval = kmem_alloc(ZAP_MAXVALUELEN, KM_SLEEP); | ||||
char setpoint[ZFS_MAX_DATASET_NAME_LEN] = | char setpoint[ZFS_MAX_DATASET_NAME_LEN] = | ||||
"Internal error - setpoint not determined"; | "Internal error - setpoint not determined"; | ||||
zfs_type_t ds_type; | zfs_type_t ds_type; | ||||
const char *prop_name = zfs_prop_to_name(zfs_prop); | |||||
zprop_type_t prop_type = zfs_prop_get_type(zfs_prop); | zprop_type_t prop_type = zfs_prop_get_type(zfs_prop); | ||||
(void) get_objset_type(ds, &ds_type); | (void) get_objset_type(ds, &ds_type); | ||||
switch (zfs_prop) { | switch (zfs_prop) { | ||||
case ZFS_PROP_REFRATIO: | case ZFS_PROP_REFRATIO: | ||||
numval = dsl_get_refratio(ds); | numval = dsl_get_refratio(ds); | ||||
break; | break; | ||||
case ZFS_PROP_USED: | case ZFS_PROP_USED: | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | case ZFS_PROP_VOLBLOCKSIZE: { | ||||
error = dmu_objset_from_ds(ds, &os); | error = dmu_objset_from_ds(ds, &os); | ||||
if (error == 0) { | if (error == 0) { | ||||
error = dmu_object_info(os, ZVOL_OBJ, &doi); | error = dmu_object_info(os, ZVOL_OBJ, &doi); | ||||
if (error == 0) | if (error == 0) | ||||
numval = doi.doi_data_block_size; | numval = doi.doi_data_block_size; | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
case ZFS_PROP_COMPRESSION: | |||||
error = dsl_prop_get_ds(ds, prop_name, sizeof (numval), 1, | |||||
&numval, setpoint); | |||||
/* Special handling is only required for ZSTD */ | |||||
if (error || numval != ZIO_COMPRESS_ZSTD) | |||||
break; | |||||
uint64_t levelval; | |||||
const char *zstd_name = zfs_prop_to_name(ZFS_PROP_ZSTD_LEVEL); | |||||
error = dsl_prop_get_ds(ds, zstd_name, sizeof (levelval), | |||||
1, &levelval, setpoint); | |||||
if (error == 0) { | |||||
if (levelval == ZIO_ZSTDLVL_DEFAULT) | |||||
break; | |||||
numval |= levelval << SPA_COMPRESSBITS; | |||||
} | |||||
break; | |||||
default: | default: | ||||
/* Did not match these props, check in the dsl_dir */ | /* Did not match these props, check in the dsl_dir */ | ||||
error = get_dsl_dir_prop(ds, zfs_prop, &numval); | error = get_dsl_dir_prop(ds, zfs_prop, &numval); | ||||
} | } | ||||
if (error != 0) { | if (error != 0) { | ||||
kmem_free(strval, ZAP_MAXVALUELEN); | kmem_free(strval, ZAP_MAXVALUELEN); | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 387 Lines • Show Last 20 Lines |