blob: b7f2c4459f33683cf80a1591ca9b586fb9bcb37f [file] [log] [blame]
David Howells3d3c9502020-05-13 17:41:20 +01001/* SPDX-License-Identifier: GPL-2.0-or-later */
2/* Internal definitions for network filesystem support
3 *
4 * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
7
8#ifdef pr_fmt
9#undef pr_fmt
10#endif
11
12#define pr_fmt(fmt) "netfs: " fmt
13
14/*
15 * read_helper.c
16 */
17extern unsigned int netfs_debug;
18
David Howells289af542020-11-03 11:32:41 +000019/*
20 * stats.c
21 */
22#ifdef CONFIG_NETFS_STATS
23extern atomic_t netfs_n_rh_readahead;
24extern atomic_t netfs_n_rh_readpage;
25extern atomic_t netfs_n_rh_rreq;
26extern atomic_t netfs_n_rh_sreq;
27extern atomic_t netfs_n_rh_download;
28extern atomic_t netfs_n_rh_download_done;
29extern atomic_t netfs_n_rh_download_failed;
30extern atomic_t netfs_n_rh_download_instead;
31extern atomic_t netfs_n_rh_read;
32extern atomic_t netfs_n_rh_read_done;
33extern atomic_t netfs_n_rh_read_failed;
34extern atomic_t netfs_n_rh_zero;
35extern atomic_t netfs_n_rh_short_read;
36extern atomic_t netfs_n_rh_write;
David Howellse1b12402020-09-22 11:06:07 +010037extern atomic_t netfs_n_rh_write_begin;
David Howells289af542020-11-03 11:32:41 +000038extern atomic_t netfs_n_rh_write_done;
39extern atomic_t netfs_n_rh_write_failed;
David Howellse1b12402020-09-22 11:06:07 +010040extern atomic_t netfs_n_rh_write_zskip;
David Howells289af542020-11-03 11:32:41 +000041
42
43static inline void netfs_stat(atomic_t *stat)
44{
45 atomic_inc(stat);
46}
47
48static inline void netfs_stat_d(atomic_t *stat)
49{
50 atomic_dec(stat);
51}
52
53#else
David Howells3d3c9502020-05-13 17:41:20 +010054#define netfs_stat(x) do {} while(0)
55#define netfs_stat_d(x) do {} while(0)
David Howells289af542020-11-03 11:32:41 +000056#endif
David Howells3d3c9502020-05-13 17:41:20 +010057
58/*****************************************************************************/
59/*
60 * debug tracing
61 */
62#define dbgprintk(FMT, ...) \
63 printk("[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__)
64
65#define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__)
66#define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
67#define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__)
68
69#ifdef __KDEBUG
70#define _enter(FMT, ...) kenter(FMT, ##__VA_ARGS__)
71#define _leave(FMT, ...) kleave(FMT, ##__VA_ARGS__)
72#define _debug(FMT, ...) kdebug(FMT, ##__VA_ARGS__)
73
74#elif defined(CONFIG_NETFS_DEBUG)
75#define _enter(FMT, ...) \
76do { \
77 if (netfs_debug) \
78 kenter(FMT, ##__VA_ARGS__); \
79} while (0)
80
81#define _leave(FMT, ...) \
82do { \
83 if (netfs_debug) \
84 kleave(FMT, ##__VA_ARGS__); \
85} while (0)
86
87#define _debug(FMT, ...) \
88do { \
89 if (netfs_debug) \
90 kdebug(FMT, ##__VA_ARGS__); \
91} while (0)
92
93#else
94#define _enter(FMT, ...) no_printk("==> %s("FMT")", __func__, ##__VA_ARGS__)
95#define _leave(FMT, ...) no_printk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
96#define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
97#endif