]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Prevent zdb(8) from occasionally hanging on I/O
authorBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 9 Jan 2018 00:15:23 +0000 (16:15 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 25 Jan 2018 21:41:51 +0000 (13:41 -0800)
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

cmd/zdb/zdb.c

index 69001071dba9fe48a88650ec684c310a50ba3138..1415be8643ae467e410189f93a481523edd79167 100644 (file)
@@ -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']) {