提交 155eb9aa 编写于 作者: A Avishay Traeger 提交者: Kevin Wolf

Fix integer overflow in block migration bandwidth calculation

block_mig_state.reads is an int, and multiplying by BLOCK_SIZE yielded a
negative number, resulting in a negative bandwidth (running on a 32-bit
machine).  Change order to avoid.
Signed-off-by: NAvishay Traeger <avishay@il.ibm.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 7d905f71
......@@ -140,7 +140,7 @@ static inline void add_avg_read_time(int64_t time)
static inline long double compute_read_bwidth(void)
{
assert(block_mig_state.total_time != 0);
return (block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time;
return (block_mig_state.reads / block_mig_state.total_time) * BLOCK_SIZE;
}
static int bmds_aio_inflight(BlkMigDevState *bmds, int64_t sector)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册