@@ -93,11 +93,8 @@ struct z_erofs_pcluster {
93
93
94
94
/* let's avoid the valid 32-bit kernel addresses */
95
95
96
- /* the chained workgroup has't submitted io (still open) */
96
+ /* the end of a chain of pclusters */
97
97
#define Z_EROFS_PCLUSTER_TAIL ((void *)0x5F0ECAFE)
98
- /* the chained workgroup has already submitted io */
99
- #define Z_EROFS_PCLUSTER_TAIL_CLOSED ((void *)0x5F0EDEAD)
100
-
101
98
#define Z_EROFS_PCLUSTER_NIL (NULL)
102
99
103
100
struct z_erofs_decompressqueue {
@@ -504,20 +501,6 @@ int __init z_erofs_init_zip_subsystem(void)
504
501
505
502
enum z_erofs_pclustermode {
506
503
Z_EROFS_PCLUSTER_INFLIGHT ,
507
- /*
508
- * The current pclusters was the tail of an exist chain, in addition
509
- * that the previous processed chained pclusters are all decided to
510
- * be hooked up to it.
511
- * A new chain will be created for the remaining pclusters which are
512
- * not processed yet, so different from Z_EROFS_PCLUSTER_FOLLOWED,
513
- * the next pcluster cannot reuse the whole page safely for inplace I/O
514
- * in the following scenario:
515
- * ________________________________________________________________
516
- * | tail (partial) page | head (partial) page |
517
- * | (belongs to the next pcl) | (belongs to the current pcl) |
518
- * |_______PCLUSTER_FOLLOWED______|________PCLUSTER_HOOKED__________|
519
- */
520
- Z_EROFS_PCLUSTER_HOOKED ,
521
504
/*
522
505
* a weak form of Z_EROFS_PCLUSTER_FOLLOWED, the difference is that it
523
506
* could be dispatched into bypass queue later due to uptodated managed
@@ -535,8 +518,8 @@ enum z_erofs_pclustermode {
535
518
* ________________________________________________________________
536
519
* | tail (partial) page | head (partial) page |
537
520
* | (of the current cl) | (of the previous collection) |
538
- * | PCLUSTER_FOLLOWED or | |
539
- * |_____PCLUSTER_HOOKED__ |___________PCLUSTER_FOLLOWED____________|
521
+ * | | |
522
+ * |__PCLUSTER_FOLLOWED___ |___________PCLUSTER_FOLLOWED____________|
540
523
*
541
524
* [ (*) the above page can be used as inplace I/O. ]
542
525
*/
@@ -550,7 +533,7 @@ struct z_erofs_decompress_frontend {
550
533
551
534
struct page * pagepool ;
552
535
struct page * candidate_bvpage ;
553
- struct z_erofs_pcluster * pcl , * tailpcl ;
536
+ struct z_erofs_pcluster * pcl ;
554
537
z_erofs_next_pcluster_t owned_head ;
555
538
enum z_erofs_pclustermode mode ;
556
539
@@ -755,19 +738,7 @@ static void z_erofs_try_to_claim_pcluster(struct z_erofs_decompress_frontend *f)
755
738
return ;
756
739
}
757
740
758
- /*
759
- * type 2, link to the end of an existing open chain, be careful
760
- * that its submission is controlled by the original attached chain.
761
- */
762
- if (* owned_head != & pcl -> next && pcl != f -> tailpcl &&
763
- cmpxchg (& pcl -> next , Z_EROFS_PCLUSTER_TAIL ,
764
- * owned_head ) == Z_EROFS_PCLUSTER_TAIL ) {
765
- * owned_head = Z_EROFS_PCLUSTER_TAIL ;
766
- f -> mode = Z_EROFS_PCLUSTER_HOOKED ;
767
- f -> tailpcl = NULL ;
768
- return ;
769
- }
770
- /* type 3, it belongs to a chain, but it isn't the end of the chain */
741
+ /* type 2, it belongs to an ongoing chain */
771
742
f -> mode = Z_EROFS_PCLUSTER_INFLIGHT ;
772
743
}
773
744
@@ -828,9 +799,6 @@ static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe)
828
799
goto err_out ;
829
800
}
830
801
}
831
- /* used to check tail merging loop due to corrupted images */
832
- if (fe -> owned_head == Z_EROFS_PCLUSTER_TAIL )
833
- fe -> tailpcl = pcl ;
834
802
fe -> owned_head = & pcl -> next ;
835
803
fe -> pcl = pcl ;
836
804
return 0 ;
@@ -851,7 +819,6 @@ static int z_erofs_collector_begin(struct z_erofs_decompress_frontend *fe)
851
819
852
820
/* must be Z_EROFS_PCLUSTER_TAIL or pointed to previous pcluster */
853
821
DBG_BUGON (fe -> owned_head == Z_EROFS_PCLUSTER_NIL );
854
- DBG_BUGON (fe -> owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED );
855
822
856
823
if (!(map -> m_flags & EROFS_MAP_META )) {
857
824
grp = erofs_find_workgroup (fe -> inode -> i_sb ,
@@ -870,10 +837,6 @@ static int z_erofs_collector_begin(struct z_erofs_decompress_frontend *fe)
870
837
871
838
if (ret == - EEXIST ) {
872
839
mutex_lock (& fe -> pcl -> lock );
873
- /* used to check tail merging loop due to corrupted images */
874
- if (fe -> owned_head == Z_EROFS_PCLUSTER_TAIL )
875
- fe -> tailpcl = fe -> pcl ;
876
-
877
840
z_erofs_try_to_claim_pcluster (fe );
878
841
} else if (ret ) {
879
842
return ret ;
@@ -1028,8 +991,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
1028
991
* those chains are handled asynchronously thus the page cannot be used
1029
992
* for inplace I/O or bvpage (should be processed in a strict order.)
1030
993
*/
1031
- tight &= (fe -> mode >= Z_EROFS_PCLUSTER_HOOKED &&
1032
- fe -> mode != Z_EROFS_PCLUSTER_FOLLOWED_NOINPLACE );
994
+ tight &= (fe -> mode > Z_EROFS_PCLUSTER_FOLLOWED_NOINPLACE );
1033
995
1034
996
cur = end - min_t (unsigned int , offset + end - map -> m_la , end );
1035
997
if (!(map -> m_flags & EROFS_MAP_MAPPED )) {
@@ -1398,10 +1360,7 @@ static void z_erofs_decompress_queue(const struct z_erofs_decompressqueue *io,
1398
1360
};
1399
1361
z_erofs_next_pcluster_t owned = io -> head ;
1400
1362
1401
- while (owned != Z_EROFS_PCLUSTER_TAIL_CLOSED ) {
1402
- /* impossible that 'owned' equals Z_EROFS_WORK_TPTR_TAIL */
1403
- DBG_BUGON (owned == Z_EROFS_PCLUSTER_TAIL );
1404
- /* impossible that 'owned' equals Z_EROFS_PCLUSTER_NIL */
1363
+ while (owned != Z_EROFS_PCLUSTER_TAIL ) {
1405
1364
DBG_BUGON (owned == Z_EROFS_PCLUSTER_NIL );
1406
1365
1407
1366
be .pcl = container_of (owned , struct z_erofs_pcluster , next );
@@ -1418,7 +1377,7 @@ static void z_erofs_decompressqueue_work(struct work_struct *work)
1418
1377
container_of (work , struct z_erofs_decompressqueue , u .work );
1419
1378
struct page * pagepool = NULL ;
1420
1379
1421
- DBG_BUGON (bgq -> head == Z_EROFS_PCLUSTER_TAIL_CLOSED );
1380
+ DBG_BUGON (bgq -> head == Z_EROFS_PCLUSTER_TAIL );
1422
1381
z_erofs_decompress_queue (bgq , & pagepool );
1423
1382
erofs_release_pages (& pagepool );
1424
1383
kvfree (bgq );
@@ -1606,7 +1565,7 @@ static struct z_erofs_decompressqueue *jobqueue_init(struct super_block *sb,
1606
1565
q -> sync = true;
1607
1566
}
1608
1567
q -> sb = sb ;
1609
- q -> head = Z_EROFS_PCLUSTER_TAIL_CLOSED ;
1568
+ q -> head = Z_EROFS_PCLUSTER_TAIL ;
1610
1569
return q ;
1611
1570
}
1612
1571
@@ -1624,11 +1583,7 @@ static void move_to_bypass_jobqueue(struct z_erofs_pcluster *pcl,
1624
1583
z_erofs_next_pcluster_t * const submit_qtail = qtail [JQ_SUBMIT ];
1625
1584
z_erofs_next_pcluster_t * const bypass_qtail = qtail [JQ_BYPASS ];
1626
1585
1627
- DBG_BUGON (owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED );
1628
- if (owned_head == Z_EROFS_PCLUSTER_TAIL )
1629
- owned_head = Z_EROFS_PCLUSTER_TAIL_CLOSED ;
1630
-
1631
- WRITE_ONCE (pcl -> next , Z_EROFS_PCLUSTER_TAIL_CLOSED );
1586
+ WRITE_ONCE (pcl -> next , Z_EROFS_PCLUSTER_TAIL );
1632
1587
1633
1588
WRITE_ONCE (* submit_qtail , owned_head );
1634
1589
WRITE_ONCE (* bypass_qtail , & pcl -> next );
@@ -1698,15 +1653,10 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
1698
1653
unsigned int i = 0 ;
1699
1654
bool bypass = true;
1700
1655
1701
- /* no possible 'owned_head' equals the following */
1702
- DBG_BUGON (owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED );
1703
1656
DBG_BUGON (owned_head == Z_EROFS_PCLUSTER_NIL );
1704
-
1705
1657
pcl = container_of (owned_head , struct z_erofs_pcluster , next );
1658
+ owned_head = READ_ONCE (pcl -> next );
1706
1659
1707
- /* close the main owned chain at first */
1708
- owned_head = cmpxchg (& pcl -> next , Z_EROFS_PCLUSTER_TAIL ,
1709
- Z_EROFS_PCLUSTER_TAIL_CLOSED );
1710
1660
if (z_erofs_is_inline_pcluster (pcl )) {
1711
1661
move_to_bypass_jobqueue (pcl , qtail , owned_head );
1712
1662
continue ;
0 commit comments