]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/task_io_accounting_ops.h
Detach sched.h from mm.h
[mirror_ubuntu-artful-kernel.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{
12 current->ioac.read_bytes += bytes;
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{
21 return p->ioac.read_bytes >> 9;
22}
23
7c3ab738
AM
24static inline void task_io_account_write(size_t bytes)
25{
26 current->ioac.write_bytes += bytes;
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{
35 return p->ioac.write_bytes >> 9;
36}
37
7c3ab738
AM
38static 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
6eaeeaba
ED
54static inline unsigned long task_io_get_inblock(const struct task_struct *p)
55{
56 return 0;
57}
58
7c3ab738
AM
59static inline void task_io_account_write(size_t bytes)
60{
61}
62
6eaeeaba
ED
63static inline unsigned long task_io_get_oublock(const struct task_struct *p)
64{
65 return 0;
66}
67
7c3ab738
AM
68static 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 */