erofs-utils: avoid the potentially wrong m_plen for big pcluster
PATCH v2 1/1 erofs-utils: avoid the potentially wrong m_plen for big pcluster
From: Yue Hu <[email protected]>
Keep in sync with the kernel commit 0d53d2e882f9 ("erofs: avoid the potentially wrong m_plen for big pcluster").
Signed-off-by Yue Hu <[email protected]>
---
v2: rebase on latest dev branch
lib/zmap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
lib/zmap.c +8 -8
@@ -115,7 +115,7 @@ struct z_erofs_maprecorder {u8 type, headtype;u16 clusterofs;u16 delta[2 ]; -erofs_blk_t pblk, compressedlcs; +erofs_blk_t pblk, compressedblks;erofs_off_t nextpackoff;bool partialref; };
@@ -172,7 +172,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,DBG_BUGON (1 );return -EFSCORRUPTED ; } - m->compressedlcs = m->delta[0 ] & + m->compressedblks = m->delta[0 ] & ~Z_EROFS_VLE_DI_D0_CBLKCNT ; m->delta[0 ] =1 ; }
@@ -274,7 +274,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,DBG_BUGON (1 );return -EFSCORRUPTED ; } - m->compressedlcs = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT ; + m->compressedblks = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT ; m->delta[0 ] =1 ;return 0 ; }else if (i +1 != (int )vcnt) {
@@ -471,7 +471,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m, } lcn = m->lcn +1 ; -if (m->compressedlcs) +if (m->compressedblks) goto out; err =z_erofs_load_cluster_from_disk (m, lcn, false);
@@ -480,7 +480,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,/* * If the 1st NONHEAD lcluster has already been handled initially w/o -* valid compressedlcs, which means at least it mustn't be CBLKCNT, or +* valid compressedblks, which means at least it mustn't be CBLKCNT, or * an internal implemenatation error is detected. * * The following code can also handle it properly anyway, but let's
@@ -496,12 +496,12 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,* if the 1st NONHEAD lcluster is actually PLAIN or HEAD type * rather than CBLKCNT, it's a 1 lcluster-sized pcluster. */ - m->compressedlcs =1 ; + m->compressedblks =1 << (lclusterbits -LOG_BLOCK_SIZE );break ;case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD :if (m->delta[0 ] !=1 ) goto err_bonus_cblkcnt; -if (m->compressedlcs) +if (m->compressedblks)break ;/* fallthrough */ default :
@@ -511,7 +511,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,return -EFSCORRUPTED ; } out: - map->m_plen = m->compressedlcs << lclusterbits; + map->m_plen = m->compressedblks <<LOG_BLOCK_SIZE ;return 0 ; err_bonus_cblkcnt: erofs_err("bogus CBLKCNT @ lcn %lu of nid %llu",
Signature · 1 line
2.17.1
Quoted 6 lines · Yue Hu
From: Yue Hu <[email protected]>
Keep in sync with the kernel commit
0d53d2e882f9("erofs: avoid the potentially wrongm_plenfor big pcluster").Signed-off-by Yue Hu <[email protected]>
Reviewed-by Gao Xiang <[email protected]>
Thanks,
Gao Xiang
Quoted 81 lines
---
v2: rebase on latest dev branchlib/zmap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)lib/zmap.c +8
-8@@ -115,7 +115,7 @@ struct z_erofs_maprecorder {u8 type, headtype;u16 clusterofs;u16 delta[2 ]; -erofs_blk_t pblk, compressedlcs; +erofs_blk_t pblk, compressedblks;erofs_off_t nextpackoff;bool partialref; };@@ -172,7 +172,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,DBG_BUGON (1 );return -EFSCORRUPTED ; } - m->compressedlcs = m->delta[0 ] & + m->compressedblks = m->delta[0 ] & ~Z_EROFS_VLE_DI_D0_CBLKCNT ; m->delta[0 ] =1 ; }@@ -274,7 +274,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,DBG_BUGON (1 );return -EFSCORRUPTED ; } - m->compressedlcs = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT ; + m->compressedblks = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT ; m->delta[0 ] =1 ;return 0 ; }else if (i +1 != (int )vcnt) {@@ -471,7 +471,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m, } lcn = m->lcn +1 ; -if (m->compressedlcs) +if (m->compressedblks) goto out; err =z_erofs_load_cluster_from_disk (m, lcn, false);@@ -480,7 +480,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,/* * If the 1st NONHEAD lcluster has already been handled initially w/o -* valid compressedlcs, which means at least it mustn't be CBLKCNT, or +* valid compressedblks, which means at least it mustn't be CBLKCNT, or * an internal implemenatation error is detected. * * The following code can also handle it properly anyway, but let's @@ -496,12 +496,12 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,* if the 1st NONHEAD lcluster is actually PLAIN or HEAD type * rather than CBLKCNT, it's a 1 lcluster-sized pcluster. */ - m->compressedlcs =1 ; + m->compressedblks =1 << (lclusterbits -LOG_BLOCK_SIZE );break ;case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD :if (m->delta[0 ] !=1 ) goto err_bonus_cblkcnt; -if (m->compressedlcs) +if (m->compressedblks)break ;/* fallthrough */ default :@@ -511,7 +511,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,return -EFSCORRUPTED ; } out: - map->m_plen = m->compressedlcs << lclusterbits; + map->m_plen = m->compressedblks <<LOG_BLOCK_SIZE ;return 0 ; err_bonus_cblkcnt: erofs_err("bogus CBLKCNT @ lcn %lu of nid %llu",Signature · 1 line
2.17.1