Skip to content

Commit 2a13fc4

Browse files
committed
erofs: consolidate z_erofs_extent_lookback()
The initial m.delta[0] also needs to be checked against zero. In addition, also drop the redundant logic that errors out for lcn == 0 / m.delta[0] == 1 case. Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent e13d315 commit 2a13fc4

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

fs/erofs/zmap.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,19 @@ static int z_erofs_extent_lookback(struct z_erofs_maprecorder *m,
272272
unsigned long lcn = m->lcn - lookback_distance;
273273
int err;
274274

275+
if (!lookback_distance)
276+
break;
277+
275278
err = z_erofs_load_lcluster_from_disk(m, lcn, false);
276279
if (err)
277280
return err;
278-
279281
if (m->type == Z_EROFS_LCLUSTER_TYPE_NONHEAD) {
280282
lookback_distance = m->delta[0];
281-
if (!lookback_distance)
282-
break;
283283
continue;
284-
} else {
285-
m->headtype = m->type;
286-
m->map->m_la = (lcn << lclusterbits) | m->clusterofs;
287-
return 0;
288284
}
285+
m->headtype = m->type;
286+
m->map->m_la = (lcn << lclusterbits) | m->clusterofs;
287+
return 0;
289288
}
290289
erofs_err(sb, "bogus lookback distance %u @ lcn %lu of nid %llu",
291290
lookback_distance, m->lcn, vi->nid);
@@ -435,13 +434,6 @@ static int z_erofs_map_blocks_fo(struct inode *inode,
435434
end = inode->i_size;
436435
} else {
437436
if (m.type != Z_EROFS_LCLUSTER_TYPE_NONHEAD) {
438-
/* m.lcn should be >= 1 if endoff < m.clusterofs */
439-
if (!m.lcn) {
440-
erofs_err(sb, "invalid logical cluster 0 at nid %llu",
441-
vi->nid);
442-
err = -EFSCORRUPTED;
443-
goto unmap_out;
444-
}
445437
end = (m.lcn << lclusterbits) | m.clusterofs;
446438
map->m_flags |= EROFS_MAP_FULL_MAPPED;
447439
m.delta[0] = 1;

0 commit comments

Comments
 (0)