diff mbox series

[34/48] shmem: Convert part of shmem_undo_range() to use a folio

Message ID 20211208042256.1923824-35-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Folios for 5.17 | expand

Commit Message

Matthew Wilcox Dec. 8, 2021, 4:22 a.m. UTC
find_lock_entries() never returns tail pages.  We cannot use page_folio()
here as the pagevec may also contain swap entries, so simply cast.

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

Comments

Christoph Hellwig Dec. 23, 2021, 7:39 a.m. UTC | #1
On Wed, Dec 08, 2021 at 04:22:42AM +0000, Matthew Wilcox (Oracle) wrote:
> find_lock_entries() never returns tail pages.  We cannot use page_folio()
> here as the pagevec may also contain swap entries, so simply cast.

Ugg.  At least this seems to be temporary, so:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/mm/shmem.c b/mm/shmem.c
index 18f93c2d68f1..40da9075374b 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -936,22 +936,22 @@  static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
 	while (index < end && find_lock_entries(mapping, index, end - 1,
 			&pvec, indices)) {
 		for (i = 0; i < pagevec_count(&pvec); i++) {
-			struct page *page = pvec.pages[i];
+			struct folio *folio = (struct folio *)pvec.pages[i];
 
 			index = indices[i];
 
-			if (xa_is_value(page)) {
+			if (xa_is_value(folio)) {
 				if (unfalloc)
 					continue;
 				nr_swaps_freed += !shmem_free_swap(mapping,
-								index, page);
+								index, folio);
 				continue;
 			}
-			index += thp_nr_pages(page) - 1;
+			index += folio_nr_pages(folio) - 1;
 
-			if (!unfalloc || !PageUptodate(page))
-				truncate_inode_page(mapping, page);
-			unlock_page(page);
+			if (!unfalloc || !folio_test_uptodate(folio))
+				truncate_inode_page(mapping, &folio->page);
+			folio_unlock(folio);
 		}
 		pagevec_remove_exceptionals(&pvec);
 		pagevec_release(&pvec);