]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
squashfs: convert squashfs_fill_page() to take a folio
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 20 Dec 2024 22:46:28 +0000 (22:46 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 25 Jan 2025 06:47:22 +0000 (22:47 -0800)
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>
fs/squashfs/file.c
fs/squashfs/squashfs.h

index 74076c4823c36ceac3d6a9b268349513b19c848b..5ca2baa16dc25dc10c3a69bb0de82956a222e062 100644 (file)
@@ -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);
        }
index 8c6fbef022f4945f4c598205ada24bb38722e88d..218868b20f16e0f9f0fbfd8946f974eec9a9a06c 100644 (file)
@@ -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);