From bb253625538824d8acae6ef62f5cdc7b1a525633 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 8 Jan 2018 16:15:23 -0800 Subject: [PATCH] Prevent zdb(8) from occasionally hanging on I/O The zdb(8) command may not terminate in the case where the pool gets suspended and there is a caller in zio_wait() blocking on an outstanding read I/O that will never complete. This can in turn cause ztest(1) to block indefinitely despite the deadman. Resolve the issue by setting the default failure mode for zdb(8) to panic. In user space we always want the command to terminate when forward progress is no longer possible. Reviewed-by: Tim Chase Reviewed by: Thomas Caputi Reviewed-by: Giuseppe Di Natale Signed-off-by: Brian Behlendorf Closes #6999 --- cmd/zdb/zdb.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 69001071d..1415be864 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -4542,6 +4542,8 @@ main(int argc, char **argv) } } else { error = open_objset(target, DMU_OST_ANY, FTAG, &os); + if (error == 0) + spa = dmu_objset_spa(os); } } nvlist_free(policy); @@ -4549,6 +4551,14 @@ main(int argc, char **argv) if (error) fatal("can't open '%s': %s", target, strerror(error)); + /* + * Set the pool failure mode to panic in order to prevent the pool + * from suspending. A suspended I/O will have no way to resume and + * can prevent the zdb(8) command from terminating as expected. + */ + if (spa != NULL) + spa->spa_failmode = ZIO_FAILURE_MODE_PANIC; + argv++; argc--; if (!dump_opt['R']) { -- 2.40.0