112296SLin.Ling@Sun.COM /* 212296SLin.Ling@Sun.COM * CDDL HEADER START 312296SLin.Ling@Sun.COM * 412296SLin.Ling@Sun.COM * The contents of this file are subject to the terms of the 512296SLin.Ling@Sun.COM * Common Development and Distribution License (the "License"). 612296SLin.Ling@Sun.COM * You may not use this file except in compliance with the License. 712296SLin.Ling@Sun.COM * 812296SLin.Ling@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 912296SLin.Ling@Sun.COM * or http://www.opensolaris.org/os/licensing. 1012296SLin.Ling@Sun.COM * See the License for the specific language governing permissions 1112296SLin.Ling@Sun.COM * and limitations under the License. 1212296SLin.Ling@Sun.COM * 1312296SLin.Ling@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 1412296SLin.Ling@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1512296SLin.Ling@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 1612296SLin.Ling@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 1712296SLin.Ling@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 1812296SLin.Ling@Sun.COM * 1912296SLin.Ling@Sun.COM * CDDL HEADER END 2012296SLin.Ling@Sun.COM */ 2112296SLin.Ling@Sun.COM /* 2212296SLin.Ling@Sun.COM * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2312296SLin.Ling@Sun.COM */ 2412296SLin.Ling@Sun.COM 2512296SLin.Ling@Sun.COM #ifndef _SYS_DSL_SCAN_H 2612296SLin.Ling@Sun.COM #define _SYS_DSL_SCAN_H 2712296SLin.Ling@Sun.COM 2812296SLin.Ling@Sun.COM #include <sys/zfs_context.h> 2912296SLin.Ling@Sun.COM #include <sys/zio.h> 3012296SLin.Ling@Sun.COM #include <sys/ddt.h> 3112296SLin.Ling@Sun.COM #include <sys/bplist.h> 3212296SLin.Ling@Sun.COM 3312296SLin.Ling@Sun.COM #ifdef __cplusplus 3412296SLin.Ling@Sun.COM extern "C" { 3512296SLin.Ling@Sun.COM #endif 3612296SLin.Ling@Sun.COM 3712296SLin.Ling@Sun.COM struct objset; 3812296SLin.Ling@Sun.COM struct dsl_dir; 3912296SLin.Ling@Sun.COM struct dsl_dataset; 4012296SLin.Ling@Sun.COM struct dsl_pool; 4112296SLin.Ling@Sun.COM struct dmu_tx; 4212296SLin.Ling@Sun.COM 4312296SLin.Ling@Sun.COM /* 4412296SLin.Ling@Sun.COM * All members of this structure must be uint64_t, for byteswap 4512296SLin.Ling@Sun.COM * purposes. 4612296SLin.Ling@Sun.COM */ 4712296SLin.Ling@Sun.COM typedef struct dsl_scan_phys { 4812296SLin.Ling@Sun.COM uint64_t scn_func; /* pool_scan_func_t */ 4912296SLin.Ling@Sun.COM uint64_t scn_state; /* dsl_scan_state_t */ 5012296SLin.Ling@Sun.COM uint64_t scn_queue_obj; 5112296SLin.Ling@Sun.COM uint64_t scn_min_txg; 5212296SLin.Ling@Sun.COM uint64_t scn_max_txg; 5312296SLin.Ling@Sun.COM uint64_t scn_cur_min_txg; 5412296SLin.Ling@Sun.COM uint64_t scn_cur_max_txg; 5512296SLin.Ling@Sun.COM uint64_t scn_start_time; 5612296SLin.Ling@Sun.COM uint64_t scn_end_time; 5712296SLin.Ling@Sun.COM uint64_t scn_to_examine; /* total bytes to be scanned */ 5812296SLin.Ling@Sun.COM uint64_t scn_examined; /* bytes scanned so far */ 5912296SLin.Ling@Sun.COM uint64_t scn_to_process; 6012296SLin.Ling@Sun.COM uint64_t scn_processed; 6112296SLin.Ling@Sun.COM uint64_t scn_errors; /* scan I/O error count */ 6212296SLin.Ling@Sun.COM uint64_t scn_ddt_class_max; 6312296SLin.Ling@Sun.COM ddt_bookmark_t scn_ddt_bookmark; 6412296SLin.Ling@Sun.COM zbookmark_t scn_bookmark; 6512296SLin.Ling@Sun.COM uint64_t scn_flags; /* dsl_scan_flags_t */ 6612296SLin.Ling@Sun.COM } dsl_scan_phys_t; 6712296SLin.Ling@Sun.COM 6812296SLin.Ling@Sun.COM #define SCAN_PHYS_NUMINTS (sizeof (dsl_scan_phys_t) / sizeof (uint64_t)) 6912296SLin.Ling@Sun.COM 7012296SLin.Ling@Sun.COM typedef enum dsl_scan_flags { 7112296SLin.Ling@Sun.COM DSF_VISIT_DS_AGAIN = 1<<0, 7212296SLin.Ling@Sun.COM } dsl_scan_flags_t; 7312296SLin.Ling@Sun.COM 7412296SLin.Ling@Sun.COM typedef struct dsl_scan { 7512296SLin.Ling@Sun.COM struct dsl_pool *scn_dp; 7612296SLin.Ling@Sun.COM 7712296SLin.Ling@Sun.COM boolean_t scn_pausing; 7812296SLin.Ling@Sun.COM uint64_t scn_restart_txg; 7912296SLin.Ling@Sun.COM uint64_t scn_sync_start_time; 80*12470SMatthew.Ahrens@Sun.COM zio_t *scn_zio_root; 8112296SLin.Ling@Sun.COM 8212296SLin.Ling@Sun.COM /* for debugging / information */ 8312296SLin.Ling@Sun.COM uint64_t scn_visited_this_txg; 8412296SLin.Ling@Sun.COM 8512296SLin.Ling@Sun.COM dsl_scan_phys_t scn_phys; 8612296SLin.Ling@Sun.COM } dsl_scan_t; 8712296SLin.Ling@Sun.COM 8812296SLin.Ling@Sun.COM int dsl_scan_init(struct dsl_pool *dp, uint64_t txg); 8912296SLin.Ling@Sun.COM void dsl_scan_fini(struct dsl_pool *dp); 9012296SLin.Ling@Sun.COM void dsl_scan_sync(struct dsl_pool *, dmu_tx_t *); 9112296SLin.Ling@Sun.COM int dsl_scan_cancel(struct dsl_pool *); 9212296SLin.Ling@Sun.COM int dsl_scan(struct dsl_pool *, pool_scan_func_t); 9312296SLin.Ling@Sun.COM void dsl_resilver_restart(struct dsl_pool *, uint64_t txg); 9412296SLin.Ling@Sun.COM boolean_t dsl_scan_resilvering(struct dsl_pool *dp); 9512296SLin.Ling@Sun.COM boolean_t dsl_dataset_unstable(struct dsl_dataset *ds); 9612296SLin.Ling@Sun.COM void dsl_scan_ddt_entry(dsl_scan_t *scn, enum zio_checksum checksum, 9712296SLin.Ling@Sun.COM ddt_entry_t *dde, dmu_tx_t *tx); 9812296SLin.Ling@Sun.COM void dsl_scan_ds_destroyed(struct dsl_dataset *ds, struct dmu_tx *tx); 9912296SLin.Ling@Sun.COM void dsl_scan_ds_snapshotted(struct dsl_dataset *ds, struct dmu_tx *tx); 10012296SLin.Ling@Sun.COM void dsl_scan_ds_clone_swapped(struct dsl_dataset *ds1, struct dsl_dataset *ds2, 10112296SLin.Ling@Sun.COM struct dmu_tx *tx); 102*12470SMatthew.Ahrens@Sun.COM boolean_t dsl_scan_active(dsl_scan_t *scn); 10312296SLin.Ling@Sun.COM 10412296SLin.Ling@Sun.COM #ifdef __cplusplus 10512296SLin.Ling@Sun.COM } 10612296SLin.Ling@Sun.COM #endif 10712296SLin.Ling@Sun.COM 10812296SLin.Ling@Sun.COM #endif /* _SYS_DSL_SCAN_H */ 109