On 24. aug. 2016 11:02, Lorenz Bauer wrote:
On 24 August 2016 at 06:27, Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no mailto:h.b.furuseth@usit.uio.no> wrote: The unix version only uses O_DIRECT if psize >= OS psize because O_DIRECT typically requires alignment on OS page boundaries, or something like that. Should be commented. Didn't find anything similar in the Windows doc, but again, I don't know Windows. Maybe Howard knows more.
According to man 2 open O_DIRECT alignment is file system specific from 2.6 onwards, but "usually" 512bytes FWIW. Not sure how that would affect this code.
I gather you mean Linux 2.6. But O_DIRECT is not Linux-specific, I don't know of a portable way to ask "is this alignment big enough?", and the code breaks if we use O_DIRECT when the OS doesn't like it. So we simply assume the OS page size is OK.