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>
This commit is contained in:
parent
5641371fd0
commit
5748be3e9e
2 changed files with 12 additions and 10 deletions
|
@ -362,19 +362,21 @@ static int read_blocklist(struct inode *inode, int index, u64 *block)
|
|||
return squashfs_block_size(size);
|
||||
}
|
||||
|
||||
void squashfs_fill_page(struct page *page, struct squashfs_cache_entry *buffer, int offset, int avail)
|
||||
static bool squashfs_fill_page(struct folio *folio,
|
||||
struct squashfs_cache_entry *buffer, size_t offset,
|
||||
size_t avail)
|
||||
{
|
||||
int copied;
|
||||
size_t copied;
|
||||
void *pageaddr;
|
||||
|
||||
pageaddr = kmap_atomic(page);
|
||||
pageaddr = kmap_local_folio(folio, 0);
|
||||
copied = squashfs_copy_data(pageaddr, buffer, offset, avail);
|
||||
memset(pageaddr + copied, 0, PAGE_SIZE - copied);
|
||||
kunmap_atomic(pageaddr);
|
||||
kunmap_local(pageaddr);
|
||||
|
||||
flush_dcache_page(page);
|
||||
if (copied == avail)
|
||||
SetPageUptodate(page);
|
||||
flush_dcache_folio(folio);
|
||||
|
||||
return copied == avail;
|
||||
}
|
||||
|
||||
/* Copy data into page cache */
|
||||
|
@ -398,6 +400,7 @@ void squashfs_copy_cache(struct folio *folio,
|
|||
bytes -= PAGE_SIZE, offset += PAGE_SIZE) {
|
||||
struct folio *push_folio;
|
||||
size_t avail = buffer ? min(bytes, PAGE_SIZE) : 0;
|
||||
bool updated = false;
|
||||
|
||||
TRACE("bytes %zu, i %d, available_bytes %zu\n", bytes, i, avail);
|
||||
|
||||
|
@ -412,9 +415,9 @@ void squashfs_copy_cache(struct folio *folio,
|
|||
if (folio_test_uptodate(push_folio))
|
||||
goto skip_folio;
|
||||
|
||||
squashfs_fill_page(&push_folio->page, buffer, offset, avail);
|
||||
updated = squashfs_fill_page(push_folio, buffer, offset, avail);
|
||||
skip_folio:
|
||||
folio_unlock(push_folio);
|
||||
folio_end_read(push_folio, updated);
|
||||
if (i != folio->index)
|
||||
folio_put(push_folio);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,6 @@ extern __le64 *squashfs_read_fragment_index_table(struct super_block *,
|
|||
u64, u64, unsigned int);
|
||||
|
||||
/* file.c */
|
||||
void squashfs_fill_page(struct page *, struct squashfs_cache_entry *, int, int);
|
||||
void squashfs_copy_cache(struct folio *, struct squashfs_cache_entry *,
|
||||
size_t bytes, size_t offset);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue