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

From: Anton Altaparmakov
Date: Tue Feb 06 2007 - 08:13:44 EST


On Tue, 2007-02-06 at 03:09 +0100, Nick Piggin wrote:
> 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.

Ouch, you are of course right. )-:

Best regards,

Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer, http://www.linux-ntfs.org/

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