1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*
* Copyright (C) 2018 Oracle. All Rights Reserved.
*
* Author: Darrick J. Wong <darrick.wong@oracle.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef XFS_SCRUB_COMMON_H_
#define XFS_SCRUB_COMMON_H_
/*
* When reporting a defective metadata object to the console, this
* is the size of the buffer to use to store the description of that
* item.
*/
#define DESCR_BUFSZ 256
bool xfs_scrub_excessive_errors(struct scrub_ctx *ctx);
enum error_level {
S_ERROR = 0,
S_WARN,
S_INFO,
};
void __str_out(struct scrub_ctx *ctx, const char *descr, enum error_level level,
int error, const char *file, int line, const char *format, ...);
#define str_errno(ctx, str) \
__str_out(ctx, str, S_ERROR, errno, __FILE__, __LINE__, NULL)
#define str_error(ctx, str, ...) \
__str_out(ctx, str, S_ERROR, 0, __FILE__, __LINE__, __VA_ARGS__)
#define str_warn(ctx, str, ...) \
__str_out(ctx, str, S_WARN, 0, __FILE__, __LINE__, __VA_ARGS__)
#define str_info(ctx, str, ...) \
__str_out(ctx, str, S_INFO, 0, __FILE__, __LINE__, __VA_ARGS__)
#define dbg_printf(fmt, ...) \
do {if (debug > 1) {printf(fmt, __VA_ARGS__);}} while (0)
/* Is this debug tweak enabled? */
static inline bool
debug_tweak_on(
const char *name)
{
return debug && getenv(name) != NULL;
}
double timeval_subtract(struct timeval *tv1, struct timeval *tv2);
double auto_space_units(unsigned long long kilobytes, char **units);
double auto_units(unsigned long long number, char **units);
unsigned int scrub_nproc(struct scrub_ctx *ctx);
unsigned int scrub_nproc_workqueue(struct scrub_ctx *ctx);
#ifndef HAVE_SYNCFS
static inline int syncfs(int fd)
{
sync();
return 0;
}
#endif
bool find_mountpoint(char *mtab, struct scrub_ctx *ctx);
void background_sleep(void);
char *string_escape(const char *in);
#define TOO_MANY_NAME_WARNINGS 10000
bool should_warn_about_name(struct scrub_ctx *ctx);
bool within_range(struct scrub_ctx *ctx, unsigned long long value,
unsigned long long desired, unsigned long long abs_threshold,
unsigned int n, unsigned int d, const char *descr);
#endif /* XFS_SCRUB_COMMON_H_ */
|