12
12
#define Z_EROFS_PCLUSTER_MAX_PAGES (Z_EROFS_PCLUSTER_MAX_SIZE / PAGE_SIZE)
13
13
#define Z_EROFS_INLINE_BVECS 2
14
14
15
- /*
16
- * let's leave a type here in case of introducing
17
- * another tagged pointer later.
18
- */
19
- typedef void * z_erofs_next_pcluster_t ;
20
-
21
15
struct z_erofs_bvec {
22
16
struct page * page ;
23
17
int offset ;
@@ -48,7 +42,7 @@ struct z_erofs_pcluster {
48
42
struct lockref lockref ;
49
43
50
44
/* A: point to next chained pcluster or TAILs */
51
- z_erofs_next_pcluster_t next ;
45
+ struct z_erofs_pcluster * next ;
52
46
53
47
/* I: start block address of this pcluster */
54
48
erofs_off_t index ;
@@ -94,12 +88,11 @@ struct z_erofs_pcluster {
94
88
95
89
/* the end of a chain of pclusters */
96
90
#define Z_EROFS_PCLUSTER_TAIL ((void *) 0x700 + POISON_POINTER_DELTA)
97
- #define Z_EROFS_PCLUSTER_NIL (NULL)
98
91
99
92
struct z_erofs_decompressqueue {
100
93
struct super_block * sb ;
94
+ struct z_erofs_pcluster * head ;
101
95
atomic_t pending_bios ;
102
- z_erofs_next_pcluster_t head ;
103
96
104
97
union {
105
98
struct completion done ;
@@ -493,8 +486,7 @@ struct z_erofs_decompress_frontend {
493
486
494
487
struct page * pagepool ;
495
488
struct page * candidate_bvpage ;
496
- struct z_erofs_pcluster * pcl ;
497
- z_erofs_next_pcluster_t owned_head ;
489
+ struct z_erofs_pcluster * pcl , * head ;
498
490
enum z_erofs_pclustermode mode ;
499
491
500
492
erofs_off_t headoffset ;
@@ -504,7 +496,7 @@ struct z_erofs_decompress_frontend {
504
496
};
505
497
506
498
#define DECOMPRESS_FRONTEND_INIT (__i ) { \
507
- .inode = __i, .owned_head = Z_EROFS_PCLUSTER_TAIL, \
499
+ .inode = __i, .head = Z_EROFS_PCLUSTER_TAIL, \
508
500
.mode = Z_EROFS_PCLUSTER_FOLLOWED }
509
501
510
502
static bool z_erofs_should_alloc_cache (struct z_erofs_decompress_frontend * fe )
@@ -752,9 +744,7 @@ static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe)
752
744
pcl -> algorithmformat = map -> m_algorithmformat ;
753
745
pcl -> length = 0 ;
754
746
pcl -> partial = true;
755
-
756
- /* new pclusters should be claimed as type 1, primary and followed */
757
- pcl -> next = fe -> owned_head ;
747
+ pcl -> next = fe -> head ;
758
748
pcl -> pageofs_out = map -> m_la & ~PAGE_MASK ;
759
749
fe -> mode = Z_EROFS_PCLUSTER_FOLLOWED ;
760
750
@@ -790,8 +780,7 @@ static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe)
790
780
goto err_out ;
791
781
}
792
782
}
793
- fe -> owned_head = & pcl -> next ;
794
- fe -> pcl = pcl ;
783
+ fe -> head = fe -> pcl = pcl ;
795
784
return 0 ;
796
785
797
786
err_out :
@@ -810,7 +799,7 @@ static int z_erofs_pcluster_begin(struct z_erofs_decompress_frontend *fe)
810
799
811
800
DBG_BUGON (fe -> pcl );
812
801
/* must be Z_EROFS_PCLUSTER_TAIL or pointed to previous pcluster */
813
- DBG_BUGON (fe -> owned_head == Z_EROFS_PCLUSTER_NIL );
802
+ DBG_BUGON (! fe -> head );
814
803
815
804
if (!(map -> m_flags & EROFS_MAP_META )) {
816
805
while (1 ) {
@@ -838,10 +827,9 @@ static int z_erofs_pcluster_begin(struct z_erofs_decompress_frontend *fe)
838
827
if (ret == - EEXIST ) {
839
828
mutex_lock (& fe -> pcl -> lock );
840
829
/* check if this pcluster hasn't been linked into any chain. */
841
- if (cmpxchg (& fe -> pcl -> next , Z_EROFS_PCLUSTER_NIL ,
842
- fe -> owned_head ) == Z_EROFS_PCLUSTER_NIL ) {
830
+ if (!cmpxchg (& fe -> pcl -> next , NULL , fe -> head )) {
843
831
/* .. so it can be attached to our submission chain */
844
- fe -> owned_head = & fe -> pcl -> next ;
832
+ fe -> head = fe -> pcl ;
845
833
fe -> mode = Z_EROFS_PCLUSTER_FOLLOWED ;
846
834
} else { /* otherwise, it belongs to an inflight chain */
847
835
fe -> mode = Z_EROFS_PCLUSTER_INFLIGHT ;
@@ -1393,7 +1381,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
1393
1381
pcl -> vcnt = 0 ;
1394
1382
1395
1383
/* pcluster lock MUST be taken before the following line */
1396
- WRITE_ONCE (pcl -> next , Z_EROFS_PCLUSTER_NIL );
1384
+ WRITE_ONCE (pcl -> next , NULL );
1397
1385
mutex_unlock (& pcl -> lock );
1398
1386
1399
1387
if (z_erofs_is_inline_pcluster (pcl ))
@@ -1411,16 +1399,14 @@ static int z_erofs_decompress_queue(const struct z_erofs_decompressqueue *io,
1411
1399
.pagepool = pagepool ,
1412
1400
.decompressed_secondary_bvecs =
1413
1401
LIST_HEAD_INIT (be .decompressed_secondary_bvecs ),
1402
+ .pcl = io -> head ,
1414
1403
};
1415
- z_erofs_next_pcluster_t owned = io -> head ;
1404
+ struct z_erofs_pcluster * next ;
1416
1405
int err = io -> eio ? - EIO : 0 ;
1417
1406
1418
- while (owned != Z_EROFS_PCLUSTER_TAIL ) {
1419
- DBG_BUGON (owned == Z_EROFS_PCLUSTER_NIL );
1420
-
1421
- be .pcl = container_of (owned , struct z_erofs_pcluster , next );
1422
- owned = READ_ONCE (be .pcl -> next );
1423
-
1407
+ for (; be .pcl != Z_EROFS_PCLUSTER_TAIL ; be .pcl = next ) {
1408
+ DBG_BUGON (!be .pcl );
1409
+ next = READ_ONCE (be .pcl -> next );
1424
1410
err = z_erofs_decompress_pcluster (& be , err ) ?: err ;
1425
1411
}
1426
1412
return err ;
@@ -1630,18 +1616,13 @@ enum {
1630
1616
NR_JOBQUEUES ,
1631
1617
};
1632
1618
1633
- static void move_to_bypass_jobqueue (struct z_erofs_pcluster * pcl ,
1634
- z_erofs_next_pcluster_t qtail [] ,
1635
- z_erofs_next_pcluster_t owned_head )
1619
+ static void z_erofs_move_to_bypass_queue (struct z_erofs_pcluster * pcl ,
1620
+ struct z_erofs_pcluster * next ,
1621
+ struct z_erofs_pcluster * * qtail [] )
1636
1622
{
1637
- z_erofs_next_pcluster_t * const submit_qtail = qtail [JQ_SUBMIT ];
1638
- z_erofs_next_pcluster_t * const bypass_qtail = qtail [JQ_BYPASS ];
1639
-
1640
1623
WRITE_ONCE (pcl -> next , Z_EROFS_PCLUSTER_TAIL );
1641
-
1642
- WRITE_ONCE (* submit_qtail , owned_head );
1643
- WRITE_ONCE (* bypass_qtail , & pcl -> next );
1644
-
1624
+ WRITE_ONCE (* qtail [JQ_SUBMIT ], next );
1625
+ WRITE_ONCE (* qtail [JQ_BYPASS ], pcl );
1645
1626
qtail [JQ_BYPASS ] = & pcl -> next ;
1646
1627
}
1647
1628
@@ -1676,9 +1657,9 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
1676
1657
{
1677
1658
struct super_block * sb = f -> inode -> i_sb ;
1678
1659
struct address_space * mc = MNGD_MAPPING (EROFS_SB (sb ));
1679
- z_erofs_next_pcluster_t qtail [NR_JOBQUEUES ];
1660
+ struct z_erofs_pcluster * * qtail [NR_JOBQUEUES ];
1680
1661
struct z_erofs_decompressqueue * q [NR_JOBQUEUES ];
1681
- z_erofs_next_pcluster_t owned_head = f -> owned_head ;
1662
+ struct z_erofs_pcluster * pcl , * next ;
1682
1663
/* bio is NULL initially, so no need to initialize last_{index,bdev} */
1683
1664
erofs_off_t last_pa ;
1684
1665
unsigned int nr_bios = 0 ;
@@ -1694,22 +1675,19 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
1694
1675
qtail [JQ_SUBMIT ] = & q [JQ_SUBMIT ]-> head ;
1695
1676
1696
1677
/* by default, all need io submission */
1697
- q [JQ_SUBMIT ]-> head = owned_head ;
1678
+ q [JQ_SUBMIT ]-> head = next = f -> head ;
1698
1679
1699
1680
do {
1700
1681
struct erofs_map_dev mdev ;
1701
- struct z_erofs_pcluster * pcl ;
1702
1682
erofs_off_t cur , end ;
1703
1683
struct bio_vec bvec ;
1704
1684
unsigned int i = 0 ;
1705
1685
bool bypass = true;
1706
1686
1707
- DBG_BUGON (owned_head == Z_EROFS_PCLUSTER_NIL );
1708
- pcl = container_of (owned_head , struct z_erofs_pcluster , next );
1709
- owned_head = READ_ONCE (pcl -> next );
1710
-
1687
+ pcl = next ;
1688
+ next = READ_ONCE (pcl -> next );
1711
1689
if (z_erofs_is_inline_pcluster (pcl )) {
1712
- move_to_bypass_jobqueue (pcl , qtail , owned_head );
1690
+ z_erofs_move_to_bypass_queue (pcl , next , qtail );
1713
1691
continue ;
1714
1692
}
1715
1693
@@ -1781,8 +1759,8 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
1781
1759
if (!bypass )
1782
1760
qtail [JQ_SUBMIT ] = & pcl -> next ;
1783
1761
else
1784
- move_to_bypass_jobqueue (pcl , qtail , owned_head );
1785
- } while (owned_head != Z_EROFS_PCLUSTER_TAIL );
1762
+ z_erofs_move_to_bypass_queue (pcl , next , qtail );
1763
+ } while (next != Z_EROFS_PCLUSTER_TAIL );
1786
1764
1787
1765
if (bio ) {
1788
1766
if (erofs_is_fileio_mode (EROFS_SB (sb )))
@@ -1814,7 +1792,7 @@ static int z_erofs_runqueue(struct z_erofs_decompress_frontend *f,
1814
1792
bool force_fg = z_erofs_is_sync_decompress (sbi , ra_folios );
1815
1793
int err ;
1816
1794
1817
- if (f -> owned_head == Z_EROFS_PCLUSTER_TAIL )
1795
+ if (f -> head == Z_EROFS_PCLUSTER_TAIL )
1818
1796
return 0 ;
1819
1797
z_erofs_submit_queue (f , io , & force_fg , !!ra_folios );
1820
1798
0 commit comments