Re: [PATCH] Fix race between callers of read_cache_page_async andinvalidate_inode_pages.

From: Neil Brown
Date: Mon Apr 27 2009 - 03:46:21 EST


On Sunday April 26, akpm@xxxxxxxxxxxxxxxxxxxx wrote:
> On Mon, 27 Apr 2009 15:20:22 +1000 Neil Brown <neilb@xxxxxxx> wrote:
>
> hrm. And where is it written that PageError() will remain inviolable
> after it has been set?

...it follows as night the day....

What use would PageError be if it can just disappear when you most
want to test it?
Then again, what use is PageUptodate if it can just disappear? My
other thought for fixing this was to change truncate_complete_page to
not clear PageUptodate.....
Oh. That's already been done in 2.6.27-rc2.

So I guess this isn't a bug in mainline anymore... sorry for the noise :-)
(I'll just go quietly fix some enterprise kernels).
>
> A safer and more formal (albeit somewhat slower) fix would be to lock
> the page and check its state under the lock.
>
> y:/usr/src/linux-2.6.30-rc3> grep -r ClearPageError . | wc -l
> 21

I think each of these do one of:
- clear the error after a successful read
- clear the error before a read attempt
- clear the error before a write
all (I think) while the page is locked. None of these would
invalidate the change I made. (and I still think that it would read
better to say
if (PageError(page))
goto error;

than
if (!PageUptodate(page))
goto error;

but no matter).

Thanks anyway.
NeilBrown
--
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/