Skip to content

Commit 37324e6

Browse files
committed
SUNRPC: Cache deferral injection
Cache deferral injection stress-tests the cache deferral logic as well as upper layer protocol deferred request handlers. This facility is for developers and professional testers to ensure coverage of the rqst deferral code paths. To date, we haven't had an adequate way to ensure these code paths are covered during testing, short of temporary code changes to force their use. A file called /sys/kernel/debug/fail_sunrpc/ignore-cache-wait enables administrators to disable cache deferral injection while allowing other types of sunrpc errors to be injected. The default setting is that cache deferral injection is enabled (ignore=false). To enable support for cache deferral injection, CONFIG_FAULT_INJECTION, CONFIG_FAULT_INJECTION_DEBUG_FS, and CONFIG_SUNRPC_DEBUG must all be set to "Y". Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 45cb795 commit 37324e6

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

net/sunrpc/cache.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
#include <linux/sunrpc/stats.h>
3434
#include <linux/sunrpc/rpc_pipe_fs.h>
3535
#include <trace/events/sunrpc.h>
36+
3637
#include "netns.h"
38+
#include "fail.h"
3739

3840
#define RPCDBG_FACILITY RPCDBG_CACHE
3941

@@ -688,16 +690,30 @@ static void cache_limit_defers(void)
688690
discard->revisit(discard, 1);
689691
}
690692

693+
#if IS_ENABLED(CONFIG_FAIL_SUNRPC)
694+
static inline bool cache_defer_immediately(void)
695+
{
696+
return !fail_sunrpc.ignore_cache_wait &&
697+
should_fail(&fail_sunrpc.attr, 1);
698+
}
699+
#else
700+
static inline bool cache_defer_immediately(void)
701+
{
702+
return false;
703+
}
704+
#endif
705+
691706
/* Return true if and only if a deferred request is queued. */
692707
static bool cache_defer_req(struct cache_req *req, struct cache_head *item)
693708
{
694709
struct cache_deferred_req *dreq;
695710

696-
if (req->thread_wait) {
711+
if (!cache_defer_immediately()) {
697712
cache_wait_req(req, item);
698713
if (!test_bit(CACHE_PENDING, &item->flags))
699714
return false;
700715
}
716+
701717
dreq = req->defer(req);
702718
if (dreq == NULL)
703719
return false;

net/sunrpc/debugfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ static void fail_sunrpc_init(void)
262262

263263
debugfs_create_bool("ignore-server-disconnect", S_IFREG | 0600, dir,
264264
&fail_sunrpc.ignore_server_disconnect);
265+
266+
debugfs_create_bool("ignore-cache-wait", S_IFREG | 0600, dir,
267+
&fail_sunrpc.ignore_cache_wait);
265268
}
266269
#else
267270
static void fail_sunrpc_init(void)

net/sunrpc/fail.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ struct fail_sunrpc_attr {
1414
struct fault_attr attr;
1515

1616
bool ignore_client_disconnect;
17-
1817
bool ignore_server_disconnect;
18+
bool ignore_cache_wait;
1919
};
2020

2121
extern struct fail_sunrpc_attr fail_sunrpc;

0 commit comments

Comments
 (0)