diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-08-17 16:35:58 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-09-11 01:30:11 -0400 |
commit | 1bcf7aadc21ad047fcdba66b080b9f809f49e4cc (patch) | |
tree | 7b4f9f5e0cf934de73703b7c030ab88741a6919f | |
parent | c08f0c1a89b651febfbb9263ca753020d73fe71b (diff) |
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>
-rw-r--r-- | fs/bcachefs/rebalance.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c index c3d577236ce2..15ce3ecba0ba 100644 --- a/fs/bcachefs/rebalance.c +++ b/fs/bcachefs/rebalance.c @@ -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); |