Direct IO and Page cache

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Fri Jul 26 10:59:25 EDT 2013


On Fri, 26 Jul 2013 00:02:31 -0400, Kumar amit mehta said:

> So leaving the hardware at the mercy of the application doesn't sound
> like a good practice. This __may__ compromise kernel stability too. Also
> think of this:

In what possible way does it compromise kernel stability?:
>
> In app1:
> fdx = open("blah" , O_RW|O_DIRECT);
> write(fdx,buf,sizeof(buf));
>
> In app2(unaware of app1):
> fdy = open("blah", O_RW);
> write(fdy,buf, sizeof(buf));
>
> I think this isn't highly unlikely to do, and if you agree with me then
> we may end up with same could-be/would-be data-corruption. Now who should
> be blamed here, app1, app2

You blame the idiot programmer who didn't use file locking, and/or the idiot
user who ran the two programs.

This isn't even about O_DIRECT - try writing two programs that both
basically do a 'write 1M of data, sleep 10 seconds' using stdio to the
same file, and see what happens....
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130726/4cd548f7/attachment.bin 


More information about the Kernelnewbies mailing list