@@ -2345,7 +2345,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
23452345 * Major change was from block_size == page_size in f2fs by default.
23462346 */
23472347static int f2fs_mpage_readpages (struct inode * inode ,
2348- struct readahead_control * rac , struct page * page )
2348+ struct readahead_control * rac , struct folio * folio )
23492349{
23502350 struct bio * bio = NULL ;
23512351 sector_t last_block_in_bio = 0 ;
@@ -2365,6 +2365,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
23652365#endif
23662366 unsigned nr_pages = rac ? readahead_count (rac ) : 1 ;
23672367 unsigned max_nr_pages = nr_pages ;
2368+ pgoff_t index ;
23682369 int ret = 0 ;
23692370
23702371 map .m_pblk = 0 ;
@@ -2378,64 +2379,63 @@ static int f2fs_mpage_readpages(struct inode *inode,
23782379
23792380 for (; nr_pages ; nr_pages -- ) {
23802381 if (rac ) {
2381- page = readahead_page (rac );
2382- prefetchw (& page -> flags );
2382+ folio = readahead_folio (rac );
2383+ prefetchw (& folio -> flags );
23832384 }
23842385
2385- #ifdef CONFIG_F2FS_FS_COMPRESSION
2386- if (f2fs_compressed_file (inode )) {
2387- /* there are remained compressed pages, submit them */
2388- if (!f2fs_cluster_can_merge_page (& cc , page -> index )) {
2389- ret = f2fs_read_multi_pages (& cc , & bio ,
2390- max_nr_pages ,
2391- & last_block_in_bio ,
2392- rac != NULL , false);
2393- f2fs_destroy_compress_ctx (& cc , false);
2394- if (ret )
2395- goto set_error_page ;
2396- }
2397- if (cc .cluster_idx == NULL_CLUSTER ) {
2398- if (nc_cluster_idx ==
2399- page -> index >> cc .log_cluster_size ) {
2400- goto read_single_page ;
2401- }
2402-
2403- ret = f2fs_is_compressed_cluster (inode , page -> index );
2404- if (ret < 0 )
2405- goto set_error_page ;
2406- else if (!ret ) {
2407- nc_cluster_idx =
2408- page -> index >> cc .log_cluster_size ;
2409- goto read_single_page ;
2410- }
2386+ index = folio_index (folio );
24112387
2412- nc_cluster_idx = NULL_CLUSTER ;
2413- }
2414- ret = f2fs_init_compress_ctx (& cc );
2388+ #ifdef CONFIG_F2FS_FS_COMPRESSION
2389+ if (!f2fs_compressed_file (inode ))
2390+ goto read_single_page ;
2391+
2392+ /* there are remained compressed pages, submit them */
2393+ if (!f2fs_cluster_can_merge_page (& cc , index )) {
2394+ ret = f2fs_read_multi_pages (& cc , & bio ,
2395+ max_nr_pages ,
2396+ & last_block_in_bio ,
2397+ rac != NULL , false);
2398+ f2fs_destroy_compress_ctx (& cc , false);
24152399 if (ret )
24162400 goto set_error_page ;
2401+ }
2402+ if (cc .cluster_idx == NULL_CLUSTER ) {
2403+ if (nc_cluster_idx == index >> cc .log_cluster_size )
2404+ goto read_single_page ;
24172405
2418- f2fs_compress_ctx_add_page (& cc , page );
2406+ ret = f2fs_is_compressed_cluster (inode , index );
2407+ if (ret < 0 )
2408+ goto set_error_page ;
2409+ else if (!ret ) {
2410+ nc_cluster_idx =
2411+ index >> cc .log_cluster_size ;
2412+ goto read_single_page ;
2413+ }
24192414
2420- goto next_page ;
2415+ nc_cluster_idx = NULL_CLUSTER ;
24212416 }
2417+ ret = f2fs_init_compress_ctx (& cc );
2418+ if (ret )
2419+ goto set_error_page ;
2420+
2421+ f2fs_compress_ctx_add_page (& cc , & folio -> page );
2422+
2423+ goto next_page ;
24222424read_single_page :
24232425#endif
24242426
2425- ret = f2fs_read_single_page (inode , page , max_nr_pages , & map ,
2427+ ret = f2fs_read_single_page (inode , & folio -> page , max_nr_pages , & map ,
24262428 & bio , & last_block_in_bio , rac );
24272429 if (ret ) {
24282430#ifdef CONFIG_F2FS_FS_COMPRESSION
24292431set_error_page :
24302432#endif
2431- zero_user_segment ( page , 0 , PAGE_SIZE );
2432- unlock_page ( page );
2433+ folio_zero_segment ( folio , 0 , folio_size ( folio ) );
2434+ folio_unlock ( folio );
24332435 }
24342436#ifdef CONFIG_F2FS_FS_COMPRESSION
24352437next_page :
24362438#endif
2437- if (rac )
2438- put_page (page );
24392439
24402440#ifdef CONFIG_F2FS_FS_COMPRESSION
24412441 if (f2fs_compressed_file (inode )) {
@@ -2472,7 +2472,7 @@ static int f2fs_read_data_folio(struct file *file, struct folio *folio)
24722472 if (f2fs_has_inline_data (inode ))
24732473 ret = f2fs_read_inline_data (inode , page );
24742474 if (ret == - EAGAIN )
2475- ret = f2fs_mpage_readpages (inode , NULL , page );
2475+ ret = f2fs_mpage_readpages (inode , NULL , folio );
24762476 return ret ;
24772477}
24782478
0 commit comments