]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - scrub/common.h
xfs_scrub: figure out how many threads we're going to need
[thirdparty/xfsprogs-dev.git] / scrub / common.h
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
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
30 bool xfs_scrub_excessive_errors(struct scrub_ctx *ctx);
31
32 enum error_level {
33 S_ERROR = 0,
34 S_WARN,
35 S_INFO,
36 };
37
38 void __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
53 /* Is this debug tweak enabled? */
54 static inline bool
55 debug_tweak_on(
56 const char *name)
57 {
58 return debug && getenv(name) != NULL;
59 }
60
61 double timeval_subtract(struct timeval *tv1, struct timeval *tv2);
62 double auto_space_units(unsigned long long kilobytes, char **units);
63 double auto_units(unsigned long long number, char **units);
64 unsigned int scrub_nproc(struct scrub_ctx *ctx);
65 unsigned int scrub_nproc_workqueue(struct scrub_ctx *ctx);
66
67 #endif /* XFS_SCRUB_COMMON_H_ */