--- linux-2.6.21-rc3/kernel/sys.c 2007-03-12 17:30:34.000000000 +0100 +++ linux-2.6.21-rc3-ed/kernel/sys.c 2007-03-12 17:50:15.000000000 +0100 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -2021,6 +2022,8 @@ static void k_getrusage(struct task_stru r->ru_nivcsw = p->signal->cnivcsw; r->ru_minflt = p->signal->cmin_flt; r->ru_majflt = p->signal->cmaj_flt; + r->ru_inblock = task_io_get_inblock(p); + r->ru_oublock = task_io_get_oublock(p); if (who == RUSAGE_CHILDREN) break; @@ -2032,6 +2035,8 @@ static void k_getrusage(struct task_stru r->ru_nivcsw += p->signal->nivcsw; r->ru_minflt += p->signal->min_flt; r->ru_majflt += p->signal->maj_flt; + r->ru_inblock += task_io_get_inblock(p); + r->ru_oublock += task_io_get_oublock(p); t = p; do { utime = cputime_add(utime, t->utime); @@ -2040,6 +2045,8 @@ static void k_getrusage(struct task_stru r->ru_nivcsw += t->nivcsw; r->ru_minflt += t->min_flt; r->ru_majflt += t->maj_flt; + r->ru_inblock += task_io_get_inblock(t); + r->ru_oublock += task_io_get_oublock(t); t = next_thread(t); } while (t != p); break; --- linux-2.6.21-rc3/include/linux/task_io_accounting_ops.h 2007-03-12 17:30:34.000000000 +0100 +++ linux-2.6.21-rc3-ed/include/linux/task_io_accounting_ops.h 2007-03-12 17:50:15.000000000 +0100 @@ -10,11 +10,29 @@ static inline void task_io_account_read( current->ioac.read_bytes += bytes; } +/* + * We approximate number of blocks, because we account bytes only. + * A 'block' is 512 bytes + */ +static inline unsigned long task_io_get_inblock(const struct task_struct *p) +{ + return p->ioac.read_bytes >> 9; +} + static inline void task_io_account_write(size_t bytes) { current->ioac.write_bytes += bytes; } +/* + * We approximate number of blocks, because we account bytes only. + * A 'block' is 512 bytes + */ +static inline unsigned long task_io_get_oublock(const struct task_struct *p) +{ + return p->ioac.write_bytes >> 9; +} + static inline void task_io_account_cancelled_write(size_t bytes) { current->ioac.cancelled_write_bytes += bytes; @@ -31,10 +49,20 @@ static inline void task_io_account_read( { } +static inline unsigned long task_io_get_inblock(const struct task_struct *p) +{ + return 0; +} + static inline void task_io_account_write(size_t bytes) { } +static inline unsigned long task_io_get_oublock(const struct task_struct *p) +{ + return 0; +} + static inline void task_io_account_cancelled_write(size_t bytes) { }