From d1043e2f6da4315f0dcbd1487b4e6b5f63bebc41 Mon Sep 17 00:00:00 2001 From: Tim Chase Date: Tue, 8 May 2018 23:45:47 -0500 Subject: [PATCH] Unify behavior of deadman parameters 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 Signed-off-by: Tim Chase Closes #7499 --- module/zfs/spa_misc.c | 58 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index e0edba155..234e5c60d 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -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");