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_
11 #define _PATH_PROC_MOUNTS "/proc/mounts"
13 extern unsigned int nr_threads
;
14 extern unsigned int bg_mode
;
15 extern unsigned int debug
;
18 extern long page_size
;
19 extern bool want_fstrim
;
20 extern bool stderr_isatty
;
21 extern bool stdout_isatty
;
22 extern bool is_service
;
35 /* Immutable scrub state. */
37 /* Strings we need for presentation */
42 struct statvfs mnt_sv
;
45 /* Open block devices */
50 /* What does the user want us to do? */
53 /* How does the user want us to react to errors? */
54 enum error_action error_action
;
56 /* fd to filesystem mount point */
59 /* Number of threads for metadata scrubbing */
60 unsigned int nr_io_threads
;
62 /* XFS specific geometry */
63 struct xfs_fsop_geom geo
;
64 struct fs_path fsinfo
;
65 unsigned int agblklog
;
66 unsigned int blocklog
;
67 unsigned int inodelog
;
68 unsigned int inopblog
;
72 /* Data block read verification buffer */
75 /* Mutable scrub state; use lock. */
77 struct xfs_action_list
*action_lists
;
78 unsigned long long max_errors
;
79 unsigned long long runtime_errors
;
80 unsigned long long errors_found
;
81 unsigned long long warnings_found
;
82 unsigned long long inodes_checked
;
83 unsigned long long bytes_checked
;
84 unsigned long long naming_warnings
;
85 unsigned long long repairs
;
86 unsigned long long preens
;
87 bool scrub_setup_succeeded
;
88 bool preen_triggers
[XFS_SCRUB_TYPE_NR
];
91 /* Phase helper functions */
92 void xfs_shutdown_fs(struct scrub_ctx
*ctx
);
93 bool xfs_cleanup_fs(struct scrub_ctx
*ctx
);
94 bool xfs_setup_fs(struct scrub_ctx
*ctx
);
95 bool xfs_scan_metadata(struct scrub_ctx
*ctx
);
96 bool xfs_scan_inodes(struct scrub_ctx
*ctx
);
97 bool xfs_scan_connections(struct scrub_ctx
*ctx
);
98 bool xfs_scan_blocks(struct scrub_ctx
*ctx
);
99 bool xfs_scan_summary(struct scrub_ctx
*ctx
);
100 bool xfs_repair_fs(struct scrub_ctx
*ctx
);
102 /* Progress estimator functions */
103 uint64_t xfs_estimate_inodes(struct scrub_ctx
*ctx
);
104 unsigned int xfs_scrub_estimate_ag_work(struct scrub_ctx
*ctx
);
105 bool xfs_estimate_metadata_work(struct scrub_ctx
*ctx
, uint64_t *items
,
106 unsigned int *nr_threads
, int *rshift
);
107 bool xfs_estimate_inodes_work(struct scrub_ctx
*ctx
, uint64_t *items
,
108 unsigned int *nr_threads
, int *rshift
);
109 bool xfs_estimate_repair_work(struct scrub_ctx
*ctx
, uint64_t *items
,
110 unsigned int *nr_threads
, int *rshift
);
111 bool xfs_estimate_verify_work(struct scrub_ctx
*ctx
, uint64_t *items
,
112 unsigned int *nr_threads
, int *rshift
);
114 #endif /* XFS_SCRUB_XFS_SCRUB_H_ */