summaryrefslogtreecommitdiff
path: root/fs/cachefiles/main.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2021-10-21 10:15:26 +0300
committerDavid Howells <dhowells@redhat.com>2022-01-07 16:40:56 +0300
commita70f6526267e9f5fbf958a69c6112938b0b14bc4 (patch)
treeb795158ca0ec0b87b96a84efeaf8160baec8d30a /fs/cachefiles/main.c
parent8390fbc46570dca6f1c7b170f19c612f9ec91a92 (diff)
downloadlinux-a70f6526267e9f5fbf958a69c6112938b0b14bc4.tar.xz
cachefiles: Add some error injection support
Add support for injecting ENOSPC or EIO errors. This needs to be enabled by CONFIG_CACHEFILES_ERROR_INJECTION=y. Once enabled, ENOSPC on things like write and mkdir can be triggered by: echo 1 >/proc/sys/cachefiles/error_injection and EIO can be triggered on most operations by: echo 2 >/proc/sys/cachefiles/error_injection Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/163819624706.215744.6911916249119962943.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/163906925343.143852.5465695512984025812.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/163967134412.1823006.7354285948280296595.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/164021532340.640689.18209494225772443698.stgit@warthog.procyon.org.uk/ # v4
Diffstat (limited to 'fs/cachefiles/main.c')
-rw-r--r--fs/cachefiles/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/cachefiles/main.c b/fs/cachefiles/main.c
index 47bc1cc078de..387d42c7185f 100644
--- a/fs/cachefiles/main.c
+++ b/fs/cachefiles/main.c
@@ -36,8 +36,18 @@ MODULE_LICENSE("GPL");
*/
static int __init cachefiles_init(void)
{
+ int ret;
+
+ ret = cachefiles_register_error_injection();
+ if (ret < 0)
+ goto error_einj;
+
pr_info("Loaded\n");
return 0;
+
+error_einj:
+ pr_err("failed to register: %d\n", ret);
+ return ret;
}
fs_initcall(cachefiles_init);
@@ -48,6 +58,8 @@ fs_initcall(cachefiles_init);
static void __exit cachefiles_exit(void)
{
pr_info("Unloading\n");
+
+ cachefiles_unregister_error_injection();
}
module_exit(cachefiles_exit);