Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  linux/fs/nfs/iostat.h
0004  *
0005  *  Declarations for NFS client per-mount statistics
0006  *
0007  *  Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com>
0008  *
0009  */
0010 
0011 #ifndef _NFS_IOSTAT
0012 #define _NFS_IOSTAT
0013 
0014 #include <linux/percpu.h>
0015 #include <linux/cache.h>
0016 #include <linux/nfs_iostat.h>
0017 
0018 struct nfs_iostats {
0019     unsigned long long  bytes[__NFSIOS_BYTESMAX];
0020 #ifdef CONFIG_NFS_FSCACHE
0021     unsigned long long  fscache[__NFSIOS_FSCACHEMAX];
0022 #endif
0023     unsigned long       events[__NFSIOS_COUNTSMAX];
0024 } ____cacheline_aligned;
0025 
0026 static inline void nfs_inc_server_stats(const struct nfs_server *server,
0027                     enum nfs_stat_eventcounters stat)
0028 {
0029     this_cpu_inc(server->io_stats->events[stat]);
0030 }
0031 
0032 static inline void nfs_inc_stats(const struct inode *inode,
0033                  enum nfs_stat_eventcounters stat)
0034 {
0035     nfs_inc_server_stats(NFS_SERVER(inode), stat);
0036 }
0037 
0038 static inline void nfs_add_server_stats(const struct nfs_server *server,
0039                     enum nfs_stat_bytecounters stat,
0040                     long addend)
0041 {
0042     this_cpu_add(server->io_stats->bytes[stat], addend);
0043 }
0044 
0045 static inline void nfs_add_stats(const struct inode *inode,
0046                  enum nfs_stat_bytecounters stat,
0047                  long addend)
0048 {
0049     nfs_add_server_stats(NFS_SERVER(inode), stat, addend);
0050 }
0051 
0052 #ifdef CONFIG_NFS_FSCACHE
0053 static inline void nfs_add_fscache_stats(struct inode *inode,
0054                      enum nfs_stat_fscachecounters stat,
0055                      long addend)
0056 {
0057     this_cpu_add(NFS_SERVER(inode)->io_stats->fscache[stat], addend);
0058 }
0059 static inline void nfs_inc_fscache_stats(struct inode *inode,
0060                      enum nfs_stat_fscachecounters stat)
0061 {
0062     this_cpu_inc(NFS_SERVER(inode)->io_stats->fscache[stat]);
0063 }
0064 #endif
0065 
0066 static inline struct nfs_iostats __percpu *nfs_alloc_iostats(void)
0067 {
0068     return alloc_percpu(struct nfs_iostats);
0069 }
0070 
0071 static inline void nfs_free_iostats(struct nfs_iostats __percpu *stats)
0072 {
0073     if (stats != NULL)
0074         free_percpu(stats);
0075 }
0076 
0077 #endif /* _NFS_IOSTAT */