Hi,
I'd like to understand the following issue:
A process is doing write sys call only, in an infinite loop. When I bring up iotop I would expect to see non-zero write speed and zeroed read speed related to that process. But iotop tells read and write can be equal (depending on single write size). Have a look at the C code:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#define BUFSIZE 1000000
char buf[BUFSIZE];
const int write_size = 4000;
int main(){
int fd;
if ((fd = open("filename", O_RDWR | O_CREAT, 0666)) < 0){
return -1;
}
ssize_t ret;
while (1){
ret = write(fd, buf, write_size);
if (ret != write_size){
return -1;
}
}
return 0;
}
If you assign different values to 'write_size' you'll see different read speeds in iotop. If the value is as in the code above, iotop shows read and write are equal.
Important:
The issue appears only under certain conditions:
- The file must be created and filled with data (lets say at least 8GB) before running the code
OS conf:
Debian lenny, 2TB disk, (both xfs and ext4 tested),
uname -a
Linux g-6 2.6.26-bpo.1-xen-amd64 #1 SMP Mon Jan 12 14:32:40 UTC 2009 x86_64 GNU/Linux
Thanks in advance for solving the mystery,
Michal.