Skip to content

Commit e4c1cf5

Browse files
committed
erofs: tidy up z_erofs_do_read_page()
- Fix a typo: spiltted => split; - Move !EROFS_MAP_MAPPED and EROFS_MAP_FRAGMENT upwards; - Increase `split` in advance to avoid unnecessary repeats. Reviewed-by: Yue Hu <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent aeebae9 commit e4c1cf5

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

fs/erofs/zdata.c

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -981,49 +981,34 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
981981
struct erofs_map_blocks *const map = &fe->map;
982982
const loff_t offset = page_offset(page);
983983
bool tight = true, exclusive;
984-
unsigned int cur, end, len, spiltted;
984+
unsigned int cur, end, len, split;
985985
int err = 0;
986986

987-
/* register locked file pages as online pages in pack */
988987
z_erofs_onlinepage_init(page);
989988

990-
spiltted = 0;
989+
split = 0;
991990
end = PAGE_SIZE;
992991
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) {
997994
z_erofs_pcluster_end(fe);
998-
map->m_la = offset + cur;
995+
map->m_la = offset + end - 1;
999996
map->m_llen = 0;
1000997
err = z_erofs_map_blocks_iter(inode, map, 0);
1001998
if (err)
1002999
goto out;
1003-
} else if (fe->pcl) {
1004-
goto hitted;
10051000
}
10061001

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;
10211005

1022-
cur = end - min_t(erofs_off_t, offset + end - map->m_la, end);
10231006
if (!(map->m_flags & EROFS_MAP_MAPPED)) {
10241007
zero_user_segment(page, cur, end);
1008+
tight = false;
10251009
goto next_part;
10261010
}
1011+
10271012
if (map->m_flags & EROFS_MAP_FRAGMENT) {
10281013
erofs_off_t fpos = offset + cur - map->m_la;
10291014

@@ -1032,12 +1017,24 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
10321017
EROFS_I(inode)->z_fragmentoff + fpos);
10331018
if (err)
10341019
goto out;
1035-
++spiltted;
10361020
tight = false;
10371021
goto next_part;
10381022
}
10391023

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));
10411038
if (cur)
10421039
tight &= (fe->mode >= Z_EROFS_PCLUSTER_FOLLOWED);
10431040

@@ -1050,8 +1047,6 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
10501047
goto out;
10511048

10521049
z_erofs_onlinepage_split(page);
1053-
/* bump up the number of spiltted parts of a page */
1054-
++spiltted;
10551050
if (fe->pcl->pageofs_out != (map->m_la & ~PAGE_MASK))
10561051
fe->pcl->multibases = true;
10571052
if (fe->pcl->length < offset + end - map->m_la) {

0 commit comments

Comments
 (0)