Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 | 2 | /* |
1da177e4 LT |
3 | * Statistics for NFS server. |
4 | * | |
5 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> | |
6 | */ | |
7f94423e CH |
7 | #ifndef _NFSD_STATS_H |
8 | #define _NFSD_STATS_H | |
1da177e4 | 9 | |
616d1ca5 | 10 | #include <uapi/linux/nfsd/stats.h> |
e567b98c | 11 | #include <linux/percpu_counter.h> |
42d671c7 | 12 | |
42d671c7 | 13 | |
e567b98c AG |
14 | enum { |
15 | NFSD_STATS_RC_HITS, /* repcache hits */ | |
16 | NFSD_STATS_RC_MISSES, /* repcache misses */ | |
17 | NFSD_STATS_RC_NOCACHE, /* uncached reqs */ | |
18 | NFSD_STATS_FH_STALE, /* FH stale error */ | |
19 | NFSD_STATS_IO_READ, /* bytes returned to read requests */ | |
20 | NFSD_STATS_IO_WRITE, /* bytes passed in write requests */ | |
e2b20950 | 21 | #ifdef CONFIG_NFSD_V4 |
e567b98c AG |
22 | NFSD_STATS_FIRST_NFS4_OP, /* count of individual nfsv4 operations */ |
23 | NFSD_STATS_LAST_NFS4_OP = NFSD_STATS_FIRST_NFS4_OP + LAST_NFS4_OP, | |
24 | #define NFSD_STATS_NFS4_OP(op) (NFSD_STATS_FIRST_NFS4_OP + (op)) | |
fd19ca36 | 25 | NFSD_STATS_WDELEG_GETATTR, /* count of getattr conflict with wdeleg */ |
e2b20950 | 26 | #endif |
e567b98c AG |
27 | NFSD_STATS_COUNTERS_NUM |
28 | }; | |
29 | ||
30 | struct nfsd_stats { | |
31 | struct percpu_counter counter[NFSD_STATS_COUNTERS_NUM]; | |
e2b20950 | 32 | |
9b6c8c9b | 33 | atomic_t th_cnt; /* number of available threads */ |
1da177e4 LT |
34 | }; |
35 | ||
1da177e4 | 36 | extern struct nfsd_stats nfsdstats; |
e567b98c | 37 | |
1da177e4 LT |
38 | extern struct svc_stat nfsd_svcstats; |
39 | ||
5ec39944 CL |
40 | int nfsd_percpu_counters_init(struct percpu_counter *counters, int num); |
41 | void nfsd_percpu_counters_reset(struct percpu_counter *counters, int num); | |
42 | void nfsd_percpu_counters_destroy(struct percpu_counter *counters, int num); | |
e567b98c AG |
43 | int nfsd_stat_init(void); |
44 | void nfsd_stat_shutdown(void); | |
45 | ||
46 | static inline void nfsd_stats_rc_hits_inc(void) | |
47 | { | |
48 | percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_HITS]); | |
49 | } | |
50 | ||
51 | static inline void nfsd_stats_rc_misses_inc(void) | |
52 | { | |
53 | percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_MISSES]); | |
54 | } | |
55 | ||
56 | static inline void nfsd_stats_rc_nocache_inc(void) | |
57 | { | |
58 | percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_NOCACHE]); | |
59 | } | |
60 | ||
20ad856e | 61 | static inline void nfsd_stats_fh_stale_inc(struct svc_export *exp) |
e567b98c AG |
62 | { |
63 | percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_FH_STALE]); | |
6939ace1 CL |
64 | if (exp && exp->ex_stats) |
65 | percpu_counter_inc(&exp->ex_stats->counter[EXP_STATS_FH_STALE]); | |
e567b98c AG |
66 | } |
67 | ||
20ad856e | 68 | static inline void nfsd_stats_io_read_add(struct svc_export *exp, s64 amount) |
e567b98c AG |
69 | { |
70 | percpu_counter_add(&nfsdstats.counter[NFSD_STATS_IO_READ], amount); | |
6939ace1 CL |
71 | if (exp && exp->ex_stats) |
72 | percpu_counter_add(&exp->ex_stats->counter[EXP_STATS_IO_READ], amount); | |
e567b98c AG |
73 | } |
74 | ||
20ad856e | 75 | static inline void nfsd_stats_io_write_add(struct svc_export *exp, s64 amount) |
e567b98c AG |
76 | { |
77 | percpu_counter_add(&nfsdstats.counter[NFSD_STATS_IO_WRITE], amount); | |
6939ace1 CL |
78 | if (exp && exp->ex_stats) |
79 | percpu_counter_add(&exp->ex_stats->counter[EXP_STATS_IO_WRITE], amount); | |
e567b98c AG |
80 | } |
81 | ||
82 | static inline void nfsd_stats_payload_misses_inc(struct nfsd_net *nn) | |
83 | { | |
84 | percpu_counter_inc(&nn->counter[NFSD_NET_PAYLOAD_MISSES]); | |
85 | } | |
86 | ||
87 | static inline void nfsd_stats_drc_mem_usage_add(struct nfsd_net *nn, s64 amount) | |
88 | { | |
89 | percpu_counter_add(&nn->counter[NFSD_NET_DRC_MEM_USAGE], amount); | |
90 | } | |
91 | ||
92 | static inline void nfsd_stats_drc_mem_usage_sub(struct nfsd_net *nn, s64 amount) | |
93 | { | |
94 | percpu_counter_sub(&nn->counter[NFSD_NET_DRC_MEM_USAGE], amount); | |
95 | } | |
1da177e4 | 96 | |
fd19ca36 DN |
97 | #ifdef CONFIG_NFSD_V4 |
98 | static inline void nfsd_stats_wdeleg_getattr_inc(void) | |
99 | { | |
100 | percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_WDELEG_GETATTR]); | |
101 | } | |
102 | #endif | |
7f94423e | 103 | #endif /* _NFSD_STATS_H */ |