xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/dsl_scan.h (revision 4a92375985c37d61406d66cd2b10ee642eb1f5e7)
13f9d6ad7SLin Ling /*
23f9d6ad7SLin Ling  * CDDL HEADER START
33f9d6ad7SLin Ling  *
43f9d6ad7SLin Ling  * The contents of this file are subject to the terms of the
53f9d6ad7SLin Ling  * Common Development and Distribution License (the "License").
63f9d6ad7SLin Ling  * You may not use this file except in compliance with the License.
73f9d6ad7SLin Ling  *
83f9d6ad7SLin Ling  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93f9d6ad7SLin Ling  * or http://www.opensolaris.org/os/licensing.
103f9d6ad7SLin Ling  * See the License for the specific language governing permissions
113f9d6ad7SLin Ling  * and limitations under the License.
123f9d6ad7SLin Ling  *
133f9d6ad7SLin Ling  * When distributing Covered Code, include this CDDL HEADER in each
143f9d6ad7SLin Ling  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153f9d6ad7SLin Ling  * If applicable, add the following below this CDDL HEADER, with the
163f9d6ad7SLin Ling  * fields enclosed by brackets "[]" replaced with your own identifying
173f9d6ad7SLin Ling  * information: Portions Copyright [yyyy] [name of copyright owner]
183f9d6ad7SLin Ling  *
193f9d6ad7SLin Ling  * CDDL HEADER END
203f9d6ad7SLin Ling  */
213f9d6ad7SLin Ling /*
223f9d6ad7SLin Ling  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23*4a923759SGeorge Wilson  * Copyright (c) 2013 by Delphix. All rights reserved.
243f9d6ad7SLin Ling  */
253f9d6ad7SLin Ling 
263f9d6ad7SLin Ling #ifndef	_SYS_DSL_SCAN_H
273f9d6ad7SLin Ling #define	_SYS_DSL_SCAN_H
283f9d6ad7SLin Ling 
293f9d6ad7SLin Ling #include <sys/zfs_context.h>
303f9d6ad7SLin Ling #include <sys/zio.h>
313f9d6ad7SLin Ling #include <sys/ddt.h>
323f9d6ad7SLin Ling #include <sys/bplist.h>
333f9d6ad7SLin Ling 
343f9d6ad7SLin Ling #ifdef	__cplusplus
353f9d6ad7SLin Ling extern "C" {
363f9d6ad7SLin Ling #endif
373f9d6ad7SLin Ling 
383f9d6ad7SLin Ling struct objset;
393f9d6ad7SLin Ling struct dsl_dir;
403f9d6ad7SLin Ling struct dsl_dataset;
413f9d6ad7SLin Ling struct dsl_pool;
423f9d6ad7SLin Ling struct dmu_tx;
433f9d6ad7SLin Ling 
443f9d6ad7SLin Ling /*
453f9d6ad7SLin Ling  * All members of this structure must be uint64_t, for byteswap
463f9d6ad7SLin Ling  * purposes.
473f9d6ad7SLin Ling  */
483f9d6ad7SLin Ling typedef struct dsl_scan_phys {
493f9d6ad7SLin Ling 	uint64_t scn_func; /* pool_scan_func_t */
503f9d6ad7SLin Ling 	uint64_t scn_state; /* dsl_scan_state_t */
513f9d6ad7SLin Ling 	uint64_t scn_queue_obj;
523f9d6ad7SLin Ling 	uint64_t scn_min_txg;
533f9d6ad7SLin Ling 	uint64_t scn_max_txg;
543f9d6ad7SLin Ling 	uint64_t scn_cur_min_txg;
553f9d6ad7SLin Ling 	uint64_t scn_cur_max_txg;
563f9d6ad7SLin Ling 	uint64_t scn_start_time;
573f9d6ad7SLin Ling 	uint64_t scn_end_time;
583f9d6ad7SLin Ling 	uint64_t scn_to_examine; /* total bytes to be scanned */
593f9d6ad7SLin Ling 	uint64_t scn_examined; /* bytes scanned so far */
603f9d6ad7SLin Ling 	uint64_t scn_to_process;
613f9d6ad7SLin Ling 	uint64_t scn_processed;
623f9d6ad7SLin Ling 	uint64_t scn_errors;	/* scan I/O error count */
633f9d6ad7SLin Ling 	uint64_t scn_ddt_class_max;
643f9d6ad7SLin Ling 	ddt_bookmark_t scn_ddt_bookmark;
653f9d6ad7SLin Ling 	zbookmark_t scn_bookmark;
663f9d6ad7SLin Ling 	uint64_t scn_flags; /* dsl_scan_flags_t */
673f9d6ad7SLin Ling } dsl_scan_phys_t;
683f9d6ad7SLin Ling 
693f9d6ad7SLin Ling #define	SCAN_PHYS_NUMINTS (sizeof (dsl_scan_phys_t) / sizeof (uint64_t))
703f9d6ad7SLin Ling 
713f9d6ad7SLin Ling typedef enum dsl_scan_flags {
723f9d6ad7SLin Ling 	DSF_VISIT_DS_AGAIN = 1<<0,
733f9d6ad7SLin Ling } dsl_scan_flags_t;
743f9d6ad7SLin Ling 
753f9d6ad7SLin Ling typedef struct dsl_scan {
763f9d6ad7SLin Ling 	struct dsl_pool *scn_dp;
773f9d6ad7SLin Ling 
783f9d6ad7SLin Ling 	boolean_t scn_pausing;
793f9d6ad7SLin Ling 	uint64_t scn_restart_txg;
803f9d6ad7SLin Ling 	uint64_t scn_sync_start_time;
81cde58dbcSMatthew Ahrens 	zio_t *scn_zio_root;
823f9d6ad7SLin Ling 
83ad135b5dSChristopher Siden 	/* for freeing blocks */
84ad135b5dSChristopher Siden 	boolean_t scn_is_bptree;
85*4a923759SGeorge Wilson 	boolean_t scn_async_destroying;
86ad135b5dSChristopher Siden 
873f9d6ad7SLin Ling 	/* for debugging / information */
883f9d6ad7SLin Ling 	uint64_t scn_visited_this_txg;
893f9d6ad7SLin Ling 
903f9d6ad7SLin Ling 	dsl_scan_phys_t scn_phys;
913f9d6ad7SLin Ling } dsl_scan_t;
923f9d6ad7SLin Ling 
933f9d6ad7SLin Ling int dsl_scan_init(struct dsl_pool *dp, uint64_t txg);
943f9d6ad7SLin Ling void dsl_scan_fini(struct dsl_pool *dp);
953f9d6ad7SLin Ling void dsl_scan_sync(struct dsl_pool *, dmu_tx_t *);
963f9d6ad7SLin Ling int dsl_scan_cancel(struct dsl_pool *);
973f9d6ad7SLin Ling int dsl_scan(struct dsl_pool *, pool_scan_func_t);
983f9d6ad7SLin Ling void dsl_resilver_restart(struct dsl_pool *, uint64_t txg);
993f9d6ad7SLin Ling boolean_t dsl_scan_resilvering(struct dsl_pool *dp);
1003f9d6ad7SLin Ling boolean_t dsl_dataset_unstable(struct dsl_dataset *ds);
1013f9d6ad7SLin Ling void dsl_scan_ddt_entry(dsl_scan_t *scn, enum zio_checksum checksum,
1023f9d6ad7SLin Ling     ddt_entry_t *dde, dmu_tx_t *tx);
1033f9d6ad7SLin Ling void dsl_scan_ds_destroyed(struct dsl_dataset *ds, struct dmu_tx *tx);
1043f9d6ad7SLin Ling void dsl_scan_ds_snapshotted(struct dsl_dataset *ds, struct dmu_tx *tx);
1053f9d6ad7SLin Ling void dsl_scan_ds_clone_swapped(struct dsl_dataset *ds1, struct dsl_dataset *ds2,
1063f9d6ad7SLin Ling     struct dmu_tx *tx);
107cde58dbcSMatthew Ahrens boolean_t dsl_scan_active(dsl_scan_t *scn);
1083f9d6ad7SLin Ling 
1093f9d6ad7SLin Ling #ifdef	__cplusplus
1103f9d6ad7SLin Ling }
1113f9d6ad7SLin Ling #endif
1123f9d6ad7SLin Ling 
1133f9d6ad7SLin Ling #endif /* _SYS_DSL_SCAN_H */
114