1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
6 #ifndef XFS_SCRUB_XFS_SCRUB_H_
7 #define XFS_SCRUB_XFS_SCRUB_H_
9 #define _PATH_PROC_MOUNTS "/proc/mounts"
11 extern unsigned int nr_threads
;
12 extern unsigned int bg_mode
;
13 extern unsigned int debug
;
16 extern long page_size
;
17 extern bool want_fstrim
;
18 extern bool stderr_isatty
;
19 extern bool stdout_isatty
;
20 extern bool is_service
;
33 /* Immutable scrub state. */
35 /* Strings we need for presentation */
40 struct statvfs mnt_sv
;
43 /* Open block devices */
48 /* What does the user want us to do? */
51 /* How does the user want us to react to errors? */
52 enum error_action error_action
;
54 /* fd to filesystem mount point */
57 /* Number of threads for metadata scrubbing */
58 unsigned int nr_io_threads
;
60 /* XFS specific geometry */
61 struct xfs_fsop_geom geo
;
62 struct fs_path fsinfo
;
63 unsigned int agblklog
;
64 unsigned int blocklog
;
65 unsigned int inodelog
;
66 unsigned int inopblog
;
70 /* Data block read verification buffer */
73 /* Mutable scrub state; use lock. */
75 struct xfs_action_list
*action_lists
;
76 unsigned long long max_errors
;
77 unsigned long long runtime_errors
;
78 unsigned long long errors_found
;
79 unsigned long long warnings_found
;
80 unsigned long long inodes_checked
;
81 unsigned long long bytes_checked
;
82 unsigned long long naming_warnings
;
83 unsigned long long repairs
;
84 unsigned long long preens
;
85 bool scrub_setup_succeeded
;
86 bool preen_triggers
[XFS_SCRUB_TYPE_NR
];
89 /* Phase helper functions */
90 void xfs_shutdown_fs(struct scrub_ctx
*ctx
);
91 bool xfs_cleanup_fs(struct scrub_ctx
*ctx
);
92 bool xfs_setup_fs(struct scrub_ctx
*ctx
);
93 bool xfs_scan_metadata(struct scrub_ctx
*ctx
);
94 bool xfs_scan_inodes(struct scrub_ctx
*ctx
);
95 bool xfs_scan_connections(struct scrub_ctx
*ctx
);
96 bool xfs_scan_blocks(struct scrub_ctx
*ctx
);
97 bool xfs_scan_summary(struct scrub_ctx
*ctx
);
98 bool xfs_repair_fs(struct scrub_ctx
*ctx
);
100 /* Progress estimator functions */
101 uint64_t xfs_estimate_inodes(struct scrub_ctx
*ctx
);
102 unsigned int xfs_scrub_estimate_ag_work(struct scrub_ctx
*ctx
);
103 bool xfs_estimate_metadata_work(struct scrub_ctx
*ctx
, uint64_t *items
,
104 unsigned int *nr_threads
, int *rshift
);
105 bool xfs_estimate_inodes_work(struct scrub_ctx
*ctx
, uint64_t *items
,
106 unsigned int *nr_threads
, int *rshift
);
107 bool xfs_estimate_repair_work(struct scrub_ctx
*ctx
, uint64_t *items
,
108 unsigned int *nr_threads
, int *rshift
);
109 bool xfs_estimate_verify_work(struct scrub_ctx
*ctx
, uint64_t *items
,
110 unsigned int *nr_threads
, int *rshift
);
112 #endif /* XFS_SCRUB_XFS_SCRUB_H_ */