From 058a171b705174bb9ae6f3f008df608867d6f637 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Mon, 1 Feb 2010 09:38:25 -0800 Subject: [PATCH] SIGUSR1 causes nfsd to dump filesystem state now for debugging. --- nfs3/rpc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/nfs3/rpc.c b/nfs3/rpc.c index 2c640d7..a807022 100644 --- a/nfs3/rpc.c +++ b/nfs3/rpc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -518,8 +519,22 @@ static GMainLoop *main_loop; static GThreadPool *rpc_thread_pool; +static volatile int fs_dump_requested = 0; + +static void sig_handler(int sig) +{ + if (sig == SIGUSR1) { + fs_dump_requested = 1; + } +} + static gboolean async_flushd(gpointer data) { + if (fs_dump_requested) { + bluesky_debug_dump(fs); + fs_dump_requested = 0; + } + bluesky_flushd_invoke(fs); return TRUE; } @@ -541,6 +556,15 @@ static async_rpc_init() g_source_set_callback(source, async_flushd, NULL, NULL); g_source_attach(source, main_context); g_source_unref(source); + + /* Signal USR1 is used to request a debugging dump of filesyste info */ + struct sigaction sa; + sa.sa_handler = sig_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + if (sigaction(SIGUSR1, &sa, NULL) < 0) { + perror("sigaction"); + } } struct rpc_call_header { -- 2.20.1