@@ -80,23 +80,22 @@ static int squashfs_bio_read_cached(struct bio *fullbio,
8080 struct address_space * cache_mapping , u64 index , int length ,
8181 u64 read_start , u64 read_end , int page_count )
8282{
83- struct page * head_to_cache = NULL , * tail_to_cache = NULL ;
83+ struct folio * head_to_cache = NULL , * tail_to_cache = NULL ;
8484 struct block_device * bdev = fullbio -> bi_bdev ;
8585 int start_idx = 0 , end_idx = 0 ;
86- struct bvec_iter_all iter_all ;
86+ struct folio_iter fi ; ;
8787 struct bio * bio = NULL ;
88- struct bio_vec * bv ;
8988 int idx = 0 ;
9089 int err = 0 ;
9190#ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL
92- struct page * * cache_pages = kmalloc_array (page_count ,
91+ struct folio * * cache_folios = kmalloc_array (page_count ,
9392 sizeof (void * ), GFP_KERNEL | __GFP_ZERO );
9493#endif
9594
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 ;
9897
99- if (page -> mapping == cache_mapping ) {
98+ if (folio -> mapping == cache_mapping ) {
10099 idx ++ ;
101100 continue ;
102101 }
@@ -111,13 +110,13 @@ static int squashfs_bio_read_cached(struct bio *fullbio,
111110 * adjacent blocks.
112111 */
113112 if (idx == 0 && index != read_start )
114- head_to_cache = page ;
113+ head_to_cache = folio ;
115114 else if (idx == page_count - 1 && index + length != read_end )
116- tail_to_cache = page ;
115+ tail_to_cache = folio ;
117116#ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL
118117 /* Cache all pages in the BIO for repeated reads */
119- else if (cache_pages )
120- cache_pages [idx ] = page ;
118+ else if (cache_folios )
119+ cache_folios [idx ] = folio ;
121120#endif
122121
123122 if (!bio || idx != end_idx ) {
@@ -150,45 +149,45 @@ static int squashfs_bio_read_cached(struct bio *fullbio,
150149 return err ;
151150
152151 if (head_to_cache ) {
153- int ret = add_to_page_cache_lru ( head_to_cache , cache_mapping ,
152+ int ret = filemap_add_folio ( cache_mapping , head_to_cache ,
154153 read_start >> PAGE_SHIFT ,
155154 GFP_NOIO );
156155
157156 if (!ret ) {
158- SetPageUptodate (head_to_cache );
159- unlock_page (head_to_cache );
157+ folio_mark_uptodate (head_to_cache );
158+ folio_unlock (head_to_cache );
160159 }
161160
162161 }
163162
164163 if (tail_to_cache ) {
165- int ret = add_to_page_cache_lru ( tail_to_cache , cache_mapping ,
164+ int ret = filemap_add_folio ( cache_mapping , tail_to_cache ,
166165 (read_end >> PAGE_SHIFT ) - 1 ,
167166 GFP_NOIO );
168167
169168 if (!ret ) {
170- SetPageUptodate (tail_to_cache );
171- unlock_page (tail_to_cache );
169+ folio_mark_uptodate (tail_to_cache );
170+ folio_unlock (tail_to_cache );
172171 }
173172 }
174173
175174#ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL
176- if (!cache_pages )
175+ if (!cache_folios )
177176 goto out ;
178177
179178 for (idx = 0 ; idx < page_count ; idx ++ ) {
180- if (!cache_pages [idx ])
179+ if (!cache_folios [idx ])
181180 continue ;
182- int ret = add_to_page_cache_lru ( cache_pages [idx ], cache_mapping ,
181+ int ret = filemap_add_folio ( cache_mapping , cache_folios [idx ],
183182 (read_start >> PAGE_SHIFT ) + idx ,
184183 GFP_NOIO );
185184
186185 if (!ret ) {
187- SetPageUptodate ( cache_pages [idx ]);
188- unlock_page ( cache_pages [idx ]);
186+ folio_mark_uptodate ( cache_folios [idx ]);
187+ folio_unlock ( cache_folios [idx ]);
189188 }
190189 }
191- kfree (cache_pages );
190+ kfree (cache_folios );
192191out :
193192#endif
194193 return 0 ;
0 commit comments