@@ -981,49 +981,34 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
981
981
struct erofs_map_blocks * const map = & fe -> map ;
982
982
const loff_t offset = page_offset (page );
983
983
bool tight = true, exclusive ;
984
- unsigned int cur , end , len , spiltted ;
984
+ unsigned int cur , end , len , split ;
985
985
int err = 0 ;
986
986
987
- /* register locked file pages as online pages in pack */
988
987
z_erofs_onlinepage_init (page );
989
988
990
- spiltted = 0 ;
989
+ split = 0 ;
991
990
end = PAGE_SIZE ;
992
991
repeat :
993
- cur = end - 1 ;
994
-
995
- if (offset + cur < map -> m_la ||
996
- offset + cur >= map -> m_la + map -> m_llen ) {
992
+ if (offset + end - 1 < map -> m_la ||
993
+ offset + end - 1 >= map -> m_la + map -> m_llen ) {
997
994
z_erofs_pcluster_end (fe );
998
- map -> m_la = offset + cur ;
995
+ map -> m_la = offset + end - 1 ;
999
996
map -> m_llen = 0 ;
1000
997
err = z_erofs_map_blocks_iter (inode , map , 0 );
1001
998
if (err )
1002
999
goto out ;
1003
- } else if (fe -> pcl ) {
1004
- goto hitted ;
1005
1000
}
1006
1001
1007
- if ((map -> m_flags & EROFS_MAP_MAPPED ) &&
1008
- !(map -> m_flags & EROFS_MAP_FRAGMENT )) {
1009
- err = z_erofs_pcluster_begin (fe );
1010
- if (err )
1011
- goto out ;
1012
- }
1013
- hitted :
1014
- /*
1015
- * Ensure the current partial page belongs to this submit chain rather
1016
- * than other concurrent submit chains or the noio(bypass) chain since
1017
- * those chains are handled asynchronously thus the page cannot be used
1018
- * for inplace I/O or bvpage (should be processed in a strict order.)
1019
- */
1020
- tight &= (fe -> mode > Z_EROFS_PCLUSTER_FOLLOWED_NOINPLACE );
1002
+ cur = offset > map -> m_la ? 0 : map -> m_la - offset ;
1003
+ /* bump split parts first to avoid several separate cases */
1004
+ ++ split ;
1021
1005
1022
- cur = end - min_t (erofs_off_t , offset + end - map -> m_la , end );
1023
1006
if (!(map -> m_flags & EROFS_MAP_MAPPED )) {
1024
1007
zero_user_segment (page , cur , end );
1008
+ tight = false;
1025
1009
goto next_part ;
1026
1010
}
1011
+
1027
1012
if (map -> m_flags & EROFS_MAP_FRAGMENT ) {
1028
1013
erofs_off_t fpos = offset + cur - map -> m_la ;
1029
1014
@@ -1032,12 +1017,24 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
1032
1017
EROFS_I (inode )-> z_fragmentoff + fpos );
1033
1018
if (err )
1034
1019
goto out ;
1035
- ++ spiltted ;
1036
1020
tight = false;
1037
1021
goto next_part ;
1038
1022
}
1039
1023
1040
- exclusive = (!cur && (!spiltted || tight ));
1024
+ if (!fe -> pcl ) {
1025
+ err = z_erofs_pcluster_begin (fe );
1026
+ if (err )
1027
+ goto out ;
1028
+ }
1029
+
1030
+ /*
1031
+ * Ensure the current partial page belongs to this submit chain rather
1032
+ * than other concurrent submit chains or the noio(bypass) chain since
1033
+ * those chains are handled asynchronously thus the page cannot be used
1034
+ * for inplace I/O or bvpage (should be processed in a strict order.)
1035
+ */
1036
+ tight &= (fe -> mode > Z_EROFS_PCLUSTER_FOLLOWED_NOINPLACE );
1037
+ exclusive = (!cur && ((split <= 1 ) || tight ));
1041
1038
if (cur )
1042
1039
tight &= (fe -> mode >= Z_EROFS_PCLUSTER_FOLLOWED );
1043
1040
@@ -1050,8 +1047,6 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
1050
1047
goto out ;
1051
1048
1052
1049
z_erofs_onlinepage_split (page );
1053
- /* bump up the number of spiltted parts of a page */
1054
- ++ spiltted ;
1055
1050
if (fe -> pcl -> pageofs_out != (map -> m_la & ~PAGE_MASK ))
1056
1051
fe -> pcl -> multibases = true;
1057
1052
if (fe -> pcl -> length < offset + end - map -> m_la ) {
0 commit comments