1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Statistics for NFS server.
5 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
10 #include <uapi/linux/nfsd/stats.h>
11 #include <linux/percpu_counter.h>
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 */
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))
26 NFSD_STATS_COUNTERS_NUM
30 struct percpu_counter counter[NFSD_STATS_COUNTERS_NUM];
32 atomic_t th_cnt; /* number of available threads */
35 extern struct nfsd_stats nfsdstats;
37 extern struct svc_stat nfsd_svcstats;
39 int nfsd_percpu_counters_init(struct percpu_counter counters[], int num);
40 void nfsd_percpu_counters_reset(struct percpu_counter counters[], int num);
41 void nfsd_percpu_counters_destroy(struct percpu_counter counters[], int num);
42 int nfsd_stat_init(void);
43 void nfsd_stat_shutdown(void);
45 static inline void nfsd_stats_rc_hits_inc(void)
47 percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_HITS]);
50 static inline void nfsd_stats_rc_misses_inc(void)
52 percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_MISSES]);
55 static inline void nfsd_stats_rc_nocache_inc(void)
57 percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_NOCACHE]);
60 static inline void nfsd_stats_fh_stale_inc(struct svc_export *exp)
62 percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_FH_STALE]);
64 percpu_counter_inc(&exp->ex_stats.counter[EXP_STATS_FH_STALE]);
67 static inline void nfsd_stats_io_read_add(struct svc_export *exp, s64 amount)
69 percpu_counter_add(&nfsdstats.counter[NFSD_STATS_IO_READ], amount);
71 percpu_counter_add(&exp->ex_stats.counter[EXP_STATS_IO_READ], amount);
74 static inline void nfsd_stats_io_write_add(struct svc_export *exp, s64 amount)
76 percpu_counter_add(&nfsdstats.counter[NFSD_STATS_IO_WRITE], amount);
78 percpu_counter_add(&exp->ex_stats.counter[EXP_STATS_IO_WRITE], amount);
81 static inline void nfsd_stats_payload_misses_inc(struct nfsd_net *nn)
83 percpu_counter_inc(&nn->counter[NFSD_NET_PAYLOAD_MISSES]);
86 static inline void nfsd_stats_drc_mem_usage_add(struct nfsd_net *nn, s64 amount)
88 percpu_counter_add(&nn->counter[NFSD_NET_DRC_MEM_USAGE], amount);
91 static inline void nfsd_stats_drc_mem_usage_sub(struct nfsd_net *nn, s64 amount)
93 percpu_counter_sub(&nn->counter[NFSD_NET_DRC_MEM_USAGE], amount);
96 #endif /* _NFSD_STATS_H */