blob: ff46c6fad79da300afaa621a41abcfb1bf4c787f [file] [log] [blame]
Andrew Morton7c3ab732006-12-10 02:19:19 -08001/*
2 * Task I/O accounting operations
3 */
4#ifndef __TASK_IO_ACCOUNTING_OPS_INCLUDED
5#define __TASK_IO_ACCOUNTING_OPS_INCLUDED
6
Alexey Dobriyane8edc6e2007-05-21 01:22:52 +04007#include <linux/sched.h>
8
Andrew Morton7c3ab732006-12-10 02:19:19 -08009#ifdef CONFIG_TASK_IO_ACCOUNTING
10static inline void task_io_account_read(size_t bytes)
11{
12 current->ioac.read_bytes += bytes;
13}
14
Eric Dumazet6eaeeab2007-05-10 22:22:37 -070015/*
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{
21 return p->ioac.read_bytes >> 9;
22}
23
Andrew Morton7c3ab732006-12-10 02:19:19 -080024static inline void task_io_account_write(size_t bytes)
25{
26 current->ioac.write_bytes += bytes;
27}
28
Eric Dumazet6eaeeab2007-05-10 22:22:37 -070029/*
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{
35 return p->ioac.write_bytes >> 9;
36}
37
Andrew Morton7c3ab732006-12-10 02:19:19 -080038static inline void task_io_account_cancelled_write(size_t bytes)
39{
40 current->ioac.cancelled_write_bytes += bytes;
41}
42
43static inline void task_io_accounting_init(struct task_struct *tsk)
44{
45 memset(&tsk->ioac, 0, sizeof(tsk->ioac));
46}
47
48#else
49
50static inline void task_io_account_read(size_t bytes)
51{
52}
53
Eric Dumazet6eaeeab2007-05-10 22:22:37 -070054static inline unsigned long task_io_get_inblock(const struct task_struct *p)
55{
56 return 0;
57}
58
Andrew Morton7c3ab732006-12-10 02:19:19 -080059static inline void task_io_account_write(size_t bytes)
60{
61}
62
Eric Dumazet6eaeeab2007-05-10 22:22:37 -070063static inline unsigned long task_io_get_oublock(const struct task_struct *p)
64{
65 return 0;
66}
67
Andrew Morton7c3ab732006-12-10 02:19:19 -080068static inline void task_io_account_cancelled_write(size_t bytes)
69{
70}
71
72static 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 */