Andrew Morton | 7c3ab73 | 2006-12-10 02:19:19 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Task I/O accounting operations |
| 3 | */ |
| 4 | #ifndef __TASK_IO_ACCOUNTING_OPS_INCLUDED |
| 5 | #define __TASK_IO_ACCOUNTING_OPS_INCLUDED |
| 6 | |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 7 | #include <linux/sched.h> |
| 8 | |
Andrew Morton | 7c3ab73 | 2006-12-10 02:19:19 -0800 | [diff] [blame] | 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 | |
Eric Dumazet | 6eaeeab | 2007-05-10 22:22:37 -0700 | [diff] [blame] | 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 | |
Andrew Morton | 7c3ab73 | 2006-12-10 02:19:19 -0800 | [diff] [blame] | 24 | static inline void task_io_account_write(size_t bytes) |
| 25 | { |
| 26 | current->ioac.write_bytes += bytes; |
| 27 | } |
| 28 | |
Eric Dumazet | 6eaeeab | 2007-05-10 22:22:37 -0700 | [diff] [blame] | 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 | |
Andrew Morton | 7c3ab73 | 2006-12-10 02:19:19 -0800 | [diff] [blame] | 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 | |
Eric Dumazet | 6eaeeab | 2007-05-10 22:22:37 -0700 | [diff] [blame] | 54 | static inline unsigned long task_io_get_inblock(const struct task_struct *p) |
| 55 | { |
| 56 | return 0; |
| 57 | } |
| 58 | |
Andrew Morton | 7c3ab73 | 2006-12-10 02:19:19 -0800 | [diff] [blame] | 59 | static inline void task_io_account_write(size_t bytes) |
| 60 | { |
| 61 | } |
| 62 | |
Eric Dumazet | 6eaeeab | 2007-05-10 22:22:37 -0700 | [diff] [blame] | 63 | static inline unsigned long task_io_get_oublock(const struct task_struct *p) |
| 64 | { |
| 65 | return 0; |
| 66 | } |
| 67 | |
Andrew Morton | 7c3ab73 | 2006-12-10 02:19:19 -0800 | [diff] [blame] | 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 */ |