Commit 9ca7d6f6 authored by Jay Lan's avatar Jay Lan Committed by Linus Torvalds

[PATCH] enhanced I/O accounting data patch

This patch is to offer common accounting data collection method at I/O for
various accounting packages including BSD accounting, ELSA, CSA and any
other acct packages that use a common layer of data collection.

Patch is made to fs/read_write.c to collect per process data on character
read/written in bytes and number of read/write syscalls made.

New struct fields are added to task_struct to store the data.

These data are collected on per process basis.
Signed-off-by: default avatarJay Lan <jlan@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6c0993a0
......@@ -216,8 +216,11 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
ret = file->f_op->read(file, buf, count, pos);
else
ret = do_sync_read(file, buf, count, pos);
if (ret > 0)
if (ret > 0) {
dnotify_parent(file->f_dentry, DN_ACCESS);
current->rchar += ret;
}
current->syscr++;
}
}
......@@ -260,8 +263,11 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
ret = file->f_op->write(file, buf, count, pos);
else
ret = do_sync_write(file, buf, count, pos);
if (ret > 0)
if (ret > 0) {
dnotify_parent(file->f_dentry, DN_MODIFY);
current->wchar += ret;
}
current->syscw++;
}
}
......@@ -540,6 +546,9 @@ sys_readv(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
fput_light(file, fput_needed);
}
if (ret > 0)
current->rchar += ret;
current->syscr++;
return ret;
}
......@@ -558,6 +567,9 @@ sys_writev(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
fput_light(file, fput_needed);
}
if (ret > 0)
current->wchar += ret;
current->syscw++;
return ret;
}
......@@ -636,6 +648,13 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
retval = in_file->f_op->sendfile(in_file, ppos, count, file_send_actor, out_file);
if (retval > 0) {
current->rchar += retval;
current->wchar += retval;
}
current->syscr++;
current->syscw++;
if (*ppos > max)
retval = -EOVERFLOW;
......
......@@ -660,6 +660,8 @@ struct task_struct {
* to a stack based synchronous wait) if its doing sync IO.
*/
wait_queue_t *io_wait;
/* i/o counters(bytes read/written, #syscalls */
u64 rchar, wchar, syscr, syscw;
#ifdef CONFIG_NUMA
struct mempolicy *mempolicy;
short il_next; /* could be shared with used_math */
......
......@@ -865,12 +865,21 @@ static task_t *copy_process(unsigned long clone_flags,
clear_tsk_thread_flag(p, TIF_SIGPENDING);
init_sigpending(&p->pending);
p->it_real_value = p->it_virt_value = p->it_prof_value = 0;
p->it_real_incr = p->it_virt_incr = p->it_prof_incr = 0;
p->it_real_value = 0;
p->it_real_incr = 0;
p->it_virt_value = 0;
p->it_virt_incr = 0;
p->it_prof_value = 0;
p->it_prof_incr = 0;
init_timer(&p->real_timer);
p->real_timer.data = (unsigned long) p;
p->utime = p->stime = 0;
p->utime = 0;
p->stime = 0;
p->rchar = 0; /* I/O counter: bytes read */
p->wchar = 0; /* I/O counter: bytes written */
p->syscr = 0; /* I/O counter: read syscalls */
p->syscw = 0; /* I/O counter: write syscalls */
p->lock_depth = -1; /* -1 = no lock */
do_posix_clock_monotonic_gettime(&p->start_time);
p->security = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment