blob: 1218733ec6b58c27ea894f13a7b61f2f7f9d1623 [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
7#ifdef CONFIG_TASK_IO_ACCOUNTING
8static inline void task_io_account_read(size_t bytes)
9{
10 current->ioac.read_bytes += bytes;
11}
12
Eric Dumazet6eaeeab2007-05-10 22:22:37 -070013/*
14 * We approximate number of blocks, because we account bytes only.
15 * A 'block' is 512 bytes
16 */
17static inline unsigned long task_io_get_inblock(const struct task_struct *p)
18{
19 return p->ioac.read_bytes >> 9;
20}
21
Andrew Morton7c3ab732006-12-10 02:19:19 -080022static inline void task_io_account_write(size_t bytes)
23{
24 current->ioac.write_bytes += bytes;
25}
26
Eric Dumazet6eaeeab2007-05-10 22:22:37 -070027/*
28 * We approximate number of blocks, because we account bytes only.
29 * A 'block' is 512 bytes
30 */
31static inline unsigned long task_io_get_oublock(const struct task_struct *p)
32{
33 return p->ioac.write_bytes >> 9;
34}
35
Andrew Morton7c3ab732006-12-10 02:19:19 -080036static inline void task_io_account_cancelled_write(size_t bytes)
37{
38 current->ioac.cancelled_write_bytes += bytes;
39}
40
41static inline void task_io_accounting_init(struct task_struct *tsk)
42{
43 memset(&tsk->ioac, 0, sizeof(tsk->ioac));
44}
45
46#else
47
48static inline void task_io_account_read(size_t bytes)
49{
50}
51
Eric Dumazet6eaeeab2007-05-10 22:22:37 -070052static inline unsigned long task_io_get_inblock(const struct task_struct *p)
53{
54 return 0;
55}
56
Andrew Morton7c3ab732006-12-10 02:19:19 -080057static inline void task_io_account_write(size_t bytes)
58{
59}
60
Eric Dumazet6eaeeab2007-05-10 22:22:37 -070061static inline unsigned long task_io_get_oublock(const struct task_struct *p)
62{
63 return 0;
64}
65
Andrew Morton7c3ab732006-12-10 02:19:19 -080066static inline void task_io_account_cancelled_write(size_t bytes)
67{
68}
69
70static 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 */