Skip to contentSkip to conversation

open(O_DIRECT) on a tmpfs?

DISCUSSION Bodo Eggert 1 participant 1 message Jan 4, 2007 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]

#1 lore raw
Quoted 4 lines · Michael Tokarev

I wonder why open() with O_DIRECT (for example) bit set is disallowed on a tmpfs (again, for example) filesystem, returning EINVAL.

Quoted 8 lines

Yes, the question may seems strange a bit, because of two somewhat conflicting reasons. First, there's no reason to use O_DIRECT with tmpfs in a first place, because tmpfs does not have backing store at all, so there's no place to do direct writes to. But on another hand, again due to the very nature of tmpfs, there's no reason not to allow O_DIRECT open and just ignore it, -- exactly because there's no backing store for this filesystem.

I'm using a tmpfs as a mostly-ramdisk, that is I've set up a large swap partition in case I need the RAM instead of using it for a filesystem. Therefore it will sometimes have a backing store.

OTOH, ramfs does not have this property (the cache is the backing store), so it would make sense to allow it at least there.

BTW: Maybe you could use a ramdisk instead of the loop-on-tmpfs.

Signature · 4 lines
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.

http://david.woodhou.se/why-not-spf.html