]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Add limits to spa_slop_shift tunable
authorLOLi <loli10K@users.noreply.github.com>
Fri, 21 Sep 2018 04:10:12 +0000 (06:10 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 21 Sep 2018 04:10:12 +0000 (21:10 -0700)
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

module/zfs/spa_misc.c

index 2c500c010c35ceab917cf8434327bb343e515409..343b01dd6aacfd580b858a9eaf4c9b56c8d96e3b 100644 (file)
@@ -2553,6 +2553,26 @@ param_set_deadman_synctime(const char *val, zfs_kernel_param_t *kp)
        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 */
 EXPORT_SYMBOL(spa_lookup);
 EXPORT_SYMBOL(spa_add);
@@ -2678,7 +2698,8 @@ module_param(spa_asize_inflation, int, 0644);
 MODULE_PARM_DESC(spa_asize_inflation,
        "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_param(zfs_ddt_data_is_special, int, 0644);