Add limits to spa_slop_shift tunable

This change adds limits to the possible spa_slop_shift values set via
the sysfs interface. Accepted values are from a minimum of 1 to a
maximum of 31 (inclusive): these limits are based on the following
values observed on a 128PB file-vdev test pool:

spa_slop_shift=1, spa_get_slop_space=63.5PiB
spa_slop_shift=2, spa_get_slop_space=31.8PiB
spa_slop_shift=3, spa_get_slop_space=15.9PiB
spa_slop_shift=4, spa_get_slop_space=7.9PiB
spa_slop_shift=5, spa_get_slop_space=4PiB
spa_slop_shift=6, spa_get_slop_space=2PiB
...
spa_slop_shift=25, spa_get_slop_space=4GiB
spa_slop_shift=26, spa_get_slop_space=2GiB
spa_slop_shift=27, spa_get_slop_space=1016MiB
spa_slop_shift=28, spa_get_slop_space=508MiB
spa_slop_shift=29, spa_get_slop_space=254MiB
spa_slop_shift=30, spa_get_slop_space=128MiB
spa_slop_shift=31, spa_get_slop_space=128MiB
spa_slop_shift=32, spa_get_slop_space=128MiB

Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #7876 
Closes #7900
This commit is contained in:
LOLi 2018-09-21 06:10:12 +02:00 committed by Brian Behlendorf
parent 145c88fb7b
commit 7522a26077

View File

@ -2553,6 +2553,26 @@ param_set_deadman_synctime(const char *val, zfs_kernel_param_t *kp)
return (0); return (0);
} }
static int
param_set_slop_shift(const char *buf, zfs_kernel_param_t *kp)
{
unsigned long val;
int error;
error = kstrtoul(buf, 0, &val);
if (error)
return (SET_ERROR(error));
if (val < 1 || val > 31)
return (SET_ERROR(-EINVAL));
error = param_set_int(buf, kp);
if (error < 0)
return (SET_ERROR(error));
return (0);
}
/* Namespace manipulation */ /* Namespace manipulation */
EXPORT_SYMBOL(spa_lookup); EXPORT_SYMBOL(spa_lookup);
EXPORT_SYMBOL(spa_add); EXPORT_SYMBOL(spa_add);
@ -2678,7 +2698,8 @@ module_param(spa_asize_inflation, int, 0644);
MODULE_PARM_DESC(spa_asize_inflation, MODULE_PARM_DESC(spa_asize_inflation,
"SPA size estimate multiplication factor"); "SPA size estimate multiplication factor");
module_param(spa_slop_shift, int, 0644); module_param_call(spa_slop_shift, param_set_slop_shift, param_get_int,
&spa_slop_shift, 0644);
MODULE_PARM_DESC(spa_slop_shift, "Reserved free space in pool"); MODULE_PARM_DESC(spa_slop_shift, "Reserved free space in pool");
module_param(zfs_ddt_data_is_special, int, 0644); module_param(zfs_ddt_data_is_special, int, 0644);