]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - scrub/common.h
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
6 #ifndef XFS_SCRUB_COMMON_H_
7 #define XFS_SCRUB_COMMON_H_
10 * When reporting a defective metadata object to the console, this
11 * is the size of the buffer to use to store the description of that
14 #define DESCR_BUFSZ 256
16 bool xfs_scrub_excessive_errors(struct scrub_ctx
*ctx
);
26 void __str_out(struct scrub_ctx
*ctx
, const char *descr
, enum error_level level
,
27 int error
, const char *file
, int line
, const char *format
, ...);
29 #define str_errno(ctx, str) \
30 __str_out(ctx, str, S_ERROR, errno, __FILE__, __LINE__, NULL)
31 #define str_error(ctx, str, ...) \
32 __str_out(ctx, str, S_ERROR, 0, __FILE__, __LINE__, __VA_ARGS__)
33 #define str_warn(ctx, str, ...) \
34 __str_out(ctx, str, S_WARN, 0, __FILE__, __LINE__, __VA_ARGS__)
35 #define str_info(ctx, str, ...) \
36 __str_out(ctx, str, S_INFO, 0, __FILE__, __LINE__, __VA_ARGS__)
37 #define record_repair(ctx, str, ...) \
38 __str_out(ctx, str, S_REPAIR, 0, __FILE__, __LINE__, __VA_ARGS__)
39 #define record_preen(ctx, str, ...) \
40 __str_out(ctx, str, S_PREEN, 0, __FILE__, __LINE__, __VA_ARGS__)
42 #define dbg_printf(fmt, ...) \
43 do {if (debug > 1) {printf(fmt, __VA_ARGS__);}} while (0)
45 void __str_log(struct scrub_ctx
*ctx
, enum error_level level
,
46 const char *format
, ...);
48 #define log_info(ctx, ...) \
49 __str_log(ctx, S_INFO, __VA_ARGS__)
50 #define log_warn(ctx, ...) \
51 __str_log(ctx, S_WARN, __VA_ARGS__)
52 #define log_err(ctx, ...) \
53 __str_log(ctx, S_ERROR, __VA_ARGS__)
55 /* Is this debug tweak enabled? */
60 return debug
&& getenv(name
) != NULL
;
63 double timeval_subtract(struct timeval
*tv1
, struct timeval
*tv2
);
64 double auto_space_units(unsigned long long kilobytes
, char **units
);
65 double auto_units(unsigned long long number
, char **units
, int *precision
);
66 unsigned int scrub_nproc(struct scrub_ctx
*ctx
);
67 unsigned int scrub_nproc_workqueue(struct scrub_ctx
*ctx
);
70 static inline int syncfs(int fd
)
77 void background_sleep(void);
78 char *string_escape(const char *in
);
80 #define TOO_MANY_NAME_WARNINGS 10000
81 bool should_warn_about_name(struct scrub_ctx
*ctx
);
83 bool within_range(struct scrub_ctx
*ctx
, unsigned long long value
,
84 unsigned long long desired
, unsigned long long abs_threshold
,
85 unsigned int n
, unsigned int d
, const char *descr
);
87 #endif /* XFS_SCRUB_COMMON_H_ */