Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband
[pandora-kernel.git] / include / linux / task_io_accounting_ops.h
1 /*
2  * Task I/O accounting operations
3  */
4 #ifndef __TASK_IO_ACCOUNTING_OPS_INCLUDED
5 #define __TASK_IO_ACCOUNTING_OPS_INCLUDED
6
7 #ifdef CONFIG_TASK_IO_ACCOUNTING
8 static inline void task_io_account_read(size_t bytes)
9 {
10         current->ioac.read_bytes += bytes;
11 }
12
13 /*
14  * We approximate number of blocks, because we account bytes only.
15  * A 'block' is 512 bytes
16  */
17 static inline unsigned long task_io_get_inblock(const struct task_struct *p)
18 {
19         return p->ioac.read_bytes >> 9;
20 }
21
22 static inline void task_io_account_write(size_t bytes)
23 {
24         current->ioac.write_bytes += bytes;
25 }
26
27 /*
28  * We approximate number of blocks, because we account bytes only.
29  * A 'block' is 512 bytes
30  */
31 static inline unsigned long task_io_get_oublock(const struct task_struct *p)
32 {
33         return p->ioac.write_bytes >> 9;
34 }
35
36 static inline void task_io_account_cancelled_write(size_t bytes)
37 {
38         current->ioac.cancelled_write_bytes += bytes;
39 }
40
41 static inline void task_io_accounting_init(struct task_struct *tsk)
42 {
43         memset(&tsk->ioac, 0, sizeof(tsk->ioac));
44 }
45
46 #else
47
48 static inline void task_io_account_read(size_t bytes)
49 {
50 }
51
52 static inline unsigned long task_io_get_inblock(const struct task_struct *p)
53 {
54         return 0;
55 }
56
57 static inline void task_io_account_write(size_t bytes)
58 {
59 }
60
61 static inline unsigned long task_io_get_oublock(const struct task_struct *p)
62 {
63         return 0;
64 }
65
66 static inline void task_io_account_cancelled_write(size_t bytes)
67 {
68 }
69
70 static inline void task_io_accounting_init(struct task_struct *tsk)
71 {
72 }
73
74 #endif          /* CONFIG_TASK_IO_ACCOUNTING */
75 #endif          /* __TASK_IO_ACCOUNTING_OPS_INCLUDED */