btrfs-progs: convert: make ASSERT not truncate cctx.total_bytes value

Commit "btrfs-progs: convert: prevent 32bit overflow for
cctx->total_bytes" added an assert to ensure that cctxx.total_bytes did
not overflow, but this ASSERT calls assert_trace, which expects a long
value.

By converting the u64 to long overflows in a 32bit machine, leading the
assert_trace to be triggered since cctx.total_bytes turns to zero.

Fix this problem by comparing the cctx.total_bytes with zero when
calling ASSERT.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Marcos Paulo de Souza 2020-08-26 15:08:20 -03:00 committed by David Sterba
parent c9c4eb1f3f
commit e44adcc5bc

View file

@ -1136,7 +1136,7 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize,
if (ret)
goto fail;
ASSERT(cctx.total_bytes);
ASSERT(cctx.total_bytes != 0);
blocksize = cctx.blocksize;
total_bytes = (u64)blocksize * (u64)cctx.block_count;
if (blocksize < 4096) {