David Howells | 3d3c950 | 2020-05-13 17:41:20 +0100 | [diff] [blame] | 1 | /* 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 | */ |
| 17 | extern unsigned int netfs_debug; |
| 18 | |
David Howells | 289af54 | 2020-11-03 11:32:41 +0000 | [diff] [blame] | 19 | /* |
| 20 | * stats.c |
| 21 | */ |
| 22 | #ifdef CONFIG_NETFS_STATS |
| 23 | extern atomic_t netfs_n_rh_readahead; |
| 24 | extern atomic_t netfs_n_rh_readpage; |
| 25 | extern atomic_t netfs_n_rh_rreq; |
| 26 | extern atomic_t netfs_n_rh_sreq; |
| 27 | extern atomic_t netfs_n_rh_download; |
| 28 | extern atomic_t netfs_n_rh_download_done; |
| 29 | extern atomic_t netfs_n_rh_download_failed; |
| 30 | extern atomic_t netfs_n_rh_download_instead; |
| 31 | extern atomic_t netfs_n_rh_read; |
| 32 | extern atomic_t netfs_n_rh_read_done; |
| 33 | extern atomic_t netfs_n_rh_read_failed; |
| 34 | extern atomic_t netfs_n_rh_zero; |
| 35 | extern atomic_t netfs_n_rh_short_read; |
| 36 | extern atomic_t netfs_n_rh_write; |
David Howells | e1b1240 | 2020-09-22 11:06:07 +0100 | [diff] [blame] | 37 | extern atomic_t netfs_n_rh_write_begin; |
David Howells | 289af54 | 2020-11-03 11:32:41 +0000 | [diff] [blame] | 38 | extern atomic_t netfs_n_rh_write_done; |
| 39 | extern atomic_t netfs_n_rh_write_failed; |
David Howells | e1b1240 | 2020-09-22 11:06:07 +0100 | [diff] [blame] | 40 | extern atomic_t netfs_n_rh_write_zskip; |
David Howells | 289af54 | 2020-11-03 11:32:41 +0000 | [diff] [blame] | 41 | |
| 42 | |
| 43 | static inline void netfs_stat(atomic_t *stat) |
| 44 | { |
| 45 | atomic_inc(stat); |
| 46 | } |
| 47 | |
| 48 | static inline void netfs_stat_d(atomic_t *stat) |
| 49 | { |
| 50 | atomic_dec(stat); |
| 51 | } |
| 52 | |
| 53 | #else |
David Howells | 3d3c950 | 2020-05-13 17:41:20 +0100 | [diff] [blame] | 54 | #define netfs_stat(x) do {} while(0) |
| 55 | #define netfs_stat_d(x) do {} while(0) |
David Howells | 289af54 | 2020-11-03 11:32:41 +0000 | [diff] [blame] | 56 | #endif |
David Howells | 3d3c950 | 2020-05-13 17:41:20 +0100 | [diff] [blame] | 57 | |
| 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, ...) \ |
| 76 | do { \ |
| 77 | if (netfs_debug) \ |
| 78 | kenter(FMT, ##__VA_ARGS__); \ |
| 79 | } while (0) |
| 80 | |
| 81 | #define _leave(FMT, ...) \ |
| 82 | do { \ |
| 83 | if (netfs_debug) \ |
| 84 | kleave(FMT, ##__VA_ARGS__); \ |
| 85 | } while (0) |
| 86 | |
| 87 | #define _debug(FMT, ...) \ |
| 88 | do { \ |
| 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 |