blob: 2ddaab1ac6537254b59d9f0a5dc5fc170e637438 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Chuck Leverd9ef5a82006-03-20 13:44:13 -05002/*
3 * linux/fs/nfs/iostat.h
4 *
5 * Declarations for NFS client per-mount statistics
6 *
7 * Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com>
8 *
Chuck Leverd9ef5a82006-03-20 13:44:13 -05009 */
10
11#ifndef _NFS_IOSTAT
12#define _NFS_IOSTAT
13
Chuck Leverd9ef5a82006-03-20 13:44:13 -050014#include <linux/percpu.h>
15#include <linux/cache.h>
Chuck Lever34e8f922008-06-12 12:32:25 -040016#include <linux/nfs_iostat.h>
Chuck Leverd9ef5a82006-03-20 13:44:13 -050017
18struct nfs_iostats {
19 unsigned long long bytes[__NFSIOS_BYTESMAX];
David Howells6a510912009-04-03 16:42:43 +010020#ifdef CONFIG_NFS_FSCACHE
21 unsigned long long fscache[__NFSIOS_FSCACHEMAX];
22#endif
Chuck Leverd9ef5a82006-03-20 13:44:13 -050023 unsigned long events[__NFSIOS_COUNTSMAX];
24} ____cacheline_aligned;
25
Trond Myklebust2e96d282008-06-11 16:42:05 -040026static inline void nfs_inc_server_stats(const struct nfs_server *server,
Chuck Lever34e8f922008-06-12 12:32:25 -040027 enum nfs_stat_eventcounters stat)
Chuck Leverd9ef5a82006-03-20 13:44:13 -050028{
Christoph Lameterfce22842009-10-03 19:48:22 +090029 this_cpu_inc(server->io_stats->events[stat]);
Chuck Leverd9ef5a82006-03-20 13:44:13 -050030}
31
Trond Myklebust2e96d282008-06-11 16:42:05 -040032static inline void nfs_inc_stats(const struct inode *inode,
Chuck Lever34e8f922008-06-12 12:32:25 -040033 enum nfs_stat_eventcounters stat)
Chuck Lever006ea732006-03-20 13:44:14 -050034{
35 nfs_inc_server_stats(NFS_SERVER(inode), stat);
36}
37
Trond Myklebust2e96d282008-06-11 16:42:05 -040038static inline void nfs_add_server_stats(const struct nfs_server *server,
Chuck Lever34e8f922008-06-12 12:32:25 -040039 enum nfs_stat_bytecounters stat,
Chuck Leverdfe52c02010-05-07 13:34:08 -040040 long addend)
Chuck Lever006ea732006-03-20 13:44:14 -050041{
Christoph Lameterfce22842009-10-03 19:48:22 +090042 this_cpu_add(server->io_stats->bytes[stat], addend);
Chuck Lever006ea732006-03-20 13:44:14 -050043}
44
Trond Myklebust2e96d282008-06-11 16:42:05 -040045static inline void nfs_add_stats(const struct inode *inode,
Chuck Lever34e8f922008-06-12 12:32:25 -040046 enum nfs_stat_bytecounters stat,
Chuck Leverdfe52c02010-05-07 13:34:08 -040047 long addend)
Chuck Leverd9ef5a82006-03-20 13:44:13 -050048{
Chuck Lever006ea732006-03-20 13:44:14 -050049 nfs_add_server_stats(NFS_SERVER(inode), stat, addend);
Chuck Leverd9ef5a82006-03-20 13:44:13 -050050}
51
David Howells6a510912009-04-03 16:42:43 +010052#ifdef CONFIG_NFS_FSCACHE
53static inline void nfs_add_fscache_stats(struct inode *inode,
54 enum nfs_stat_fscachecounters stat,
Chuck Leverdfe52c02010-05-07 13:34:08 -040055 long addend)
David Howells6a510912009-04-03 16:42:43 +010056{
Christoph Lameterfce22842009-10-03 19:48:22 +090057 this_cpu_add(NFS_SERVER(inode)->io_stats->fscache[stat], addend);
David Howells6a510912009-04-03 16:42:43 +010058}
Li RongQinge9f456c2014-11-23 12:47:41 +080059static inline void nfs_inc_fscache_stats(struct inode *inode,
60 enum nfs_stat_fscachecounters stat)
61{
62 this_cpu_inc(NFS_SERVER(inode)->io_stats->fscache[stat]);
63}
David Howells6a510912009-04-03 16:42:43 +010064#endif
65
Tejun Heo003cb602010-02-02 14:39:01 +090066static inline struct nfs_iostats __percpu *nfs_alloc_iostats(void)
Chuck Leverd9ef5a82006-03-20 13:44:13 -050067{
68 return alloc_percpu(struct nfs_iostats);
69}
70
Tejun Heo003cb602010-02-02 14:39:01 +090071static inline void nfs_free_iostats(struct nfs_iostats __percpu *stats)
Chuck Leverd9ef5a82006-03-20 13:44:13 -050072{
Trond Myklebust01d0ae82006-03-20 13:44:48 -050073 if (stats != NULL)
74 free_percpu(stats);
Chuck Leverd9ef5a82006-03-20 13:44:13 -050075}
76
Chuck Lever34e8f922008-06-12 12:32:25 -040077#endif /* _NFS_IOSTAT */