[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20061004165504.c1dd3dd3.akpm@osdl.org>
Date: Wed, 4 Oct 2006 16:55:04 -0700
From: Andrew Morton <akpm@...l.org>
To: Jeff Moyer <jmoyer@...hat.com>
Cc: Zach Brown <zach.brown@...cle.com>, linux-kernel@...r.kernel.org
Subject: Re: [patch] call truncate_inode_pages in the DIO fallback to
buffered I/O path
On Wed, 04 Oct 2006 16:53:53 -0400
Jeff Moyer <jmoyer@...hat.com> wrote:
> The man page for open states:
>
> O_DIRECT
> Try to minimize cache effects of the I/O to and from this file.
>
> I think that invalidating the page cache pages we use when falling back to
> buffered I/O stays true to the above description.
What the manpage forgot to mention is "direct-io is synchronous".
Except it isn't, when we fall back to buffered-IO. So yup, I think we
could justify this (sort of) change on those grounds alone: preserving the
synchronous semantics.
I'd propose that we do this via
generic_file_buffered_write(...);
do_sync_file_range(..., SYNC_FILE_RANGE_WAIT_BEFORE|
SYNC_FILE_RANGE_WRITE|
SYNC_FILE_RANGE_WAIT_AFTER)
invalidate_mapping_pages(...);
There is a slight inefficiency here: generic_file_direct_IO() does
invalidate_inode_pages2_range(), then we go and instantiate some pagecache,
then we strip it away again with invalidate_mapping_pages(). That first
invalidate_inode_pages2_range() was somewhat of a waste of cycles.
But we expect that the next call to generic_file_direct_IO() won't actually
call invalidate_inode_pages2_range(), because mapping->nrpages is usually
zero.
Well, it would have been, back in the days when we were invalidating the
whole file. Now are more efficient and we only invalidate the specific
segment of that file. So if there's a stray pagecache page somewhere at the
far end ofthe file, we'll pointlessly call invalidate_inode_pages2_range() every
time. Oh well.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists