nlm: Ensure callback code also checks that the files match
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / task_io_accounting_ops.h
CommitLineData
7c3ab738
AM
1/*
2 * Task I/O accounting operations
3 */
4#ifndef __TASK_IO_ACCOUNTING_OPS_INCLUDED
5#define __TASK_IO_ACCOUNTING_OPS_INCLUDED
6
e8edc6e0
AD
7#include <linux/sched.h>
8
7c3ab738
AM
9#ifdef CONFIG_TASK_IO_ACCOUNTING
10static inline void task_io_account_read(size_t bytes)
11{
940389b8 12 current->ioac.read_bytes += bytes;
7c3ab738
AM
13}
14
6eaeeaba
ED
15/*
16 * We approximate number of blocks, because we account bytes only.
17 * A 'block' is 512 bytes
18 */
19static inline unsigned long task_io_get_inblock(const struct task_struct *p)
20{
940389b8 21 return p->ioac.read_bytes >> 9;
6eaeeaba
ED
22}
23
7c3ab738
AM
24static inline void task_io_account_write(size_t bytes)
25{
940389b8 26 current->ioac.write_bytes += bytes;
7c3ab738
AM
27}
28
6eaeeaba
ED
29/*
30 * We approximate number of blocks, because we account bytes only.
31 * A 'block' is 512 bytes
32 */
33static inline unsigned long task_io_get_oublock(const struct task_struct *p)
34{
940389b8 35 return p->ioac.write_bytes >> 9;
6eaeeaba
ED
36}
37
7c3ab738
AM
38static inline void task_io_account_cancelled_write(size_t bytes)
39{
940389b8 40 current->ioac.cancelled_write_bytes += bytes;
7c3ab738
AM
41}
42
940389b8 43static inline void task_io_accounting_init(struct task_io_accounting *ioac)
7c3ab738 44{
5995477a
AR
45 memset(ioac, 0, sizeof(*ioac));
46}
47
940389b8
AR
48static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
49 struct task_io_accounting *src)
5995477a 50{
940389b8
AR
51 dst->read_bytes += src->read_bytes;
52 dst->write_bytes += src->write_bytes;
53 dst->cancelled_write_bytes += src->cancelled_write_bytes;
7c3ab738
AM
54}
55
56#else
57
58static inline void task_io_account_read(size_t bytes)
59{
60}
61
6eaeeaba
ED
62static inline unsigned long task_io_get_inblock(const struct task_struct *p)
63{
64 return 0;
65}
66
7c3ab738
AM
67static inline void task_io_account_write(size_t bytes)
68{
69}
70
6eaeeaba
ED
71static inline unsigned long task_io_get_oublock(const struct task_struct *p)
72{
73 return 0;
74}
75
7c3ab738
AM
76static inline void task_io_account_cancelled_write(size_t bytes)
77{
78}
79
940389b8 80static inline void task_io_accounting_init(struct task_io_accounting *ioac)
5995477a
AR
81{
82}
83
940389b8
AR
84static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
85 struct task_io_accounting *src)
7c3ab738
AM
86{
87}
88
5995477a
AR
89#endif /* CONFIG_TASK_IO_ACCOUNTING */
90
91#ifdef CONFIG_TASK_XACCT
940389b8
AR
92static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
93 struct task_io_accounting *src)
5995477a 94{
940389b8
AR
95 dst->rchar += src->rchar;
96 dst->wchar += src->wchar;
97 dst->syscr += src->syscr;
98 dst->syscw += src->syscw;
5995477a
AR
99}
100#else
940389b8
AR
101static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
102 struct task_io_accounting *src)
5995477a
AR
103{
104}
105#endif /* CONFIG_TASK_XACCT */
106
940389b8
AR
107static inline void task_io_accounting_add(struct task_io_accounting *dst,
108 struct task_io_accounting *src)
5995477a
AR
109{
110 task_chr_io_accounting_add(dst, src);
111 task_blk_io_accounting_add(dst, src);
112}
113#endif /* __TASK_IO_ACCOUNTING_OPS_INCLUDED */