]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - scrub/xfs_scrub.h
xfs_scrub: create a bitmap data structure
[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;
31
32enum scrub_mode {
33 SCRUB_MODE_DRY_RUN,
34 SCRUB_MODE_PREEN,
35 SCRUB_MODE_REPAIR,
36};
37#define SCRUB_MODE_DEFAULT SCRUB_MODE_PREEN
38
39enum error_action {
40 ERRORS_CONTINUE,
41 ERRORS_SHUTDOWN,
42};
f0585fce
DW
43
44struct scrub_ctx {
828105d1
DW
45 /* Immutable scrub state. */
46
47 /* Strings we need for presentation */
48 char *mntpoint;
49 char *blkdev;
50
50a573a7
DW
51 /* Mountpoint info */
52 struct stat mnt_sb;
53 struct statvfs mnt_sv;
54 struct statfs mnt_sf;
55
56 /* Open block devices */
57 struct disk *datadev;
58 struct disk *logdev;
59 struct disk *rtdev;
60
828105d1
DW
61 /* What does the user want us to do? */
62 enum scrub_mode mode;
63
64 /* How does the user want us to react to errors? */
65 enum error_action error_action;
66
50a573a7
DW
67 /* fd to filesystem mount point */
68 int mnt_fd;
69
e031d90f
DW
70 /* Number of threads for metadata scrubbing */
71 unsigned int nr_io_threads;
72
50a573a7
DW
73 /* XFS specific geometry */
74 struct xfs_fsop_geom geo;
75 struct fs_path fsinfo;
76 unsigned int agblklog;
77 unsigned int blocklog;
78 unsigned int inodelog;
79 unsigned int inopblog;
80 void *fshandle;
81 size_t fshandle_len;
82
f0585fce
DW
83 /* Mutable scrub state; use lock. */
84 pthread_mutex_t lock;
85 unsigned long long max_errors;
86 unsigned long long runtime_errors;
87 unsigned long long errors_found;
88 unsigned long long warnings_found;
fa16b376 89 unsigned long long inodes_checked;
396cd022 90 unsigned long long naming_warnings;
828105d1 91 bool need_repair;
50a573a7 92 bool preen_triggers[XFS_SCRUB_TYPE_NR];
f0585fce
DW
93};
94
50a573a7
DW
95/* Phase helper functions */
96void xfs_shutdown_fs(struct scrub_ctx *ctx);
97bool xfs_cleanup_fs(struct scrub_ctx *ctx);
98bool xfs_setup_fs(struct scrub_ctx *ctx);
e758ad01 99bool xfs_scan_metadata(struct scrub_ctx *ctx);
fa16b376 100bool xfs_scan_inodes(struct scrub_ctx *ctx);
c4892e76 101bool xfs_scan_connections(struct scrub_ctx *ctx);
50a573a7 102
95b1e505 103#endif /* XFS_SCRUB_XFS_SCRUB_H_ */