2 * Copyright (C) 2018 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it would be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef XFS_SCRUB_XFS_SCRUB_H_
21 #define XFS_SCRUB_XFS_SCRUB_H_
23 #define _PATH_PROC_MOUNTS "/proc/mounts"
25 extern unsigned int nr_threads
;
26 extern unsigned int bg_mode
;
27 extern unsigned int debug
;
30 extern long page_size
;
31 extern bool want_fstrim
;
32 extern bool stderr_isatty
;
33 extern bool stdout_isatty
;
40 #define SCRUB_MODE_DEFAULT SCRUB_MODE_PREEN
48 /* Immutable scrub state. */
50 /* Strings we need for presentation */
56 struct statvfs mnt_sv
;
59 /* Open block devices */
64 /* What does the user want us to do? */
67 /* How does the user want us to react to errors? */
68 enum error_action error_action
;
70 /* fd to filesystem mount point */
73 /* Number of threads for metadata scrubbing */
74 unsigned int nr_io_threads
;
76 /* XFS specific geometry */
77 struct xfs_fsop_geom geo
;
78 struct fs_path fsinfo
;
79 unsigned int agblklog
;
80 unsigned int blocklog
;
81 unsigned int inodelog
;
82 unsigned int inopblog
;
86 /* Data block read verification buffer */
89 /* Mutable scrub state; use lock. */
91 unsigned long long max_errors
;
92 unsigned long long runtime_errors
;
93 unsigned long long errors_found
;
94 unsigned long long warnings_found
;
95 unsigned long long inodes_checked
;
96 unsigned long long bytes_checked
;
97 unsigned long long naming_warnings
;
99 bool preen_triggers
[XFS_SCRUB_TYPE_NR
];
102 /* Phase helper functions */
103 void xfs_shutdown_fs(struct scrub_ctx
*ctx
);
104 bool xfs_cleanup_fs(struct scrub_ctx
*ctx
);
105 bool xfs_setup_fs(struct scrub_ctx
*ctx
);
106 bool xfs_scan_metadata(struct scrub_ctx
*ctx
);
107 bool xfs_scan_inodes(struct scrub_ctx
*ctx
);
108 bool xfs_scan_connections(struct scrub_ctx
*ctx
);
109 bool xfs_scan_blocks(struct scrub_ctx
*ctx
);
110 bool xfs_scan_summary(struct scrub_ctx
*ctx
);
111 bool xfs_repair_fs(struct scrub_ctx
*ctx
);
112 bool xfs_optimize_fs(struct scrub_ctx
*ctx
);
114 /* Progress estimator functions */
115 uint64_t xfs_estimate_inodes(struct scrub_ctx
*ctx
);
116 unsigned int xfs_scrub_estimate_ag_work(struct scrub_ctx
*ctx
);
117 bool xfs_estimate_metadata_work(struct scrub_ctx
*ctx
, uint64_t *items
,
118 unsigned int *nr_threads
, int *rshift
);
119 bool xfs_estimate_inodes_work(struct scrub_ctx
*ctx
, uint64_t *items
,
120 unsigned int *nr_threads
, int *rshift
);
121 bool xfs_estimate_repair_work(struct scrub_ctx
*ctx
, uint64_t *items
,
122 unsigned int *nr_threads
, int *rshift
);
123 bool xfs_estimate_verify_work(struct scrub_ctx
*ctx
, uint64_t *items
,
124 unsigned int *nr_threads
, int *rshift
);
126 #endif /* XFS_SCRUB_XFS_SCRUB_H_ */