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) 2013 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 void dsl_scan_cancel_sync(void *, dmu_tx_t
*);
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
);
95 * It's possible that we're resuming a scan after a reboot so
96 * make sure that the scan_async_destroying flag is initialized
99 ASSERT(!scn
->scn_async_destroying
);
100 scn
->scn_async_destroying
= spa_feature_is_active(dp
->dp_spa
,
101 &spa_feature_table
[SPA_FEATURE_ASYNC_DESTROY
]);
103 err
= zap_lookup(dp
->dp_meta_objset
, DMU_POOL_DIRECTORY_OBJECT
,
104 "scrub_func", sizeof (uint64_t), 1, &f
);
107 * There was an old-style scrub in progress. Restart a
108 * new-style scrub from the beginning.
110 scn
->scn_restart_txg
= txg
;
111 zfs_dbgmsg("old-style scrub was in progress; "
112 "restarting new-style scrub in txg %llu",
113 scn
->scn_restart_txg
);
116 * Load the queue obj from the old location so that it
117 * can be freed by dsl_scan_done().
119 (void) zap_lookup(dp
->dp_meta_objset
, DMU_POOL_DIRECTORY_OBJECT
,
120 "scrub_queue", sizeof (uint64_t), 1,
121 &scn
->scn_phys
.scn_queue_obj
);
123 err
= zap_lookup(dp
->dp_meta_objset
, DMU_POOL_DIRECTORY_OBJECT
,
124 DMU_POOL_SCAN
, sizeof (uint64_t), SCAN_PHYS_NUMINTS
,
131 if (scn
->scn_phys
.scn_state
== DSS_SCANNING
&&
132 spa_prev_software_version(dp
->dp_spa
) < SPA_VERSION_SCAN
) {
134 * A new-type scrub was in progress on an old
135 * pool, and the pool was accessed by old
136 * software. Restart from the beginning, since
137 * the old software may have changed the pool in
140 scn
->scn_restart_txg
= txg
;
141 zfs_dbgmsg("new-style scrub was modified "
142 "by old software; restarting in txg %llu",
143 scn
->scn_restart_txg
);
147 spa_scan_stat_init(spa
);
152 dsl_scan_fini(dsl_pool_t
*dp
)
155 kmem_free(dp
->dp_scan
, sizeof (dsl_scan_t
));
162 dsl_scan_setup_check(void *arg
, dmu_tx_t
*tx
)
164 dsl_scan_t
*scn
= dmu_tx_pool(tx
)->dp_scan
;
166 if (scn
->scn_phys
.scn_state
== DSS_SCANNING
)
167 return (SET_ERROR(EBUSY
));
173 dsl_scan_setup_sync(void *arg
, dmu_tx_t
*tx
)
175 dsl_scan_t
*scn
= dmu_tx_pool(tx
)->dp_scan
;
176 pool_scan_func_t
*funcp
= arg
;
177 dmu_object_type_t ot
= 0;
178 dsl_pool_t
*dp
= scn
->scn_dp
;
179 spa_t
*spa
= dp
->dp_spa
;
181 ASSERT(scn
->scn_phys
.scn_state
!= DSS_SCANNING
);
182 ASSERT(*funcp
> POOL_SCAN_NONE
&& *funcp
< POOL_SCAN_FUNCS
);
183 bzero(&scn
->scn_phys
, sizeof (scn
->scn_phys
));
184 scn
->scn_phys
.scn_func
= *funcp
;
185 scn
->scn_phys
.scn_state
= DSS_SCANNING
;
186 scn
->scn_phys
.scn_min_txg
= 0;
187 scn
->scn_phys
.scn_max_txg
= tx
->tx_txg
;
188 scn
->scn_phys
.scn_ddt_class_max
= DDT_CLASSES
- 1; /* the entire DDT */
189 scn
->scn_phys
.scn_start_time
= gethrestime_sec();
190 scn
->scn_phys
.scn_errors
= 0;
191 scn
->scn_phys
.scn_to_examine
= spa
->spa_root_vdev
->vdev_stat
.vs_alloc
;
192 scn
->scn_restart_txg
= 0;
193 scn
->scn_done_txg
= 0;
194 spa_scan_stat_init(spa
);
196 if (DSL_SCAN_IS_SCRUB_RESILVER(scn
)) {
197 scn
->scn_phys
.scn_ddt_class_max
= zfs_scrub_ddt_class_max
;
199 /* rewrite all disk labels */
200 vdev_config_dirty(spa
->spa_root_vdev
);
202 if (vdev_resilver_needed(spa
->spa_root_vdev
,
203 &scn
->scn_phys
.scn_min_txg
, &scn
->scn_phys
.scn_max_txg
)) {
204 spa_event_notify(spa
, NULL
,
205 FM_EREPORT_ZFS_RESILVER_START
);
207 spa_event_notify(spa
, NULL
,
208 FM_EREPORT_ZFS_SCRUB_START
);
211 spa
->spa_scrub_started
= B_TRUE
;
213 * If this is an incremental scrub, limit the DDT scrub phase
214 * to just the auto-ditto class (for correctness); the rest
215 * of the scrub should go faster using top-down pruning.
217 if (scn
->scn_phys
.scn_min_txg
> TXG_INITIAL
)
218 scn
->scn_phys
.scn_ddt_class_max
= DDT_CLASS_DITTO
;
222 /* back to the generic stuff */
224 if (dp
->dp_blkstats
== NULL
) {
225 dp
->dp_blkstats
= kmem_alloc(sizeof (zfs_all_blkstats_t
),
226 KM_PUSHPAGE
| KM_NODEBUG
);
228 bzero(dp
->dp_blkstats
, sizeof (zfs_all_blkstats_t
));
230 if (spa_version(spa
) < SPA_VERSION_DSL_SCRUB
)
231 ot
= DMU_OT_ZAP_OTHER
;
233 scn
->scn_phys
.scn_queue_obj
= zap_create(dp
->dp_meta_objset
,
234 ot
? ot
: DMU_OT_SCAN_QUEUE
, DMU_OT_NONE
, 0, tx
);
236 dsl_scan_sync_state(scn
, tx
);
238 spa_history_log_internal(spa
, "scan setup", tx
,
239 "func=%u mintxg=%llu maxtxg=%llu",
240 *funcp
, scn
->scn_phys
.scn_min_txg
, scn
->scn_phys
.scn_max_txg
);
245 dsl_scan_done(dsl_scan_t
*scn
, boolean_t complete
, dmu_tx_t
*tx
)
247 static const char *old_names
[] = {
249 "scrub_ddt_bookmark",
250 "scrub_ddt_class_max",
259 dsl_pool_t
*dp
= scn
->scn_dp
;
260 spa_t
*spa
= dp
->dp_spa
;
263 /* Remove any remnants of an old-style scrub. */
264 for (i
= 0; old_names
[i
]; i
++) {
265 (void) zap_remove(dp
->dp_meta_objset
,
266 DMU_POOL_DIRECTORY_OBJECT
, old_names
[i
], tx
);
269 if (scn
->scn_phys
.scn_queue_obj
!= 0) {
270 VERIFY(0 == dmu_object_free(dp
->dp_meta_objset
,
271 scn
->scn_phys
.scn_queue_obj
, tx
));
272 scn
->scn_phys
.scn_queue_obj
= 0;
276 * If we were "restarted" from a stopped state, don't bother
277 * with anything else.
279 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
283 scn
->scn_phys
.scn_state
= DSS_FINISHED
;
285 scn
->scn_phys
.scn_state
= DSS_CANCELED
;
287 spa_history_log_internal(spa
, "scan done", tx
,
288 "complete=%u", complete
);
290 if (DSL_SCAN_IS_SCRUB_RESILVER(scn
)) {
291 mutex_enter(&spa
->spa_scrub_lock
);
292 while (spa
->spa_scrub_inflight
> 0) {
293 cv_wait(&spa
->spa_scrub_io_cv
,
294 &spa
->spa_scrub_lock
);
296 mutex_exit(&spa
->spa_scrub_lock
);
297 spa
->spa_scrub_started
= B_FALSE
;
298 spa
->spa_scrub_active
= B_FALSE
;
301 * If the scrub/resilver completed, update all DTLs to
302 * reflect this. Whether it succeeded or not, vacate
303 * all temporary scrub DTLs.
305 vdev_dtl_reassess(spa
->spa_root_vdev
, tx
->tx_txg
,
306 complete
? scn
->scn_phys
.scn_max_txg
: 0, B_TRUE
);
308 spa_event_notify(spa
, NULL
, scn
->scn_phys
.scn_min_txg
?
309 FM_EREPORT_ZFS_RESILVER_FINISH
:
310 FM_EREPORT_ZFS_SCRUB_FINISH
);
312 spa_errlog_rotate(spa
);
315 * We may have finished replacing a device.
316 * Let the async thread assess this and handle the detach.
318 spa_async_request(spa
, SPA_ASYNC_RESILVER_DONE
);
321 scn
->scn_phys
.scn_end_time
= gethrestime_sec();
326 dsl_scan_cancel_check(void *arg
, dmu_tx_t
*tx
)
328 dsl_scan_t
*scn
= dmu_tx_pool(tx
)->dp_scan
;
330 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
331 return (SET_ERROR(ENOENT
));
337 dsl_scan_cancel_sync(void *arg
, dmu_tx_t
*tx
)
339 dsl_scan_t
*scn
= dmu_tx_pool(tx
)->dp_scan
;
341 dsl_scan_done(scn
, B_FALSE
, tx
);
342 dsl_scan_sync_state(scn
, tx
);
346 dsl_scan_cancel(dsl_pool_t
*dp
)
348 return (dsl_sync_task(spa_name(dp
->dp_spa
), dsl_scan_cancel_check
,
349 dsl_scan_cancel_sync
, NULL
, 3));
352 static void dsl_scan_visitbp(blkptr_t
*bp
,
353 const zbookmark_t
*zb
, dnode_phys_t
*dnp
, arc_buf_t
*pbuf
,
354 dsl_dataset_t
*ds
, dsl_scan_t
*scn
, dmu_objset_type_t ostype
,
356 inline __attribute__((always_inline
)) static void dsl_scan_visitdnode(
357 dsl_scan_t
*, dsl_dataset_t
*ds
, dmu_objset_type_t ostype
,
358 dnode_phys_t
*dnp
, arc_buf_t
*buf
, uint64_t object
, dmu_tx_t
*tx
);
361 dsl_free(dsl_pool_t
*dp
, uint64_t txg
, const blkptr_t
*bp
)
363 zio_free(dp
->dp_spa
, txg
, bp
);
367 dsl_free_sync(zio_t
*pio
, dsl_pool_t
*dp
, uint64_t txg
, const blkptr_t
*bpp
)
369 ASSERT(dsl_pool_sync_context(dp
));
370 zio_nowait(zio_free_sync(pio
, dp
->dp_spa
, txg
, bpp
, pio
->io_flags
));
374 dsl_scan_ds_maxtxg(dsl_dataset_t
*ds
)
376 uint64_t smt
= ds
->ds_dir
->dd_pool
->dp_scan
->scn_phys
.scn_max_txg
;
377 if (dsl_dataset_is_snapshot(ds
))
378 return (MIN(smt
, ds
->ds_phys
->ds_creation_txg
));
383 dsl_scan_sync_state(dsl_scan_t
*scn
, dmu_tx_t
*tx
)
385 VERIFY0(zap_update(scn
->scn_dp
->dp_meta_objset
,
386 DMU_POOL_DIRECTORY_OBJECT
,
387 DMU_POOL_SCAN
, sizeof (uint64_t), SCAN_PHYS_NUMINTS
,
388 &scn
->scn_phys
, tx
));
392 dsl_scan_check_pause(dsl_scan_t
*scn
, const zbookmark_t
*zb
)
394 uint64_t elapsed_nanosecs
;
397 /* we never skip user/group accounting objects */
398 if (zb
&& (int64_t)zb
->zb_object
< 0)
401 if (scn
->scn_pausing
)
402 return (B_TRUE
); /* we're already pausing */
404 if (!ZB_IS_ZERO(&scn
->scn_phys
.scn_bookmark
))
405 return (B_FALSE
); /* we're resuming */
407 /* We only know how to resume from level-0 blocks. */
408 if (zb
&& zb
->zb_level
!= 0)
411 mintime
= (scn
->scn_phys
.scn_func
== POOL_SCAN_RESILVER
) ?
412 zfs_resilver_min_time_ms
: zfs_scan_min_time_ms
;
413 elapsed_nanosecs
= gethrtime() - scn
->scn_sync_start_time
;
414 if (elapsed_nanosecs
/ NANOSEC
> zfs_txg_timeout
||
415 (NSEC2MSEC(elapsed_nanosecs
) > mintime
&&
416 txg_sync_waiting(scn
->scn_dp
)) ||
417 spa_shutting_down(scn
->scn_dp
->dp_spa
)) {
419 dprintf("pausing at bookmark %llx/%llx/%llx/%llx\n",
420 (longlong_t
)zb
->zb_objset
,
421 (longlong_t
)zb
->zb_object
,
422 (longlong_t
)zb
->zb_level
,
423 (longlong_t
)zb
->zb_blkid
);
424 scn
->scn_phys
.scn_bookmark
= *zb
;
426 dprintf("pausing at DDT bookmark %llx/%llx/%llx/%llx\n",
427 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_class
,
428 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_type
,
429 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_checksum
,
430 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_cursor
);
431 scn
->scn_pausing
= B_TRUE
;
437 typedef struct zil_scan_arg
{
439 zil_header_t
*zsa_zh
;
444 dsl_scan_zil_block(zilog_t
*zilog
, blkptr_t
*bp
, void *arg
, uint64_t claim_txg
)
446 zil_scan_arg_t
*zsa
= arg
;
447 dsl_pool_t
*dp
= zsa
->zsa_dp
;
448 dsl_scan_t
*scn
= dp
->dp_scan
;
449 zil_header_t
*zh
= zsa
->zsa_zh
;
452 if (bp
->blk_birth
<= scn
->scn_phys
.scn_cur_min_txg
)
456 * One block ("stubby") can be allocated a long time ago; we
457 * want to visit that one because it has been allocated
458 * (on-disk) even if it hasn't been claimed (even though for
459 * scrub there's nothing to do to it).
461 if (claim_txg
== 0 && bp
->blk_birth
>= spa_first_txg(dp
->dp_spa
))
464 SET_BOOKMARK(&zb
, zh
->zh_log
.blk_cksum
.zc_word
[ZIL_ZC_OBJSET
],
465 ZB_ZIL_OBJECT
, ZB_ZIL_LEVEL
, bp
->blk_cksum
.zc_word
[ZIL_ZC_SEQ
]);
467 VERIFY(0 == scan_funcs
[scn
->scn_phys
.scn_func
](dp
, bp
, &zb
));
473 dsl_scan_zil_record(zilog_t
*zilog
, lr_t
*lrc
, void *arg
, uint64_t claim_txg
)
475 if (lrc
->lrc_txtype
== TX_WRITE
) {
476 zil_scan_arg_t
*zsa
= arg
;
477 dsl_pool_t
*dp
= zsa
->zsa_dp
;
478 dsl_scan_t
*scn
= dp
->dp_scan
;
479 zil_header_t
*zh
= zsa
->zsa_zh
;
480 lr_write_t
*lr
= (lr_write_t
*)lrc
;
481 blkptr_t
*bp
= &lr
->lr_blkptr
;
484 if (bp
->blk_birth
<= scn
->scn_phys
.scn_cur_min_txg
)
488 * birth can be < claim_txg if this record's txg is
489 * already txg sync'ed (but this log block contains
490 * other records that are not synced)
492 if (claim_txg
== 0 || bp
->blk_birth
< claim_txg
)
495 SET_BOOKMARK(&zb
, zh
->zh_log
.blk_cksum
.zc_word
[ZIL_ZC_OBJSET
],
496 lr
->lr_foid
, ZB_ZIL_LEVEL
,
497 lr
->lr_offset
/ BP_GET_LSIZE(bp
));
499 VERIFY(0 == scan_funcs
[scn
->scn_phys
.scn_func
](dp
, bp
, &zb
));
505 dsl_scan_zil(dsl_pool_t
*dp
, zil_header_t
*zh
)
507 uint64_t claim_txg
= zh
->zh_claim_txg
;
508 zil_scan_arg_t zsa
= { dp
, zh
};
512 * We only want to visit blocks that have been claimed but not yet
513 * replayed (or, in read-only mode, blocks that *would* be claimed).
515 if (claim_txg
== 0 && spa_writeable(dp
->dp_spa
))
518 zilog
= zil_alloc(dp
->dp_meta_objset
, zh
);
520 (void) zil_parse(zilog
, dsl_scan_zil_block
, dsl_scan_zil_record
, &zsa
,
528 dsl_scan_prefetch(dsl_scan_t
*scn
, arc_buf_t
*buf
, blkptr_t
*bp
,
529 uint64_t objset
, uint64_t object
, uint64_t blkid
)
532 uint32_t flags
= ARC_NOWAIT
| ARC_PREFETCH
;
534 if (zfs_no_scrub_prefetch
)
537 if (BP_IS_HOLE(bp
) || bp
->blk_birth
<= scn
->scn_phys
.scn_min_txg
||
538 (BP_GET_LEVEL(bp
) == 0 && BP_GET_TYPE(bp
) != DMU_OT_DNODE
))
541 SET_BOOKMARK(&czb
, objset
, object
, BP_GET_LEVEL(bp
), blkid
);
543 (void) arc_read(scn
->scn_zio_root
, scn
->scn_dp
->dp_spa
, bp
,
544 NULL
, NULL
, ZIO_PRIORITY_ASYNC_READ
,
545 ZIO_FLAG_CANFAIL
| ZIO_FLAG_SCAN_THREAD
, &flags
, &czb
);
549 dsl_scan_check_resume(dsl_scan_t
*scn
, const dnode_phys_t
*dnp
,
550 const zbookmark_t
*zb
)
553 * We never skip over user/group accounting objects (obj<0)
555 if (!ZB_IS_ZERO(&scn
->scn_phys
.scn_bookmark
) &&
556 (int64_t)zb
->zb_object
>= 0) {
558 * If we already visited this bp & everything below (in
559 * a prior txg sync), don't bother doing it again.
561 if (zbookmark_is_before(dnp
, zb
, &scn
->scn_phys
.scn_bookmark
))
565 * If we found the block we're trying to resume from, or
566 * we went past it to a different object, zero it out to
567 * indicate that it's OK to start checking for pausing
570 if (bcmp(zb
, &scn
->scn_phys
.scn_bookmark
, sizeof (*zb
)) == 0 ||
571 zb
->zb_object
> scn
->scn_phys
.scn_bookmark
.zb_object
) {
572 dprintf("resuming at %llx/%llx/%llx/%llx\n",
573 (longlong_t
)zb
->zb_objset
,
574 (longlong_t
)zb
->zb_object
,
575 (longlong_t
)zb
->zb_level
,
576 (longlong_t
)zb
->zb_blkid
);
577 bzero(&scn
->scn_phys
.scn_bookmark
, sizeof (*zb
));
584 * Return nonzero on i/o error.
585 * Return new buf to write out in *bufp.
587 inline __attribute__((always_inline
)) static int
588 dsl_scan_recurse(dsl_scan_t
*scn
, dsl_dataset_t
*ds
, dmu_objset_type_t ostype
,
589 dnode_phys_t
*dnp
, const blkptr_t
*bp
,
590 const zbookmark_t
*zb
, dmu_tx_t
*tx
, arc_buf_t
**bufp
)
592 dsl_pool_t
*dp
= scn
->scn_dp
;
593 int zio_flags
= ZIO_FLAG_CANFAIL
| ZIO_FLAG_SCAN_THREAD
;
596 if (BP_GET_LEVEL(bp
) > 0) {
597 uint32_t flags
= ARC_WAIT
;
600 int epb
= BP_GET_LSIZE(bp
) >> SPA_BLKPTRSHIFT
;
602 err
= arc_read(NULL
, dp
->dp_spa
, bp
, arc_getbuf_func
, bufp
,
603 ZIO_PRIORITY_ASYNC_READ
, zio_flags
, &flags
, zb
);
605 scn
->scn_phys
.scn_errors
++;
608 for (i
= 0, cbp
= (*bufp
)->b_data
; i
< epb
; i
++, cbp
++) {
609 dsl_scan_prefetch(scn
, *bufp
, cbp
, zb
->zb_objset
,
610 zb
->zb_object
, zb
->zb_blkid
* epb
+ i
);
612 for (i
= 0, cbp
= (*bufp
)->b_data
; i
< epb
; i
++, cbp
++) {
615 SET_BOOKMARK(&czb
, zb
->zb_objset
, zb
->zb_object
,
617 zb
->zb_blkid
* epb
+ i
);
618 dsl_scan_visitbp(cbp
, &czb
, dnp
,
619 *bufp
, ds
, scn
, ostype
, tx
);
621 } else if (BP_GET_TYPE(bp
) == DMU_OT_USERGROUP_USED
) {
622 uint32_t flags
= ARC_WAIT
;
624 err
= arc_read(NULL
, dp
->dp_spa
, bp
, arc_getbuf_func
, bufp
,
625 ZIO_PRIORITY_ASYNC_READ
, zio_flags
, &flags
, zb
);
627 scn
->scn_phys
.scn_errors
++;
630 } else if (BP_GET_TYPE(bp
) == DMU_OT_DNODE
) {
631 uint32_t flags
= ARC_WAIT
;
634 int epb
= BP_GET_LSIZE(bp
) >> DNODE_SHIFT
;
636 err
= arc_read(NULL
, dp
->dp_spa
, bp
, arc_getbuf_func
, bufp
,
637 ZIO_PRIORITY_ASYNC_READ
, zio_flags
, &flags
, zb
);
639 scn
->scn_phys
.scn_errors
++;
642 for (i
= 0, cdnp
= (*bufp
)->b_data
; i
< epb
; i
++, cdnp
++) {
643 for (j
= 0; j
< cdnp
->dn_nblkptr
; j
++) {
644 blkptr_t
*cbp
= &cdnp
->dn_blkptr
[j
];
645 dsl_scan_prefetch(scn
, *bufp
, cbp
,
646 zb
->zb_objset
, zb
->zb_blkid
* epb
+ i
, j
);
649 for (i
= 0, cdnp
= (*bufp
)->b_data
; i
< epb
; i
++, cdnp
++) {
650 dsl_scan_visitdnode(scn
, ds
, ostype
,
651 cdnp
, *bufp
, zb
->zb_blkid
* epb
+ i
, tx
);
654 } else if (BP_GET_TYPE(bp
) == DMU_OT_OBJSET
) {
655 uint32_t flags
= ARC_WAIT
;
658 err
= arc_read(NULL
, dp
->dp_spa
, bp
, arc_getbuf_func
, bufp
,
659 ZIO_PRIORITY_ASYNC_READ
, zio_flags
, &flags
, zb
);
661 scn
->scn_phys
.scn_errors
++;
665 osp
= (*bufp
)->b_data
;
667 dsl_scan_visitdnode(scn
, ds
, osp
->os_type
,
668 &osp
->os_meta_dnode
, *bufp
, DMU_META_DNODE_OBJECT
, tx
);
670 if (OBJSET_BUF_HAS_USERUSED(*bufp
)) {
672 * We also always visit user/group accounting
673 * objects, and never skip them, even if we are
674 * pausing. This is necessary so that the space
675 * deltas from this txg get integrated.
677 dsl_scan_visitdnode(scn
, ds
, osp
->os_type
,
678 &osp
->os_groupused_dnode
, *bufp
,
679 DMU_GROUPUSED_OBJECT
, tx
);
680 dsl_scan_visitdnode(scn
, ds
, osp
->os_type
,
681 &osp
->os_userused_dnode
, *bufp
,
682 DMU_USERUSED_OBJECT
, tx
);
689 inline __attribute__((always_inline
)) static void
690 dsl_scan_visitdnode(dsl_scan_t
*scn
, dsl_dataset_t
*ds
,
691 dmu_objset_type_t ostype
, dnode_phys_t
*dnp
, arc_buf_t
*buf
,
692 uint64_t object
, dmu_tx_t
*tx
)
696 for (j
= 0; j
< dnp
->dn_nblkptr
; j
++) {
699 SET_BOOKMARK(&czb
, ds
? ds
->ds_object
: 0, object
,
700 dnp
->dn_nlevels
- 1, j
);
701 dsl_scan_visitbp(&dnp
->dn_blkptr
[j
],
702 &czb
, dnp
, buf
, ds
, scn
, ostype
, tx
);
705 if (dnp
->dn_flags
& DNODE_FLAG_SPILL_BLKPTR
) {
707 SET_BOOKMARK(&czb
, ds
? ds
->ds_object
: 0, object
,
709 dsl_scan_visitbp(&dnp
->dn_spill
,
710 &czb
, dnp
, buf
, ds
, scn
, ostype
, tx
);
715 * The arguments are in this order because mdb can only print the
716 * first 5; we want them to be useful.
719 dsl_scan_visitbp(blkptr_t
*bp
, const zbookmark_t
*zb
,
720 dnode_phys_t
*dnp
, arc_buf_t
*pbuf
,
721 dsl_dataset_t
*ds
, dsl_scan_t
*scn
, dmu_objset_type_t ostype
,
724 dsl_pool_t
*dp
= scn
->scn_dp
;
725 arc_buf_t
*buf
= NULL
;
728 bp_toread
= kmem_alloc(sizeof (blkptr_t
), KM_PUSHPAGE
);
731 /* ASSERT(pbuf == NULL || arc_released(pbuf)); */
733 if (dsl_scan_check_pause(scn
, zb
))
736 if (dsl_scan_check_resume(scn
, dnp
, zb
))
739 if (bp
->blk_birth
== 0)
742 scn
->scn_visited_this_txg
++;
745 * This debugging is commented out to conserve stack space. This
746 * function is called recursively and the debugging addes several
747 * bytes to the stack for each call. It can be commented back in
748 * if required to debug an issue in dsl_scan_visitbp().
751 * "visiting ds=%p/%llu zb=%llx/%llx/%llx/%llx buf=%p bp=%p",
752 * ds, ds ? ds->ds_object : 0,
753 * zb->zb_objset, zb->zb_object, zb->zb_level, zb->zb_blkid,
757 if (bp
->blk_birth
<= scn
->scn_phys
.scn_cur_min_txg
)
760 if (dsl_scan_recurse(scn
, ds
, ostype
, dnp
, bp_toread
, zb
, tx
,
765 * If dsl_scan_ddt() has aready visited this block, it will have
766 * already done any translations or scrubbing, so don't call the
769 if (ddt_class_contains(dp
->dp_spa
,
770 scn
->scn_phys
.scn_ddt_class_max
, bp
)) {
776 * If this block is from the future (after cur_max_txg), then we
777 * are doing this on behalf of a deleted snapshot, and we will
778 * revisit the future block on the next pass of this dataset.
779 * Don't scan it now unless we need to because something
780 * under it was modified.
782 if (BP_PHYSICAL_BIRTH(bp
) <= scn
->scn_phys
.scn_cur_max_txg
) {
783 scan_funcs
[scn
->scn_phys
.scn_func
](dp
, bp
, zb
);
786 (void) arc_buf_remove_ref(buf
, &buf
);
788 kmem_free(bp_toread
, sizeof (blkptr_t
));
792 dsl_scan_visit_rootbp(dsl_scan_t
*scn
, dsl_dataset_t
*ds
, blkptr_t
*bp
,
797 SET_BOOKMARK(&zb
, ds
? ds
->ds_object
: DMU_META_OBJSET
,
798 ZB_ROOT_OBJECT
, ZB_ROOT_LEVEL
, ZB_ROOT_BLKID
);
799 dsl_scan_visitbp(bp
, &zb
, NULL
, NULL
,
800 ds
, scn
, DMU_OST_NONE
, tx
);
802 dprintf_ds(ds
, "finished scan%s", "");
806 dsl_scan_ds_destroyed(dsl_dataset_t
*ds
, dmu_tx_t
*tx
)
808 dsl_pool_t
*dp
= ds
->ds_dir
->dd_pool
;
809 dsl_scan_t
*scn
= dp
->dp_scan
;
812 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
815 if (scn
->scn_phys
.scn_bookmark
.zb_objset
== ds
->ds_object
) {
816 if (dsl_dataset_is_snapshot(ds
)) {
817 /* Note, scn_cur_{min,max}_txg stays the same. */
818 scn
->scn_phys
.scn_bookmark
.zb_objset
=
819 ds
->ds_phys
->ds_next_snap_obj
;
820 zfs_dbgmsg("destroying ds %llu; currently traversing; "
821 "reset zb_objset to %llu",
822 (u_longlong_t
)ds
->ds_object
,
823 (u_longlong_t
)ds
->ds_phys
->ds_next_snap_obj
);
824 scn
->scn_phys
.scn_flags
|= DSF_VISIT_DS_AGAIN
;
826 SET_BOOKMARK(&scn
->scn_phys
.scn_bookmark
,
827 ZB_DESTROYED_OBJSET
, 0, 0, 0);
828 zfs_dbgmsg("destroying ds %llu; currently traversing; "
829 "reset bookmark to -1,0,0,0",
830 (u_longlong_t
)ds
->ds_object
);
832 } else if (zap_lookup_int_key(dp
->dp_meta_objset
,
833 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
, &mintxg
) == 0) {
834 ASSERT3U(ds
->ds_phys
->ds_num_children
, <=, 1);
835 VERIFY3U(0, ==, zap_remove_int(dp
->dp_meta_objset
,
836 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
, tx
));
837 if (dsl_dataset_is_snapshot(ds
)) {
839 * We keep the same mintxg; it could be >
840 * ds_creation_txg if the previous snapshot was
843 VERIFY(zap_add_int_key(dp
->dp_meta_objset
,
844 scn
->scn_phys
.scn_queue_obj
,
845 ds
->ds_phys
->ds_next_snap_obj
, mintxg
, tx
) == 0);
846 zfs_dbgmsg("destroying ds %llu; in queue; "
847 "replacing with %llu",
848 (u_longlong_t
)ds
->ds_object
,
849 (u_longlong_t
)ds
->ds_phys
->ds_next_snap_obj
);
851 zfs_dbgmsg("destroying ds %llu; in queue; removing",
852 (u_longlong_t
)ds
->ds_object
);
855 zfs_dbgmsg("destroying ds %llu; ignoring",
856 (u_longlong_t
)ds
->ds_object
);
860 * dsl_scan_sync() should be called after this, and should sync
861 * out our changed state, but just to be safe, do it here.
863 dsl_scan_sync_state(scn
, tx
);
867 dsl_scan_ds_snapshotted(dsl_dataset_t
*ds
, dmu_tx_t
*tx
)
869 dsl_pool_t
*dp
= ds
->ds_dir
->dd_pool
;
870 dsl_scan_t
*scn
= dp
->dp_scan
;
873 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
876 ASSERT(ds
->ds_phys
->ds_prev_snap_obj
!= 0);
878 if (scn
->scn_phys
.scn_bookmark
.zb_objset
== ds
->ds_object
) {
879 scn
->scn_phys
.scn_bookmark
.zb_objset
=
880 ds
->ds_phys
->ds_prev_snap_obj
;
881 zfs_dbgmsg("snapshotting ds %llu; currently traversing; "
882 "reset zb_objset to %llu",
883 (u_longlong_t
)ds
->ds_object
,
884 (u_longlong_t
)ds
->ds_phys
->ds_prev_snap_obj
);
885 } else if (zap_lookup_int_key(dp
->dp_meta_objset
,
886 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
, &mintxg
) == 0) {
887 VERIFY3U(0, ==, zap_remove_int(dp
->dp_meta_objset
,
888 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
, tx
));
889 VERIFY(zap_add_int_key(dp
->dp_meta_objset
,
890 scn
->scn_phys
.scn_queue_obj
,
891 ds
->ds_phys
->ds_prev_snap_obj
, mintxg
, tx
) == 0);
892 zfs_dbgmsg("snapshotting ds %llu; in queue; "
893 "replacing with %llu",
894 (u_longlong_t
)ds
->ds_object
,
895 (u_longlong_t
)ds
->ds_phys
->ds_prev_snap_obj
);
897 dsl_scan_sync_state(scn
, tx
);
901 dsl_scan_ds_clone_swapped(dsl_dataset_t
*ds1
, dsl_dataset_t
*ds2
, dmu_tx_t
*tx
)
903 dsl_pool_t
*dp
= ds1
->ds_dir
->dd_pool
;
904 dsl_scan_t
*scn
= dp
->dp_scan
;
907 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
910 if (scn
->scn_phys
.scn_bookmark
.zb_objset
== ds1
->ds_object
) {
911 scn
->scn_phys
.scn_bookmark
.zb_objset
= ds2
->ds_object
;
912 zfs_dbgmsg("clone_swap ds %llu; currently traversing; "
913 "reset zb_objset to %llu",
914 (u_longlong_t
)ds1
->ds_object
,
915 (u_longlong_t
)ds2
->ds_object
);
916 } else if (scn
->scn_phys
.scn_bookmark
.zb_objset
== ds2
->ds_object
) {
917 scn
->scn_phys
.scn_bookmark
.zb_objset
= ds1
->ds_object
;
918 zfs_dbgmsg("clone_swap ds %llu; currently traversing; "
919 "reset zb_objset to %llu",
920 (u_longlong_t
)ds2
->ds_object
,
921 (u_longlong_t
)ds1
->ds_object
);
924 if (zap_lookup_int_key(dp
->dp_meta_objset
, scn
->scn_phys
.scn_queue_obj
,
925 ds1
->ds_object
, &mintxg
) == 0) {
928 ASSERT3U(mintxg
, ==, ds1
->ds_phys
->ds_prev_snap_txg
);
929 ASSERT3U(mintxg
, ==, ds2
->ds_phys
->ds_prev_snap_txg
);
930 VERIFY3U(0, ==, zap_remove_int(dp
->dp_meta_objset
,
931 scn
->scn_phys
.scn_queue_obj
, ds1
->ds_object
, tx
));
932 err
= zap_add_int_key(dp
->dp_meta_objset
,
933 scn
->scn_phys
.scn_queue_obj
, ds2
->ds_object
, mintxg
, tx
);
934 VERIFY(err
== 0 || err
== EEXIST
);
936 /* Both were there to begin with */
937 VERIFY(0 == zap_add_int_key(dp
->dp_meta_objset
,
938 scn
->scn_phys
.scn_queue_obj
,
939 ds1
->ds_object
, mintxg
, tx
));
941 zfs_dbgmsg("clone_swap ds %llu; in queue; "
942 "replacing with %llu",
943 (u_longlong_t
)ds1
->ds_object
,
944 (u_longlong_t
)ds2
->ds_object
);
945 } else if (zap_lookup_int_key(dp
->dp_meta_objset
,
946 scn
->scn_phys
.scn_queue_obj
, ds2
->ds_object
, &mintxg
) == 0) {
947 ASSERT3U(mintxg
, ==, ds1
->ds_phys
->ds_prev_snap_txg
);
948 ASSERT3U(mintxg
, ==, ds2
->ds_phys
->ds_prev_snap_txg
);
949 VERIFY3U(0, ==, zap_remove_int(dp
->dp_meta_objset
,
950 scn
->scn_phys
.scn_queue_obj
, ds2
->ds_object
, tx
));
951 VERIFY(0 == zap_add_int_key(dp
->dp_meta_objset
,
952 scn
->scn_phys
.scn_queue_obj
, ds1
->ds_object
, mintxg
, tx
));
953 zfs_dbgmsg("clone_swap ds %llu; in queue; "
954 "replacing with %llu",
955 (u_longlong_t
)ds2
->ds_object
,
956 (u_longlong_t
)ds1
->ds_object
);
959 dsl_scan_sync_state(scn
, tx
);
962 struct enqueue_clones_arg
{
969 enqueue_clones_cb(dsl_pool_t
*dp
, dsl_dataset_t
*hds
, void *arg
)
971 struct enqueue_clones_arg
*eca
= arg
;
974 dsl_scan_t
*scn
= dp
->dp_scan
;
976 if (hds
->ds_dir
->dd_phys
->dd_origin_obj
!= eca
->originobj
)
979 err
= dsl_dataset_hold_obj(dp
, hds
->ds_object
, FTAG
, &ds
);
983 while (ds
->ds_phys
->ds_prev_snap_obj
!= eca
->originobj
) {
985 err
= dsl_dataset_hold_obj(dp
,
986 ds
->ds_phys
->ds_prev_snap_obj
, FTAG
, &prev
);
988 dsl_dataset_rele(ds
, FTAG
);
993 VERIFY(zap_add_int_key(dp
->dp_meta_objset
,
994 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
,
995 ds
->ds_phys
->ds_prev_snap_txg
, eca
->tx
) == 0);
996 dsl_dataset_rele(ds
, FTAG
);
1001 dsl_scan_visitds(dsl_scan_t
*scn
, uint64_t dsobj
, dmu_tx_t
*tx
)
1003 dsl_pool_t
*dp
= scn
->scn_dp
;
1008 VERIFY3U(0, ==, dsl_dataset_hold_obj(dp
, dsobj
, FTAG
, &ds
));
1010 if (dmu_objset_from_ds(ds
, &os
))
1014 * Only the ZIL in the head (non-snapshot) is valid. Even though
1015 * snapshots can have ZIL block pointers (which may be the same
1016 * BP as in the head), they must be ignored. So we traverse the
1017 * ZIL here, rather than in scan_recurse(), because the regular
1018 * snapshot block-sharing rules don't apply to it.
1020 if (DSL_SCAN_IS_SCRUB_RESILVER(scn
) && !dsl_dataset_is_snapshot(ds
))
1021 dsl_scan_zil(dp
, &os
->os_zil_header
);
1024 * Iterate over the bps in this ds.
1026 dmu_buf_will_dirty(ds
->ds_dbuf
, tx
);
1027 dsl_scan_visit_rootbp(scn
, ds
, &ds
->ds_phys
->ds_bp
, tx
);
1029 dsname
= kmem_alloc(ZFS_MAXNAMELEN
, KM_PUSHPAGE
);
1030 dsl_dataset_name(ds
, dsname
);
1031 zfs_dbgmsg("scanned dataset %llu (%s) with min=%llu max=%llu; "
1033 (longlong_t
)dsobj
, dsname
,
1034 (longlong_t
)scn
->scn_phys
.scn_cur_min_txg
,
1035 (longlong_t
)scn
->scn_phys
.scn_cur_max_txg
,
1036 (int)scn
->scn_pausing
);
1037 kmem_free(dsname
, ZFS_MAXNAMELEN
);
1039 if (scn
->scn_pausing
)
1043 * We've finished this pass over this dataset.
1047 * If we did not completely visit this dataset, do another pass.
1049 if (scn
->scn_phys
.scn_flags
& DSF_VISIT_DS_AGAIN
) {
1050 zfs_dbgmsg("incomplete pass; visiting again");
1051 scn
->scn_phys
.scn_flags
&= ~DSF_VISIT_DS_AGAIN
;
1052 VERIFY(zap_add_int_key(dp
->dp_meta_objset
,
1053 scn
->scn_phys
.scn_queue_obj
, ds
->ds_object
,
1054 scn
->scn_phys
.scn_cur_max_txg
, tx
) == 0);
1059 * Add descendent datasets to work queue.
1061 if (ds
->ds_phys
->ds_next_snap_obj
!= 0) {
1062 VERIFY(zap_add_int_key(dp
->dp_meta_objset
,
1063 scn
->scn_phys
.scn_queue_obj
, ds
->ds_phys
->ds_next_snap_obj
,
1064 ds
->ds_phys
->ds_creation_txg
, tx
) == 0);
1066 if (ds
->ds_phys
->ds_num_children
> 1) {
1067 boolean_t usenext
= B_FALSE
;
1068 if (ds
->ds_phys
->ds_next_clones_obj
!= 0) {
1071 * A bug in a previous version of the code could
1072 * cause upgrade_clones_cb() to not set
1073 * ds_next_snap_obj when it should, leading to a
1074 * missing entry. Therefore we can only use the
1075 * next_clones_obj when its count is correct.
1077 int err
= zap_count(dp
->dp_meta_objset
,
1078 ds
->ds_phys
->ds_next_clones_obj
, &count
);
1080 count
== ds
->ds_phys
->ds_num_children
- 1)
1085 VERIFY0(zap_join_key(dp
->dp_meta_objset
,
1086 ds
->ds_phys
->ds_next_clones_obj
,
1087 scn
->scn_phys
.scn_queue_obj
,
1088 ds
->ds_phys
->ds_creation_txg
, tx
));
1090 struct enqueue_clones_arg eca
;
1092 eca
.originobj
= ds
->ds_object
;
1094 VERIFY0(dmu_objset_find_dp(dp
, dp
->dp_root_dir_obj
,
1095 enqueue_clones_cb
, &eca
, DS_FIND_CHILDREN
));
1100 dsl_dataset_rele(ds
, FTAG
);
1105 enqueue_cb(dsl_pool_t
*dp
, dsl_dataset_t
*hds
, void *arg
)
1110 dsl_scan_t
*scn
= dp
->dp_scan
;
1112 err
= dsl_dataset_hold_obj(dp
, hds
->ds_object
, FTAG
, &ds
);
1116 while (ds
->ds_phys
->ds_prev_snap_obj
!= 0) {
1117 dsl_dataset_t
*prev
;
1118 err
= dsl_dataset_hold_obj(dp
, ds
->ds_phys
->ds_prev_snap_obj
,
1121 dsl_dataset_rele(ds
, FTAG
);
1126 * If this is a clone, we don't need to worry about it for now.
1128 if (prev
->ds_phys
->ds_next_snap_obj
!= ds
->ds_object
) {
1129 dsl_dataset_rele(ds
, FTAG
);
1130 dsl_dataset_rele(prev
, FTAG
);
1133 dsl_dataset_rele(ds
, FTAG
);
1137 VERIFY(zap_add_int_key(dp
->dp_meta_objset
, scn
->scn_phys
.scn_queue_obj
,
1138 ds
->ds_object
, ds
->ds_phys
->ds_prev_snap_txg
, tx
) == 0);
1139 dsl_dataset_rele(ds
, FTAG
);
1144 * Scrub/dedup interaction.
1146 * If there are N references to a deduped block, we don't want to scrub it
1147 * N times -- ideally, we should scrub it exactly once.
1149 * We leverage the fact that the dde's replication class (enum ddt_class)
1150 * is ordered from highest replication class (DDT_CLASS_DITTO) to lowest
1151 * (DDT_CLASS_UNIQUE) so that we may walk the DDT in that order.
1153 * To prevent excess scrubbing, the scrub begins by walking the DDT
1154 * to find all blocks with refcnt > 1, and scrubs each of these once.
1155 * Since there are two replication classes which contain blocks with
1156 * refcnt > 1, we scrub the highest replication class (DDT_CLASS_DITTO) first.
1157 * Finally the top-down scrub begins, only visiting blocks with refcnt == 1.
1159 * There would be nothing more to say if a block's refcnt couldn't change
1160 * during a scrub, but of course it can so we must account for changes
1161 * in a block's replication class.
1163 * Here's an example of what can occur:
1165 * If a block has refcnt > 1 during the DDT scrub phase, but has refcnt == 1
1166 * when visited during the top-down scrub phase, it will be scrubbed twice.
1167 * This negates our scrub optimization, but is otherwise harmless.
1169 * If a block has refcnt == 1 during the DDT scrub phase, but has refcnt > 1
1170 * on each visit during the top-down scrub phase, it will never be scrubbed.
1171 * To catch this, ddt_sync_entry() notifies the scrub code whenever a block's
1172 * reference class transitions to a higher level (i.e DDT_CLASS_UNIQUE to
1173 * DDT_CLASS_DUPLICATE); if it transitions from refcnt == 1 to refcnt > 1
1174 * while a scrub is in progress, it scrubs the block right then.
1177 dsl_scan_ddt(dsl_scan_t
*scn
, dmu_tx_t
*tx
)
1179 ddt_bookmark_t
*ddb
= &scn
->scn_phys
.scn_ddt_bookmark
;
1184 bzero(&dde
, sizeof (ddt_entry_t
));
1186 while ((error
= ddt_walk(scn
->scn_dp
->dp_spa
, ddb
, &dde
)) == 0) {
1189 if (ddb
->ddb_class
> scn
->scn_phys
.scn_ddt_class_max
)
1191 dprintf("visiting ddb=%llu/%llu/%llu/%llx\n",
1192 (longlong_t
)ddb
->ddb_class
,
1193 (longlong_t
)ddb
->ddb_type
,
1194 (longlong_t
)ddb
->ddb_checksum
,
1195 (longlong_t
)ddb
->ddb_cursor
);
1197 /* There should be no pending changes to the dedup table */
1198 ddt
= scn
->scn_dp
->dp_spa
->spa_ddt
[ddb
->ddb_checksum
];
1199 ASSERT(avl_first(&ddt
->ddt_tree
) == NULL
);
1201 dsl_scan_ddt_entry(scn
, ddb
->ddb_checksum
, &dde
, tx
);
1204 if (dsl_scan_check_pause(scn
, NULL
))
1208 zfs_dbgmsg("scanned %llu ddt entries with class_max = %u; pausing=%u",
1209 (longlong_t
)n
, (int)scn
->scn_phys
.scn_ddt_class_max
,
1210 (int)scn
->scn_pausing
);
1212 ASSERT(error
== 0 || error
== ENOENT
);
1213 ASSERT(error
!= ENOENT
||
1214 ddb
->ddb_class
> scn
->scn_phys
.scn_ddt_class_max
);
1219 dsl_scan_ddt_entry(dsl_scan_t
*scn
, enum zio_checksum checksum
,
1220 ddt_entry_t
*dde
, dmu_tx_t
*tx
)
1222 const ddt_key_t
*ddk
= &dde
->dde_key
;
1223 ddt_phys_t
*ddp
= dde
->dde_phys
;
1225 zbookmark_t zb
= { 0 };
1228 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
1231 for (p
= 0; p
< DDT_PHYS_TYPES
; p
++, ddp
++) {
1232 if (ddp
->ddp_phys_birth
== 0 ||
1233 ddp
->ddp_phys_birth
> scn
->scn_phys
.scn_max_txg
)
1235 ddt_bp_create(checksum
, ddk
, ddp
, &bp
);
1237 scn
->scn_visited_this_txg
++;
1238 scan_funcs
[scn
->scn_phys
.scn_func
](scn
->scn_dp
, &bp
, &zb
);
1243 dsl_scan_visit(dsl_scan_t
*scn
, dmu_tx_t
*tx
)
1245 dsl_pool_t
*dp
= scn
->scn_dp
;
1247 zap_attribute_t
*za
;
1249 if (scn
->scn_phys
.scn_ddt_bookmark
.ddb_class
<=
1250 scn
->scn_phys
.scn_ddt_class_max
) {
1251 scn
->scn_phys
.scn_cur_min_txg
= scn
->scn_phys
.scn_min_txg
;
1252 scn
->scn_phys
.scn_cur_max_txg
= scn
->scn_phys
.scn_max_txg
;
1253 dsl_scan_ddt(scn
, tx
);
1254 if (scn
->scn_pausing
)
1258 if (scn
->scn_phys
.scn_bookmark
.zb_objset
== DMU_META_OBJSET
) {
1259 /* First do the MOS & ORIGIN */
1261 scn
->scn_phys
.scn_cur_min_txg
= scn
->scn_phys
.scn_min_txg
;
1262 scn
->scn_phys
.scn_cur_max_txg
= scn
->scn_phys
.scn_max_txg
;
1263 dsl_scan_visit_rootbp(scn
, NULL
,
1264 &dp
->dp_meta_rootbp
, tx
);
1265 spa_set_rootblkptr(dp
->dp_spa
, &dp
->dp_meta_rootbp
);
1266 if (scn
->scn_pausing
)
1269 if (spa_version(dp
->dp_spa
) < SPA_VERSION_DSL_SCRUB
) {
1270 VERIFY0(dmu_objset_find_dp(dp
, dp
->dp_root_dir_obj
,
1271 enqueue_cb
, tx
, DS_FIND_CHILDREN
));
1273 dsl_scan_visitds(scn
,
1274 dp
->dp_origin_snap
->ds_object
, tx
);
1276 ASSERT(!scn
->scn_pausing
);
1277 } else if (scn
->scn_phys
.scn_bookmark
.zb_objset
!=
1278 ZB_DESTROYED_OBJSET
) {
1280 * If we were paused, continue from here. Note if the
1281 * ds we were paused on was deleted, the zb_objset may
1282 * be -1, so we will skip this and find a new objset
1285 dsl_scan_visitds(scn
, scn
->scn_phys
.scn_bookmark
.zb_objset
, tx
);
1286 if (scn
->scn_pausing
)
1291 * In case we were paused right at the end of the ds, zero the
1292 * bookmark so we don't think that we're still trying to resume.
1294 bzero(&scn
->scn_phys
.scn_bookmark
, sizeof (zbookmark_t
));
1295 zc
= kmem_alloc(sizeof (zap_cursor_t
), KM_PUSHPAGE
);
1296 za
= kmem_alloc(sizeof (zap_attribute_t
), KM_PUSHPAGE
);
1298 /* keep pulling things out of the zap-object-as-queue */
1299 while (zap_cursor_init(zc
, dp
->dp_meta_objset
,
1300 scn
->scn_phys
.scn_queue_obj
),
1301 zap_cursor_retrieve(zc
, za
) == 0) {
1305 dsobj
= strtonum(za
->za_name
, NULL
);
1306 VERIFY3U(0, ==, zap_remove_int(dp
->dp_meta_objset
,
1307 scn
->scn_phys
.scn_queue_obj
, dsobj
, tx
));
1309 /* Set up min/max txg */
1310 VERIFY3U(0, ==, dsl_dataset_hold_obj(dp
, dsobj
, FTAG
, &ds
));
1311 if (za
->za_first_integer
!= 0) {
1312 scn
->scn_phys
.scn_cur_min_txg
=
1313 MAX(scn
->scn_phys
.scn_min_txg
,
1314 za
->za_first_integer
);
1316 scn
->scn_phys
.scn_cur_min_txg
=
1317 MAX(scn
->scn_phys
.scn_min_txg
,
1318 ds
->ds_phys
->ds_prev_snap_txg
);
1320 scn
->scn_phys
.scn_cur_max_txg
= dsl_scan_ds_maxtxg(ds
);
1321 dsl_dataset_rele(ds
, FTAG
);
1323 dsl_scan_visitds(scn
, dsobj
, tx
);
1324 zap_cursor_fini(zc
);
1325 if (scn
->scn_pausing
)
1328 zap_cursor_fini(zc
);
1330 kmem_free(za
, sizeof (zap_attribute_t
));
1331 kmem_free(zc
, sizeof (zap_cursor_t
));
1335 dsl_scan_free_should_pause(dsl_scan_t
*scn
)
1337 uint64_t elapsed_nanosecs
;
1342 elapsed_nanosecs
= gethrtime() - scn
->scn_sync_start_time
;
1343 return (elapsed_nanosecs
/ NANOSEC
> zfs_txg_timeout
||
1344 (NSEC2MSEC(elapsed_nanosecs
) > zfs_free_min_time_ms
&&
1345 txg_sync_waiting(scn
->scn_dp
)) ||
1346 spa_shutting_down(scn
->scn_dp
->dp_spa
));
1350 dsl_scan_free_block_cb(void *arg
, const blkptr_t
*bp
, dmu_tx_t
*tx
)
1352 dsl_scan_t
*scn
= arg
;
1354 if (!scn
->scn_is_bptree
||
1355 (BP_GET_LEVEL(bp
) == 0 && BP_GET_TYPE(bp
) != DMU_OT_OBJSET
)) {
1356 if (dsl_scan_free_should_pause(scn
))
1357 return (SET_ERROR(ERESTART
));
1360 zio_nowait(zio_free_sync(scn
->scn_zio_root
, scn
->scn_dp
->dp_spa
,
1361 dmu_tx_get_txg(tx
), bp
, 0));
1362 dsl_dir_diduse_space(tx
->tx_pool
->dp_free_dir
, DD_USED_HEAD
,
1363 -bp_get_dsize_sync(scn
->scn_dp
->dp_spa
, bp
),
1364 -BP_GET_PSIZE(bp
), -BP_GET_UCSIZE(bp
), tx
);
1365 scn
->scn_visited_this_txg
++;
1370 dsl_scan_active(dsl_scan_t
*scn
)
1372 spa_t
*spa
= scn
->scn_dp
->dp_spa
;
1373 uint64_t used
= 0, comp
, uncomp
;
1375 if (spa
->spa_load_state
!= SPA_LOAD_NONE
)
1377 if (spa_shutting_down(spa
))
1380 if (scn
->scn_phys
.scn_state
== DSS_SCANNING
||
1381 scn
->scn_async_destroying
)
1384 if (spa_version(scn
->scn_dp
->dp_spa
) >= SPA_VERSION_DEADLISTS
) {
1385 (void) bpobj_space(&scn
->scn_dp
->dp_free_bpobj
,
1386 &used
, &comp
, &uncomp
);
1392 dsl_scan_sync(dsl_pool_t
*dp
, dmu_tx_t
*tx
)
1394 dsl_scan_t
*scn
= dp
->dp_scan
;
1395 spa_t
*spa
= dp
->dp_spa
;
1399 * Check for scn_restart_txg before checking spa_load_state, so
1400 * that we can restart an old-style scan while the pool is being
1401 * imported (see dsl_scan_init).
1403 if (scn
->scn_restart_txg
!= 0 &&
1404 scn
->scn_restart_txg
<= tx
->tx_txg
) {
1405 pool_scan_func_t func
= POOL_SCAN_SCRUB
;
1406 dsl_scan_done(scn
, B_FALSE
, tx
);
1407 if (vdev_resilver_needed(spa
->spa_root_vdev
, NULL
, NULL
))
1408 func
= POOL_SCAN_RESILVER
;
1409 zfs_dbgmsg("restarting scan func=%u txg=%llu",
1411 dsl_scan_setup_sync(&func
, tx
);
1414 if (!dsl_scan_active(scn
) ||
1415 spa_sync_pass(dp
->dp_spa
) > 1)
1418 scn
->scn_visited_this_txg
= 0;
1419 scn
->scn_pausing
= B_FALSE
;
1420 scn
->scn_sync_start_time
= gethrtime();
1421 spa
->spa_scrub_active
= B_TRUE
;
1424 * First process the free list. If we pause the free, don't do
1425 * any scanning. This ensures that there is no free list when
1426 * we are scanning, so the scan code doesn't have to worry about
1429 if (spa_version(dp
->dp_spa
) >= SPA_VERSION_DEADLISTS
) {
1430 scn
->scn_is_bptree
= B_FALSE
;
1431 scn
->scn_zio_root
= zio_root(dp
->dp_spa
, NULL
,
1432 NULL
, ZIO_FLAG_MUSTSUCCEED
);
1433 err
= bpobj_iterate(&dp
->dp_free_bpobj
,
1434 dsl_scan_free_block_cb
, scn
, tx
);
1435 VERIFY3U(0, ==, zio_wait(scn
->scn_zio_root
));
1437 if (err
== 0 && spa_feature_is_active(spa
,
1438 &spa_feature_table
[SPA_FEATURE_ASYNC_DESTROY
])) {
1439 ASSERT(scn
->scn_async_destroying
);
1440 scn
->scn_is_bptree
= B_TRUE
;
1441 scn
->scn_zio_root
= zio_root(dp
->dp_spa
, NULL
,
1442 NULL
, ZIO_FLAG_MUSTSUCCEED
);
1443 err
= bptree_iterate(dp
->dp_meta_objset
,
1444 dp
->dp_bptree_obj
, B_TRUE
, dsl_scan_free_block_cb
,
1446 VERIFY0(zio_wait(scn
->scn_zio_root
));
1449 zfeature_info_t
*feat
= &spa_feature_table
1450 [SPA_FEATURE_ASYNC_DESTROY
];
1451 /* finished; deactivate async destroy feature */
1452 spa_feature_decr(spa
, feat
, tx
);
1453 ASSERT(!spa_feature_is_active(spa
, feat
));
1454 VERIFY0(zap_remove(dp
->dp_meta_objset
,
1455 DMU_POOL_DIRECTORY_OBJECT
,
1456 DMU_POOL_BPTREE_OBJ
, tx
));
1457 VERIFY0(bptree_free(dp
->dp_meta_objset
,
1458 dp
->dp_bptree_obj
, tx
));
1459 dp
->dp_bptree_obj
= 0;
1460 scn
->scn_async_destroying
= B_FALSE
;
1463 if (scn
->scn_visited_this_txg
) {
1464 zfs_dbgmsg("freed %llu blocks in %llums from "
1465 "free_bpobj/bptree txg %llu",
1466 (longlong_t
)scn
->scn_visited_this_txg
,
1468 NSEC2MSEC(gethrtime() - scn
->scn_sync_start_time
),
1469 (longlong_t
)tx
->tx_txg
);
1470 scn
->scn_visited_this_txg
= 0;
1472 * Re-sync the ddt so that we can further modify
1473 * it when doing bprewrite.
1475 ddt_sync(spa
, tx
->tx_txg
);
1477 if (err
== ERESTART
)
1481 if (scn
->scn_phys
.scn_state
!= DSS_SCANNING
)
1484 if (scn
->scn_done_txg
== tx
->tx_txg
) {
1485 ASSERT(!scn
->scn_pausing
);
1486 /* finished with scan. */
1487 zfs_dbgmsg("txg %llu scan complete", tx
->tx_txg
);
1488 dsl_scan_done(scn
, B_TRUE
, tx
);
1489 ASSERT3U(spa
->spa_scrub_inflight
, ==, 0);
1490 dsl_scan_sync_state(scn
, tx
);
1494 if (scn
->scn_phys
.scn_ddt_bookmark
.ddb_class
<=
1495 scn
->scn_phys
.scn_ddt_class_max
) {
1496 zfs_dbgmsg("doing scan sync txg %llu; "
1497 "ddt bm=%llu/%llu/%llu/%llx",
1498 (longlong_t
)tx
->tx_txg
,
1499 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_class
,
1500 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_type
,
1501 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_checksum
,
1502 (longlong_t
)scn
->scn_phys
.scn_ddt_bookmark
.ddb_cursor
);
1503 ASSERT(scn
->scn_phys
.scn_bookmark
.zb_objset
== 0);
1504 ASSERT(scn
->scn_phys
.scn_bookmark
.zb_object
== 0);
1505 ASSERT(scn
->scn_phys
.scn_bookmark
.zb_level
== 0);
1506 ASSERT(scn
->scn_phys
.scn_bookmark
.zb_blkid
== 0);
1508 zfs_dbgmsg("doing scan sync txg %llu; bm=%llu/%llu/%llu/%llu",
1509 (longlong_t
)tx
->tx_txg
,
1510 (longlong_t
)scn
->scn_phys
.scn_bookmark
.zb_objset
,
1511 (longlong_t
)scn
->scn_phys
.scn_bookmark
.zb_object
,
1512 (longlong_t
)scn
->scn_phys
.scn_bookmark
.zb_level
,
1513 (longlong_t
)scn
->scn_phys
.scn_bookmark
.zb_blkid
);
1516 scn
->scn_zio_root
= zio_root(dp
->dp_spa
, NULL
,
1517 NULL
, ZIO_FLAG_CANFAIL
);
1518 dsl_pool_config_enter(dp
, FTAG
);
1519 dsl_scan_visit(scn
, tx
);
1520 dsl_pool_config_exit(dp
, FTAG
);
1521 (void) zio_wait(scn
->scn_zio_root
);
1522 scn
->scn_zio_root
= NULL
;
1524 zfs_dbgmsg("visited %llu blocks in %llums",
1525 (longlong_t
)scn
->scn_visited_this_txg
,
1526 (longlong_t
)NSEC2MSEC(gethrtime() - scn
->scn_sync_start_time
));
1528 if (!scn
->scn_pausing
) {
1529 scn
->scn_done_txg
= tx
->tx_txg
+ 1;
1530 zfs_dbgmsg("txg %llu traversal complete, waiting till txg %llu",
1531 tx
->tx_txg
, scn
->scn_done_txg
);
1534 if (DSL_SCAN_IS_SCRUB_RESILVER(scn
)) {
1535 mutex_enter(&spa
->spa_scrub_lock
);
1536 while (spa
->spa_scrub_inflight
> 0) {
1537 cv_wait(&spa
->spa_scrub_io_cv
,
1538 &spa
->spa_scrub_lock
);
1540 mutex_exit(&spa
->spa_scrub_lock
);
1543 dsl_scan_sync_state(scn
, tx
);
1547 * This will start a new scan, or restart an existing one.
1550 dsl_resilver_restart(dsl_pool_t
*dp
, uint64_t txg
)
1554 tx
= dmu_tx_create_dd(dp
->dp_mos_dir
);
1555 VERIFY(0 == dmu_tx_assign(tx
, TXG_WAIT
));
1557 txg
= dmu_tx_get_txg(tx
);
1558 dp
->dp_scan
->scn_restart_txg
= txg
;
1561 dp
->dp_scan
->scn_restart_txg
= txg
;
1563 zfs_dbgmsg("restarting resilver txg=%llu", txg
);
1567 dsl_scan_resilvering(dsl_pool_t
*dp
)
1569 return (dp
->dp_scan
->scn_phys
.scn_state
== DSS_SCANNING
&&
1570 dp
->dp_scan
->scn_phys
.scn_func
== POOL_SCAN_RESILVER
);
1578 count_block(zfs_all_blkstats_t
*zab
, const blkptr_t
*bp
)
1583 * If we resume after a reboot, zab will be NULL; don't record
1584 * incomplete stats in that case.
1589 for (i
= 0; i
< 4; i
++) {
1590 int l
= (i
< 2) ? BP_GET_LEVEL(bp
) : DN_MAX_LEVELS
;
1591 int t
= (i
& 1) ? BP_GET_TYPE(bp
) : DMU_OT_TOTAL
;
1595 if (t
& DMU_OT_NEWTYPE
)
1598 zb
= &zab
->zab_type
[l
][t
];
1600 zb
->zb_asize
+= BP_GET_ASIZE(bp
);
1601 zb
->zb_lsize
+= BP_GET_LSIZE(bp
);
1602 zb
->zb_psize
+= BP_GET_PSIZE(bp
);
1603 zb
->zb_gangs
+= BP_COUNT_GANG(bp
);
1605 switch (BP_GET_NDVAS(bp
)) {
1607 if (DVA_GET_VDEV(&bp
->blk_dva
[0]) ==
1608 DVA_GET_VDEV(&bp
->blk_dva
[1]))
1609 zb
->zb_ditto_2_of_2_samevdev
++;
1612 equal
= (DVA_GET_VDEV(&bp
->blk_dva
[0]) ==
1613 DVA_GET_VDEV(&bp
->blk_dva
[1])) +
1614 (DVA_GET_VDEV(&bp
->blk_dva
[0]) ==
1615 DVA_GET_VDEV(&bp
->blk_dva
[2])) +
1616 (DVA_GET_VDEV(&bp
->blk_dva
[1]) ==
1617 DVA_GET_VDEV(&bp
->blk_dva
[2]));
1619 zb
->zb_ditto_2_of_3_samevdev
++;
1620 else if (equal
== 3)
1621 zb
->zb_ditto_3_of_3_samevdev
++;
1628 dsl_scan_scrub_done(zio_t
*zio
)
1630 spa_t
*spa
= zio
->io_spa
;
1632 zio_data_buf_free(zio
->io_data
, zio
->io_size
);
1634 mutex_enter(&spa
->spa_scrub_lock
);
1635 spa
->spa_scrub_inflight
--;
1636 cv_broadcast(&spa
->spa_scrub_io_cv
);
1638 if (zio
->io_error
&& (zio
->io_error
!= ECKSUM
||
1639 !(zio
->io_flags
& ZIO_FLAG_SPECULATIVE
))) {
1640 spa
->spa_dsl_pool
->dp_scan
->scn_phys
.scn_errors
++;
1642 mutex_exit(&spa
->spa_scrub_lock
);
1646 dsl_scan_scrub_cb(dsl_pool_t
*dp
,
1647 const blkptr_t
*bp
, const zbookmark_t
*zb
)
1649 dsl_scan_t
*scn
= dp
->dp_scan
;
1650 size_t size
= BP_GET_PSIZE(bp
);
1651 spa_t
*spa
= dp
->dp_spa
;
1652 uint64_t phys_birth
= BP_PHYSICAL_BIRTH(bp
);
1653 boolean_t needs_io
= B_FALSE
;
1654 int zio_flags
= ZIO_FLAG_SCAN_THREAD
| ZIO_FLAG_RAW
| ZIO_FLAG_CANFAIL
;
1658 if (phys_birth
<= scn
->scn_phys
.scn_min_txg
||
1659 phys_birth
>= scn
->scn_phys
.scn_max_txg
)
1662 count_block(dp
->dp_blkstats
, bp
);
1664 ASSERT(DSL_SCAN_IS_SCRUB_RESILVER(scn
));
1665 if (scn
->scn_phys
.scn_func
== POOL_SCAN_SCRUB
) {
1666 zio_flags
|= ZIO_FLAG_SCRUB
;
1668 scan_delay
= zfs_scrub_delay
;
1670 ASSERT3U(scn
->scn_phys
.scn_func
, ==, POOL_SCAN_RESILVER
);
1671 zio_flags
|= ZIO_FLAG_RESILVER
;
1673 scan_delay
= zfs_resilver_delay
;
1676 /* If it's an intent log block, failure is expected. */
1677 if (zb
->zb_level
== ZB_ZIL_LEVEL
)
1678 zio_flags
|= ZIO_FLAG_SPECULATIVE
;
1680 for (d
= 0; d
< BP_GET_NDVAS(bp
); d
++) {
1681 vdev_t
*vd
= vdev_lookup_top(spa
,
1682 DVA_GET_VDEV(&bp
->blk_dva
[d
]));
1685 * Keep track of how much data we've examined so that
1686 * zpool(1M) status can make useful progress reports.
1688 scn
->scn_phys
.scn_examined
+= DVA_GET_ASIZE(&bp
->blk_dva
[d
]);
1689 spa
->spa_scan_pass_exam
+= DVA_GET_ASIZE(&bp
->blk_dva
[d
]);
1691 /* if it's a resilver, this may not be in the target range */
1693 if (DVA_GET_GANG(&bp
->blk_dva
[d
])) {
1695 * Gang members may be spread across multiple
1696 * vdevs, so the best estimate we have is the
1697 * scrub range, which has already been checked.
1698 * XXX -- it would be better to change our
1699 * allocation policy to ensure that all
1700 * gang members reside on the same vdev.
1704 needs_io
= vdev_dtl_contains(vd
, DTL_PARTIAL
,
1710 if (needs_io
&& !zfs_no_scrub_io
) {
1711 vdev_t
*rvd
= spa
->spa_root_vdev
;
1712 uint64_t maxinflight
= rvd
->vdev_children
* zfs_top_maxinflight
;
1713 void *data
= zio_data_buf_alloc(size
);
1715 mutex_enter(&spa
->spa_scrub_lock
);
1716 while (spa
->spa_scrub_inflight
>= maxinflight
)
1717 cv_wait(&spa
->spa_scrub_io_cv
, &spa
->spa_scrub_lock
);
1718 spa
->spa_scrub_inflight
++;
1719 mutex_exit(&spa
->spa_scrub_lock
);
1722 * If we're seeing recent (zfs_scan_idle) "important" I/Os
1723 * then throttle our workload to limit the impact of a scan.
1725 if (ddi_get_lbolt64() - spa
->spa_last_io
<= zfs_scan_idle
)
1728 zio_nowait(zio_read(NULL
, spa
, bp
, data
, size
,
1729 dsl_scan_scrub_done
, NULL
, ZIO_PRIORITY_SCRUB
,
1733 /* do not relocate this block */
1738 dsl_scan(dsl_pool_t
*dp
, pool_scan_func_t func
)
1740 spa_t
*spa
= dp
->dp_spa
;
1743 * Purge all vdev caches and probe all devices. We do this here
1744 * rather than in sync context because this requires a writer lock
1745 * on the spa_config lock, which we can't do from sync context. The
1746 * spa_scrub_reopen flag indicates that vdev_open() should not
1747 * attempt to start another scrub.
1749 spa_vdev_state_enter(spa
, SCL_NONE
);
1750 spa
->spa_scrub_reopen
= B_TRUE
;
1751 vdev_reopen(spa
->spa_root_vdev
);
1752 spa
->spa_scrub_reopen
= B_FALSE
;
1753 (void) spa_vdev_state_exit(spa
, NULL
, 0);
1755 return (dsl_sync_task(spa_name(spa
), dsl_scan_setup_check
,
1756 dsl_scan_setup_sync
, &func
, 0));
1759 #if defined(_KERNEL) && defined(HAVE_SPL)
1760 module_param(zfs_top_maxinflight
, int, 0644);
1761 MODULE_PARM_DESC(zfs_top_maxinflight
, "Max I/Os per top-level");
1763 module_param(zfs_resilver_delay
, int, 0644);
1764 MODULE_PARM_DESC(zfs_resilver_delay
, "Number of ticks to delay resilver");
1766 module_param(zfs_scrub_delay
, int, 0644);
1767 MODULE_PARM_DESC(zfs_scrub_delay
, "Number of ticks to delay scrub");
1769 module_param(zfs_scan_idle
, int, 0644);
1770 MODULE_PARM_DESC(zfs_scan_idle
, "Idle window in clock ticks");
1772 module_param(zfs_scan_min_time_ms
, int, 0644);
1773 MODULE_PARM_DESC(zfs_scan_min_time_ms
, "Min millisecs to scrub per txg");
1775 module_param(zfs_free_min_time_ms
, int, 0644);
1776 MODULE_PARM_DESC(zfs_free_min_time_ms
, "Min millisecs to free per txg");
1778 module_param(zfs_resilver_min_time_ms
, int, 0644);
1779 MODULE_PARM_DESC(zfs_resilver_min_time_ms
, "Min millisecs to resilver per txg");
1781 module_param(zfs_no_scrub_io
, int, 0644);
1782 MODULE_PARM_DESC(zfs_no_scrub_io
, "Set to disable scrub I/O");
1784 module_param(zfs_no_scrub_prefetch
, int, 0644);
1785 MODULE_PARM_DESC(zfs_no_scrub_prefetch
, "Set to disable scrub prefetching");