]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - scrub/xfs_scrub.h
xfs_scrub: log operational messages when interactive
[thirdparty/xfsprogs-dev.git] / scrub / xfs_scrub.h
CommitLineData
95b1e505
DW
1/*
2 * Copyright (C) 2018 Oracle. All Rights Reserved.
3 *
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it would be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20#ifndef XFS_SCRUB_XFS_SCRUB_H_
21#define XFS_SCRUB_XFS_SCRUB_H_
22
828105d1
DW
23#define _PATH_PROC_MOUNTS "/proc/mounts"
24
25extern unsigned int nr_threads;
26extern unsigned int bg_mode;
f0585fce 27extern unsigned int debug;
828105d1
DW
28extern int nproc;
29extern bool verbose;
30extern long page_size;
7e36bc0f 31extern bool want_fstrim;
ed60d210
DW
32extern bool stderr_isatty;
33extern bool stdout_isatty;
7c309151 34extern bool is_service;
828105d1
DW
35
36enum scrub_mode {
37 SCRUB_MODE_DRY_RUN,
828105d1
DW
38 SCRUB_MODE_REPAIR,
39};
828105d1
DW
40
41enum error_action {
42 ERRORS_CONTINUE,
43 ERRORS_SHUTDOWN,
44};
f0585fce
DW
45
46struct scrub_ctx {
828105d1
DW
47 /* Immutable scrub state. */
48
49 /* Strings we need for presentation */
50 char *mntpoint;
51 char *blkdev;
52
50a573a7
DW
53 /* Mountpoint info */
54 struct stat mnt_sb;
55 struct statvfs mnt_sv;
56 struct statfs mnt_sf;
57
58 /* Open block devices */
59 struct disk *datadev;
60 struct disk *logdev;
61 struct disk *rtdev;
62
828105d1
DW
63 /* What does the user want us to do? */
64 enum scrub_mode mode;
65
66 /* How does the user want us to react to errors? */
67 enum error_action error_action;
68
50a573a7
DW
69 /* fd to filesystem mount point */
70 int mnt_fd;
71
e031d90f
DW
72 /* Number of threads for metadata scrubbing */
73 unsigned int nr_io_threads;
74
50a573a7
DW
75 /* XFS specific geometry */
76 struct xfs_fsop_geom geo;
77 struct fs_path fsinfo;
78 unsigned int agblklog;
79 unsigned int blocklog;
80 unsigned int inodelog;
81 unsigned int inopblog;
82 void *fshandle;
83 size_t fshandle_len;
84
2000470d
DW
85 /* Data block read verification buffer */
86 void *readbuf;
87
f0585fce
DW
88 /* Mutable scrub state; use lock. */
89 pthread_mutex_t lock;
90 unsigned long long max_errors;
91 unsigned long long runtime_errors;
92 unsigned long long errors_found;
93 unsigned long long warnings_found;
fa16b376 94 unsigned long long inodes_checked;
b364a9c0 95 unsigned long long bytes_checked;
396cd022 96 unsigned long long naming_warnings;
19852474
DW
97 unsigned long long repairs;
98 unsigned long long preens;
828105d1 99 bool need_repair;
50a573a7 100 bool preen_triggers[XFS_SCRUB_TYPE_NR];
f0585fce
DW
101};
102
50a573a7
DW
103/* Phase helper functions */
104void xfs_shutdown_fs(struct scrub_ctx *ctx);
105bool xfs_cleanup_fs(struct scrub_ctx *ctx);
106bool xfs_setup_fs(struct scrub_ctx *ctx);
e758ad01 107bool xfs_scan_metadata(struct scrub_ctx *ctx);
fa16b376 108bool xfs_scan_inodes(struct scrub_ctx *ctx);
c4892e76 109bool xfs_scan_connections(struct scrub_ctx *ctx);
b364a9c0 110bool xfs_scan_blocks(struct scrub_ctx *ctx);
698c6c7c 111bool xfs_scan_summary(struct scrub_ctx *ctx);
7e36bc0f 112bool xfs_repair_fs(struct scrub_ctx *ctx);
50a573a7 113
ed60d210
DW
114/* Progress estimator functions */
115uint64_t xfs_estimate_inodes(struct scrub_ctx *ctx);
116unsigned int xfs_scrub_estimate_ag_work(struct scrub_ctx *ctx);
117bool xfs_estimate_metadata_work(struct scrub_ctx *ctx, uint64_t *items,
118 unsigned int *nr_threads, int *rshift);
119bool xfs_estimate_inodes_work(struct scrub_ctx *ctx, uint64_t *items,
120 unsigned int *nr_threads, int *rshift);
121bool xfs_estimate_repair_work(struct scrub_ctx *ctx, uint64_t *items,
122 unsigned int *nr_threads, int *rshift);
123bool xfs_estimate_verify_work(struct scrub_ctx *ctx, uint64_t *items,
124 unsigned int *nr_threads, int *rshift);
125
95b1e505 126#endif /* XFS_SCRUB_XFS_SCRUB_H_ */