4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012 by Delphix. All rights reserved.
26 #include <sys/dsl_scan.h>
27 #include <sys/dsl_pool.h>
28 #include <sys/dsl_dataset.h>
29 #include <sys/dsl_prop.h>
30 #include <sys/dsl_dir.h>
31 #include <sys/dsl_synctask.h>
32 #include <sys/dnode.h>
33 #include <sys/dmu_tx.h>
34 #include <sys/dmu_objset.h>
38 #include <sys/zfs_context.h>
39 #include <sys/fs/zfs.h>
40 #include <sys/zfs_znode.h>
41 #include <sys/spa_impl.h>
42 #include <sys/vdev_impl.h>
43 #include <sys/zil_impl.h>
44 #include <sys/zio_checksum.h>
47 #include <sys/sa_impl.h>
48 #include <sys/zfeature.h>
50 #include <sys/zfs_vfsops.h>
53 typedef int (scan_cb_t
)(dsl_pool_t
*, const blkptr_t
*, const zbookmark_t
*);
55 static scan_cb_t dsl_scan_scrub_cb
;
56 static dsl_syncfunc_t dsl_scan_cancel_sync
;
57 static void dsl_scan_sync_state(dsl_scan_t
*, dmu_tx_t
*tx
);
59 int zfs_top_maxinflight
= 32; /* maximum I/Os per top-level */
60 int zfs_resilver_delay
= 2; /* number of ticks to delay resilver */
61 int zfs_scrub_delay
= 4; /* number of ticks to delay scrub */
62 int zfs_scan_idle
= 50; /* idle window in clock ticks */
64 int zfs_scan_min_time_ms
= 1000; /* min millisecs to scrub per txg */
65 int zfs_free_min_time_ms
= 1000; /* min millisecs to free per txg */
66 int zfs_resilver_min_time_ms
= 3000; /* min millisecs to resilver per txg */
67 int zfs_no_scrub_io
= B_FALSE
; /* set to disable scrub i/o */
68 int zfs_no_scrub_prefetch
= B_FALSE
; /* set to disable srub prefetching */
69 enum ddt_class zfs_scrub_ddt_class_max
= DDT_CLASS_DUPLICATE
;
70 int dsl_scan_delay_completion
= B_FALSE
; /* set to delay scan completion */
72 #define DSL_SCAN_IS_SCRUB_RESILVER(scn) \
73 ((scn)->scn_phys.scn_func == POOL_SCAN_SCRUB || \
74 (scn)->scn_phys.scn_func == POOL_SCAN_RESILVER)
76 /* the order has to match pool_scan_type */
77 static scan_cb_t
*scan_funcs
[POOL_SCAN_FUNCS
] = {
79 dsl_scan_scrub_cb
, /* POOL_SCAN_SCRUB */
80 dsl_scan_scrub_cb
, /* POOL_SCAN_RESILVER */
84 dsl_scan_init(dsl_pool_t
*dp
, uint64_t txg
)
88 spa_t
*spa
= dp
->dp_spa
;
91 scn
= dp
->dp_scan
= kmem_zalloc(sizeof (dsl_scan_t
), KM_SLEEP
);
94 err
= zap_lookup(dp
->dp_meta_objset
, DMU_POOL_DIRECTORY_OBJECT
,
95 "scrub_func", sizeof (uint64_t), 1, &f
);
98 * There was an old-style scrub in progress. Restart a
99 * new-style scrub from the beginning.
101 scn
->scn_restart_txg
= txg
;
102 zfs_dbgmsg("old-style scrub was in progress; "
103 "restarting new-style scrub in txg %llu",
104 scn
->scn_restart_txg
);
107 * Load the queue obj from the old location so that it
108 * can be freed by dsl_scan_done().
110 (void) zap_lookup(dp
->dp_meta_objset
, DMU_POOL_DIRECTORY_OBJECT
,
111 "scrub_queue", sizeof (uint64_t), 1,
112 &scn
->scn_phys
.scn_queue_obj
);
114 err
= zap_lookup(dp
->dp_meta_objset
, DMU_POOL_DIRECTORY_OBJECT
,
115 DMU_POOL_SCAN
, sizeof (uint64_t), SCAN_PHYS_NUMINTS
,
122 if (scn
->scn_phys
.scn_state
== DSS_SCANNING
&&
123 spa_prev_software_version(dp
->dp_spa
) < SPA_VERSION_SCAN
) {
125 * A new-type scrub was in progress on an old
126 * pool, and the pool was accessed by old
127 * software. Restart from the beginning, since
128 * the old software may have changed the pool in
131 scn
->scn_restart_txg
= txg
;
132 zfs_dbgmsg("new-style scrub was modified "
133 "by old software; restarting in txg %llu",
134 scn
->scn_restart_txg
);
138 spa_scan_stat_init(spa
);
143 dsl_scan_fini(dsl_pool_t
*dp
)
146 kmem_free(dp
->dp_scan
, sizeof (dsl_scan_t
));
153 dsl_scan_setup_check(void *arg1
, void *arg2
, dmu_tx_t
*tx
)
155 dsl_scan_t
*scn
= arg1
;
157 if (scn
->scn_phys
.scn_state
== DSS_SCANNING
)
165 dsl_scan_setup_sync(void *arg1
, void *arg2
, dmu_tx_t
*tx
)
167 dsl_scan_t
*scn
= arg1
;
168 pool_scan_func_t
*funcp
= arg2
;
169 dmu_object_type_t ot
= 0;
170 dsl_pool_t
*dp
= scn
->scn_dp
;
171 spa_t
*spa
= dp
->dp_spa
;
173 ASSERT(scn
->scn_phys
.scn_state
!= DSS_SCANNING
);
174 ASSERT(*funcp
> POOL_SCAN_NONE
&& *funcp
< POOL_SCAN_FUNCS
);
175 bzero(&scn
->scn_phys
, sizeof (scn
->scn_phys
));
176 scn
->scn_phys
.scn_func
= *funcp
;
177 scn
->scn_phys
.scn_state
= DSS_SCANNING
;
178 scn
->scn_phys
.scn_min_txg
= 0;
179 scn
->scn_phys
.scn_max_txg
= tx
->tx_txg
;
180 scn
->scn_phys
.scn_ddt_class_max
= DDT_CLASSES
- 1; /* the entire DDT */
181 scn
->scn_phys
.scn_start_time
= gethrestime_sec();
182 scn
->scn_phys
.scn_errors
= 0;
183 scn
->scn_phys
.scn_to_examine
= spa
->spa_root_vdev
->vdev_stat
.vs_alloc
;
184 scn
->scn_restart_txg
= 0;
185 spa_scan_stat_init(spa
);
187 if (DSL_SCAN_IS_SCRUB_RESILVER(scn
)) {
188 scn
->scn_phys
.scn_ddt_class_max
= zfs_scrub_ddt_class_max
;
190 /* rewrite all disk labels */
191 vdev_config_dirty(spa
->spa_root_vdev
);
193 if (vdev_resilver_needed(spa
->spa_root_vdev
,
194 &scn
->scn_phys
.scn_min_txg
, &scn
->scn_phys
.scn_max_txg
)) {
195 spa_event_notify(spa
, NULL
, FM_EREPORT_ZFS_RESILVER_START
);
197 spa_event_notify(spa
, NULL
, FM_EREPORT_ZFS_SCRUB_START
);
200 spa
->spa_scrub_started
= B_TRUE
;
202 * If this is an incremental scrub, limit the DDT scrub phase
203 * to just the auto-ditto class (for correctness); the rest
204 * of the scrub should go faster using top-down pruning.
206 if (scn
->scn_phys
.scn_min_txg
> TXG_INITIAL
)
207 scn
->scn_phys
.scn_ddt_class_max
= DDT_CLASS_DITTO
;
211 /* back to the generic stuff */
213 if (dp
->dp_blkstats
== NULL
) {
214 dp
->dp_blkstats
= kmem_alloc(sizeof (zfs_all_blkstats_t
),
215 KM_PUSHPAGE
| KM_NODEBUG
);
217 bzero(dp
->dp_blkstats
, sizeof (zfs_all_blkstats_t
));
219 if (spa_version(spa
) < SPA_VERSION_DSL_SCRUB
)
220 ot
= DMU_OT_ZAP_OTHER
;
222 scn
->scn_phys
.scn_queue_obj
= zap_create(dp
->dp_meta_objset
,
223 ot
? ot
: DMU_OT_SCAN_QUEUE
, DMU_OT_NONE
, 0, tx
);
225 dsl_scan_sync_state(scn
, tx
);
227 spa_history_log_internal(spa
, "scan setup", tx
,
228 "func=%u mintxg=%llu maxtxg=%llu",
229 *funcp
, scn
->scn_phys
.scn_min_txg
, scn
->scn_phys
.scn_max_txg
);
234 dsl_scan_done(dsl_scan_t
*scn
, boolean_t complete
, dmu_tx_t
*tx
)
236 static const char *old_names
[] = {
238 "scrub_ddt_bookmark",
239 "scrub_ddt_class_max",
248 dsl_pool_t
*dp
= scn
->scn_dp
;
249 spa_t
*spa
= dp
->dp_spa
;
252 /* Remove any remnants of an old-style scrub. */
253 for (i
= 0; old_names
[i
]; i
++) {
254 (void) zap_remove(dp
->dp_meta_objset
,
255 DMU_POOL_DIRECTORY_OBJECT
, old_names
[i
], tx
);
258 if (scn
->scn_phys
.scn_queue_obj
!= 0) {
259 VERIFY(0 == dmu_object_free(dp
->dp_meta_objset
,
260 scn
->scn_phys
.scn_queue_obj
, tx
));
261 scn
->scn_phys
.scn_queue_obj
= 0;
265 * If we were "restarted" from a stopped state, don't bother
266 * with anything else.
268 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
272 scn
->scn_phys
.scn_state
= DSS_FINISHED
;
274 scn
->scn_phys
.scn_state
= DSS_CANCELED
;
276 spa_history_log_internal(spa
, "scan done", tx
,
277 "complete=%u", complete
);
279 if (DSL_SCAN_IS_SCRUB_RESILVER(scn
)) {
280 mutex_enter(&spa
->spa_scrub_lock
);
281 while (spa
->spa_scrub_inflight
> 0) {
282 cv_wait(&spa
->spa_scrub_io_cv
,
283 &spa
->spa_scrub_lock
);
285 mutex_exit(&spa
->spa_scrub_lock
);
286 spa
->spa_scrub_started
= B_FALSE
;
287 spa
->spa_scrub_active
= B_FALSE
;
290 * If the scrub/resilver completed, update all DTLs to
291 * reflect this. Whether it succeeded or not, vacate
292 * all temporary scrub DTLs.
294 vdev_dtl_reassess(spa
->spa_root_vdev
, tx
->tx_txg
,
295 complete
? scn
->scn_phys
.scn_max_txg
: 0, B_TRUE
);
297 spa_event_notify(spa
, NULL
, scn
->scn_phys
.scn_min_txg
?
298 FM_EREPORT_ZFS_RESILVER_FINISH
:
299 FM_EREPORT_ZFS_SCRUB_FINISH
);
301 spa_errlog_rotate(spa
);
304 * We may have finished replacing a device.
305 * Let the async thread assess this and handle the detach.
307 spa_async_request(spa
, SPA_ASYNC_RESILVER_DONE
);
310 scn
->scn_phys
.scn_end_time
= gethrestime_sec();
315 dsl_scan_cancel_check(void *arg1
, void *arg2
, dmu_tx_t
*tx
)
317 dsl_scan_t
*scn
= arg1
;
319 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
326 dsl_scan_cancel_sync(void *arg1
, void *arg2
, dmu_tx_t
*tx
)
328 dsl_scan_t
*scn
= arg1
;
330 dsl_scan_done(scn
, B_FALSE
, tx
);
331 dsl_scan_sync_state(scn
, tx
);
335 dsl_scan_cancel(dsl_pool_t
*dp
)
337 boolean_t complete
= B_FALSE
;
340 err
= dsl_sync_task_do(dp
, dsl_scan_cancel_check
,
341 dsl_scan_cancel_sync
, dp
->dp_scan
, &complete
, 3);
345 static void dsl_scan_visitbp(blkptr_t
*bp
,
346 const zbookmark_t
*zb
, dnode_phys_t
*dnp
, arc_buf_t
*pbuf
,
347 dsl_dataset_t
*ds
, dsl_scan_t
*scn
, dmu_objset_type_t ostype
,
349 inline __attribute__((always_inline
)) static void dsl_scan_visitdnode(
350 dsl_scan_t
*, dsl_dataset_t
*ds
, dmu_objset_type_t ostype
,
351 dnode_phys_t
*dnp
, arc_buf_t
*buf
, uint64_t object
, dmu_tx_t
*tx
);
354 dsl_free(dsl_pool_t
*dp
, uint64_t txg
, const blkptr_t
*bp
)
356 zio_free(dp
->dp_spa
, txg
, bp
);
360 dsl_free_sync(zio_t
*pio
, dsl_pool_t
*dp
, uint64_t txg
, const blkptr_t
*bpp
)
362 ASSERT(dsl_pool_sync_context(dp
));
363 zio_nowait(zio_free_sync(pio
, dp
->dp_spa
, txg
, bpp
, pio
->io_flags
));
367 dsl_scan_ds_maxtxg(dsl_dataset_t
*ds
)
369 uint64_t smt
= ds
->ds_dir
->dd_pool
->dp_scan
->scn_phys
.scn_max_txg
;
370 if (dsl_dataset_is_snapshot(ds
))
371 return (MIN(smt
, ds
->ds_phys
->ds_creation_txg
));
376 dsl_scan_sync_state(dsl_scan_t
*scn
, dmu_tx_t
*tx
)
378 VERIFY(0 == zap_update(scn
->scn_dp
->dp_meta_objset
,
379 DMU_POOL_DIRECTORY_OBJECT
,
380 DMU_POOL_SCAN
, sizeof (uint64_t), SCAN_PHYS_NUMINTS
,
381 &scn
->scn_phys
, tx
));
385 dsl_scan_check_pause(dsl_scan_t
*scn
, const zbookmark_t
*zb
)
387 uint64_t elapsed_nanosecs
;
390 /* we never skip user/group accounting objects */
391 if (zb
&& (int64_t)zb
->zb_object
< 0)
394 if (scn
->scn_pausing
)
395 return (B_TRUE
); /* we're already pausing */
397 if (!ZB_IS_ZERO(&scn
->scn_phys
.scn_bookmark
))
398 return (B_FALSE
); /* we're resuming */
400 /* We only know how to resume from level-0 blocks. */
401 if (zb
&& zb
->zb_level
!= 0)
404 mintime
= (scn
->scn_phys
.scn_func
== POOL_SCAN_RESILVER
) ?
405 zfs_resilver_min_time_ms
: zfs_scan_min_time_ms
;
406 elapsed_nanosecs
= gethrtime() - scn
->scn_sync_start_time
;
407 if (elapsed_nanosecs
/ NANOSEC
> zfs_txg_timeout
||
408 (elapsed_nanosecs
/ MICROSEC
> mintime
&&
409 txg_sync_waiting(scn
->scn_dp
)) ||
410 spa_shutting_down(scn
->scn_dp
->dp_spa
)) {
412 dprintf("pausing at bookmark %llx/%llx/%llx/%llx\n",
413 (longlong_t
)zb
->zb_objset
,
414 (longlong_t
)zb
->zb_object
,
415 (longlong_t
)zb
->zb_level
,
416 (longlong_t
)zb
->zb_blkid
);
417 scn
->scn_phys
.scn_bookmark
= *zb
;
419 dprintf("pausing at DDT bookmark %llx/%llx/%llx/%llx\n",
420 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_class
,
421 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_type
,
422 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_checksum
,
423 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_cursor
);
424 scn
->scn_pausing
= B_TRUE
;
430 typedef struct zil_scan_arg
{
432 zil_header_t
*zsa_zh
;
437 dsl_scan_zil_block(zilog_t
*zilog
, blkptr_t
*bp
, void *arg
, uint64_t claim_txg
)
439 zil_scan_arg_t
*zsa
= arg
;
440 dsl_pool_t
*dp
= zsa
->zsa_dp
;
441 dsl_scan_t
*scn
= dp
->dp_scan
;
442 zil_header_t
*zh
= zsa
->zsa_zh
;
445 if (bp
->blk_birth
<= scn
->scn_phys
.scn_cur_min_txg
)
449 * One block ("stubby") can be allocated a long time ago; we
450 * want to visit that one because it has been allocated
451 * (on-disk) even if it hasn't been claimed (even though for
452 * scrub there's nothing to do to it).
454 if (claim_txg
== 0 && bp
->blk_birth
>= spa_first_txg(dp
->dp_spa
))
457 SET_BOOKMARK(&zb
, zh
->zh_log
.blk_cksum
.zc_word
[ZIL_ZC_OBJSET
],
458 ZB_ZIL_OBJECT
, ZB_ZIL_LEVEL
, bp
->blk_cksum
.zc_word
[ZIL_ZC_SEQ
]);
460 VERIFY(0 == scan_funcs
[scn
->scn_phys
.scn_func
](dp
, bp
, &zb
));
466 dsl_scan_zil_record(zilog_t
*zilog
, lr_t
*lrc
, void *arg
, uint64_t claim_txg
)
468 if (lrc
->lrc_txtype
== TX_WRITE
) {
469 zil_scan_arg_t
*zsa
= arg
;
470 dsl_pool_t
*dp
= zsa
->zsa_dp
;
471 dsl_scan_t
*scn
= dp
->dp_scan
;
472 zil_header_t
*zh
= zsa
->zsa_zh
;
473 lr_write_t
*lr
= (lr_write_t
*)lrc
;
474 blkptr_t
*bp
= &lr
->lr_blkptr
;
477 if (bp
->blk_birth
<= scn
->scn_phys
.scn_cur_min_txg
)
481 * birth can be < claim_txg if this record's txg is
482 * already txg sync'ed (but this log block contains
483 * other records that are not synced)
485 if (claim_txg
== 0 || bp
->blk_birth
< claim_txg
)
488 SET_BOOKMARK(&zb
, zh
->zh_log
.blk_cksum
.zc_word
[ZIL_ZC_OBJSET
],
489 lr
->lr_foid
, ZB_ZIL_LEVEL
,
490 lr
->lr_offset
/ BP_GET_LSIZE(bp
));
492 VERIFY(0 == scan_funcs
[scn
->scn_phys
.scn_func
](dp
, bp
, &zb
));
498 dsl_scan_zil(dsl_pool_t
*dp
, zil_header_t
*zh
)
500 uint64_t claim_txg
= zh
->zh_claim_txg
;
501 zil_scan_arg_t zsa
= { dp
, zh
};
505 * We only want to visit blocks that have been claimed but not yet
506 * replayed (or, in read-only mode, blocks that *would* be claimed).
508 if (claim_txg
== 0 && spa_writeable(dp
->dp_spa
))
511 zilog
= zil_alloc(dp
->dp_meta_objset
, zh
);
513 (void) zil_parse(zilog
, dsl_scan_zil_block
, dsl_scan_zil_record
, &zsa
,
521 dsl_scan_prefetch(dsl_scan_t
*scn
, arc_buf_t
*buf
, blkptr_t
*bp
,
522 uint64_t objset
, uint64_t object
, uint64_t blkid
)
525 uint32_t flags
= ARC_NOWAIT
| ARC_PREFETCH
;
527 if (zfs_no_scrub_prefetch
)
530 if (BP_IS_HOLE(bp
) || bp
->blk_birth
<= scn
->scn_phys
.scn_min_txg
||
531 (BP_GET_LEVEL(bp
) == 0 && BP_GET_TYPE(bp
) != DMU_OT_DNODE
))
534 SET_BOOKMARK(&czb
, objset
, object
, BP_GET_LEVEL(bp
), blkid
);
536 (void) arc_read(scn
->scn_zio_root
, scn
->scn_dp
->dp_spa
, bp
,
537 NULL
, NULL
, ZIO_PRIORITY_ASYNC_READ
,
538 ZIO_FLAG_CANFAIL
| ZIO_FLAG_SCAN_THREAD
, &flags
, &czb
);
542 dsl_scan_check_resume(dsl_scan_t
*scn
, const dnode_phys_t
*dnp
,
543 const zbookmark_t
*zb
)
546 * We never skip over user/group accounting objects (obj<0)
548 if (!ZB_IS_ZERO(&scn
->scn_phys
.scn_bookmark
) &&
549 (int64_t)zb
->zb_object
>= 0) {
551 * If we already visited this bp & everything below (in
552 * a prior txg sync), don't bother doing it again.
554 if (zbookmark_is_before(dnp
, zb
, &scn
->scn_phys
.scn_bookmark
))
558 * If we found the block we're trying to resume from, or
559 * we went past it to a different object, zero it out to
560 * indicate that it's OK to start checking for pausing
563 if (bcmp(zb
, &scn
->scn_phys
.scn_bookmark
, sizeof (*zb
)) == 0 ||
564 zb
->zb_object
> scn
->scn_phys
.scn_bookmark
.zb_object
) {
565 dprintf("resuming at %llx/%llx/%llx/%llx\n",
566 (longlong_t
)zb
->zb_objset
,
567 (longlong_t
)zb
->zb_object
,
568 (longlong_t
)zb
->zb_level
,
569 (longlong_t
)zb
->zb_blkid
);
570 bzero(&scn
->scn_phys
.scn_bookmark
, sizeof (*zb
));
577 * Return nonzero on i/o error.
578 * Return new buf to write out in *bufp.
580 inline __attribute__((always_inline
)) static int
581 dsl_scan_recurse(dsl_scan_t
*scn
, dsl_dataset_t
*ds
, dmu_objset_type_t ostype
,
582 dnode_phys_t
*dnp
, const blkptr_t
*bp
,
583 const zbookmark_t
*zb
, dmu_tx_t
*tx
, arc_buf_t
**bufp
)
585 dsl_pool_t
*dp
= scn
->scn_dp
;
586 int zio_flags
= ZIO_FLAG_CANFAIL
| ZIO_FLAG_SCAN_THREAD
;
589 if (BP_GET_LEVEL(bp
) > 0) {
590 uint32_t flags
= ARC_WAIT
;
593 int epb
= BP_GET_LSIZE(bp
) >> SPA_BLKPTRSHIFT
;
595 err
= arc_read(NULL
, dp
->dp_spa
, bp
, arc_getbuf_func
, bufp
,
596 ZIO_PRIORITY_ASYNC_READ
, zio_flags
, &flags
, zb
);
598 scn
->scn_phys
.scn_errors
++;
601 for (i
= 0, cbp
= (*bufp
)->b_data
; i
< epb
; i
++, cbp
++) {
602 dsl_scan_prefetch(scn
, *bufp
, cbp
, zb
->zb_objset
,
603 zb
->zb_object
, zb
->zb_blkid
* epb
+ i
);
605 for (i
= 0, cbp
= (*bufp
)->b_data
; i
< epb
; i
++, cbp
++) {
608 SET_BOOKMARK(&czb
, zb
->zb_objset
, zb
->zb_object
,
610 zb
->zb_blkid
* epb
+ i
);
611 dsl_scan_visitbp(cbp
, &czb
, dnp
,
612 *bufp
, ds
, scn
, ostype
, tx
);
614 } else if (BP_GET_TYPE(bp
) == DMU_OT_USERGROUP_USED
) {
615 uint32_t flags
= ARC_WAIT
;
617 err
= arc_read(NULL
, dp
->dp_spa
, bp
, arc_getbuf_func
, bufp
,
618 ZIO_PRIORITY_ASYNC_READ
, zio_flags
, &flags
, zb
);
620 scn
->scn_phys
.scn_errors
++;
623 } else if (BP_GET_TYPE(bp
) == DMU_OT_DNODE
) {
624 uint32_t flags
= ARC_WAIT
;
627 int epb
= BP_GET_LSIZE(bp
) >> DNODE_SHIFT
;
629 err
= arc_read(NULL
, dp
->dp_spa
, bp
, arc_getbuf_func
, bufp
,
630 ZIO_PRIORITY_ASYNC_READ
, zio_flags
, &flags
, zb
);
632 scn
->scn_phys
.scn_errors
++;
635 for (i
= 0, cdnp
= (*bufp
)->b_data
; i
< epb
; i
++, cdnp
++) {
636 for (j
= 0; j
< cdnp
->dn_nblkptr
; j
++) {
637 blkptr_t
*cbp
= &cdnp
->dn_blkptr
[j
];
638 dsl_scan_prefetch(scn
, *bufp
, cbp
,
639 zb
->zb_objset
, zb
->zb_blkid
* epb
+ i
, j
);
642 for (i
= 0, cdnp
= (*bufp
)->b_data
; i
< epb
; i
++, cdnp
++) {
643 dsl_scan_visitdnode(scn
, ds
, ostype
,
644 cdnp
, *bufp
, zb
->zb_blkid
* epb
+ i
, tx
);
647 } else if (BP_GET_TYPE(bp
) == DMU_OT_OBJSET
) {
648 uint32_t flags
= ARC_WAIT
;
651 err
= arc_read(NULL
, dp
->dp_spa
, bp
, arc_getbuf_func
, bufp
,
652 ZIO_PRIORITY_ASYNC_READ
, zio_flags
, &flags
, zb
);
654 scn
->scn_phys
.scn_errors
++;
658 osp
= (*bufp
)->b_data
;
660 dsl_scan_visitdnode(scn
, ds
, osp
->os_type
,
661 &osp
->os_meta_dnode
, *bufp
, DMU_META_DNODE_OBJECT
, tx
);
663 if (OBJSET_BUF_HAS_USERUSED(*bufp
)) {
665 * We also always visit user/group accounting
666 * objects, and never skip them, even if we are
667 * pausing. This is necessary so that the space
668 * deltas from this txg get integrated.
670 dsl_scan_visitdnode(scn
, ds
, osp
->os_type
,
671 &osp
->os_groupused_dnode
, *bufp
,
672 DMU_GROUPUSED_OBJECT
, tx
);
673 dsl_scan_visitdnode(scn
, ds
, osp
->os_type
,
674 &osp
->os_userused_dnode
, *bufp
,
675 DMU_USERUSED_OBJECT
, tx
);
682 inline __attribute__((always_inline
)) static void
683 dsl_scan_visitdnode(dsl_scan_t
*scn
, dsl_dataset_t
*ds
,
684 dmu_objset_type_t ostype
, dnode_phys_t
*dnp
, arc_buf_t
*buf
,
685 uint64_t object
, dmu_tx_t
*tx
)
689 for (j
= 0; j
< dnp
->dn_nblkptr
; j
++) {
692 SET_BOOKMARK(&czb
, ds
? ds
->ds_object
: 0, object
,
693 dnp
->dn_nlevels
- 1, j
);
694 dsl_scan_visitbp(&dnp
->dn_blkptr
[j
],
695 &czb
, dnp
, buf
, ds
, scn
, ostype
, tx
);
698 if (dnp
->dn_flags
& DNODE_FLAG_SPILL_BLKPTR
) {
700 SET_BOOKMARK(&czb
, ds
? ds
->ds_object
: 0, object
,
702 dsl_scan_visitbp(&dnp
->dn_spill
,
703 &czb
, dnp
, buf
, ds
, scn
, ostype
, tx
);
708 * The arguments are in this order because mdb can only print the
709 * first 5; we want them to be useful.
712 dsl_scan_visitbp(blkptr_t
*bp
, const zbookmark_t
*zb
,
713 dnode_phys_t
*dnp
, arc_buf_t
*pbuf
,
714 dsl_dataset_t
*ds
, dsl_scan_t
*scn
, dmu_objset_type_t ostype
,
717 dsl_pool_t
*dp
= scn
->scn_dp
;
718 arc_buf_t
*buf
= NULL
;
721 bp_toread
= kmem_alloc(sizeof (blkptr_t
), KM_PUSHPAGE
);
724 /* ASSERT(pbuf == NULL || arc_released(pbuf)); */
726 if (dsl_scan_check_pause(scn
, zb
))
729 if (dsl_scan_check_resume(scn
, dnp
, zb
))
732 if (bp
->blk_birth
== 0)
735 scn
->scn_visited_this_txg
++;
738 * This debugging is commented out to conserve stack space. This
739 * function is called recursively and the debugging addes several
740 * bytes to the stack for each call. It can be commented back in
741 * if required to debug an issue in dsl_scan_visitbp().
744 * "visiting ds=%p/%llu zb=%llx/%llx/%llx/%llx buf=%p bp=%p",
745 * ds, ds ? ds->ds_object : 0,
746 * zb->zb_objset, zb->zb_object, zb->zb_level, zb->zb_blkid,
750 if (bp
->blk_birth
<= scn
->scn_phys
.scn_cur_min_txg
)
753 if (dsl_scan_recurse(scn
, ds
, ostype
, dnp
, bp_toread
, zb
, tx
,
758 * If dsl_scan_ddt() has aready visited this block, it will have
759 * already done any translations or scrubbing, so don't call the
762 if (ddt_class_contains(dp
->dp_spa
,
763 scn
->scn_phys
.scn_ddt_class_max
, bp
)) {
769 * If this block is from the future (after cur_max_txg), then we
770 * are doing this on behalf of a deleted snapshot, and we will
771 * revisit the future block on the next pass of this dataset.
772 * Don't scan it now unless we need to because something
773 * under it was modified.
775 if (bp
->blk_birth
<= scn
->scn_phys
.scn_cur_max_txg
) {
776 scan_funcs
[scn
->scn_phys
.scn_func
](dp
, bp
, zb
);
779 (void) arc_buf_remove_ref(buf
, &buf
);
781 kmem_free(bp_toread
, sizeof(blkptr_t
));
785 dsl_scan_visit_rootbp(dsl_scan_t
*scn
, dsl_dataset_t
*ds
, blkptr_t
*bp
,
790 SET_BOOKMARK(&zb
, ds
? ds
->ds_object
: DMU_META_OBJSET
,
791 ZB_ROOT_OBJECT
, ZB_ROOT_LEVEL
, ZB_ROOT_BLKID
);
792 dsl_scan_visitbp(bp
, &zb
, NULL
, NULL
,
793 ds
, scn
, DMU_OST_NONE
, tx
);
795 dprintf_ds(ds
, "finished scan%s", "");
799 dsl_scan_ds_destroyed(dsl_dataset_t
*ds
, dmu_tx_t
*tx
)
801 dsl_pool_t
*dp
= ds
->ds_dir
->dd_pool
;
802 dsl_scan_t
*scn
= dp
->dp_scan
;
805 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
808 if (scn
->scn_phys
.scn_bookmark
.zb_objset
== ds
->ds_object
) {
809 if (dsl_dataset_is_snapshot(ds
)) {
810 /* Note, scn_cur_{min,max}_txg stays the same. */
811 scn
->scn_phys
.scn_bookmark
.zb_objset
=
812 ds
->ds_phys
->ds_next_snap_obj
;
813 zfs_dbgmsg("destroying ds %llu; currently traversing; "
814 "reset zb_objset to %llu",
815 (u_longlong_t
)ds
->ds_object
,
816 (u_longlong_t
)ds
->ds_phys
->ds_next_snap_obj
);
817 scn
->scn_phys
.scn_flags
|= DSF_VISIT_DS_AGAIN
;
819 SET_BOOKMARK(&scn
->scn_phys
.scn_bookmark
,
820 ZB_DESTROYED_OBJSET
, 0, 0, 0);
821 zfs_dbgmsg("destroying ds %llu; currently traversing; "
822 "reset bookmark to -1,0,0,0",
823 (u_longlong_t
)ds
->ds_object
);
825 } else if (zap_lookup_int_key(dp
->dp_meta_objset
,
826 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
, &mintxg
) == 0) {
827 ASSERT3U(ds
->ds_phys
->ds_num_children
, <=, 1);
828 VERIFY3U(0, ==, zap_remove_int(dp
->dp_meta_objset
,
829 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
, tx
));
830 if (dsl_dataset_is_snapshot(ds
)) {
832 * We keep the same mintxg; it could be >
833 * ds_creation_txg if the previous snapshot was
836 VERIFY(zap_add_int_key(dp
->dp_meta_objset
,
837 scn
->scn_phys
.scn_queue_obj
,
838 ds
->ds_phys
->ds_next_snap_obj
, mintxg
, tx
) == 0);
839 zfs_dbgmsg("destroying ds %llu; in queue; "
840 "replacing with %llu",
841 (u_longlong_t
)ds
->ds_object
,
842 (u_longlong_t
)ds
->ds_phys
->ds_next_snap_obj
);
844 zfs_dbgmsg("destroying ds %llu; in queue; removing",
845 (u_longlong_t
)ds
->ds_object
);
848 zfs_dbgmsg("destroying ds %llu; ignoring",
849 (u_longlong_t
)ds
->ds_object
);
853 * dsl_scan_sync() should be called after this, and should sync
854 * out our changed state, but just to be safe, do it here.
856 dsl_scan_sync_state(scn
, tx
);
860 dsl_scan_ds_snapshotted(dsl_dataset_t
*ds
, dmu_tx_t
*tx
)
862 dsl_pool_t
*dp
= ds
->ds_dir
->dd_pool
;
863 dsl_scan_t
*scn
= dp
->dp_scan
;
866 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
869 ASSERT(ds
->ds_phys
->ds_prev_snap_obj
!= 0);
871 if (scn
->scn_phys
.scn_bookmark
.zb_objset
== ds
->ds_object
) {
872 scn
->scn_phys
.scn_bookmark
.zb_objset
=
873 ds
->ds_phys
->ds_prev_snap_obj
;
874 zfs_dbgmsg("snapshotting ds %llu; currently traversing; "
875 "reset zb_objset to %llu",
876 (u_longlong_t
)ds
->ds_object
,
877 (u_longlong_t
)ds
->ds_phys
->ds_prev_snap_obj
);
878 } else if (zap_lookup_int_key(dp
->dp_meta_objset
,
879 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
, &mintxg
) == 0) {
880 VERIFY3U(0, ==, zap_remove_int(dp
->dp_meta_objset
,
881 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
, tx
));
882 VERIFY(zap_add_int_key(dp
->dp_meta_objset
,
883 scn
->scn_phys
.scn_queue_obj
,
884 ds
->ds_phys
->ds_prev_snap_obj
, mintxg
, tx
) == 0);
885 zfs_dbgmsg("snapshotting ds %llu; in queue; "
886 "replacing with %llu",
887 (u_longlong_t
)ds
->ds_object
,
888 (u_longlong_t
)ds
->ds_phys
->ds_prev_snap_obj
);
890 dsl_scan_sync_state(scn
, tx
);
894 dsl_scan_ds_clone_swapped(dsl_dataset_t
*ds1
, dsl_dataset_t
*ds2
, dmu_tx_t
*tx
)
896 dsl_pool_t
*dp
= ds1
->ds_dir
->dd_pool
;
897 dsl_scan_t
*scn
= dp
->dp_scan
;
900 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
903 if (scn
->scn_phys
.scn_bookmark
.zb_objset
== ds1
->ds_object
) {
904 scn
->scn_phys
.scn_bookmark
.zb_objset
= ds2
->ds_object
;
905 zfs_dbgmsg("clone_swap ds %llu; currently traversing; "
906 "reset zb_objset to %llu",
907 (u_longlong_t
)ds1
->ds_object
,
908 (u_longlong_t
)ds2
->ds_object
);
909 } else if (scn
->scn_phys
.scn_bookmark
.zb_objset
== ds2
->ds_object
) {
910 scn
->scn_phys
.scn_bookmark
.zb_objset
= ds1
->ds_object
;
911 zfs_dbgmsg("clone_swap ds %llu; currently traversing; "
912 "reset zb_objset to %llu",
913 (u_longlong_t
)ds2
->ds_object
,
914 (u_longlong_t
)ds1
->ds_object
);
917 if (zap_lookup_int_key(dp
->dp_meta_objset
, scn
->scn_phys
.scn_queue_obj
,
918 ds1
->ds_object
, &mintxg
) == 0) {
921 ASSERT3U(mintxg
, ==, ds1
->ds_phys
->ds_prev_snap_txg
);
922 ASSERT3U(mintxg
, ==, ds2
->ds_phys
->ds_prev_snap_txg
);
923 VERIFY3U(0, ==, zap_remove_int(dp
->dp_meta_objset
,
924 scn
->scn_phys
.scn_queue_obj
, ds1
->ds_object
, tx
));
925 err
= zap_add_int_key(dp
->dp_meta_objset
,
926 scn
->scn_phys
.scn_queue_obj
, ds2
->ds_object
, mintxg
, tx
);
927 VERIFY(err
== 0 || err
== EEXIST
);
929 /* Both were there to begin with */
930 VERIFY(0 == zap_add_int_key(dp
->dp_meta_objset
,
931 scn
->scn_phys
.scn_queue_obj
,
932 ds1
->ds_object
, mintxg
, tx
));
934 zfs_dbgmsg("clone_swap ds %llu; in queue; "
935 "replacing with %llu",
936 (u_longlong_t
)ds1
->ds_object
,
937 (u_longlong_t
)ds2
->ds_object
);
938 } else if (zap_lookup_int_key(dp
->dp_meta_objset
,
939 scn
->scn_phys
.scn_queue_obj
, ds2
->ds_object
, &mintxg
) == 0) {
940 ASSERT3U(mintxg
, ==, ds1
->ds_phys
->ds_prev_snap_txg
);
941 ASSERT3U(mintxg
, ==, ds2
->ds_phys
->ds_prev_snap_txg
);
942 VERIFY3U(0, ==, zap_remove_int(dp
->dp_meta_objset
,
943 scn
->scn_phys
.scn_queue_obj
, ds2
->ds_object
, tx
));
944 VERIFY(0 == zap_add_int_key(dp
->dp_meta_objset
,
945 scn
->scn_phys
.scn_queue_obj
, ds1
->ds_object
, mintxg
, tx
));
946 zfs_dbgmsg("clone_swap ds %llu; in queue; "
947 "replacing with %llu",
948 (u_longlong_t
)ds2
->ds_object
,
949 (u_longlong_t
)ds1
->ds_object
);
952 dsl_scan_sync_state(scn
, tx
);
955 struct enqueue_clones_arg
{
962 enqueue_clones_cb(spa_t
*spa
, uint64_t dsobj
, const char *dsname
, void *arg
)
964 struct enqueue_clones_arg
*eca
= arg
;
967 dsl_pool_t
*dp
= spa
->spa_dsl_pool
;
968 dsl_scan_t
*scn
= dp
->dp_scan
;
970 err
= dsl_dataset_hold_obj(dp
, dsobj
, FTAG
, &ds
);
974 if (ds
->ds_dir
->dd_phys
->dd_origin_obj
== eca
->originobj
) {
975 while (ds
->ds_phys
->ds_prev_snap_obj
!= eca
->originobj
) {
977 err
= dsl_dataset_hold_obj(dp
,
978 ds
->ds_phys
->ds_prev_snap_obj
, FTAG
, &prev
);
980 dsl_dataset_rele(ds
, FTAG
);
985 VERIFY(zap_add_int_key(dp
->dp_meta_objset
,
986 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
,
987 ds
->ds_phys
->ds_prev_snap_txg
, eca
->tx
) == 0);
989 dsl_dataset_rele(ds
, FTAG
);
994 dsl_scan_visitds(dsl_scan_t
*scn
, uint64_t dsobj
, dmu_tx_t
*tx
)
996 dsl_pool_t
*dp
= scn
->scn_dp
;
1001 VERIFY3U(0, ==, dsl_dataset_hold_obj(dp
, dsobj
, FTAG
, &ds
));
1003 if (dmu_objset_from_ds(ds
, &os
))
1007 * Only the ZIL in the head (non-snapshot) is valid. Even though
1008 * snapshots can have ZIL block pointers (which may be the same
1009 * BP as in the head), they must be ignored. So we traverse the
1010 * ZIL here, rather than in scan_recurse(), because the regular
1011 * snapshot block-sharing rules don't apply to it.
1013 if (DSL_SCAN_IS_SCRUB_RESILVER(scn
) && !dsl_dataset_is_snapshot(ds
))
1014 dsl_scan_zil(dp
, &os
->os_zil_header
);
1017 * Iterate over the bps in this ds.
1019 dmu_buf_will_dirty(ds
->ds_dbuf
, tx
);
1020 dsl_scan_visit_rootbp(scn
, ds
, &ds
->ds_phys
->ds_bp
, tx
);
1022 dsname
= kmem_alloc(ZFS_MAXNAMELEN
, KM_PUSHPAGE
);
1023 dsl_dataset_name(ds
, dsname
);
1024 zfs_dbgmsg("scanned dataset %llu (%s) with min=%llu max=%llu; "
1026 (longlong_t
)dsobj
, dsname
,
1027 (longlong_t
)scn
->scn_phys
.scn_cur_min_txg
,
1028 (longlong_t
)scn
->scn_phys
.scn_cur_max_txg
,
1029 (int)scn
->scn_pausing
);
1030 kmem_free(dsname
, ZFS_MAXNAMELEN
);
1032 if (scn
->scn_pausing
)
1036 * We've finished this pass over this dataset.
1040 * If we did not completely visit this dataset, do another pass.
1042 if (scn
->scn_phys
.scn_flags
& DSF_VISIT_DS_AGAIN
) {
1043 zfs_dbgmsg("incomplete pass; visiting again");
1044 scn
->scn_phys
.scn_flags
&= ~DSF_VISIT_DS_AGAIN
;
1045 VERIFY(zap_add_int_key(dp
->dp_meta_objset
,
1046 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
,
1047 scn
->scn_phys
.scn_cur_max_txg
, tx
) == 0);
1052 * Add descendent datasets to work queue.
1054 if (ds
->ds_phys
->ds_next_snap_obj
!= 0) {
1055 VERIFY(zap_add_int_key(dp
->dp_meta_objset
,
1056 scn
->scn_phys
.scn_queue_obj
, ds
->ds_phys
->ds_next_snap_obj
,
1057 ds
->ds_phys
->ds_creation_txg
, tx
) == 0);
1059 if (ds
->ds_phys
->ds_num_children
> 1) {
1060 boolean_t usenext
= B_FALSE
;
1061 if (ds
->ds_phys
->ds_next_clones_obj
!= 0) {
1064 * A bug in a previous version of the code could
1065 * cause upgrade_clones_cb() to not set
1066 * ds_next_snap_obj when it should, leading to a
1067 * missing entry. Therefore we can only use the
1068 * next_clones_obj when its count is correct.
1070 int err
= zap_count(dp
->dp_meta_objset
,
1071 ds
->ds_phys
->ds_next_clones_obj
, &count
);
1073 count
== ds
->ds_phys
->ds_num_children
- 1)
1078 VERIFY(zap_join_key(dp
->dp_meta_objset
,
1079 ds
->ds_phys
->ds_next_clones_obj
,
1080 scn
->scn_phys
.scn_queue_obj
,
1081 ds
->ds_phys
->ds_creation_txg
, tx
) == 0);
1083 struct enqueue_clones_arg eca
;
1085 eca
.originobj
= ds
->ds_object
;
1087 (void) dmu_objset_find_spa(ds
->ds_dir
->dd_pool
->dp_spa
,
1088 NULL
, enqueue_clones_cb
, &eca
, DS_FIND_CHILDREN
);
1093 dsl_dataset_rele(ds
, FTAG
);
1098 enqueue_cb(spa_t
*spa
, uint64_t dsobj
, const char *dsname
, void *arg
)
1103 dsl_pool_t
*dp
= spa
->spa_dsl_pool
;
1104 dsl_scan_t
*scn
= dp
->dp_scan
;
1106 err
= dsl_dataset_hold_obj(dp
, dsobj
, FTAG
, &ds
);
1110 while (ds
->ds_phys
->ds_prev_snap_obj
!= 0) {
1111 dsl_dataset_t
*prev
;
1112 err
= dsl_dataset_hold_obj(dp
, ds
->ds_phys
->ds_prev_snap_obj
,
1115 dsl_dataset_rele(ds
, FTAG
);
1120 * If this is a clone, we don't need to worry about it for now.
1122 if (prev
->ds_phys
->ds_next_snap_obj
!= ds
->ds_object
) {
1123 dsl_dataset_rele(ds
, FTAG
);
1124 dsl_dataset_rele(prev
, FTAG
);
1127 dsl_dataset_rele(ds
, FTAG
);
1131 VERIFY(zap_add_int_key(dp
->dp_meta_objset
, scn
->scn_phys
.scn_queue_obj
,
1132 ds
->ds_object
, ds
->ds_phys
->ds_prev_snap_txg
, tx
) == 0);
1133 dsl_dataset_rele(ds
, FTAG
);
1138 * Scrub/dedup interaction.
1140 * If there are N references to a deduped block, we don't want to scrub it
1141 * N times -- ideally, we should scrub it exactly once.
1143 * We leverage the fact that the dde's replication class (enum ddt_class)
1144 * is ordered from highest replication class (DDT_CLASS_DITTO) to lowest
1145 * (DDT_CLASS_UNIQUE) so that we may walk the DDT in that order.
1147 * To prevent excess scrubbing, the scrub begins by walking the DDT
1148 * to find all blocks with refcnt > 1, and scrubs each of these once.
1149 * Since there are two replication classes which contain blocks with
1150 * refcnt > 1, we scrub the highest replication class (DDT_CLASS_DITTO) first.
1151 * Finally the top-down scrub begins, only visiting blocks with refcnt == 1.
1153 * There would be nothing more to say if a block's refcnt couldn't change
1154 * during a scrub, but of course it can so we must account for changes
1155 * in a block's replication class.
1157 * Here's an example of what can occur:
1159 * If a block has refcnt > 1 during the DDT scrub phase, but has refcnt == 1
1160 * when visited during the top-down scrub phase, it will be scrubbed twice.
1161 * This negates our scrub optimization, but is otherwise harmless.
1163 * If a block has refcnt == 1 during the DDT scrub phase, but has refcnt > 1
1164 * on each visit during the top-down scrub phase, it will never be scrubbed.
1165 * To catch this, ddt_sync_entry() notifies the scrub code whenever a block's
1166 * reference class transitions to a higher level (i.e DDT_CLASS_UNIQUE to
1167 * DDT_CLASS_DUPLICATE); if it transitions from refcnt == 1 to refcnt > 1
1168 * while a scrub is in progress, it scrubs the block right then.
1171 dsl_scan_ddt(dsl_scan_t
*scn
, dmu_tx_t
*tx
)
1173 ddt_bookmark_t
*ddb
= &scn
->scn_phys
.scn_ddt_bookmark
;
1178 bzero(&dde
, sizeof (ddt_entry_t
));
1180 while ((error
= ddt_walk(scn
->scn_dp
->dp_spa
, ddb
, &dde
)) == 0) {
1183 if (ddb
->ddb_class
> scn
->scn_phys
.scn_ddt_class_max
)
1185 dprintf("visiting ddb=%llu/%llu/%llu/%llx\n",
1186 (longlong_t
)ddb
->ddb_class
,
1187 (longlong_t
)ddb
->ddb_type
,
1188 (longlong_t
)ddb
->ddb_checksum
,
1189 (longlong_t
)ddb
->ddb_cursor
);
1191 /* There should be no pending changes to the dedup table */
1192 ddt
= scn
->scn_dp
->dp_spa
->spa_ddt
[ddb
->ddb_checksum
];
1193 ASSERT(avl_first(&ddt
->ddt_tree
) == NULL
);
1195 dsl_scan_ddt_entry(scn
, ddb
->ddb_checksum
, &dde
, tx
);
1198 if (dsl_scan_check_pause(scn
, NULL
))
1202 zfs_dbgmsg("scanned %llu ddt entries with class_max = %u; pausing=%u",
1203 (longlong_t
)n
, (int)scn
->scn_phys
.scn_ddt_class_max
,
1204 (int)scn
->scn_pausing
);
1206 ASSERT(error
== 0 || error
== ENOENT
);
1207 ASSERT(error
!= ENOENT
||
1208 ddb
->ddb_class
> scn
->scn_phys
.scn_ddt_class_max
);
1213 dsl_scan_ddt_entry(dsl_scan_t
*scn
, enum zio_checksum checksum
,
1214 ddt_entry_t
*dde
, dmu_tx_t
*tx
)
1216 const ddt_key_t
*ddk
= &dde
->dde_key
;
1217 ddt_phys_t
*ddp
= dde
->dde_phys
;
1219 zbookmark_t zb
= { 0 };
1222 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
1225 for (p
= 0; p
< DDT_PHYS_TYPES
; p
++, ddp
++) {
1226 if (ddp
->ddp_phys_birth
== 0 ||
1227 ddp
->ddp_phys_birth
> scn
->scn_phys
.scn_cur_max_txg
)
1229 ddt_bp_create(checksum
, ddk
, ddp
, &bp
);
1231 scn
->scn_visited_this_txg
++;
1232 scan_funcs
[scn
->scn_phys
.scn_func
](scn
->scn_dp
, &bp
, &zb
);
1237 dsl_scan_visit(dsl_scan_t
*scn
, dmu_tx_t
*tx
)
1239 dsl_pool_t
*dp
= scn
->scn_dp
;
1241 zap_attribute_t
*za
;
1243 if (scn
->scn_phys
.scn_ddt_bookmark
.ddb_class
<=
1244 scn
->scn_phys
.scn_ddt_class_max
) {
1245 scn
->scn_phys
.scn_cur_min_txg
= scn
->scn_phys
.scn_min_txg
;
1246 scn
->scn_phys
.scn_cur_max_txg
= scn
->scn_phys
.scn_max_txg
;
1247 dsl_scan_ddt(scn
, tx
);
1248 if (scn
->scn_pausing
)
1252 if (scn
->scn_phys
.scn_bookmark
.zb_objset
== DMU_META_OBJSET
) {
1253 /* First do the MOS & ORIGIN */
1255 scn
->scn_phys
.scn_cur_min_txg
= scn
->scn_phys
.scn_min_txg
;
1256 scn
->scn_phys
.scn_cur_max_txg
= scn
->scn_phys
.scn_max_txg
;
1257 dsl_scan_visit_rootbp(scn
, NULL
,
1258 &dp
->dp_meta_rootbp
, tx
);
1259 spa_set_rootblkptr(dp
->dp_spa
, &dp
->dp_meta_rootbp
);
1260 if (scn
->scn_pausing
)
1263 if (spa_version(dp
->dp_spa
) < SPA_VERSION_DSL_SCRUB
) {
1264 VERIFY(0 == dmu_objset_find_spa(dp
->dp_spa
,
1265 NULL
, enqueue_cb
, tx
, DS_FIND_CHILDREN
));
1267 dsl_scan_visitds(scn
,
1268 dp
->dp_origin_snap
->ds_object
, tx
);
1270 ASSERT(!scn
->scn_pausing
);
1271 } else if (scn
->scn_phys
.scn_bookmark
.zb_objset
!=
1272 ZB_DESTROYED_OBJSET
) {
1274 * If we were paused, continue from here. Note if the
1275 * ds we were paused on was deleted, the zb_objset may
1276 * be -1, so we will skip this and find a new objset
1279 dsl_scan_visitds(scn
, scn
->scn_phys
.scn_bookmark
.zb_objset
, tx
);
1280 if (scn
->scn_pausing
)
1285 * In case we were paused right at the end of the ds, zero the
1286 * bookmark so we don't think that we're still trying to resume.
1288 bzero(&scn
->scn_phys
.scn_bookmark
, sizeof (zbookmark_t
));
1289 zc
= kmem_alloc(sizeof(zap_cursor_t
), KM_PUSHPAGE
);
1290 za
= kmem_alloc(sizeof(zap_attribute_t
), KM_PUSHPAGE
);
1292 /* keep pulling things out of the zap-object-as-queue */
1293 while (zap_cursor_init(zc
, dp
->dp_meta_objset
,
1294 scn
->scn_phys
.scn_queue_obj
),
1295 zap_cursor_retrieve(zc
, za
) == 0) {
1299 dsobj
= strtonum(za
->za_name
, NULL
);
1300 VERIFY3U(0, ==, zap_remove_int(dp
->dp_meta_objset
,
1301 scn
->scn_phys
.scn_queue_obj
, dsobj
, tx
));
1303 /* Set up min/max txg */
1304 VERIFY3U(0, ==, dsl_dataset_hold_obj(dp
, dsobj
, FTAG
, &ds
));
1305 if (za
->za_first_integer
!= 0) {
1306 scn
->scn_phys
.scn_cur_min_txg
=
1307 MAX(scn
->scn_phys
.scn_min_txg
,
1308 za
->za_first_integer
);
1310 scn
->scn_phys
.scn_cur_min_txg
=
1311 MAX(scn
->scn_phys
.scn_min_txg
,
1312 ds
->ds_phys
->ds_prev_snap_txg
);
1314 scn
->scn_phys
.scn_cur_max_txg
= dsl_scan_ds_maxtxg(ds
);
1315 dsl_dataset_rele(ds
, FTAG
);
1317 dsl_scan_visitds(scn
, dsobj
, tx
);
1318 zap_cursor_fini(zc
);
1319 if (scn
->scn_pausing
)
1322 zap_cursor_fini(zc
);
1324 kmem_free(za
, sizeof(zap_attribute_t
));
1325 kmem_free(zc
, sizeof(zap_cursor_t
));
1329 dsl_scan_free_should_pause(dsl_scan_t
*scn
)
1331 uint64_t elapsed_nanosecs
;
1333 elapsed_nanosecs
= gethrtime() - scn
->scn_sync_start_time
;
1334 return (elapsed_nanosecs
/ NANOSEC
> zfs_txg_timeout
||
1335 (elapsed_nanosecs
/ MICROSEC
> zfs_free_min_time_ms
&&
1336 txg_sync_waiting(scn
->scn_dp
)) ||
1337 spa_shutting_down(scn
->scn_dp
->dp_spa
));
1341 dsl_scan_free_block_cb(void *arg
, const blkptr_t
*bp
, dmu_tx_t
*tx
)
1343 dsl_scan_t
*scn
= arg
;
1345 if (!scn
->scn_is_bptree
||
1346 (BP_GET_LEVEL(bp
) == 0 && BP_GET_TYPE(bp
) != DMU_OT_OBJSET
)) {
1347 if (dsl_scan_free_should_pause(scn
))
1351 zio_nowait(zio_free_sync(scn
->scn_zio_root
, scn
->scn_dp
->dp_spa
,
1352 dmu_tx_get_txg(tx
), bp
, 0));
1353 dsl_dir_diduse_space(tx
->tx_pool
->dp_free_dir
, DD_USED_HEAD
,
1354 -bp_get_dsize_sync(scn
->scn_dp
->dp_spa
, bp
),
1355 -BP_GET_PSIZE(bp
), -BP_GET_UCSIZE(bp
), tx
);
1356 scn
->scn_visited_this_txg
++;
1361 dsl_scan_active(dsl_scan_t
*scn
)
1363 spa_t
*spa
= scn
->scn_dp
->dp_spa
;
1364 uint64_t used
= 0, comp
, uncomp
;
1366 if (spa
->spa_load_state
!= SPA_LOAD_NONE
)
1368 if (spa_shutting_down(spa
))
1371 if (scn
->scn_phys
.scn_state
== DSS_SCANNING
)
1374 if (spa_feature_is_active(spa
,
1375 &spa_feature_table
[SPA_FEATURE_ASYNC_DESTROY
])) {
1378 if (spa_version(scn
->scn_dp
->dp_spa
) >= SPA_VERSION_DEADLISTS
) {
1379 (void) bpobj_space(&scn
->scn_dp
->dp_free_bpobj
,
1380 &used
, &comp
, &uncomp
);
1386 dsl_scan_sync(dsl_pool_t
*dp
, dmu_tx_t
*tx
)
1388 dsl_scan_t
*scn
= dp
->dp_scan
;
1389 spa_t
*spa
= dp
->dp_spa
;
1393 * Check for scn_restart_txg before checking spa_load_state, so
1394 * that we can restart an old-style scan while the pool is being
1395 * imported (see dsl_scan_init).
1397 if (scn
->scn_restart_txg
!= 0 &&
1398 scn
->scn_restart_txg
<= tx
->tx_txg
) {
1399 pool_scan_func_t func
= POOL_SCAN_SCRUB
;
1400 dsl_scan_done(scn
, B_FALSE
, tx
);
1401 if (vdev_resilver_needed(spa
->spa_root_vdev
, NULL
, NULL
))
1402 func
= POOL_SCAN_RESILVER
;
1403 zfs_dbgmsg("restarting scan func=%u txg=%llu",
1405 dsl_scan_setup_sync(scn
, &func
, tx
);
1408 if (!dsl_scan_active(scn
) ||
1409 spa_sync_pass(dp
->dp_spa
) > 1)
1412 scn
->scn_visited_this_txg
= 0;
1413 scn
->scn_pausing
= B_FALSE
;
1414 scn
->scn_sync_start_time
= gethrtime();
1415 spa
->spa_scrub_active
= B_TRUE
;
1418 * First process the free list. If we pause the free, don't do
1419 * any scanning. This ensures that there is no free list when
1420 * we are scanning, so the scan code doesn't have to worry about
1423 if (spa_version(dp
->dp_spa
) >= SPA_VERSION_DEADLISTS
) {
1424 scn
->scn_is_bptree
= B_FALSE
;
1425 scn
->scn_zio_root
= zio_root(dp
->dp_spa
, NULL
,
1426 NULL
, ZIO_FLAG_MUSTSUCCEED
);
1427 err
= bpobj_iterate(&dp
->dp_free_bpobj
,
1428 dsl_scan_free_block_cb
, scn
, tx
);
1429 VERIFY3U(0, ==, zio_wait(scn
->scn_zio_root
));
1431 if (err
== 0 && spa_feature_is_active(spa
,
1432 &spa_feature_table
[SPA_FEATURE_ASYNC_DESTROY
])) {
1433 scn
->scn_is_bptree
= B_TRUE
;
1434 scn
->scn_zio_root
= zio_root(dp
->dp_spa
, NULL
,
1435 NULL
, ZIO_FLAG_MUSTSUCCEED
);
1436 err
= bptree_iterate(dp
->dp_meta_objset
,
1437 dp
->dp_bptree_obj
, B_TRUE
, dsl_scan_free_block_cb
,
1439 VERIFY3U(0, ==, zio_wait(scn
->scn_zio_root
));
1443 /* disable async destroy feature */
1444 spa_feature_decr(spa
,
1445 &spa_feature_table
[SPA_FEATURE_ASYNC_DESTROY
], tx
);
1446 ASSERT(!spa_feature_is_active(spa
,
1447 &spa_feature_table
[SPA_FEATURE_ASYNC_DESTROY
]));
1448 VERIFY3U(0, ==, zap_remove(dp
->dp_meta_objset
,
1449 DMU_POOL_DIRECTORY_OBJECT
,
1450 DMU_POOL_BPTREE_OBJ
, tx
));
1451 VERIFY3U(0, ==, bptree_free(dp
->dp_meta_objset
,
1452 dp
->dp_bptree_obj
, tx
));
1453 dp
->dp_bptree_obj
= 0;
1455 if (scn
->scn_visited_this_txg
) {
1456 zfs_dbgmsg("freed %llu blocks in %llums from "
1457 "free_bpobj/bptree txg %llu",
1458 (longlong_t
)scn
->scn_visited_this_txg
,
1460 (gethrtime() - scn
->scn_sync_start_time
) / MICROSEC
,
1461 (longlong_t
)tx
->tx_txg
);
1462 scn
->scn_visited_this_txg
= 0;
1464 * Re-sync the ddt so that we can further modify
1465 * it when doing bprewrite.
1467 ddt_sync(spa
, tx
->tx_txg
);
1469 if (err
== ERESTART
)
1473 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
1476 if (scn
->scn_phys
.scn_ddt_bookmark
.ddb_class
<=
1477 scn
->scn_phys
.scn_ddt_class_max
) {
1478 zfs_dbgmsg("doing scan sync txg %llu; "
1479 "ddt bm=%llu/%llu/%llu/%llx",
1480 (longlong_t
)tx
->tx_txg
,
1481 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_class
,
1482 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_type
,
1483 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_checksum
,
1484 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_cursor
);
1485 ASSERT(scn
->scn_phys
.scn_bookmark
.zb_objset
== 0);
1486 ASSERT(scn
->scn_phys
.scn_bookmark
.zb_object
== 0);
1487 ASSERT(scn
->scn_phys
.scn_bookmark
.zb_level
== 0);
1488 ASSERT(scn
->scn_phys
.scn_bookmark
.zb_blkid
== 0);
1490 zfs_dbgmsg("doing scan sync txg %llu; bm=%llu/%llu/%llu/%llu",
1491 (longlong_t
)tx
->tx_txg
,
1492 (longlong_t
)scn
->scn_phys
.scn_bookmark
.zb_objset
,
1493 (longlong_t
)scn
->scn_phys
.scn_bookmark
.zb_object
,
1494 (longlong_t
)scn
->scn_phys
.scn_bookmark
.zb_level
,
1495 (longlong_t
)scn
->scn_phys
.scn_bookmark
.zb_blkid
);
1498 scn
->scn_zio_root
= zio_root(dp
->dp_spa
, NULL
,
1499 NULL
, ZIO_FLAG_CANFAIL
);
1500 dsl_scan_visit(scn
, tx
);
1501 (void) zio_wait(scn
->scn_zio_root
);
1502 scn
->scn_zio_root
= NULL
;
1504 zfs_dbgmsg("visited %llu blocks in %llums",
1505 (longlong_t
)scn
->scn_visited_this_txg
,
1506 (longlong_t
)(gethrtime() - scn
->scn_sync_start_time
) / MICROSEC
);
1508 if (!scn
->scn_pausing
) {
1509 /* finished with scan. */
1510 zfs_dbgmsg("finished scan txg %llu", (longlong_t
)tx
->tx_txg
);
1511 dsl_scan_done(scn
, B_TRUE
, tx
);
1514 if (DSL_SCAN_IS_SCRUB_RESILVER(scn
)) {
1515 mutex_enter(&spa
->spa_scrub_lock
);
1516 while (spa
->spa_scrub_inflight
> 0) {
1517 cv_wait(&spa
->spa_scrub_io_cv
,
1518 &spa
->spa_scrub_lock
);
1520 mutex_exit(&spa
->spa_scrub_lock
);
1523 dsl_scan_sync_state(scn
, tx
);
1527 * This will start a new scan, or restart an existing one.
1530 dsl_resilver_restart(dsl_pool_t
*dp
, uint64_t txg
)
1534 tx
= dmu_tx_create_dd(dp
->dp_mos_dir
);
1535 VERIFY(0 == dmu_tx_assign(tx
, TXG_WAIT
));
1537 txg
= dmu_tx_get_txg(tx
);
1538 dp
->dp_scan
->scn_restart_txg
= txg
;
1541 dp
->dp_scan
->scn_restart_txg
= txg
;
1543 zfs_dbgmsg("restarting resilver txg=%llu", txg
);
1547 dsl_scan_resilvering(dsl_pool_t
*dp
)
1549 return (dp
->dp_scan
->scn_phys
.scn_state
== DSS_SCANNING
&&
1550 dp
->dp_scan
->scn_phys
.scn_func
== POOL_SCAN_RESILVER
);
1558 count_block(zfs_all_blkstats_t
*zab
, const blkptr_t
*bp
)
1563 * If we resume after a reboot, zab will be NULL; don't record
1564 * incomplete stats in that case.
1569 for (i
= 0; i
< 4; i
++) {
1570 int l
= (i
< 2) ? BP_GET_LEVEL(bp
) : DN_MAX_LEVELS
;
1571 int t
= (i
& 1) ? BP_GET_TYPE(bp
) : DMU_OT_TOTAL
;
1575 if (t
& DMU_OT_NEWTYPE
)
1578 zb
= &zab
->zab_type
[l
][t
];
1580 zb
->zb_asize
+= BP_GET_ASIZE(bp
);
1581 zb
->zb_lsize
+= BP_GET_LSIZE(bp
);
1582 zb
->zb_psize
+= BP_GET_PSIZE(bp
);
1583 zb
->zb_gangs
+= BP_COUNT_GANG(bp
);
1585 switch (BP_GET_NDVAS(bp
)) {
1587 if (DVA_GET_VDEV(&bp
->blk_dva
[0]) ==
1588 DVA_GET_VDEV(&bp
->blk_dva
[1]))
1589 zb
->zb_ditto_2_of_2_samevdev
++;
1592 equal
= (DVA_GET_VDEV(&bp
->blk_dva
[0]) ==
1593 DVA_GET_VDEV(&bp
->blk_dva
[1])) +
1594 (DVA_GET_VDEV(&bp
->blk_dva
[0]) ==
1595 DVA_GET_VDEV(&bp
->blk_dva
[2])) +
1596 (DVA_GET_VDEV(&bp
->blk_dva
[1]) ==
1597 DVA_GET_VDEV(&bp
->blk_dva
[2]));
1599 zb
->zb_ditto_2_of_3_samevdev
++;
1600 else if (equal
== 3)
1601 zb
->zb_ditto_3_of_3_samevdev
++;
1608 dsl_scan_scrub_done(zio_t
*zio
)
1610 spa_t
*spa
= zio
->io_spa
;
1612 zio_data_buf_free(zio
->io_data
, zio
->io_size
);
1614 mutex_enter(&spa
->spa_scrub_lock
);
1615 spa
->spa_scrub_inflight
--;
1616 cv_broadcast(&spa
->spa_scrub_io_cv
);
1618 if (zio
->io_error
&& (zio
->io_error
!= ECKSUM
||
1619 !(zio
->io_flags
& ZIO_FLAG_SPECULATIVE
))) {
1620 spa
->spa_dsl_pool
->dp_scan
->scn_phys
.scn_errors
++;
1622 mutex_exit(&spa
->spa_scrub_lock
);
1626 dsl_scan_scrub_cb(dsl_pool_t
*dp
,
1627 const blkptr_t
*bp
, const zbookmark_t
*zb
)
1629 dsl_scan_t
*scn
= dp
->dp_scan
;
1630 size_t size
= BP_GET_PSIZE(bp
);
1631 spa_t
*spa
= dp
->dp_spa
;
1632 uint64_t phys_birth
= BP_PHYSICAL_BIRTH(bp
);
1633 boolean_t needs_io
= B_FALSE
;
1634 int zio_flags
= ZIO_FLAG_SCAN_THREAD
| ZIO_FLAG_RAW
| ZIO_FLAG_CANFAIL
;
1635 int zio_priority
= 0;
1639 if (phys_birth
<= scn
->scn_phys
.scn_min_txg
||
1640 phys_birth
>= scn
->scn_phys
.scn_max_txg
)
1643 count_block(dp
->dp_blkstats
, bp
);
1645 ASSERT(DSL_SCAN_IS_SCRUB_RESILVER(scn
));
1646 if (scn
->scn_phys
.scn_func
== POOL_SCAN_SCRUB
) {
1647 zio_flags
|= ZIO_FLAG_SCRUB
;
1648 zio_priority
= ZIO_PRIORITY_SCRUB
;
1650 scan_delay
= zfs_scrub_delay
;
1651 } else if (scn
->scn_phys
.scn_func
== POOL_SCAN_RESILVER
) {
1652 zio_flags
|= ZIO_FLAG_RESILVER
;
1653 zio_priority
= ZIO_PRIORITY_RESILVER
;
1655 scan_delay
= zfs_resilver_delay
;
1658 /* If it's an intent log block, failure is expected. */
1659 if (zb
->zb_level
== ZB_ZIL_LEVEL
)
1660 zio_flags
|= ZIO_FLAG_SPECULATIVE
;
1662 for (d
= 0; d
< BP_GET_NDVAS(bp
); d
++) {
1663 vdev_t
*vd
= vdev_lookup_top(spa
,
1664 DVA_GET_VDEV(&bp
->blk_dva
[d
]));
1667 * Keep track of how much data we've examined so that
1668 * zpool(1M) status can make useful progress reports.
1670 scn
->scn_phys
.scn_examined
+= DVA_GET_ASIZE(&bp
->blk_dva
[d
]);
1671 spa
->spa_scan_pass_exam
+= DVA_GET_ASIZE(&bp
->blk_dva
[d
]);
1673 /* if it's a resilver, this may not be in the target range */
1675 if (DVA_GET_GANG(&bp
->blk_dva
[d
])) {
1677 * Gang members may be spread across multiple
1678 * vdevs, so the best estimate we have is the
1679 * scrub range, which has already been checked.
1680 * XXX -- it would be better to change our
1681 * allocation policy to ensure that all
1682 * gang members reside on the same vdev.
1686 needs_io
= vdev_dtl_contains(vd
, DTL_PARTIAL
,
1692 if (needs_io
&& !zfs_no_scrub_io
) {
1693 vdev_t
*rvd
= spa
->spa_root_vdev
;
1694 uint64_t maxinflight
= rvd
->vdev_children
* zfs_top_maxinflight
;
1695 void *data
= zio_data_buf_alloc(size
);
1697 mutex_enter(&spa
->spa_scrub_lock
);
1698 while (spa
->spa_scrub_inflight
>= maxinflight
)
1699 cv_wait(&spa
->spa_scrub_io_cv
, &spa
->spa_scrub_lock
);
1700 spa
->spa_scrub_inflight
++;
1701 mutex_exit(&spa
->spa_scrub_lock
);
1704 * If we're seeing recent (zfs_scan_idle) "important" I/Os
1705 * then throttle our workload to limit the impact of a scan.
1707 if (ddi_get_lbolt64() - spa
->spa_last_io
<= zfs_scan_idle
)
1710 zio_nowait(zio_read(NULL
, spa
, bp
, data
, size
,
1711 dsl_scan_scrub_done
, NULL
, zio_priority
,
1715 /* do not relocate this block */
1720 dsl_scan(dsl_pool_t
*dp
, pool_scan_func_t func
)
1722 spa_t
*spa
= dp
->dp_spa
;
1725 * Purge all vdev caches and probe all devices. We do this here
1726 * rather than in sync context because this requires a writer lock
1727 * on the spa_config lock, which we can't do from sync context. The
1728 * spa_scrub_reopen flag indicates that vdev_open() should not
1729 * attempt to start another scrub.
1731 spa_vdev_state_enter(spa
, SCL_NONE
);
1732 spa
->spa_scrub_reopen
= B_TRUE
;
1733 vdev_reopen(spa
->spa_root_vdev
);
1734 spa
->spa_scrub_reopen
= B_FALSE
;
1735 (void) spa_vdev_state_exit(spa
, NULL
, 0);
1737 return (dsl_sync_task_do(dp
, dsl_scan_setup_check
,
1738 dsl_scan_setup_sync
, dp
->dp_scan
, &func
, 0));
1741 #if defined(_KERNEL) && defined(HAVE_SPL)
1742 module_param(zfs_top_maxinflight
, int, 0644);
1743 MODULE_PARM_DESC(zfs_top_maxinflight
, "Max I/Os per top-level");
1745 module_param(zfs_resilver_delay
, int, 0644);
1746 MODULE_PARM_DESC(zfs_resilver_delay
, "Number of ticks to delay resilver");
1748 module_param(zfs_scrub_delay
, int, 0644);
1749 MODULE_PARM_DESC(zfs_scrub_delay
, "Number of ticks to delay scrub");
1751 module_param(zfs_scan_idle
, int, 0644);
1752 MODULE_PARM_DESC(zfs_scan_idle
, "Idle window in clock ticks");
1754 module_param(zfs_scan_min_time_ms
, int, 0644);
1755 MODULE_PARM_DESC(zfs_scan_min_time_ms
, "Min millisecs to scrub per txg");
1757 module_param(zfs_free_min_time_ms
, int, 0644);
1758 MODULE_PARM_DESC(zfs_free_min_time_ms
, "Min millisecs to free per txg");
1760 module_param(zfs_resilver_min_time_ms
, int, 0644);
1761 MODULE_PARM_DESC(zfs_resilver_min_time_ms
, "Min millisecs to resilver per txg");
1763 module_param(zfs_no_scrub_io
, int, 0644);
1764 MODULE_PARM_DESC(zfs_no_scrub_io
, "Set to disable scrub I/O");
1766 module_param(zfs_no_scrub_prefetch
, int, 0644);
1767 MODULE_PARM_DESC(zfs_no_scrub_prefetch
, "Set to disable scrub prefetching");