]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Unify behavior of deadman parameters
authorTim Chase <tim@chase2k.com>
Wed, 9 May 2018 04:45:47 +0000 (23:45 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 9 May 2018 04:45:47 +0000 (21:45 -0700)
The zfs_deadman_failmode, zfs_deadman_ziotime_ms and
zfs_deadman_synctime_ms paramaters are stored per-pool.  However,
only the zfs_deadman_failmode updates the per-pool state when it's
change.  This patch gives adds the same behavior to the other two
for consistency.

Also, in all 3 three cases, only update the per-pool parameters
if spa_init() has actually been called in order to avoid panicking
when trying to take a lock on the spa_namespace_lock mutex.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Closes #7499

module/zfs/spa_misc.c

index e0edba1554a69c9e22521ac85af9331917c94e21..234e5c60d80b0a472ccf119619c7b96680f0e45c 100644 (file)
@@ -2274,14 +2274,58 @@ param_set_deadman_failmode(const char *val, zfs_kernel_param_t *kp)
            strcmp(val, "panic"))
                return (SET_ERROR(-EINVAL));
 
-       mutex_enter(&spa_namespace_lock);
-       while ((spa = spa_next(spa)) != NULL)
-               spa_set_deadman_failmode(spa, val);
-       mutex_exit(&spa_namespace_lock);
+       if (spa_mode_global != 0) {
+               mutex_enter(&spa_namespace_lock);
+               while ((spa = spa_next(spa)) != NULL)
+                       spa_set_deadman_failmode(spa, val);
+               mutex_exit(&spa_namespace_lock);
+       }
 
        return (param_set_charp(val, kp));
 }
 
+static int
+param_set_deadman_ziotime(const char *val, zfs_kernel_param_t *kp)
+{
+       spa_t *spa = NULL;
+       int error;
+
+       error = param_set_ulong(val, kp);
+       if (error < 0)
+               return (SET_ERROR(error));
+
+       if (spa_mode_global != 0) {
+               mutex_enter(&spa_namespace_lock);
+               while ((spa = spa_next(spa)) != NULL)
+                       spa->spa_deadman_ziotime =
+                           MSEC2NSEC(zfs_deadman_ziotime_ms);
+               mutex_exit(&spa_namespace_lock);
+       }
+
+       return (0);
+}
+
+static int
+param_set_deadman_synctime(const char *val, zfs_kernel_param_t *kp)
+{
+       spa_t *spa = NULL;
+       int error;
+
+       error = param_set_ulong(val, kp);
+       if (error < 0)
+               return (SET_ERROR(error));
+
+       if (spa_mode_global != 0) {
+               mutex_enter(&spa_namespace_lock);
+               while ((spa = spa_next(spa)) != NULL)
+                       spa->spa_deadman_synctime =
+                           MSEC2NSEC(zfs_deadman_synctime_ms);
+               mutex_exit(&spa_namespace_lock);
+       }
+
+       return (0);
+}
+
 /* Namespace manipulation */
 EXPORT_SYMBOL(spa_lookup);
 EXPORT_SYMBOL(spa_add);
@@ -2374,11 +2418,13 @@ module_param(zfs_free_leak_on_eio, int, 0644);
 MODULE_PARM_DESC(zfs_free_leak_on_eio,
        "Set to ignore IO errors during free and permanently leak the space");
 
-module_param(zfs_deadman_synctime_ms, ulong, 0644);
+module_param_call(zfs_deadman_synctime_ms, param_set_deadman_synctime,
+    param_get_ulong, &zfs_deadman_synctime_ms, 0644);
 MODULE_PARM_DESC(zfs_deadman_synctime_ms,
        "Pool sync expiration time in milliseconds");
 
-module_param(zfs_deadman_ziotime_ms, ulong, 0644);
+module_param_call(zfs_deadman_ziotime_ms, param_set_deadman_ziotime,
+    param_get_ulong, &zfs_deadman_ziotime_ms, 0644);
 MODULE_PARM_DESC(zfs_deadman_ziotime_ms,
        "IO expiration time in milliseconds");