erofs-utils: use the BLK_ROUND_UP directly
PATCH 1/1 erofs-utils: use the BLK_ROUND_UP directly
Just simplify the code.
Signed-off-by Yue Hu <[email protected]>
--- fsck/main.c | 6 ++---- lib/compress.c | 4 ++-- lib/data.c | 2 +- lib/zmap.c | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-)
fsck/main.c +2 -4
@@ -483,10 +483,8 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd) }if (fsckcfg.print_comp_ratio) { - fsckcfg.logical_blocks += -DIV_ROUND_UP (inode->i_size,EROFS_BLKSIZ ); - fsckcfg.physical_blocks += -DIV_ROUND_UP (pchunk_len,EROFS_BLKSIZ ); + fsckcfg.logical_blocks +=BLK_ROUND_UP (inode->i_size); + fsckcfg.physical_blocks +=BLK_ROUND_UP (pchunk_len); } out:if (raw)
lib/compress.c +2 -2
@@ -303,7 +303,7 @@ nocompression: tailused = ret & (EROFS_BLKSIZ -1 ); padding =0 ; - ctx->compressedblks =DIV_ROUND_UP (ret,EROFS_BLKSIZ ); + ctx->compressedblks =BLK_ROUND_UP (ret);DBG_BUGON (ctx->compressedblks *EROFS_BLKSIZ >= count);/* zero out garbage trailing data for non-0padding */
@@ -584,7 +584,7 @@ void z_erofs_drop_inline_pcluster(struct erofs_inode *inode)u8 *out; eofs = inode->extent_isize - - (4 << (DIV_ROUND_UP (inode->i_size,EROFS_BLKSIZ ) &1 )); + (4 << (BLK_ROUND_UP (inode->i_size) &1 )); base =round_down (eofs,8 ); pos =16 /* encodebits */ * ((eofs - base) /4 ); out = inode->compressmeta + base;
lib/data.c +1 -1
@@ -22,7 +22,7 @@ static int erofs_map_blocks_flatmode(struct erofs_inode *inode,trace_erofs_map_blocks_flatmode_enter (inode, map, flags); - nblocks =DIV_ROUND_UP (inode->i_size,EROFS_BLKSIZ ); + nblocks =BLK_ROUND_UP (inode->i_size); lastblk = nblocks - tailendpacking;/* there is no hole in flatmode */
lib/zmap.c +1 -1
@@ -325,7 +325,7 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,const erofs_off_t ebase =round_up (iloc (vi->nid) + vi->inode_isize + vi->xattr_isize,8 ) +sizeof (struct z_erofs_map_header ); -const unsigned int totalidx =DIV_ROUND_UP (vi->i_size,EROFS_BLKSIZ ); +const unsigned int totalidx =BLK_ROUND_UP (vi->i_size);unsigned int compacted_4b_initial, compacted_2b;unsigned int amortizedshift;erofs_off_t pos;
Signature · 1 line
2.17.1
Quoted 3 lines · Yue Hu
Just simplify the code.
Signed-off-by Yue Hu <[email protected]>
LGTM,
Reviewed-by Gao Xiang <[email protected]>
Thanks,
Gao Xiang
Quoted 74 lines
--- fsck/main.c | 6 ++---- lib/compress.c | 4 ++-- lib/data.c | 2 +- lib/zmap.c | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-)fsck/main.c +2
-4@@ -483,10 +483,8 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd) }if (fsckcfg.print_comp_ratio) { - fsckcfg.logical_blocks += -DIV_ROUND_UP (inode->i_size,EROFS_BLKSIZ ); - fsckcfg.physical_blocks += -DIV_ROUND_UP (pchunk_len,EROFS_BLKSIZ ); + fsckcfg.logical_blocks +=BLK_ROUND_UP (inode->i_size); + fsckcfg.physical_blocks +=BLK_ROUND_UP (pchunk_len); } out:if (raw)lib/compress.c +2
-2@@ -303,7 +303,7 @@ nocompression: tailused = ret & (EROFS_BLKSIZ -1 ); padding =0 ; - ctx->compressedblks =DIV_ROUND_UP (ret,EROFS_BLKSIZ ); + ctx->compressedblks =BLK_ROUND_UP (ret);DBG_BUGON (ctx->compressedblks *EROFS_BLKSIZ >= count);/* zero out garbage trailing data for non-0padding */ @@ -584,7 +584,7 @@ void z_erofs_drop_inline_pcluster(struct erofs_inode *inode)u8 *out; eofs = inode->extent_isize - - (4 << (DIV_ROUND_UP (inode->i_size,EROFS_BLKSIZ ) &1 )); + (4 << (BLK_ROUND_UP (inode->i_size) &1 )); base =round_down (eofs,8 ); pos =16 /* encodebits */ * ((eofs - base) /4 ); out = inode->compressmeta + base;lib/data.c +1
-1@@ -22,7 +22,7 @@ static int erofs_map_blocks_flatmode(struct erofs_inode *inode,trace_erofs_map_blocks_flatmode_enter (inode, map, flags); - nblocks =DIV_ROUND_UP (inode->i_size,EROFS_BLKSIZ ); + nblocks =BLK_ROUND_UP (inode->i_size); lastblk = nblocks - tailendpacking;/* there is no hole in flatmode */ lib/zmap.c +1
-1@@ -325,7 +325,7 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,const erofs_off_t ebase =round_up (iloc (vi->nid) + vi->inode_isize + vi->xattr_isize,8 ) +sizeof (struct z_erofs_map_header ); -const unsigned int totalidx =DIV_ROUND_UP (vi->i_size,EROFS_BLKSIZ ); +const unsigned int totalidx =BLK_ROUND_UP (vi->i_size);unsigned int compacted_4b_initial, compacted_2b;unsigned int amortizedshift;erofs_off_t pos;Signature · 1 line
2.17.1