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

FIX oom and blk alloc overflow which cause OOM #554

Merged
merged 3 commits into from
Sep 23, 2024

Conversation

shosseinimotlagh
Copy link
Contributor

No description provided.

@yamingk yamingk changed the title FIX oom and metablk corruption FIX oom and blk alloc overflow which cause OOM Sep 18, 2024
yamingk
yamingk previously approved these changes Sep 18, 2024
szmyd
szmyd previously approved these changes Sep 19, 2024
@szmyd szmyd closed this Sep 19, 2024
@szmyd szmyd reopened this Sep 19, 2024
yamingk
yamingk previously approved these changes Sep 20, 2024
@@ -325,26 +325,31 @@ class BlkStore {
BlkAllocStatus alloc_contiguous_blk(const uint32_t size, blk_alloc_hints& hints, BlkId* const out_blkid) {
// Allocate a block from the device manager
assert(size % m_pagesz == 0);
const blk_count_t nblks{static_cast< blk_count_t >(size / m_pagesz)};
const uint32_t nblks{static_cast< uint32_t >(size / m_pagesz)};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't make sense to me. We change this from a 16bit value to a 32bit value (to avoid overflow?) and then later immediately cast it back to a 16bit parameter in the call to alloc_contig...; what's the point?

szmyd
szmyd previously approved these changes Sep 20, 2024
Copy link
Collaborator

@szmyd szmyd left a comment

Choose a reason for hiding this comment

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

looks ok to me; might want to wait for @yamingk to also approve.

if (nblks <= BlkId::max_blks_in_op()) {
return (m_vdev.alloc_blk(nblks, hints, out_blkid));
auto max_val = std::numeric_limits< blk_count_t >::max();
HS_DBG_ASSERT_LE(nblks, max_val, "nblks must be less than {}", max_val);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: do we still this assert since you've added static assert at blk.h? I mean the static assert at blk.h can make sure this assert always true, right? Also can we just use one line: HS_DBG_ASSERT_LE(nblks, std::numeric_limits< blk_count_t >::max(), "nblks must be less than {}", max_val);, although compiler might do the same for optimization. I am fine either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remove it

@@ -325,6 +325,9 @@ class BlkStore {
BlkAllocStatus alloc_contiguous_blk(const uint32_t size, blk_alloc_hints& hints, BlkId* const out_blkid) {
// Allocate a block from the device manager
assert(size % m_pagesz == 0);
static uint32_t max_suppoted_size = m_pagesz * std::numeric_limits< blk_count_t >::max();
Copy link
Contributor

@yamingk yamingk Sep 23, 2024

Choose a reason for hiding this comment

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

nit: ideally this max_supported_size should come from Chunk::BlkAlloc::max_supported_size(). We can do it from 4.x

@szmyd szmyd merged commit 5b3a605 into eBay:stable/v3.7.x Sep 23, 2024
14 of 16 checks passed
@shosseinimotlagh shosseinimotlagh deleted the fix-meta-oom branch September 23, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants