]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - scrub/xfs_scrub.h
xfsprogs: Release v6.7.0
[thirdparty/xfsprogs-dev.git] / scrub / xfs_scrub.h
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 extern char *progname;
10
11 #define _PATH_PROC_MOUNTS "/proc/mounts"
12
13 extern unsigned int nr_threads;
14 extern unsigned int bg_mode;
15 extern unsigned int debug;
16 extern int nproc;
17 extern bool verbose;
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;
23
24 enum scrub_mode {
25 SCRUB_MODE_DRY_RUN,
26 SCRUB_MODE_REPAIR,
27 };
28
29 enum error_action {
30 ERRORS_CONTINUE,
31 ERRORS_SHUTDOWN,
32 };
33
34 struct scrub_ctx {
35 /* Immutable scrub state. */
36
37 /* Strings we need for presentation */
38 char *mntpoint;
39
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
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
56 /* fd to filesystem mount point */
57 int mnt_fd;
58
59 /* Number of threads for metadata scrubbing */
60 unsigned int nr_io_threads;
61
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
72 /* Data block read verification buffer */
73 void *readbuf;
74
75 /* Mutable scrub state; use lock. */
76 pthread_mutex_t 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];
89 };
90
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);
101
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
114 #endif /* XFS_SCRUB_XFS_SCRUB_H_ */