@@ -236,13 +236,14 @@ static void z_erofs_bvec_iter_begin(struct z_erofs_bvec_iter *iter,
236
236
237
237
static int z_erofs_bvec_enqueue (struct z_erofs_bvec_iter * iter ,
238
238
struct z_erofs_bvec * bvec ,
239
- struct page * * candidate_bvpage )
239
+ struct page * * candidate_bvpage ,
240
+ struct page * * pagepool )
240
241
{
241
242
if (iter -> cur >= iter -> nr ) {
242
243
struct page * nextpage = * candidate_bvpage ;
243
244
244
245
if (!nextpage ) {
245
- nextpage = alloc_page ( GFP_NOFS );
246
+ nextpage = erofs_allocpage ( pagepool , GFP_NOFS );
246
247
if (!nextpage )
247
248
return - ENOMEM ;
248
249
set_page_private (nextpage , Z_EROFS_SHORTLIVED_PAGE );
@@ -406,6 +407,7 @@ struct z_erofs_decompress_frontend {
406
407
struct erofs_map_blocks map ;
407
408
struct z_erofs_bvec_iter biter ;
408
409
410
+ struct page * pagepool ;
409
411
struct page * candidate_bvpage ;
410
412
struct z_erofs_pcluster * pcl ;
411
413
z_erofs_next_pcluster_t owned_head ;
@@ -440,8 +442,7 @@ static bool z_erofs_should_alloc_cache(struct z_erofs_decompress_frontend *fe)
440
442
return false;
441
443
}
442
444
443
- static void z_erofs_bind_cache (struct z_erofs_decompress_frontend * fe ,
444
- struct page * * pagepool )
445
+ static void z_erofs_bind_cache (struct z_erofs_decompress_frontend * fe )
445
446
{
446
447
struct address_space * mc = MNGD_MAPPING (EROFS_I_SB (fe -> inode ));
447
448
struct z_erofs_pcluster * pcl = fe -> pcl ;
@@ -482,7 +483,7 @@ static void z_erofs_bind_cache(struct z_erofs_decompress_frontend *fe,
482
483
* succeeds or fallback to in-place I/O instead
483
484
* to avoid any direct reclaim.
484
485
*/
485
- newpage = erofs_allocpage (pagepool , gfp );
486
+ newpage = erofs_allocpage (& fe -> pagepool , gfp );
486
487
if (!newpage )
487
488
continue ;
488
489
set_page_private (newpage , Z_EROFS_PREALLOCATED_PAGE );
@@ -495,7 +496,7 @@ static void z_erofs_bind_cache(struct z_erofs_decompress_frontend *fe,
495
496
if (page )
496
497
put_page (page );
497
498
else if (newpage )
498
- erofs_pagepool_add (pagepool , newpage );
499
+ erofs_pagepool_add (& fe -> pagepool , newpage );
499
500
}
500
501
501
502
/*
@@ -593,7 +594,8 @@ static int z_erofs_attach_page(struct z_erofs_decompress_frontend *fe,
593
594
!fe -> candidate_bvpage )
594
595
fe -> candidate_bvpage = bvec -> page ;
595
596
}
596
- ret = z_erofs_bvec_enqueue (& fe -> biter , bvec , & fe -> candidate_bvpage );
597
+ ret = z_erofs_bvec_enqueue (& fe -> biter , bvec , & fe -> candidate_bvpage ,
598
+ & fe -> pagepool );
597
599
fe -> pcl -> vcnt += (ret >= 0 );
598
600
return ret ;
599
601
}
@@ -797,7 +799,7 @@ static int z_erofs_read_fragment(struct inode *inode, erofs_off_t pos,
797
799
}
798
800
799
801
static int z_erofs_do_read_page (struct z_erofs_decompress_frontend * fe ,
800
- struct page * page , struct page * * pagepool )
802
+ struct page * page )
801
803
{
802
804
struct inode * const inode = fe -> inode ;
803
805
struct erofs_map_blocks * const map = & fe -> map ;
@@ -858,7 +860,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
858
860
fe -> mode = Z_EROFS_PCLUSTER_FOLLOWED_NOINPLACE ;
859
861
} else {
860
862
/* bind cache first when cached decompression is preferred */
861
- z_erofs_bind_cache (fe , pagepool );
863
+ z_erofs_bind_cache (fe );
862
864
}
863
865
hitted :
864
866
/*
@@ -1470,7 +1472,6 @@ static void z_erofs_decompressqueue_endio(struct bio *bio)
1470
1472
}
1471
1473
1472
1474
static void z_erofs_submit_queue (struct z_erofs_decompress_frontend * f ,
1473
- struct page * * pagepool ,
1474
1475
struct z_erofs_decompressqueue * fgq ,
1475
1476
bool * force_fg , bool readahead )
1476
1477
{
@@ -1528,8 +1529,8 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
1528
1529
do {
1529
1530
struct page * page ;
1530
1531
1531
- page = pickup_page_for_submission (pcl , i ++ , pagepool ,
1532
- mc );
1532
+ page = pickup_page_for_submission (pcl , i ++ ,
1533
+ & f -> pagepool , mc );
1533
1534
if (!page )
1534
1535
continue ;
1535
1536
@@ -1594,16 +1595,16 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
1594
1595
}
1595
1596
1596
1597
static void z_erofs_runqueue (struct z_erofs_decompress_frontend * f ,
1597
- struct page * * pagepool , bool force_fg , bool ra )
1598
+ bool force_fg , bool ra )
1598
1599
{
1599
1600
struct z_erofs_decompressqueue io [NR_JOBQUEUES ];
1600
1601
1601
1602
if (f -> owned_head == Z_EROFS_PCLUSTER_TAIL )
1602
1603
return ;
1603
- z_erofs_submit_queue (f , pagepool , io , & force_fg , ra );
1604
+ z_erofs_submit_queue (f , io , & force_fg , ra );
1604
1605
1605
1606
/* handle bypass queue (no i/o pclusters) immediately */
1606
- z_erofs_decompress_queue (& io [JQ_BYPASS ], pagepool );
1607
+ z_erofs_decompress_queue (& io [JQ_BYPASS ], & f -> pagepool );
1607
1608
1608
1609
if (!force_fg )
1609
1610
return ;
@@ -1612,16 +1613,15 @@ static void z_erofs_runqueue(struct z_erofs_decompress_frontend *f,
1612
1613
wait_for_completion_io (& io [JQ_SUBMIT ].u .done );
1613
1614
1614
1615
/* handle synchronous decompress queue in the caller context */
1615
- z_erofs_decompress_queue (& io [JQ_SUBMIT ], pagepool );
1616
+ z_erofs_decompress_queue (& io [JQ_SUBMIT ], & f -> pagepool );
1616
1617
}
1617
1618
1618
1619
/*
1619
1620
* Since partial uptodate is still unimplemented for now, we have to use
1620
1621
* approximate readmore strategies as a start.
1621
1622
*/
1622
1623
static void z_erofs_pcluster_readmore (struct z_erofs_decompress_frontend * f ,
1623
- struct readahead_control * rac ,
1624
- struct page * * pagepool , bool backmost )
1624
+ struct readahead_control * rac , bool backmost )
1625
1625
{
1626
1626
struct inode * inode = f -> inode ;
1627
1627
struct erofs_map_blocks * map = & f -> map ;
@@ -1663,7 +1663,7 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
1663
1663
if (PageUptodate (page )) {
1664
1664
unlock_page (page );
1665
1665
} else {
1666
- err = z_erofs_do_read_page (f , page , pagepool );
1666
+ err = z_erofs_do_read_page (f , page );
1667
1667
if (err )
1668
1668
erofs_err (inode -> i_sb ,
1669
1669
"readmore error at page %lu @ nid %llu" ,
@@ -1684,27 +1684,24 @@ static int z_erofs_read_folio(struct file *file, struct folio *folio)
1684
1684
struct inode * const inode = page -> mapping -> host ;
1685
1685
struct erofs_sb_info * const sbi = EROFS_I_SB (inode );
1686
1686
struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT (inode );
1687
- struct page * pagepool = NULL ;
1688
1687
int err ;
1689
1688
1690
1689
trace_erofs_readpage (page , false);
1691
1690
f .headoffset = (erofs_off_t )page -> index << PAGE_SHIFT ;
1692
1691
1693
- z_erofs_pcluster_readmore (& f , NULL , & pagepool , true);
1694
- err = z_erofs_do_read_page (& f , page , & pagepool );
1695
- z_erofs_pcluster_readmore (& f , NULL , & pagepool , false);
1696
-
1692
+ z_erofs_pcluster_readmore (& f , NULL , true);
1693
+ err = z_erofs_do_read_page (& f , page );
1694
+ z_erofs_pcluster_readmore (& f , NULL , false);
1697
1695
(void )z_erofs_collector_end (& f );
1698
1696
1699
1697
/* if some compressed cluster ready, need submit them anyway */
1700
- z_erofs_runqueue (& f , & pagepool , z_erofs_is_sync_decompress (sbi , 0 ),
1701
- false);
1698
+ z_erofs_runqueue (& f , z_erofs_is_sync_decompress (sbi , 0 ), false);
1702
1699
1703
1700
if (err )
1704
1701
erofs_err (inode -> i_sb , "failed to read, err [%d]" , err );
1705
1702
1706
1703
erofs_put_metabuf (& f .map .buf );
1707
- erofs_release_pages (& pagepool );
1704
+ erofs_release_pages (& f . pagepool );
1708
1705
return err ;
1709
1706
}
1710
1707
@@ -1713,12 +1710,12 @@ static void z_erofs_readahead(struct readahead_control *rac)
1713
1710
struct inode * const inode = rac -> mapping -> host ;
1714
1711
struct erofs_sb_info * const sbi = EROFS_I_SB (inode );
1715
1712
struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT (inode );
1716
- struct page * pagepool = NULL , * head = NULL , * page ;
1713
+ struct page * head = NULL , * page ;
1717
1714
unsigned int nr_pages ;
1718
1715
1719
1716
f .headoffset = readahead_pos (rac );
1720
1717
1721
- z_erofs_pcluster_readmore (& f , rac , & pagepool , true);
1718
+ z_erofs_pcluster_readmore (& f , rac , true);
1722
1719
nr_pages = readahead_count (rac );
1723
1720
trace_erofs_readpages (inode , readahead_index (rac ), nr_pages , false);
1724
1721
@@ -1734,20 +1731,19 @@ static void z_erofs_readahead(struct readahead_control *rac)
1734
1731
/* traversal in reverse order */
1735
1732
head = (void * )page_private (page );
1736
1733
1737
- err = z_erofs_do_read_page (& f , page , & pagepool );
1734
+ err = z_erofs_do_read_page (& f , page );
1738
1735
if (err )
1739
1736
erofs_err (inode -> i_sb ,
1740
1737
"readahead error at page %lu @ nid %llu" ,
1741
1738
page -> index , EROFS_I (inode )-> nid );
1742
1739
put_page (page );
1743
1740
}
1744
- z_erofs_pcluster_readmore (& f , rac , & pagepool , false);
1741
+ z_erofs_pcluster_readmore (& f , rac , false);
1745
1742
(void )z_erofs_collector_end (& f );
1746
1743
1747
- z_erofs_runqueue (& f , & pagepool ,
1748
- z_erofs_is_sync_decompress (sbi , nr_pages ), true);
1744
+ z_erofs_runqueue (& f , z_erofs_is_sync_decompress (sbi , nr_pages ), true);
1749
1745
erofs_put_metabuf (& f .map .buf );
1750
- erofs_release_pages (& pagepool );
1746
+ erofs_release_pages (& f . pagepool );
1751
1747
}
1752
1748
1753
1749
const struct address_space_operations z_erofs_aops = {
0 commit comments