From 82492e966c382e77d8862604d30ee063a51a6cc7 Mon Sep 17 00:00:00 2001 From: emaste Date: Sat, 23 Sep 2017 12:35:46 +0000 Subject: [PATCH] Revert r323935 as it broke the build subr_witness.c:2577:4: error: use of undeclared identifier 'req' req->oldidx = 0; ^ --- sys/kern/subr_witness.c | 61 +++++++++++------------------------------ 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index dffbb3afbae6..be3ca31df356 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -2539,18 +2539,31 @@ DB_SHOW_COMMAND(witness, db_witness_display) } #endif -static void -sbuf_print_witness_badstacks(struct sbuf *sb) +static int +sysctl_debug_witness_badstacks(SYSCTL_HANDLER_ARGS) { struct witness_lock_order_data *data1, *data2, *tmp_data1, *tmp_data2; struct witness *tmp_w1, *tmp_w2, *w1, *w2; + struct sbuf *sb; u_int w_rmatrix1, w_rmatrix2; - int generation, i, j; + int error, generation, i, j; tmp_data1 = NULL; tmp_data2 = NULL; tmp_w1 = NULL; tmp_w2 = NULL; + if (witness_watch < 1) { + error = SYSCTL_OUT(req, w_notrunning, sizeof(w_notrunning)); + return (error); + } + if (witness_cold) { + error = SYSCTL_OUT(req, w_stillcold, sizeof(w_stillcold)); + return (error); + } + error = 0; + sb = sbuf_new(NULL, NULL, badstack_sbuf_size, SBUF_AUTOEXTEND); + if (sb == NULL) + return (ENOMEM); /* Allocate and init temporary storage space. */ tmp_w1 = malloc(sizeof(struct witness), M_TEMP, M_WAITOK | M_ZERO); @@ -2670,28 +2683,6 @@ restart: free(tmp_data2, M_TEMP); free(tmp_w1, M_TEMP); free(tmp_w2, M_TEMP); -} - -static int -sysctl_debug_witness_badstacks(SYSCTL_HANDLER_ARGS) -{ - struct sbuf *sb; - int error; - - if (witness_watch < 1) { - error = SYSCTL_OUT(req, w_notrunning, sizeof(w_notrunning)); - return (error); - } - if (witness_cold) { - error = SYSCTL_OUT(req, w_stillcold, sizeof(w_stillcold)); - return (error); - } - error = 0; - sb = sbuf_new(NULL, NULL, badstack_sbuf_size, SBUF_AUTOEXTEND); - if (sb == NULL) - return (ENOMEM); - - sbuf_print_witness_badstacks(sb); sbuf_finish(sb); error = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1); @@ -2700,26 +2691,6 @@ sysctl_debug_witness_badstacks(SYSCTL_HANDLER_ARGS) return (error); } -#ifdef DDB -static int -sbuf_db_printf_drain(void *arg __unused, const char *data, int len) -{ - - return (db_printf("%.*s", len, data)); -} - -DB_SHOW_COMMAND(badstacks, db_witness_badstacks) -{ - struct sbuf sb; - char buffer[128]; - - sbuf_new(&sb, buffer, sizeof(buffer), SBUF_FIXEDLEN); - sbuf_set_drain(&sb, sbuf_db_printf_drain, NULL); - sbuf_print_witness_badstacks(&sb); - sbuf_finish(&sb); -} -#endif - static int sysctl_debug_witness_channel(SYSCTL_HANDLER_ARGS) {