Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/bluestore: fix empty store divide by 0 runtime error #46133

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/os/bluestore/BlueStore.h
Expand Up @@ -2460,7 +2460,8 @@ class BlueStore : public ObjectStore,
return (2 > onode_num) ? 2 : onode_num;
}
double get_bytes_per_onode() const {
return (double)_get_used_bytes() / (double)_get_num_onodes();
return std::max((double)_get_used_bytes(), 1.0) /
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like std::max should be applied to _get_num_onodes() call not _get_used_bytes() to fight devision by zero issue

(double)_get_num_onodes();
}
};
std::shared_ptr<MetaCache> meta_cache;
Expand Down