Re: [patch 9/9] mm: fix pagecache write deadlocks

From: Nick Piggin
Date: Mon Feb 05 2007 - 21:09:38 EST


On Sun, Feb 04, 2007 at 05:40:35PM +0000, Anton Altaparmakov wrote:
> On Sun, 4 Feb 2007, Andrew Morton wrote:
> > truncate's OK: we're holding i_mutex.
>
> How about excluding readpage() (in addition to truncate if Nick is right
> and some cases of truncate do not hold i_mutex) with an extra page flag as
> I proposed for truncate exclusion? Then it would not matter that
> prepare_write might have allocated blocks and might expose stale data.
> It would go to sleep and wait on the bit to be cleared instead of trying
> to bring the page uptodate. It can then lock the page and either find it
> uptodate (because commit_write did it) or not and then bring it uptodate.
>
> Then we could safely fault in the page, copy from it into a temporary
> page, then lock the destination page again and copy into it.
>
> This is getting more involved as a patch again... )-: But at least it
> does not affect the common case except for having to check the new page
> flag in every readpage() and truncate() call. But at least the checks
> could be with an "if (unlikely(newpageflag()))" so should not be too bad.
>
> Have I missed anything this time?

Yes. If you have a flag to exclude readpage(), then you must also
exclude filemap_nopage, in which case it is still deadlocky.

-
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/