mirror of
https://github.com/Zygo/bees.git
synced 2025-07-02 00:32:27 +02:00
extent scan: don't divide by zero if there were no loops
Commit 183b6a5361
("extent scan: refactor
BeesCrawl, BeesScanMode*") moved some statistics calculations out of
the loop in `find_next_extent`, but did not ensure that the statistics
would not be calculated if the loop had not executed any iterations.
In rare instances, the function returns without entering the loop at all,
which results in divide by zero. Add a check just before doing that.
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
@ -948,6 +948,7 @@ BeesScanModeExtent::SizeTier::find_next_extent()
|
|||||||
const auto search_calls = BtrfsIoctlSearchKey::s_calls - init_s_calls;
|
const auto search_calls = BtrfsIoctlSearchKey::s_calls - init_s_calls;
|
||||||
const auto search_loops = BtrfsIoctlSearchKey::s_loops - init_s_loops;
|
const auto search_loops = BtrfsIoctlSearchKey::s_loops - init_s_loops;
|
||||||
if (crawl_time.age() > 1) {
|
if (crawl_time.age() > 1) {
|
||||||
|
if (loop_count) {
|
||||||
BEESLOGDEBUG(
|
BEESLOGDEBUG(
|
||||||
"loop_count " << loop_count
|
"loop_count " << loop_count
|
||||||
<< " size_low_count " << size_low_count
|
<< " size_low_count " << size_low_count
|
||||||
@ -964,6 +965,7 @@ BeesScanModeExtent::SizeTier::find_next_extent()
|
|||||||
<< " skip/loop " << (100 * skip_count / loop_count) << "%"
|
<< " skip/loop " << (100 * skip_count / loop_count) << "%"
|
||||||
<< " flop/loop " << (100 * flop_count / loop_count) << "%"
|
<< " flop/loop " << (100 * flop_count / loop_count) << "%"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
if (debug_oss) {
|
if (debug_oss) {
|
||||||
BEESLOGDEBUG("debug oss trace:\n" << debug_oss->str());
|
BEESLOGDEBUG("debug oss trace:\n" << debug_oss->str());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user