aboutsummaryrefslogtreecommitdiff
path: root/mm/zswap.c
diff options
context:
space:
mode:
authorAlex Shi <alex.shi@linaro.org>2017-02-10 12:00:58 +0800
committerAlex Shi <alex.shi@linaro.org>2017-02-10 12:00:58 +0800
commitfd0d0fd17f47e0015e5be2a1e58434144a5f99e0 (patch)
treef2cb780174ccdee6d1a95fd421ef7bcf1dd4be1c /mm/zswap.c
parentd69f58e2b8396658b7577113f9887bd4d66d25f8 (diff)
parent6a1bd90632464c129ad5f9ca7c54917a6dd7cb4b (diff)
Merge tag 'v4.4.48' into linux-linaro-lsk-v4.4
This is the 4.4.48 stable release
Diffstat (limited to 'mm/zswap.c')
-rw-r--r--mm/zswap.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/mm/zswap.c b/mm/zswap.c
index 340261946fda..45476f429789 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -78,7 +78,13 @@ static u64 zswap_duplicate_entry;
/* Enable/disable zswap (disabled by default) */
static bool zswap_enabled;
-module_param_named(enabled, zswap_enabled, bool, 0644);
+static int zswap_enabled_param_set(const char *,
+ const struct kernel_param *);
+static struct kernel_param_ops zswap_enabled_param_ops = {
+ .set = zswap_enabled_param_set,
+ .get = param_get_bool,
+};
+module_param_cb(enabled, &zswap_enabled_param_ops, &zswap_enabled, 0644);
/* Crypto compressor to use */
#define ZSWAP_COMPRESSOR_DEFAULT "lzo"
@@ -176,6 +182,9 @@ static atomic_t zswap_pools_count = ATOMIC_INIT(0);
/* used by param callback function */
static bool zswap_init_started;
+/* fatal error during init */
+static bool zswap_init_failed;
+
/*********************************
* helpers and fwd declarations
**********************************/
@@ -702,6 +711,11 @@ static int __zswap_param_set(const char *val, const struct kernel_param *kp,
char *s = strstrip((char *)val);
int ret;
+ if (zswap_init_failed) {
+ pr_err("can't set param, initialization failed\n");
+ return -ENODEV;
+ }
+
/* no change required */
if (!strcmp(s, *(char **)kp->arg))
return 0;
@@ -781,6 +795,17 @@ static int zswap_zpool_param_set(const char *val,
return __zswap_param_set(val, kp, NULL, zswap_compressor);
}
+static int zswap_enabled_param_set(const char *val,
+ const struct kernel_param *kp)
+{
+ if (zswap_init_failed) {
+ pr_err("can't enable, initialization failed\n");
+ return -ENODEV;
+ }
+
+ return param_set_bool(val, kp);
+}
+
/*********************************
* writeback code
**********************************/
@@ -1267,6 +1292,9 @@ pool_fail:
dstmem_fail:
zswap_entry_cache_destroy();
cache_fail:
+ /* if built-in, we aren't unloaded on failure; don't allow use */
+ zswap_init_failed = true;
+ zswap_enabled = false;
return -ENOMEM;
}
/* must be late so crypto has time to come up */