Re: [Patch] invalidate range of pages after direct IO write

From: Andrew Morton
Date: Thu Feb 03 2005 - 19:18:37 EST


Zach Brown <zach.brown@xxxxxxxxxx> wrote:
>
> After a direct IO write only invalidate the pages that the write intersected.
> invalidate_inode_pages2_range(mapping, pgoff start, pgoff end) is added and
> called from generic_file_direct_IO(). This doesn't break some subtle agreement
> with some other part of the code, does it?

It should be OK.

Note that the same optimisation should be made in the call to
unmap_mapping_range() in generic_file_direct_IO(). Currently we try and
unmap the whole file, even if we're only writing a single byte. Given that
you're now calculating iov_length() in there we might as well use that
number a few lines further up in that function.

Note that invalidate_inode_pages[_range2] also does the unmapping thing -
in the direct-io case we don't expect that path th ever trigger: the only
way we'll find mapped pages here is if someone raced and faulted a page
back in.

Reading the code, I'm unable to convince myself that it won't go into an
infinite loop if it finds a page at page->index = -1. But I didn't try
very hard ;)

Minor note on this:

return invalidate_inode_pages2_range(mapping, 0, ~0UL);

I just use `-1' there. We don't _know_ that pgoff_t is an unsigned long.
Some smarty may come along one day and make it unsigned long long, in which
case the code will break. Using -1 here just works everywhere.

I'll make that change and plop the patch into -mm, but we need to think
about the infinite-loop problem..
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/