Re: [PATCH] Fix vmtruncate race and distributed filesystem race

From: Andrew Morton (akpm@digeo.com)
Date: Mon Jun 23 2003 - 01:32:35 EST


"Paul E. McKenney" <paulmck@us.ibm.com> wrote:
>
> > but you can't trap this with a single counter increment in do_truncate:
> >
> > CPU 0 CPU 1
> > ---------- -----------
> > do_no_page
> > truncate

        i_size = new_i_size;

> > increment counter
> > read counter
> > ->nopage

                                check i_size

> > vmtruncate
> > read counter again -> different so retry
> >
> > thanks to the second counter increment after vmtruncate in my fix, the
> > above race couldn't happen.
>
> The trick is that CPU 0 is expected to have updated the filesystem's
> idea of what pages are available before calling vmtruncate,
> invalidate_mmap_range() or whichever.

i_size has been updated, and filemap_nopage() will return NULL.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jun 23 2003 - 22:00:40 EST