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: use folios in squashfs_bio_read_cached()

Remove an access to page->mapping and a few calls to the old page-based
APIs. This doesn't support large folios, but it's still a nice
improvement.

Link: https://lkml.kernel.org/r/20250612143903.2849289-3-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
c9e3fb05 ca742a82

+22 -23
+22 -23
fs/squashfs/block.c
··· 80 80 struct address_space *cache_mapping, u64 index, int length, 81 81 u64 read_start, u64 read_end, int page_count) 82 82 { 83 - struct page *head_to_cache = NULL, *tail_to_cache = NULL; 83 + struct folio *head_to_cache = NULL, *tail_to_cache = NULL; 84 84 struct block_device *bdev = fullbio->bi_bdev; 85 85 int start_idx = 0, end_idx = 0; 86 - struct bvec_iter_all iter_all; 86 + struct folio_iter fi;; 87 87 struct bio *bio = NULL; 88 - struct bio_vec *bv; 89 88 int idx = 0; 90 89 int err = 0; 91 90 #ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL 92 - struct page **cache_pages = kmalloc_array(page_count, 91 + struct folio **cache_folios = kmalloc_array(page_count, 93 92 sizeof(void *), GFP_KERNEL | __GFP_ZERO); 94 93 #endif 95 94 96 - bio_for_each_segment_all(bv, fullbio, iter_all) { 97 - struct page *page = bv->bv_page; 95 + bio_for_each_folio_all(fi, fullbio) { 96 + struct folio *folio = fi.folio; 98 97 99 - if (page->mapping == cache_mapping) { 98 + if (folio->mapping == cache_mapping) { 100 99 idx++; 101 100 continue; 102 101 } ··· 110 111 * adjacent blocks. 111 112 */ 112 113 if (idx == 0 && index != read_start) 113 - head_to_cache = page; 114 + head_to_cache = folio; 114 115 else if (idx == page_count - 1 && index + length != read_end) 115 - tail_to_cache = page; 116 + tail_to_cache = folio; 116 117 #ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL 117 118 /* Cache all pages in the BIO for repeated reads */ 118 - else if (cache_pages) 119 - cache_pages[idx] = page; 119 + else if (cache_folios) 120 + cache_folios[idx] = folio; 120 121 #endif 121 122 122 123 if (!bio || idx != end_idx) { ··· 149 150 return err; 150 151 151 152 if (head_to_cache) { 152 - int ret = add_to_page_cache_lru(head_to_cache, cache_mapping, 153 + int ret = filemap_add_folio(cache_mapping, head_to_cache, 153 154 read_start >> PAGE_SHIFT, 154 155 GFP_NOIO); 155 156 156 157 if (!ret) { 157 - SetPageUptodate(head_to_cache); 158 - unlock_page(head_to_cache); 158 + folio_mark_uptodate(head_to_cache); 159 + folio_unlock(head_to_cache); 159 160 } 160 161 161 162 } 162 163 163 164 if (tail_to_cache) { 164 - int ret = add_to_page_cache_lru(tail_to_cache, cache_mapping, 165 + int ret = filemap_add_folio(cache_mapping, tail_to_cache, 165 166 (read_end >> PAGE_SHIFT) - 1, 166 167 GFP_NOIO); 167 168 168 169 if (!ret) { 169 - SetPageUptodate(tail_to_cache); 170 - unlock_page(tail_to_cache); 170 + folio_mark_uptodate(tail_to_cache); 171 + folio_unlock(tail_to_cache); 171 172 } 172 173 } 173 174 174 175 #ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL 175 - if (!cache_pages) 176 + if (!cache_folios) 176 177 goto out; 177 178 178 179 for (idx = 0; idx < page_count; idx++) { 179 - if (!cache_pages[idx]) 180 + if (!cache_folios[idx]) 180 181 continue; 181 - int ret = add_to_page_cache_lru(cache_pages[idx], cache_mapping, 182 + int ret = filemap_add_folio(cache_mapping, cache_folios[idx], 182 183 (read_start >> PAGE_SHIFT) + idx, 183 184 GFP_NOIO); 184 185 185 186 if (!ret) { 186 - SetPageUptodate(cache_pages[idx]); 187 - unlock_page(cache_pages[idx]); 187 + folio_mark_uptodate(cache_folios[idx]); 188 + folio_unlock(cache_folios[idx]); 188 189 } 189 190 } 190 - kfree(cache_pages); 191 + kfree(cache_folios); 191 192 out: 192 193 #endif 193 194 return 0;