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) 2018, Intel Corporation.
23 * Copyright (c) 2020 by Lawrence Livermore National Security, LLC.
26 #ifndef _SYS_VDEV_REBUILD_H
27 #define _SYS_VDEV_REBUILD_H
36 * Number of entries in the physical vdev_rebuild_phys structure. This
37 * state is stored per top-level as VDEV_ZAP_TOP_VDEV_REBUILD_PHYS.
39 #define REBUILD_PHYS_ENTRIES 12
42 * On-disk rebuild configuration and state. When adding new fields they
43 * must be added to the end of the structure.
45 typedef struct vdev_rebuild_phys {
46 uint64_t vrp_rebuild_state; /* vdev_rebuild_state_t */
47 uint64_t vrp_last_offset; /* last rebuilt offset */
48 uint64_t vrp_min_txg; /* minimum missing txg */
49 uint64_t vrp_max_txg; /* maximum missing txg */
50 uint64_t vrp_start_time; /* start time */
51 uint64_t vrp_end_time; /* end time */
52 uint64_t vrp_scan_time_ms; /* total run time in ms */
53 uint64_t vrp_bytes_scanned; /* alloc bytes scanned */
54 uint64_t vrp_bytes_issued; /* read bytes rebuilt */
55 uint64_t vrp_bytes_rebuilt; /* rebuilt bytes */
56 uint64_t vrp_bytes_est; /* total bytes to scan */
57 uint64_t vrp_errors; /* errors during rebuild */
58 } vdev_rebuild_phys_t;
61 * The vdev_rebuild_t describes the current state and how a top-level vdev
62 * should be rebuilt. The core elements are the top-vdev, the metaslab being
63 * rebuilt, range tree containing the allocted extents and the on-disk state.
65 typedef struct vdev_rebuild {
66 vdev_t *vr_top_vdev; /* top-level vdev to rebuild */
67 metaslab_t *vr_scan_msp; /* scanning disabled metaslab */
68 range_tree_t *vr_scan_tree; /* scan ranges (in metaslab) */
70 /* In-core state and progress */
71 uint64_t vr_scan_offset[TXG_SIZE];
72 uint64_t vr_prev_scan_time_ms; /* any previous scan time */
74 /* Per-rebuild pass statistics for calculating bandwidth */
75 uint64_t vr_pass_start_time;
76 uint64_t vr_pass_bytes_scanned;
77 uint64_t vr_pass_bytes_issued;
79 /* On-disk state updated by vdev_rebuild_zap_update_sync() */
80 vdev_rebuild_phys_t vr_rebuild_phys;
83 boolean_t vdev_rebuild_active(vdev_t *);
85 int vdev_rebuild_load(vdev_t *);
86 void vdev_rebuild(vdev_t *);
87 void vdev_rebuild_stop_wait(vdev_t *);
88 void vdev_rebuild_stop_all(spa_t *);
89 void vdev_rebuild_restart(spa_t *);
90 void vdev_rebuild_clear_sync(void *, dmu_tx_t *);
91 int vdev_rebuild_get_stats(vdev_t *, vdev_rebuild_stat_t *);
97 #endif /* _SYS_VDEV_REBUILD_H */