erofs-utils: lib: `fragment_size` should be 64 bits
PATCH 1/1 erofs-utils: lib: `fragment_size` should be 64 bits
-Eall-fragments is broken if i_size is more than 32 bits.
Fixes fcaa988a6ef6 ("erofs-utils: add `-Eall-fragments` option")
Signed-off-by Gao Xiang <[email protected]>
--- include/erofs/internal.h | 12 ++++++++---- lib/compress.c | 9 +++++---- 2 files changed, 13 insertions(+), 8 deletions(-)
include/erofs/internal.h +8 -4
@@ -233,16 +233,20 @@ struct erofs_inode {uint8_t z_algorithmtype[2 ];uint8_t z_logical_clusterbits;uint8_t z_physical_clusterblks; -uint64_t z_tailextent_headlcn; -unsigned int z_idataoff; +union { +uint64_t z_tailextent_headlcn; +erofs_off_t fragment_size; + }; +union { +unsigned int z_idataoff; +erofs_off_t fragmentoff; + };#define z_idata_size idata_size }; };#ifdef WITH_ANDROID uint64_t capabilities;#endif -erofs_off_t fragmentoff; -unsigned int fragment_size; };static inline erofs_off_t erofs_iloc (struct erofs_inode *inode)
lib/compress.c +5 -4
@@ -373,9 +373,9 @@ static bool z_erofs_fixup_deduped_fragment(struct z_erofs_vle_compress_ctx *ctx,/* try to fix again if it gets larger (should be rare) */ if (inode->fragment_size < newsize) { - ctx->pclustersize =min (z_erofs_get_max_pclustersize (inode), -roundup (newsize - inode->fragment_size, -erofs_blksiz (sbi))); + ctx->pclustersize =min_t (erofs_off_t,z_erofs_get_max_pclustersize (inode), +roundup (newsize - inode->fragment_size, +erofs_blksiz (sbi)));return false; }
@@ -1005,7 +1005,8 @@ int erofs_write_compressed_file(struct erofs_inode *inode, int fd) sbi->saved_by_deduplication += inode->fragment_size;/* if the entire file is a fragment, a simplified form is used. */ -if (inode->i_size == inode->fragment_size) { +if (inode->i_size <= inode->fragment_size) { +DBG_BUGON (inode->i_size < inode->fragment_size);DBG_BUGON (inode->fragmentoff >>63 ); *(__le64 *)compressmeta =cpu_to_le64 (inode->fragmentoff |1ULL <<63 );
Signature · 1 line
2.39.3
Quoted 4 lines · On Wed, 15 Nov 2023 10:49:52 +0800 Gao Xiang <[email protected]>…
-Eall-fragmentsis broken ifi_sizeis more than 32 bits.Fixes fcaa988a6ef6 ("erofs-utils: add `-Eall-fragments` option")Signed-off-by Gao Xiang <[email protected]>
Reviewed-by Yue Hu <[email protected]>