Re: [PATCH 02/10] mm/truncate: Inline invalidate_complete_page() into its one caller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2022/2/15 4:00, Matthew Wilcox (Oracle) wrote:
> invalidate_inode_page() is the only caller of invalidate_complete_page()
> and inlining it reveals that the first check is unnecessary (because we
> hold the page locked, and we just retrieved the mapping from the page).
> Actually, it does make a difference, in that tail pages no longer fail
> at this check, so it's now possible to remove a tail page from a mapping.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> ---
>  mm/truncate.c | 28 +++++-----------------------
>  1 file changed, 5 insertions(+), 23 deletions(-)
> 
> diff --git a/mm/truncate.c b/mm/truncate.c
> index 9dbf0b75da5d..e5e2edaa0b76 100644
> --- a/mm/truncate.c
> +++ b/mm/truncate.c
> @@ -193,27 +193,6 @@ static void truncate_cleanup_folio(struct folio *folio)
>  	folio_clear_mappedtodisk(folio);
>  }
>  
> -/*
> - * This is for invalidate_mapping_pages().  That function can be called at
> - * any time, and is not supposed to throw away dirty pages.  But pages can
> - * be marked dirty at any time too, so use remove_mapping which safely
> - * discards clean, unused pages.
> - *
> - * Returns non-zero if the page was successfully invalidated.
> - */
> -static int
> -invalidate_complete_page(struct address_space *mapping, struct page *page)
> -{
> -
> -	if (page->mapping != mapping)
> -		return 0;
> -
> -	if (page_has_private(page) && !try_to_release_page(page, 0))
> -		return 0;
> -
> -	return remove_mapping(mapping, page);
> -}
> -
>  int truncate_inode_folio(struct address_space *mapping, struct folio *folio)
>  {
>  	if (folio->mapping != mapping)
> @@ -309,7 +288,10 @@ int invalidate_inode_page(struct page *page)
>  		return 0;
>  	if (page_mapped(page))
>  		return 0;
> -	return invalidate_complete_page(mapping, page);

It seems the checking of page->mapping != mapping is removed here.
IIUC, this would cause possibly unexpected side effect because
swapcache page can be invalidate now. I think this function is
not intended to deal with swapcache though it could do this.
Or am I miss anything?

Many thanks!

> +	if (page_has_private(page) && !try_to_release_page(page, 0))
> +		return 0;
> +
> +	return remove_mapping(mapping, page);
>  }
>  
>  /**
> @@ -584,7 +566,7 @@ void invalidate_mapping_pagevec(struct address_space *mapping,
>  }
>  
>  /*
> - * This is like invalidate_complete_page(), except it ignores the page's
> + * This is like invalidate_inode_page(), except it ignores the page's
>   * refcount.  We do this because invalidate_inode_pages2() needs stronger
>   * invalidation guarantees, and cannot afford to leave pages behind because
>   * shrink_page_list() has a temp ref on them, or because they're transiently
> 




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux