diff --git a/convert/main.c b/convert/main.c index 95ceec11..fc139e4a 100644 --- a/convert/main.c +++ b/convert/main.c @@ -1134,7 +1134,6 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize, int ret; int fd = -1; u32 blocksize; - u64 total_bytes; struct btrfs_root *root; struct btrfs_root *image_root; struct btrfs_convert_context cctx; @@ -1161,7 +1160,6 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize, ASSERT(cctx.total_bytes != 0); blocksize = cctx.blocksize; - total_bytes = (u64)blocksize * (u64)cctx.block_count; if (blocksize < 4096) { error("block size is too small: %u < 4096", blocksize); goto fail; @@ -1223,7 +1221,7 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize, mkfs_cfg.csum_type = csum_type; mkfs_cfg.label = cctx.label; - mkfs_cfg.num_bytes = total_bytes; + mkfs_cfg.num_bytes = cctx.total_bytes; mkfs_cfg.nodesize = nodesize; mkfs_cfg.sectorsize = blocksize; mkfs_cfg.stripesize = blocksize; diff --git a/convert/source-ext2.c b/convert/source-ext2.c index 9fad4c50..610db16b 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -92,8 +92,8 @@ static int ext2_open_fs(struct btrfs_convert_context *cctx, const char *name) cctx->fs_data = ext2_fs; cctx->blocksize = ext2_fs->blocksize; - cctx->block_count = ext2_fs->super->s_blocks_count; - cctx->total_bytes = (u64)ext2_fs->super->s_blocks_count * ext2_fs->blocksize; + cctx->block_count = ext2fs_blocks_count(ext2_fs->super); + cctx->total_bytes = cctx->block_count * cctx->blocksize; cctx->label = strndup((char *)ext2_fs->super->s_volume_name, 16); cctx->first_data_block = ext2_fs->super->s_first_data_block; cctx->inodes_count = ext2_fs->super->s_inodes_count;