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; |
| 37 | extern atomic_t netfs_n_rh_write_done; |
| 38 | extern atomic_t netfs_n_rh_write_failed; |
| 39 | |
| 40 | |
| 41 | static inline void netfs_stat(atomic_t *stat) |
| 42 | { |
| 43 | atomic_inc(stat); |
| 44 | } |
| 45 | |
| 46 | static inline void netfs_stat_d(atomic_t *stat) |
| 47 | { |
| 48 | atomic_dec(stat); |
| 49 | } |
| 50 | |
| 51 | #else |
David Howells | 3d3c950 | 2020-05-13 17:41:20 +0100 | [diff] [blame] | 52 | #define netfs_stat(x) do {} while(0) |
| 53 | #define netfs_stat_d(x) do {} while(0) |
David Howells | 289af54 | 2020-11-03 11:32:41 +0000 | [diff] [blame^] | 54 | #endif |
David Howells | 3d3c950 | 2020-05-13 17:41:20 +0100 | [diff] [blame] | 55 | |
| 56 | /*****************************************************************************/ |
| 57 | /* |
| 58 | * debug tracing |
| 59 | */ |
| 60 | #define dbgprintk(FMT, ...) \ |
| 61 | printk("[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__) |
| 62 | |
| 63 | #define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__) |
| 64 | #define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__) |
| 65 | #define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__) |
| 66 | |
| 67 | #ifdef __KDEBUG |
| 68 | #define _enter(FMT, ...) kenter(FMT, ##__VA_ARGS__) |
| 69 | #define _leave(FMT, ...) kleave(FMT, ##__VA_ARGS__) |
| 70 | #define _debug(FMT, ...) kdebug(FMT, ##__VA_ARGS__) |
| 71 | |
| 72 | #elif defined(CONFIG_NETFS_DEBUG) |
| 73 | #define _enter(FMT, ...) \ |
| 74 | do { \ |
| 75 | if (netfs_debug) \ |
| 76 | kenter(FMT, ##__VA_ARGS__); \ |
| 77 | } while (0) |
| 78 | |
| 79 | #define _leave(FMT, ...) \ |
| 80 | do { \ |
| 81 | if (netfs_debug) \ |
| 82 | kleave(FMT, ##__VA_ARGS__); \ |
| 83 | } while (0) |
| 84 | |
| 85 | #define _debug(FMT, ...) \ |
| 86 | do { \ |
| 87 | if (netfs_debug) \ |
| 88 | kdebug(FMT, ##__VA_ARGS__); \ |
| 89 | } while (0) |
| 90 | |
| 91 | #else |
| 92 | #define _enter(FMT, ...) no_printk("==> %s("FMT")", __func__, ##__VA_ARGS__) |
| 93 | #define _leave(FMT, ...) no_printk("<== %s()"FMT"", __func__, ##__VA_ARGS__) |
| 94 | #define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__) |
| 95 | #endif |