0001
0002
0003
0004
0005
0006
0007 #ifndef _NFSD_STATS_H
0008 #define _NFSD_STATS_H
0009
0010 #include <uapi/linux/nfsd/stats.h>
0011 #include <linux/percpu_counter.h>
0012
0013
0014 enum {
0015 NFSD_STATS_RC_HITS,
0016 NFSD_STATS_RC_MISSES,
0017 NFSD_STATS_RC_NOCACHE,
0018 NFSD_STATS_FH_STALE,
0019 NFSD_STATS_IO_READ,
0020 NFSD_STATS_IO_WRITE,
0021 #ifdef CONFIG_NFSD_V4
0022 NFSD_STATS_FIRST_NFS4_OP,
0023 NFSD_STATS_LAST_NFS4_OP = NFSD_STATS_FIRST_NFS4_OP + LAST_NFS4_OP,
0024 #define NFSD_STATS_NFS4_OP(op) (NFSD_STATS_FIRST_NFS4_OP + (op))
0025 #endif
0026 NFSD_STATS_COUNTERS_NUM
0027 };
0028
0029 struct nfsd_stats {
0030 struct percpu_counter counter[NFSD_STATS_COUNTERS_NUM];
0031
0032 atomic_t th_cnt;
0033 };
0034
0035 extern struct nfsd_stats nfsdstats;
0036
0037 extern struct svc_stat nfsd_svcstats;
0038
0039 int nfsd_percpu_counters_init(struct percpu_counter counters[], int num);
0040 void nfsd_percpu_counters_reset(struct percpu_counter counters[], int num);
0041 void nfsd_percpu_counters_destroy(struct percpu_counter counters[], int num);
0042 int nfsd_stat_init(void);
0043 void nfsd_stat_shutdown(void);
0044
0045 static inline void nfsd_stats_rc_hits_inc(void)
0046 {
0047 percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_HITS]);
0048 }
0049
0050 static inline void nfsd_stats_rc_misses_inc(void)
0051 {
0052 percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_MISSES]);
0053 }
0054
0055 static inline void nfsd_stats_rc_nocache_inc(void)
0056 {
0057 percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_RC_NOCACHE]);
0058 }
0059
0060 static inline void nfsd_stats_fh_stale_inc(struct svc_export *exp)
0061 {
0062 percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_FH_STALE]);
0063 if (exp)
0064 percpu_counter_inc(&exp->ex_stats.counter[EXP_STATS_FH_STALE]);
0065 }
0066
0067 static inline void nfsd_stats_io_read_add(struct svc_export *exp, s64 amount)
0068 {
0069 percpu_counter_add(&nfsdstats.counter[NFSD_STATS_IO_READ], amount);
0070 if (exp)
0071 percpu_counter_add(&exp->ex_stats.counter[EXP_STATS_IO_READ], amount);
0072 }
0073
0074 static inline void nfsd_stats_io_write_add(struct svc_export *exp, s64 amount)
0075 {
0076 percpu_counter_add(&nfsdstats.counter[NFSD_STATS_IO_WRITE], amount);
0077 if (exp)
0078 percpu_counter_add(&exp->ex_stats.counter[EXP_STATS_IO_WRITE], amount);
0079 }
0080
0081 static inline void nfsd_stats_payload_misses_inc(struct nfsd_net *nn)
0082 {
0083 percpu_counter_inc(&nn->counter[NFSD_NET_PAYLOAD_MISSES]);
0084 }
0085
0086 static inline void nfsd_stats_drc_mem_usage_add(struct nfsd_net *nn, s64 amount)
0087 {
0088 percpu_counter_add(&nn->counter[NFSD_NET_DRC_MEM_USAGE], amount);
0089 }
0090
0091 static inline void nfsd_stats_drc_mem_usage_sub(struct nfsd_net *nn, s64 amount)
0092 {
0093 percpu_counter_sub(&nn->counter[NFSD_NET_DRC_MEM_USAGE], amount);
0094 }
0095
0096 #endif