Commit 5fd96a45 authored by jonas@eel.(none)'s avatar jonas@eel.(none)

ndb - bug#26514

  fix overflow that could occur when have either lots of dd-data or very high dd-parallelism
parent be0798a0
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
RWPool::RWPool() RWPool::RWPool()
{ {
bzero(this, sizeof(* this)); bzero(this, sizeof(* this));
m_current_pos = GLOBAL_PAGE_SIZE_WORDS; m_current_pos = RWPage::RWPAGE_WORDS;
m_current_first_free = REC_NIL; m_current_first_free = REC_NIL;
m_first_free_page = RNIL; m_first_free_page = RNIL;
} }
...@@ -57,7 +57,7 @@ seize_free: ...@@ -57,7 +57,7 @@ seize_free:
m_current_first_free = pageP->m_data[pos+m_record_info.m_offset_next_pool]; m_current_first_free = pageP->m_data[pos+m_record_info.m_offset_next_pool];
return true; return true;
} }
else if (pos + size < GLOBAL_PAGE_SIZE_WORDS) else if (pos + size < RWPage::RWPAGE_WORDS)
{ {
seize_first: seize_first:
ptr.i = (m_current_page_no << POOL_RECORD_BITS) + pos; ptr.i = (m_current_page_no << POOL_RECORD_BITS) + pos;
...@@ -81,11 +81,14 @@ seize_first: ...@@ -81,11 +81,14 @@ seize_first:
{ {
pageP = m_current_page = m_memroot + m_first_free_page; pageP = m_current_page = m_memroot + m_first_free_page;
m_current_page_no = m_first_free_page; m_current_page_no = m_first_free_page;
m_current_pos = GLOBAL_PAGE_SIZE_WORDS; m_current_pos = RWPage::RWPAGE_WORDS;
m_current_first_free = m_current_page->m_first_free; m_current_first_free = m_current_page->m_first_free;
m_first_free_page = m_current_page->m_next_page; m_first_free_page = m_current_page->m_next_page;
m_current_ref_count = m_current_page->m_ref_count; m_current_ref_count = m_current_page->m_ref_count;
if (m_first_free_page != RNIL)
{
(m_memroot + m_first_free_page)->m_prev_page = RNIL; (m_memroot + m_first_free_page)->m_prev_page = RNIL;
}
goto seize_free; goto seize_free;
} }
...@@ -105,7 +108,7 @@ seize_first: ...@@ -105,7 +108,7 @@ seize_first:
m_current_page = 0; m_current_page = 0;
m_current_page_no = RNIL; m_current_page_no = RNIL;
m_current_pos = GLOBAL_PAGE_SIZE_WORDS; m_current_pos = RWPage::RWPAGE_WORDS;
m_current_first_free = REC_NIL; m_current_first_free = REC_NIL;
return false; return false;
...@@ -154,6 +157,7 @@ RWPool::release(Ptr<void> ptr) ...@@ -154,6 +157,7 @@ RWPool::release(Ptr<void> ptr)
} }
page->m_next_page = ffp; page->m_next_page = ffp;
page->m_prev_page = RNIL; page->m_prev_page = RNIL;
m_first_free_page = ptr_page;
return; return;
} }
else if(ref_cnt == 1) else if(ref_cnt == 1)
......
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
struct RWPage struct RWPage
{ {
STATIC_CONST( RWPAGE_WORDS = GLOBAL_PAGE_SIZE_WORDS - 4 );
Uint32 m_type_id; Uint32 m_type_id;
Uint16 m_first_free; Uint16 m_first_free;
Uint16 m_ref_count; Uint16 m_ref_count;
Uint32 m_next_page; Uint32 m_next_page;
Uint32 m_prev_page; Uint32 m_prev_page;
Uint32 m_data[GLOBAL_PAGE_SIZE_WORDS - 4]; Uint32 m_data[RWPAGE_WORDS];
}; };
/** /**
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
WOPool::WOPool() WOPool::WOPool()
{ {
bzero(this, sizeof(* this)); bzero(this, sizeof(* this));
m_current_pos = GLOBAL_PAGE_SIZE_WORDS; m_current_pos = WOPage::WOPAGE_WORDS;
} }
void void
......
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
struct WOPage struct WOPage
{ {
STATIC_CONST( WOPAGE_WORDS = GLOBAL_PAGE_SIZE_WORDS - 2 );
Uint32 m_type_id; Uint32 m_type_id;
Uint32 m_ref_count; Uint32 m_ref_count;
Uint32 m_data[GLOBAL_PAGE_SIZE_WORDS - 2]; Uint32 m_data[WOPAGE_WORDS];
}; };
/** /**
...@@ -61,7 +63,7 @@ WOPool::seize(Ptr<void>& ptr) ...@@ -61,7 +63,7 @@ WOPool::seize(Ptr<void>& ptr)
Uint32 pos = m_current_pos; Uint32 pos = m_current_pos;
Uint32 size = m_record_info.m_size; Uint32 size = m_record_info.m_size;
WOPage *pageP = m_current_page; WOPage *pageP = m_current_page;
if (likely(pos + size < GLOBAL_PAGE_SIZE_WORDS)) if (likely(pos + size < WOPage::WOPAGE_WORDS))
{ {
ptr.i = (m_current_page_no << POOL_RECORD_BITS) + pos; ptr.i = (m_current_page_no << POOL_RECORD_BITS) + pos;
ptr.p = (pageP->m_data + pos); ptr.p = (pageP->m_data + pos);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment