Commit 0d823b42 authored by Gao Xiang's avatar Gao Xiang

erofs: clean up z_erofs_collector_begin()

Rearrange the code and get rid of all gotos.
Reviewed-by: default avatarYue Hu <huyue2@coolpad.com>
Acked-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20220715154203.48093-3-hsiangkao@linux.alibaba.com
parent 83a386c0
...@@ -521,7 +521,7 @@ static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe) ...@@ -521,7 +521,7 @@ static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe)
static int z_erofs_collector_begin(struct z_erofs_decompress_frontend *fe) static int z_erofs_collector_begin(struct z_erofs_decompress_frontend *fe)
{ {
struct erofs_map_blocks *map = &fe->map; struct erofs_map_blocks *map = &fe->map;
struct erofs_workgroup *grp; struct erofs_workgroup *grp = NULL;
int ret; int ret;
DBG_BUGON(fe->pcl); DBG_BUGON(fe->pcl);
...@@ -530,33 +530,31 @@ static int z_erofs_collector_begin(struct z_erofs_decompress_frontend *fe) ...@@ -530,33 +530,31 @@ static int z_erofs_collector_begin(struct z_erofs_decompress_frontend *fe)
DBG_BUGON(fe->owned_head == Z_EROFS_PCLUSTER_NIL); DBG_BUGON(fe->owned_head == Z_EROFS_PCLUSTER_NIL);
DBG_BUGON(fe->owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED); DBG_BUGON(fe->owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED);
if (map->m_flags & EROFS_MAP_META) { if (!(map->m_flags & EROFS_MAP_META)) {
if ((map->m_pa & ~PAGE_MASK) + map->m_plen > PAGE_SIZE) { grp = erofs_find_workgroup(fe->inode->i_sb,
DBG_BUGON(1); map->m_pa >> PAGE_SHIFT);
return -EFSCORRUPTED; } else if ((map->m_pa & ~PAGE_MASK) + map->m_plen > PAGE_SIZE) {
} DBG_BUGON(1);
goto tailpacking; return -EFSCORRUPTED;
} }
grp = erofs_find_workgroup(fe->inode->i_sb, map->m_pa >> PAGE_SHIFT);
if (grp) { if (grp) {
fe->pcl = container_of(grp, struct z_erofs_pcluster, obj); fe->pcl = container_of(grp, struct z_erofs_pcluster, obj);
ret = -EEXIST;
} else { } else {
tailpacking:
ret = z_erofs_register_pcluster(fe); ret = z_erofs_register_pcluster(fe);
if (!ret)
goto out;
if (ret != -EEXIST)
return ret;
} }
ret = z_erofs_lookup_pcluster(fe); if (ret == -EEXIST) {
if (ret) { ret = z_erofs_lookup_pcluster(fe);
erofs_workgroup_put(&fe->pcl->obj); if (ret) {
erofs_workgroup_put(&fe->pcl->obj);
return ret;
}
} else if (ret) {
return ret; return ret;
} }
out:
z_erofs_pagevec_ctor_init(&fe->vector, Z_EROFS_NR_INLINE_PAGEVECS, z_erofs_pagevec_ctor_init(&fe->vector, Z_EROFS_NR_INLINE_PAGEVECS,
fe->pcl->pagevec, fe->pcl->vcnt); fe->pcl->pagevec, fe->pcl->vcnt);
/* since file-backed online pages are traversed in reverse order */ /* since file-backed online pages are traversed in reverse order */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment