Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

squashfs: use a folio throughout squashfs_read_folio()

Use modern folio APIs where they exist and convert back to struct
page for the internal functions.

Link: https://lkml.kernel.org/r/20241220224634.723899-1-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Phillip Lougher <phillip@squashfs.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
608c2501 d7f4b23c

+9 -16
+9 -16
fs/squashfs/file.c
··· 445 445 446 446 static int squashfs_read_folio(struct file *file, struct folio *folio) 447 447 { 448 - struct page *page = &folio->page; 449 - struct inode *inode = page->mapping->host; 448 + struct inode *inode = folio->mapping->host; 450 449 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; 451 - int index = page->index >> (msblk->block_log - PAGE_SHIFT); 450 + int index = folio->index >> (msblk->block_log - PAGE_SHIFT); 452 451 int file_end = i_size_read(inode) >> msblk->block_log; 453 452 int expected = index == file_end ? 454 453 (i_size_read(inode) & (msblk->block_size - 1)) : 455 454 msblk->block_size; 456 455 int res = 0; 457 - void *pageaddr; 458 456 459 457 TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n", 460 - page->index, squashfs_i(inode)->start); 458 + folio->index, squashfs_i(inode)->start); 461 459 462 - if (page->index >= ((i_size_read(inode) + PAGE_SIZE - 1) >> 460 + if (folio->index >= ((i_size_read(inode) + PAGE_SIZE - 1) >> 463 461 PAGE_SHIFT)) 464 462 goto out; 465 463 ··· 470 472 goto out; 471 473 472 474 if (res == 0) 473 - res = squashfs_readpage_sparse(page, expected); 475 + res = squashfs_readpage_sparse(&folio->page, expected); 474 476 else 475 - res = squashfs_readpage_block(page, block, res, expected); 477 + res = squashfs_readpage_block(&folio->page, block, res, expected); 476 478 } else 477 - res = squashfs_readpage_fragment(page, expected); 479 + res = squashfs_readpage_fragment(&folio->page, expected); 478 480 479 481 if (!res) 480 482 return 0; 481 483 482 484 out: 483 - pageaddr = kmap_atomic(page); 484 - memset(pageaddr, 0, PAGE_SIZE); 485 - kunmap_atomic(pageaddr); 486 - flush_dcache_page(page); 487 - if (res == 0) 488 - SetPageUptodate(page); 489 - unlock_page(page); 485 + folio_zero_segment(folio, 0, folio_size(folio)); 486 + folio_end_read(folio, res == 0); 490 487 491 488 return res; 492 489 }