I have a program that is used to exercise several disk units in a raid configuration. 1 process synchronously (O_SYNC
) writes random data to a file using write()
. It then puts the name of the directory into a shared-memory queue, where a 2nd process is waiting for the queue to have entries to read the data back into memory using read()
.
The problem that I can't seem to overcome is that when the 2nd process attempts to read the data back into memory, none of the disk units show read accesses. The program has code to check whether or not the data read back in is equal to the code that is written to disk, and the data always matches.
My question is, how can I make the OS (IBM i) not buffer the data when it is written to disk so that the read()
system call accesses the data on the disk rather than in cache? I am doing simple throughput calculations and the read()
operations are always 10+ times faster than the write
operations.
I have tried using the O_DIRECT
flag, but cannot seem to get the data to write to the file. It could have to do with setting up the correct aligned buffers. I have also tried the posix_fadvise(fd, offset,len, POSIX_FADV_DONTNEED)
system call.
I have read through this similar question but haven't found a solution. I can provide code if it would be helpful.