Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Gao Xiang 2a13fc41 e13d315a

+6 -14
+6 -14
fs/erofs/zmap.c
··· 272 272 unsigned long lcn = m->lcn - lookback_distance; 273 273 int err; 274 274 275 + if (!lookback_distance) 276 + break; 277 + 275 278 err = z_erofs_load_lcluster_from_disk(m, lcn, false); 276 279 if (err) 277 280 return err; 278 - 279 281 if (m->type == Z_EROFS_LCLUSTER_TYPE_NONHEAD) { 280 282 lookback_distance = m->delta[0]; 281 - if (!lookback_distance) 282 - break; 283 283 continue; 284 - } else { 285 - m->headtype = m->type; 286 - m->map->m_la = (lcn << lclusterbits) | m->clusterofs; 287 - return 0; 288 284 } 285 + m->headtype = m->type; 286 + m->map->m_la = (lcn << lclusterbits) | m->clusterofs; 287 + return 0; 289 288 } 290 289 erofs_err(sb, "bogus lookback distance %u @ lcn %lu of nid %llu", 291 290 lookback_distance, m->lcn, vi->nid); ··· 434 435 end = inode->i_size; 435 436 } else { 436 437 if (m.type != Z_EROFS_LCLUSTER_TYPE_NONHEAD) { 437 - /* m.lcn should be >= 1 if endoff < m.clusterofs */ 438 - if (!m.lcn) { 439 - erofs_err(sb, "invalid logical cluster 0 at nid %llu", 440 - vi->nid); 441 - err = -EFSCORRUPTED; 442 - goto unmap_out; 443 - } 444 438 end = (m.lcn << lclusterbits) | m.clusterofs; 445 439 map->m_flags |= EROFS_MAP_FULL_MAPPED; 446 440 m.delta[0] = 1;