mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 06:43:09 +00:00
a70f652626
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
66 lines
1.4 KiB
C
66 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/* Network filesystem caching backend to use cache files on a premounted
|
|
* filesystem
|
|
*
|
|
* Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/completion.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/file.h>
|
|
#include <linux/namei.h>
|
|
#include <linux/mount.h>
|
|
#include <linux/statfs.h>
|
|
#include <linux/sysctl.h>
|
|
#include <linux/miscdevice.h>
|
|
#include <linux/netfs.h>
|
|
#include <trace/events/netfs.h>
|
|
#define CREATE_TRACE_POINTS
|
|
#include "internal.h"
|
|
|
|
unsigned cachefiles_debug;
|
|
module_param_named(debug, cachefiles_debug, uint, S_IWUSR | S_IRUGO);
|
|
MODULE_PARM_DESC(cachefiles_debug, "CacheFiles debugging mask");
|
|
|
|
MODULE_DESCRIPTION("Mounted-filesystem based cache");
|
|
MODULE_AUTHOR("Red Hat, Inc.");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
/*
|
|
* initialise the fs caching module
|
|
*/
|
|
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);
|
|
|
|
/*
|
|
* clean up on module removal
|
|
*/
|
|
static void __exit cachefiles_exit(void)
|
|
{
|
|
pr_info("Unloading\n");
|
|
|
|
cachefiles_unregister_error_injection();
|
|
}
|
|
|
|
module_exit(cachefiles_exit);
|