1

bcachefs: Fix divide by zero in rebalance_work()

This fixes https://github.com/koverstreet/bcachefs-tools/issues/159

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-08-17 16:35:58 -04:00
parent 8e877caaad
commit d0445e131e

View File

@ -113,6 +113,10 @@ static void rebalance_work_accumulate(struct rebalance_work *w,
unsigned percent_full;
u64 work = dev_work + unknown_dev;
/* avoid divide by 0 */
if (!capacity)
return;
if (work < dev_work || work < unknown_dev)
work = U64_MAX;
work = min(work, capacity);