Skip to contentSkip to conversation

O_DIRECT fails in some kernel and FS

DISCUSSION Andi Kleen 3 participants 3 messages Feb 3, 2002 – Feb 4, 2002 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#1 lore raw
Quoted 7 lines · Jeff Garzik
Quoted 3 lines · Stephen Lord

Can't you fall back to buffered I/O for the tail? OK it complicates the code, probably a lot, but it keeps things sane from the user's point of view.

For O_DIRECT, IMHO you should fail not fallback. You're simply lying to the underlying program otherwise.

It's just impossible to write a tail which is smaller than a disk block without another buffer.

-Andi

#2 lore raw
In reply to a message not in the archive
Quoted 8 lines · Andi Kleen
Quoted 5 lines · Jeff Garzik
Quoted 3 lines · Stephen Lord

Can't you fall back to buffered I/O for the tail? OK it complicates the code, probably a lot, but it keeps things sane from the user's point of view.

Quoted 5 lines
Quoted 2 lines

For O_DIRECT, IMHO you should fail not fallback. You're simply lying to the underlying program otherwise.

It's just impossible to write a tail which is smaller than a disk block without another buffer.

I argue, for reiserfs:

For O_DIRECT writes, the preferred behavior is to write disk blocks obtained through the normal methods (get_block, etc.), and fully support inodes for which file tails do not exist.

For O_DIRECT reads, if the data is determined to be in a file tail, ->direct_IO should either (a) fail or (b) dump the file tail to a normal disk block before performing ->direct_IO.

Signature · 3 lines
Jeff Garzik      | "I went through my candy like hot oatmeal
Building 1024    |  through an internally-buttered weasel."
MandrakeSoft     |             - goats.com
#3 lore raw
Quoted 12 lines · On Monday, February 04, 2002 10:13:37 AM -0500 Jeff Garzik…
Quoted 11 lines · Andi Kleen
Quoted 7 lines · Jeff Garzik
Quoted 3 lines · Stephen Lord

Can't you fall back to buffered I/O for the tail? OK it complicates the code, probably a lot, but it keeps things sane from the user's point of view.

For O_DIRECT, IMHO you should fail not fallback. You're simply lying to the underlying program otherwise.

Quoted 8 lines
Quoted 2 lines

It's just impossible to write a tail which is smaller than a disk block without another buffer.

I argue, for reiserfs:

For O_DIRECT writes, the preferred behavior is to write disk blocks obtained through the normal methods (get_block, etc.), and fully support inodes for which file tails do not exist.

Done ;-)

Quoted 4 lines

For O_DIRECT reads, if the data is determined to be in a file tail, ->direct_IO should either (a) fail or (b) dump the file tail to a normal disk block before performing ->direct_IO.

The current patch does A. Another option is to change the reiserfs open code to detect the tail and do an -EINVAL for o_direct. This gives the application a better way to fall back to normal open methods than returning an error during the read.

Just to restate, the current O_DIRECT code can never hit a reiserfs tail in the normal case. By definition, reiserfs tails are not block aligned, and O_DIRECT writes are. The only time it is a concern is with a screwy interaction between expanding truncates and tails on kernels < 2.4.17. Since most O_DIRECT users are databases, and tails are never created on files > 16k in size, I don't expect anyone to ever see the reiserfs triggered -EINVAL from the current patch (famous last words).

-chris