On Thu, 17 Sep 2020, Dave Chinner wrote:
> 
> So....
> 
> P0                                    p1
> 
> hole punch starts
>   takes XFS_MMAPLOCK_EXCL
>   truncate_pagecache_range()
>     unmap_mapping_range(start, end)
>       <clears ptes>
>                                       <read fault>
>                                       do_fault_around()
>                                         ->map_pages
>                                           filemap_map_pages()
>                                             page mapping valid,
>                                             page is up to date
>                                             maps PTEs
>                                       <fault done>
>     truncate_inode_pages_range()
>       truncate_cleanup_page(page)
>         invalidates page
>       delete_from_page_cache_batch(page)
>         frees page
>                                       <pte now points to a freed page>

No.  filemap_map_pages() checks page->mapping after trylock_page(),
before setting up the pte; and truncate_cleanup_page() does a one-page
unmap_mapping_range() if page_mapped(), while holding page lock.

(Of course, there's a different thread, in which less reliance on
page lock is being discussed, but that would be a future thing.)

Hugh

Reply via email to