]>
Commit | Line | Data |
---|---|---|
959ef981 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
95b1e505 DW |
2 | /* |
3 | * Copyright (C) 2018 Oracle. All Rights Reserved. | |
95b1e505 | 4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> |
95b1e505 DW |
5 | */ |
6 | #ifndef XFS_SCRUB_XFS_SCRUB_H_ | |
7 | #define XFS_SCRUB_XFS_SCRUB_H_ | |
8 | ||
28e36fcc ES |
9 | extern char *progname; |
10 | ||
828105d1 DW |
11 | #define _PATH_PROC_MOUNTS "/proc/mounts" |
12 | ||
32c6cc09 | 13 | extern unsigned int force_nr_threads; |
828105d1 | 14 | extern unsigned int bg_mode; |
f0585fce | 15 | extern unsigned int debug; |
828105d1 DW |
16 | extern int nproc; |
17 | extern bool verbose; | |
18 | extern long page_size; | |
7e36bc0f | 19 | extern bool want_fstrim; |
ed60d210 DW |
20 | extern bool stderr_isatty; |
21 | extern bool stdout_isatty; | |
7c309151 | 22 | extern bool is_service; |
828105d1 DW |
23 | |
24 | enum scrub_mode { | |
25 | SCRUB_MODE_DRY_RUN, | |
828105d1 DW |
26 | SCRUB_MODE_REPAIR, |
27 | }; | |
828105d1 DW |
28 | |
29 | enum error_action { | |
30 | ERRORS_CONTINUE, | |
31 | ERRORS_SHUTDOWN, | |
32 | }; | |
f0585fce DW |
33 | |
34 | struct scrub_ctx { | |
828105d1 DW |
35 | /* Immutable scrub state. */ |
36 | ||
37 | /* Strings we need for presentation */ | |
38 | char *mntpoint; | |
828105d1 | 39 | |
50a573a7 DW |
40 | /* Mountpoint info */ |
41 | struct stat mnt_sb; | |
42 | struct statvfs mnt_sv; | |
43 | struct statfs mnt_sf; | |
44 | ||
45 | /* Open block devices */ | |
46 | struct disk *datadev; | |
47 | struct disk *logdev; | |
48 | struct disk *rtdev; | |
49 | ||
828105d1 DW |
50 | /* What does the user want us to do? */ |
51 | enum scrub_mode mode; | |
52 | ||
53 | /* How does the user want us to react to errors? */ | |
54 | enum error_action error_action; | |
55 | ||
50a573a7 DW |
56 | /* fd to filesystem mount point */ |
57 | int mnt_fd; | |
58 | ||
e031d90f DW |
59 | /* Number of threads for metadata scrubbing */ |
60 | unsigned int nr_io_threads; | |
61 | ||
50a573a7 DW |
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; | |
69 | void *fshandle; | |
70 | size_t fshandle_len; | |
71 | ||
2000470d DW |
72 | /* Data block read verification buffer */ |
73 | void *readbuf; | |
74 | ||
f0585fce DW |
75 | /* Mutable scrub state; use lock. */ |
76 | pthread_mutex_t lock; | |
ee310b0c | 77 | struct xfs_action_list *action_lists; |
f0585fce DW |
78 | unsigned long long max_errors; |
79 | unsigned long long runtime_errors; | |
80 | unsigned long long errors_found; | |
81 | unsigned long long warnings_found; | |
fa16b376 | 82 | unsigned long long inodes_checked; |
b364a9c0 | 83 | unsigned long long bytes_checked; |
396cd022 | 84 | unsigned long long naming_warnings; |
19852474 DW |
85 | unsigned long long repairs; |
86 | unsigned long long preens; | |
c767c5ae | 87 | bool scrub_setup_succeeded; |
50a573a7 | 88 | bool preen_triggers[XFS_SCRUB_TYPE_NR]; |
f0585fce DW |
89 | }; |
90 | ||
50a573a7 DW |
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); | |
e758ad01 | 95 | bool xfs_scan_metadata(struct scrub_ctx *ctx); |
fa16b376 | 96 | bool xfs_scan_inodes(struct scrub_ctx *ctx); |
c4892e76 | 97 | bool xfs_scan_connections(struct scrub_ctx *ctx); |
b364a9c0 | 98 | bool xfs_scan_blocks(struct scrub_ctx *ctx); |
698c6c7c | 99 | bool xfs_scan_summary(struct scrub_ctx *ctx); |
7e36bc0f | 100 | bool xfs_repair_fs(struct scrub_ctx *ctx); |
50a573a7 | 101 | |
ed60d210 DW |
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); | |
113 | ||
95b1e505 | 114 | #endif /* XFS_SCRUB_XFS_SCRUB_H_ */ |