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