]>
Commit | Line | Data |
---|---|---|
1 | // SPDX-License-Identifier: GPL-2.0+ | |
2 | /* | |
3 | * Copyright (C) 2018 Oracle. All Rights Reserved. | |
4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> | |
5 | */ | |
6 | #ifndef XFS_SCRUB_XFS_SCRUB_H_ | |
7 | #define XFS_SCRUB_XFS_SCRUB_H_ | |
8 | ||
9 | #include "libfrog/fsgeom.h" | |
10 | ||
11 | extern char *progname; | |
12 | ||
13 | #define _PATH_PROC_MOUNTS "/proc/mounts" | |
14 | ||
15 | extern unsigned int force_nr_threads; | |
16 | extern unsigned int bg_mode; | |
17 | extern unsigned int debug; | |
18 | extern bool verbose; | |
19 | extern long page_size; | |
20 | extern bool want_fstrim; | |
21 | extern bool stderr_isatty; | |
22 | extern bool stdout_isatty; | |
23 | extern bool is_service; | |
24 | ||
25 | enum scrub_mode { | |
26 | SCRUB_MODE_DRY_RUN, | |
27 | SCRUB_MODE_REPAIR, | |
28 | }; | |
29 | ||
30 | enum error_action { | |
31 | ERRORS_CONTINUE, | |
32 | ERRORS_SHUTDOWN, | |
33 | }; | |
34 | ||
35 | struct scrub_ctx { | |
36 | /* Immutable scrub state. */ | |
37 | ||
38 | /* Strings we need for presentation */ | |
39 | char *mntpoint; | |
40 | ||
41 | /* Mountpoint info */ | |
42 | struct stat mnt_sb; | |
43 | struct statvfs mnt_sv; | |
44 | struct statfs mnt_sf; | |
45 | ||
46 | /* Open block devices */ | |
47 | struct disk *datadev; | |
48 | struct disk *logdev; | |
49 | struct disk *rtdev; | |
50 | ||
51 | /* What does the user want us to do? */ | |
52 | enum scrub_mode mode; | |
53 | ||
54 | /* How does the user want us to react to errors? */ | |
55 | enum error_action error_action; | |
56 | ||
57 | /* xfrog context for the mount point */ | |
58 | struct xfs_fd mnt; | |
59 | ||
60 | /* Number of threads for metadata scrubbing */ | |
61 | unsigned int nr_io_threads; | |
62 | ||
63 | /* XFS specific geometry */ | |
64 | struct fs_path fsinfo; | |
65 | void *fshandle; | |
66 | size_t fshandle_len; | |
67 | ||
68 | /* Data block read verification buffer */ | |
69 | void *readbuf; | |
70 | ||
71 | /* Mutable scrub state; use lock. */ | |
72 | pthread_mutex_t lock; | |
73 | struct action_list *action_lists; | |
74 | unsigned long long max_errors; | |
75 | unsigned long long runtime_errors; | |
76 | unsigned long long corruptions_found; | |
77 | unsigned long long unfixable_errors; | |
78 | unsigned long long warnings_found; | |
79 | unsigned long long inodes_checked; | |
80 | unsigned long long bytes_checked; | |
81 | unsigned long long naming_warnings; | |
82 | unsigned long long repairs; | |
83 | unsigned long long preens; | |
84 | bool scrub_setup_succeeded; | |
85 | bool preen_triggers[XFS_SCRUB_TYPE_NR]; | |
86 | }; | |
87 | ||
88 | /* Phase helper functions */ | |
89 | void xfs_shutdown_fs(struct scrub_ctx *ctx); | |
90 | int scrub_cleanup(struct scrub_ctx *ctx); | |
91 | int phase1_func(struct scrub_ctx *ctx); | |
92 | int phase2_func(struct scrub_ctx *ctx); | |
93 | int phase3_func(struct scrub_ctx *ctx); | |
94 | int phase4_func(struct scrub_ctx *ctx); | |
95 | int phase5_func(struct scrub_ctx *ctx); | |
96 | int phase6_func(struct scrub_ctx *ctx); | |
97 | int phase7_func(struct scrub_ctx *ctx); | |
98 | ||
99 | /* Progress estimator functions */ | |
100 | unsigned int scrub_estimate_ag_work(struct scrub_ctx *ctx); | |
101 | int phase2_estimate(struct scrub_ctx *ctx, uint64_t *items, | |
102 | unsigned int *nr_threads, int *rshift); | |
103 | int phase3_estimate(struct scrub_ctx *ctx, uint64_t *items, | |
104 | unsigned int *nr_threads, int *rshift); | |
105 | int phase4_estimate(struct scrub_ctx *ctx, uint64_t *items, | |
106 | unsigned int *nr_threads, int *rshift); | |
107 | int phase5_estimate(struct scrub_ctx *ctx, uint64_t *items, | |
108 | unsigned int *nr_threads, int *rshift); | |
109 | int phase6_estimate(struct scrub_ctx *ctx, uint64_t *items, | |
110 | unsigned int *nr_threads, int *rshift); | |
111 | ||
112 | #endif /* XFS_SCRUB_XFS_SCRUB_H_ */ |