Subject: Re: Is O_DIRECT useless on NetBSD?
To: Antti Kantee <email@example.com>
From: Chuck Silvers <firstname.lastname@example.org>
Date: 12/17/2007 19:44:54
On Wed, Nov 21, 2007 at 04:39:13PM +0200, Antti Kantee wrote:
> On Wed Nov 21 2007 at 15:11:39 +0100, Roland Illig wrote:
> > >All the involved filesystems are ffs. So did I understand O_DIRECT
> > >wrong? Or is it at all impossible to disable the kernel cache for file
> > >data?
> I am assuming your archiver is extending the file. This does not work
> for O_DIRECT and it falls back to the buffered path. I am not sure
> if there is any real reason why it shouldn't be allowed, but at least
> currently the O_DIRECT code doesn't do block allocation. Maybe $ubcgod
> knows a deeper truth?
O_DIRECT is a no-op for allocating writes only because I didn't bother
to do the extra work to support it. at the time, I was interested in
database-style operation, ie. I/O to a pre-allocated file, so I didn't
need to worry about allocation. to add O_DIRECT support for allocation
probably wouldn't be all that hard, the only really interesting case
being correct integration with softdeps. freebsd handles this by
implementing O_DIRECT writes as buffered, but invalidating each buffer
instead of leaving it in the cache after it's on disk (or at least that's
what they did when I looked several years ago). a better implementation
would still do the writes as direct but create the necessary dependencies
to prevent the inode or indirect block from being written until the
direct I/O completes successfully.