Re: Kernel bug: Bad page state: related to generic symlink code and mmap

Linus Torvalds
2005-08-19T16:22:06Z

On Fri, 19 Aug 2005, Linus Torvalds wrote:
>
> The generic "page cache for symlinks" code does _not_ support invalidating
> the cache while it's being used. A local filesystem will obviously never
> invalidate the cache at all.
>
> Hmm.. NFS _does_ use the page cache for symlinks [..]

Looking more and more at this, I'm convinced this is it.

Basically, page_follow_link_light() and page_put_link() depend on the fact
that the page in the page cache is the same one the whole time:
page_follow_link_light() will increment the page count of the page it
finds at offset 0, and page_put_link() will decrement it. If the page has
changed, they increment/decrement different pages.

There's two ways to fix this:

- document this as a fundamental fact, and apply the ncpfs patch. Local
filesystems can still continue to use the generic helper functions
(all other users _are_ local filesystems).

- make "nameidata" contain not just the virtual addresses of the names,
but also have a "struct page *pages[MAX_NESTED_LINKS + 1]", and save
away the page there. That will fix ncpfs, and we could then make NFS
also use the generic routines.

I suspect that #1 is the prudent one. We have a patch already, and we
don't want to grow nameidata. I'll commit a comment at the head of
page_follow_link_light() too.

Linus