diff mbox series

[03/10] mm/truncate: Convert invalidate_inode_page() to use a folio

Message ID 20220214200017.3150590-4-willy@infradead.org (mailing list archive)
State New
Headers show
Series Various fixes around invalidate_page() | expand

Commit Message

Matthew Wilcox Feb. 14, 2022, 8 p.m. UTC
This saves a number of calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/truncate.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig Feb. 15, 2022, 7:18 a.m. UTC | #1
On Mon, Feb 14, 2022 at 08:00:10PM +0000, Matthew Wilcox (Oracle) wrote:
> This saves a number of calls to compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
Miaohe Lin Feb. 15, 2022, 8:32 a.m. UTC | #2
On 2022/2/15 4:00, Matthew Wilcox (Oracle) wrote:
> This saves a number of calls to compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---

LGTM. Thanks.

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

>  mm/truncate.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/truncate.c b/mm/truncate.c
> index e5e2edaa0b76..b73c30c95cd0 100644
> --- a/mm/truncate.c
> +++ b/mm/truncate.c
> @@ -281,14 +281,15 @@ EXPORT_SYMBOL(generic_error_remove_page);
>   */
>  int invalidate_inode_page(struct page *page)
>  {
> -	struct address_space *mapping = page_mapping(page);
> +	struct folio *folio = page_folio(page);
> +	struct address_space *mapping = folio_mapping(folio);
>  	if (!mapping)
>  		return 0;
> -	if (PageDirty(page) || PageWriteback(page))
> +	if (folio_test_dirty(folio) || folio_test_writeback(folio))
>  		return 0;
>  	if (page_mapped(page))
>  		return 0;
> -	if (page_has_private(page) && !try_to_release_page(page, 0))
> +	if (folio_has_private(folio) && !filemap_release_folio(folio, 0))
>  		return 0;
>  
>  	return remove_mapping(mapping, page);
>
diff mbox series

Patch

diff --git a/mm/truncate.c b/mm/truncate.c
index e5e2edaa0b76..b73c30c95cd0 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -281,14 +281,15 @@  EXPORT_SYMBOL(generic_error_remove_page);
  */
 int invalidate_inode_page(struct page *page)
 {
-	struct address_space *mapping = page_mapping(page);
+	struct folio *folio = page_folio(page);
+	struct address_space *mapping = folio_mapping(folio);
 	if (!mapping)
 		return 0;
-	if (PageDirty(page) || PageWriteback(page))
+	if (folio_test_dirty(folio) || folio_test_writeback(folio))
 		return 0;
 	if (page_mapped(page))
 		return 0;
-	if (page_has_private(page) && !try_to_release_page(page, 0))
+	if (folio_has_private(folio) && !filemap_release_folio(folio, 0))
 		return 0;
 
 	return remove_mapping(mapping, page);