Skip to content

Commit ea0b7b0

Browse files
taigerhuhsiangkao
authored andcommitted
erofs: avoid the potentially wrong m_plen for big pcluster
Actually, 'compressedlcs' stores compressed block count rather than lcluster count. Therefore, the number of bits for shifting the count should be 'LOG_BLOCK_SIZE' rather than 'lclusterbits' although current lcluster size is 4K. The value of 'm_plen' will be wrong once we enable the non 4K-sized lcluster. Signed-off-by: Yue Hu <[email protected]> Reviewed-by: Gao Xiang <[email protected]> Reviewed-by: Chao Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Gao Xiang <[email protected]>
1 parent 5bd9628 commit ea0b7b0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/erofs/zmap.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ struct z_erofs_maprecorder {
141141
u8 type, headtype;
142142
u16 clusterofs;
143143
u16 delta[2];
144-
erofs_blk_t pblk, compressedlcs;
144+
erofs_blk_t pblk, compressedblks;
145145
erofs_off_t nextpackoff;
146146
};
147147

@@ -192,7 +192,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,
192192
DBG_BUGON(1);
193193
return -EFSCORRUPTED;
194194
}
195-
m->compressedlcs = m->delta[0] &
195+
m->compressedblks = m->delta[0] &
196196
~Z_EROFS_VLE_DI_D0_CBLKCNT;
197197
m->delta[0] = 1;
198198
}
@@ -293,7 +293,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
293293
DBG_BUGON(1);
294294
return -EFSCORRUPTED;
295295
}
296-
m->compressedlcs = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT;
296+
m->compressedblks = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT;
297297
m->delta[0] = 1;
298298
return 0;
299299
} else if (i + 1 != (int)vcnt) {
@@ -497,7 +497,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
497497
return 0;
498498
}
499499
lcn = m->lcn + 1;
500-
if (m->compressedlcs)
500+
if (m->compressedblks)
501501
goto out;
502502

503503
err = z_erofs_load_cluster_from_disk(m, lcn, false);
@@ -506,7 +506,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
506506

507507
/*
508508
* If the 1st NONHEAD lcluster has already been handled initially w/o
509-
* valid compressedlcs, which means at least it mustn't be CBLKCNT, or
509+
* valid compressedblks, which means at least it mustn't be CBLKCNT, or
510510
* an internal implemenatation error is detected.
511511
*
512512
* The following code can also handle it properly anyway, but let's
@@ -523,12 +523,12 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
523523
* if the 1st NONHEAD lcluster is actually PLAIN or HEAD type
524524
* rather than CBLKCNT, it's a 1 lcluster-sized pcluster.
525525
*/
526-
m->compressedlcs = 1;
526+
m->compressedblks = 1 << (lclusterbits - LOG_BLOCK_SIZE);
527527
break;
528528
case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:
529529
if (m->delta[0] != 1)
530530
goto err_bonus_cblkcnt;
531-
if (m->compressedlcs)
531+
if (m->compressedblks)
532532
break;
533533
fallthrough;
534534
default:
@@ -539,7 +539,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
539539
return -EFSCORRUPTED;
540540
}
541541
out:
542-
map->m_plen = (u64)m->compressedlcs << lclusterbits;
542+
map->m_plen = (u64)m->compressedblks << LOG_BLOCK_SIZE;
543543
return 0;
544544
err_bonus_cblkcnt:
545545
erofs_err(m->inode->i_sb,

0 commit comments

Comments
 (0)