-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
f0a70f5
to
e7453e4
Compare
00a9874
to
aaefa88
Compare
src/engine/blkstore/blkstore.hpp
Outdated
@@ -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)}; |
There was a problem hiding this comment.
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?
aaefa88
to
f057a76
Compare
There was a problem hiding this 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.
src/engine/blkstore/blkstore.hpp
Outdated
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
f057a76
to
b44e697
Compare
No description provided.