]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/dmu_traverse.c
Fix hung z_zvol tasks during 'zfs receive'
[mirror_zfs.git] / module / zfs / dmu_traverse.c
index a2566ced3211eac30eafa7ae5a3743b4a3950a20..f63903ef649dc82960c263b164484d0b170c9d28 100644 (file)
@@ -31,6 +31,7 @@
 #include <sys/dsl_pool.h>
 #include <sys/dnode.h>
 #include <sys/spa.h>
+#include <sys/spa_impl.h>
 #include <sys/zio.h>
 #include <sys/dmu_impl.h>
 #include <sys/sa.h>
@@ -599,24 +600,32 @@ traverse_impl(spa_t *spa, dsl_dataset_t *ds, uint64_t objset, blkptr_t *rootbp,
 
        /* See comment on ZIL traversal in dsl_scan_visitds. */
        if (ds != NULL && !ds->ds_is_snapshot && !BP_IS_HOLE(rootbp)) {
+               enum zio_flag zio_flags = ZIO_FLAG_CANFAIL;
                uint32_t flags = ARC_FLAG_WAIT;
                objset_phys_t *osp;
                arc_buf_t *buf;
 
-               err = arc_read(NULL, td->td_spa, rootbp,
-                   arc_getbuf_func, &buf,
-                   ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, czb);
-               if (err != 0)
-                       return (err);
-
-               osp = buf->b_data;
-               traverse_zil(td, &osp->os_zil_header);
-               arc_buf_destroy(buf, &buf);
+               err = arc_read(NULL, td->td_spa, rootbp, arc_getbuf_func,
+                   &buf, ZIO_PRIORITY_ASYNC_READ, zio_flags, &flags, czb);
+               if (err != 0) {
+                       /*
+                        * If both TRAVERSE_HARD and TRAVERSE_PRE are set,
+                        * continue to visitbp so that td_func can be called
+                        * in pre stage, and err will reset to zero.
+                        */
+                       if (!(td->td_flags & TRAVERSE_HARD) ||
+                           !(td->td_flags & TRAVERSE_PRE))
+                               return (err);
+               } else {
+                       osp = buf->b_data;
+                       traverse_zil(td, &osp->os_zil_header);
+                       arc_buf_destroy(buf, &buf);
+               }
        }
 
        if (!(flags & TRAVERSE_PREFETCH_DATA) ||
-           0 == taskq_dispatch(system_taskq, traverse_prefetch_thread,
-           td, TQ_NOQUEUE))
+           taskq_dispatch(spa->spa_prefetch_taskq, traverse_prefetch_thread,
+           td, TQ_NOQUEUE) == TASKQID_INVALID)
                pd->pd_exited = B_TRUE;
 
        err = traverse_visitbp(td, NULL, rootbp, czb);