BACKPORT: 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 <huyue2@coolpad.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230817082813.81180-4-hsiangkao@linux.alibaba.com

Bug: 318378021
Change-Id: I465fd33c7cbbe91d5da4b4ee2343a7b319534148
(cherry picked from commit e4c1cf523d820730a86cae2c6d55924833b6f7ac)
[dhavale: resolved small conflict in zdata.c in z_erofs_do_read_page()]
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
This commit is contained in:
Gao Xiang 2023-08-17 16:28:09 +08:00 committed by Treehugger Robot
parent dc94c3cc6b
commit 0d329bbe5c

View file

@ -985,53 +985,35 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
struct erofs_map_blocks *const map = &fe->map;
const loff_t offset = page_offset(page);
bool tight = true, exclusive;
unsigned int cur, end, len, spiltted;
unsigned int cur, end, len, split;
int err = 0;
/* register locked file pages as online pages in pack */
z_erofs_onlinepage_init(page);
spiltted = 0;
split = 0;
end = PAGE_SIZE;
repeat:
cur = end - 1;
if (offset + cur < map->m_la ||
offset + cur >= map->m_la + map->m_llen) {
erofs_dbg("out-of-range map @ pos %llu", offset + cur);
if (offset + end - 1 < map->m_la ||
offset + end - 1 >= map->m_la + map->m_llen) {
erofs_dbg("out-of-range map @ pos %llu", offset + end - 1);
z_erofs_pcluster_end(fe);
map->m_la = offset + cur;
map->m_la = offset + end - 1;
map->m_llen = 0;
err = z_erofs_map_blocks_iter(inode, map, 0);
if (err)
goto out;
} else if (fe->pcl) {
goto hitted;
}
if ((map->m_flags & EROFS_MAP_MAPPED) &&
!(map->m_flags & EROFS_MAP_FRAGMENT)) {
err = z_erofs_pcluster_begin(fe);
if (err)
goto out;
}
hitted:
/*
* Ensure the current partial page belongs to this submit chain rather
* than other concurrent submit chains or the noio(bypass) chain since
* those chains are handled asynchronously thus the page cannot be used
* for inplace I/O or bvpage (should be processed in a strict order.)
*/
tight &= (fe->mode > Z_EROFS_PCLUSTER_FOLLOWED_NOINPLACE);
cur = offset > map->m_la ? 0 : map->m_la - offset;
/* bump split parts first to avoid several separate cases */
++split;
cur = end - min_t(erofs_off_t, offset + end - map->m_la, end);
if (!(map->m_flags & EROFS_MAP_MAPPED)) {
zero_user_segment(page, cur, end);
++spiltted;
tight = false;
goto next_part;
}
if (map->m_flags & EROFS_MAP_FRAGMENT) {
erofs_off_t fpos = offset + cur - map->m_la;
@ -1040,12 +1022,24 @@ hitted:
EROFS_I(inode)->z_fragmentoff + fpos);
if (err)
goto out;
++spiltted;
tight = false;
goto next_part;
}
exclusive = (!cur && (!spiltted || tight));
if (!fe->pcl) {
err = z_erofs_pcluster_begin(fe);
if (err)
goto out;
}
/*
* Ensure the current partial page belongs to this submit chain rather
* than other concurrent submit chains or the noio(bypass) chain since
* those chains are handled asynchronously thus the page cannot be used
* for inplace I/O or bvpage (should be processed in a strict order.)
*/
tight &= (fe->mode > Z_EROFS_PCLUSTER_FOLLOWED_NOINPLACE);
exclusive = (!cur && ((split <= 1) || tight));
if (cur)
tight &= (fe->mode >= Z_EROFS_PCLUSTER_FOLLOWED);
@ -1058,8 +1052,6 @@ hitted:
goto out;
z_erofs_onlinepage_split(page);
/* bump up the number of spiltted parts of a page */
++spiltted;
if (fe->pcl->pageofs_out != (map->m_la & ~PAGE_MASK))
fe->pcl->multibases = true;
if (fe->pcl->length < offset + end - map->m_la) {
@ -1084,8 +1076,8 @@ out:
z_erofs_page_mark_eio(page);
z_erofs_onlinepage_endio(page);
erofs_dbg("%s, finish page: %pK spiltted: %u map->m_llen %llu",
__func__, page, spiltted, map->m_llen);
erofs_dbg("%s, finish page: %pK split: %u map->m_llen %llu",
__func__, page, split, map->m_llen);
return err;
}