user buffer after doing 'write' to file opened with O_DIRECT
- by user1868481
I'm using the O_DIRECT flag to write to the disk directly from the user buffer.
But as far as I understand, Linux doesn't guarantee that after this call, the data is written.
It just writes directly from the user buffer to the physical device using DMA or anything else...
Therefore, I don't understand if I can write to the user buffer after the call to 'write' function.
I'm sure that example code will help to understand my question:
char *user_buff = malloc(...); /* assume it is aligned as needed */
fd = open(..., O_DIRECT);
write(fd, ...)
memset(user_buff, 0, ...)
Is the last line (memset) legal? Is writing to the user buffer valid that is maybe used by DMA to transfer data to the device?