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

Configure Feed

Select the types of activity you want to include in your feed.

squashfs: convert squashfs_fill_page() to take a folio

squashfs_fill_page is only used in this file, so make it static.
Use kmap_local instead of kmap_atomic, and return a bool so that
the caller can use folio_end_read() which saves an atomic operation
over calling folio_mark_uptodate() followed by folio_unlock().

[willy@infradead.org: fix polarity of "uptodate" Thanks to Ryan for testing]
Link: https://lkml.kernel.org/r/20250110163300.3346321-2-willy@infradead.org
Link: https://lkml.kernel.org/r/20241220224634.723899-5-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Tested-by: Ryan Roberts <ryan.roberts@arm.com>
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
5748be3e 5641371f

+12 -10
+12 -9
fs/squashfs/file.c
··· 362 362 return squashfs_block_size(size); 363 363 } 364 364 365 - void squashfs_fill_page(struct page *page, struct squashfs_cache_entry *buffer, int offset, int avail) 365 + static bool squashfs_fill_page(struct folio *folio, 366 + struct squashfs_cache_entry *buffer, size_t offset, 367 + size_t avail) 366 368 { 367 - int copied; 369 + size_t copied; 368 370 void *pageaddr; 369 371 370 - pageaddr = kmap_atomic(page); 372 + pageaddr = kmap_local_folio(folio, 0); 371 373 copied = squashfs_copy_data(pageaddr, buffer, offset, avail); 372 374 memset(pageaddr + copied, 0, PAGE_SIZE - copied); 373 - kunmap_atomic(pageaddr); 375 + kunmap_local(pageaddr); 374 376 375 - flush_dcache_page(page); 376 - if (copied == avail) 377 - SetPageUptodate(page); 377 + flush_dcache_folio(folio); 378 + 379 + return copied == avail; 378 380 } 379 381 380 382 /* Copy data into page cache */ ··· 400 398 bytes -= PAGE_SIZE, offset += PAGE_SIZE) { 401 399 struct folio *push_folio; 402 400 size_t avail = buffer ? min(bytes, PAGE_SIZE) : 0; 401 + bool updated = false; 403 402 404 403 TRACE("bytes %zu, i %d, available_bytes %zu\n", bytes, i, avail); 405 404 ··· 415 412 if (folio_test_uptodate(push_folio)) 416 413 goto skip_folio; 417 414 418 - squashfs_fill_page(&push_folio->page, buffer, offset, avail); 415 + updated = squashfs_fill_page(push_folio, buffer, offset, avail); 419 416 skip_folio: 420 - folio_unlock(push_folio); 417 + folio_end_read(push_folio, updated); 421 418 if (i != folio->index) 422 419 folio_put(push_folio); 423 420 }
-1
fs/squashfs/squashfs.h
··· 73 73 u64, u64, unsigned int); 74 74 75 75 /* file.c */ 76 - void squashfs_fill_page(struct page *, struct squashfs_cache_entry *, int, int); 77 76 void squashfs_copy_cache(struct folio *, struct squashfs_cache_entry *, 78 77 size_t bytes, size_t offset); 79 78