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 <tim@chase2k.com>
Reviewed by: Thomas Caputi <tcaputi@datto.com>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #6999
This commit is contained in:
Brian Behlendorf 2018-01-08 16:15:23 -08:00
parent 8fb1ede146
commit bb25362553

View File

@ -4542,6 +4542,8 @@ main(int argc, char **argv)
} }
} else { } else {
error = open_objset(target, DMU_OST_ANY, FTAG, &os); error = open_objset(target, DMU_OST_ANY, FTAG, &os);
if (error == 0)
spa = dmu_objset_spa(os);
} }
} }
nvlist_free(policy); nvlist_free(policy);
@ -4549,6 +4551,14 @@ main(int argc, char **argv)
if (error) if (error)
fatal("can't open '%s': %s", target, strerror(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++; argv++;
argc--; argc--;
if (!dump_opt['R']) { if (!dump_opt['R']) {