]>
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 | ||
fee68490 | 9 | #include "libfrog/fsgeom.h" |
3f9efb2e | 10 | |
28e36fcc ES |
11 | extern char *progname; |
12 | ||
828105d1 DW |
13 | #define _PATH_PROC_MOUNTS "/proc/mounts" |
14 | ||
32c6cc09 | 15 | extern unsigned int force_nr_threads; |
828105d1 | 16 | extern unsigned int bg_mode; |
f0585fce | 17 | extern unsigned int debug; |
828105d1 DW |
18 | extern bool verbose; |
19 | extern long page_size; | |
7e36bc0f | 20 | extern bool want_fstrim; |
ed60d210 DW |
21 | extern bool stderr_isatty; |
22 | extern bool stdout_isatty; | |
7c309151 | 23 | extern bool is_service; |
828105d1 DW |
24 | |
25 | enum scrub_mode { | |
26 | SCRUB_MODE_DRY_RUN, | |
828105d1 DW |
27 | SCRUB_MODE_REPAIR, |
28 | }; | |
828105d1 DW |
29 | |
30 | enum error_action { | |
31 | ERRORS_CONTINUE, | |
32 | ERRORS_SHUTDOWN, | |
33 | }; | |
f0585fce DW |
34 | |
35 | struct scrub_ctx { | |
828105d1 DW |
36 | /* Immutable scrub state. */ |
37 | ||
38 | /* Strings we need for presentation */ | |
39 | char *mntpoint; | |
828105d1 | 40 | |
50a573a7 DW |
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 | ||
828105d1 DW |
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 | ||
3f9efb2e DW |
57 | /* xfrog context for the mount point */ |
58 | struct xfs_fd mnt; | |
50a573a7 | 59 | |
e031d90f DW |
60 | /* Number of threads for metadata scrubbing */ |
61 | unsigned int nr_io_threads; | |
62 | ||
50a573a7 | 63 | /* XFS specific geometry */ |
50a573a7 | 64 | struct fs_path fsinfo; |
50a573a7 DW |
65 | void *fshandle; |
66 | size_t fshandle_len; | |
67 | ||
2000470d DW |
68 | /* Data block read verification buffer */ |
69 | void *readbuf; | |
70 | ||
f0585fce DW |
71 | /* Mutable scrub state; use lock. */ |
72 | pthread_mutex_t lock; | |
ee310b0c | 73 | struct xfs_action_list *action_lists; |
f0585fce DW |
74 | unsigned long long max_errors; |
75 | unsigned long long runtime_errors; | |
abc2e70d | 76 | unsigned long long corruptions_found; |
49e05cb0 | 77 | unsigned long long unfixable_errors; |
f0585fce | 78 | unsigned long long warnings_found; |
fa16b376 | 79 | unsigned long long inodes_checked; |
b364a9c0 | 80 | unsigned long long bytes_checked; |
396cd022 | 81 | unsigned long long naming_warnings; |
19852474 DW |
82 | unsigned long long repairs; |
83 | unsigned long long preens; | |
c767c5ae | 84 | bool scrub_setup_succeeded; |
50a573a7 | 85 | bool preen_triggers[XFS_SCRUB_TYPE_NR]; |
f0585fce DW |
86 | }; |
87 | ||
50a573a7 DW |
88 | /* Phase helper functions */ |
89 | void xfs_shutdown_fs(struct scrub_ctx *ctx); | |
90 | bool xfs_cleanup_fs(struct scrub_ctx *ctx); | |
91 | bool xfs_setup_fs(struct scrub_ctx *ctx); | |
e758ad01 | 92 | bool xfs_scan_metadata(struct scrub_ctx *ctx); |
fa16b376 | 93 | bool xfs_scan_inodes(struct scrub_ctx *ctx); |
c4892e76 | 94 | bool xfs_scan_connections(struct scrub_ctx *ctx); |
b364a9c0 | 95 | bool xfs_scan_blocks(struct scrub_ctx *ctx); |
698c6c7c | 96 | bool xfs_scan_summary(struct scrub_ctx *ctx); |
7e36bc0f | 97 | bool xfs_repair_fs(struct scrub_ctx *ctx); |
50a573a7 | 98 | |
ed60d210 DW |
99 | /* Progress estimator functions */ |
100 | uint64_t xfs_estimate_inodes(struct scrub_ctx *ctx); | |
d22f2471 | 101 | unsigned int scrub_estimate_ag_work(struct scrub_ctx *ctx); |
ed60d210 DW |
102 | bool xfs_estimate_metadata_work(struct scrub_ctx *ctx, uint64_t *items, |
103 | unsigned int *nr_threads, int *rshift); | |
104 | bool xfs_estimate_inodes_work(struct scrub_ctx *ctx, uint64_t *items, | |
105 | unsigned int *nr_threads, int *rshift); | |
106 | bool xfs_estimate_repair_work(struct scrub_ctx *ctx, uint64_t *items, | |
107 | unsigned int *nr_threads, int *rshift); | |
108 | bool xfs_estimate_verify_work(struct scrub_ctx *ctx, uint64_t *items, | |
109 | unsigned int *nr_threads, int *rshift); | |
110 | ||
95b1e505 | 111 | #endif /* XFS_SCRUB_XFS_SCRUB_H_ */ |