Ion Badulescu <[EMAIL PROTECTED]> writes:
> On 5 Apr 2000, Eric W. Biederman wrote:
>
> > > Summary: a page should not be in the cache and not be up-to-date. If it is
> > > not up-to-date, then it should also probably be locked, but only b/c it is
> > > probably in transit from the disk to the cache.
> >
> > Nope.
>
> Oh yeah. Just think about it a little bit:
I have a lot. It took a while before I could accept it.
> what's the point of keeping it
> in the cache if its not valid and will never become valid? The next read
> operation will end up throwing it away anyway. It can only confuse things.
Delayed write.
It isn't necessarily true the next read page will throw the page
away. Page_Uptodate simply means the generic code can't assume
all of the data is the page is uptodate.
>
> Besides, have a look at read_cache_page():
> it's supposed to return a page
> that's either uptodate or in the process of becoming uptodate. What is the
> point of duplicating read_cache_page()'s code in all its callers just to
> handle this silly case?
read_cache_page is new, broken and overdesigned.
It probably should look like.
And it's nfs callers need to be changed to call wait_on_page...
Unless someone sees a problem with this I'll make a patch up shortly
and send it to Linus.
struct page *read_cache_page(struct address_space *mapping,
unsigned long index);
{
int (*readpage)(void *, struct page*);
struct page **hash = page_hash(mapping, index);
struct page *page, *cached_page = NULL;
int error;
readpage = mapping->a_ops->readpage;
repeat:
page = __find_get_page(mapping, index, hash);
if (!page) {
if (!cached_page) {
cached_page = page_cache_alloc();
if (!cached_page)
return ERR_PTR(-ENOMEM);
}
page = cached_page;
if (add_to_page_cache_unique(page, mapping, index, hash))
goto repeat;
cached_page = NULL;
}
if (!Page_Uptodate(page)) {
lock_page(page);
if (Page_Uptodate(page)) {
UnlockPage(page);
} else {
error = readpage(data, page);
if (error) {
page_cache_release(page);
page = ERR_PTR(err);
}
}
}
if (cached_page)
page_cache_free(cached_page);
return page;
}
Eric