]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - scrub/common.h
xfs_scrub: optionally use SCSI READ VERIFY commands to scrub data blocks on disk
[thirdparty/xfsprogs-dev.git] / scrub / common.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_COMMON_H_
21#define XFS_SCRUB_COMMON_H_
22
f0585fce
DW
23/*
24 * When reporting a defective metadata object to the console, this
25 * is the size of the buffer to use to store the description of that
26 * item.
27 */
28#define DESCR_BUFSZ 256
29
30bool xfs_scrub_excessive_errors(struct scrub_ctx *ctx);
31
32enum error_level {
33 S_ERROR = 0,
34 S_WARN,
35 S_INFO,
36};
37
38void __str_out(struct scrub_ctx *ctx, const char *descr, enum error_level level,
39 int error, const char *file, int line, const char *format, ...);
40
41#define str_errno(ctx, str) \
42 __str_out(ctx, str, S_ERROR, errno, __FILE__, __LINE__, NULL)
43#define str_error(ctx, str, ...) \
44 __str_out(ctx, str, S_ERROR, 0, __FILE__, __LINE__, __VA_ARGS__)
45#define str_warn(ctx, str, ...) \
46 __str_out(ctx, str, S_WARN, 0, __FILE__, __LINE__, __VA_ARGS__)
47#define str_info(ctx, str, ...) \
48 __str_out(ctx, str, S_INFO, 0, __FILE__, __LINE__, __VA_ARGS__)
49
50#define dbg_printf(fmt, ...) \
51 do {if (debug > 1) {printf(fmt, __VA_ARGS__);}} while (0)
52
828105d1
DW
53/* Is this debug tweak enabled? */
54static inline bool
55debug_tweak_on(
56 const char *name)
57{
58 return debug && getenv(name) != NULL;
59}
60
173a0283
DW
61double timeval_subtract(struct timeval *tv1, struct timeval *tv2);
62double auto_space_units(unsigned long long kilobytes, char **units);
63double auto_units(unsigned long long number, char **units);
e031d90f
DW
64unsigned int scrub_nproc(struct scrub_ctx *ctx);
65unsigned int scrub_nproc_workqueue(struct scrub_ctx *ctx);
173a0283 66
50a573a7
DW
67#ifndef HAVE_SYNCFS
68static inline int syncfs(int fd)
69{
70 sync();
71 return 0;
72}
73#endif
74
75bool find_mountpoint(char *mtab, struct scrub_ctx *ctx);
fd7d73c0 76void background_sleep(void);
396cd022
DW
77char *string_escape(const char *in);
78
79#define TOO_MANY_NAME_WARNINGS 10000
80bool should_warn_about_name(struct scrub_ctx *ctx);
50a573a7 81
95b1e505 82#endif /* XFS_SCRUB_COMMON_H_ */