]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/sys/vdev_rebuild.h
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / include / sys / vdev_rebuild.h
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2018, Intel Corporation.
23  * Copyright (c) 2020 by Lawrence Livermore National Security, LLC.
24  */
25
26 #ifndef _SYS_VDEV_REBUILD_H
27 #define _SYS_VDEV_REBUILD_H
28
29 #include <sys/spa.h>
30
31 #ifdef  __cplusplus
32 extern "C" {
33 #endif
34
35 /*
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.
38  */
39 #define REBUILD_PHYS_ENTRIES    12
40
41 /*
42  * On-disk rebuild configuration and state.  When adding new fields they
43  * must be added to the end of the structure.
44  */
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;
59
60 /*
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.
64  */
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) */
69
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 */
73
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;
78
79         /* On-disk state updated by vdev_rebuild_zap_update_sync() */
80         vdev_rebuild_phys_t vr_rebuild_phys;
81 } vdev_rebuild_t;
82
83 boolean_t vdev_rebuild_active(vdev_t *);
84
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 *);
92
93 #ifdef  __cplusplus
94 }
95 #endif
96
97 #endif /* _SYS_VDEV_REBUILD_H */