Commit 56165c20 authored by unknown's avatar unknown

ndb - bug#34378

  Using more than 16g can cause record-pool ptr.i values to overflow
  Fix by splitting memory into 2 zones, lo(16g)/hi(rest)
  When record pools only use zone_lo, and datamemory, buffers etc...can use any


storage/ndb/src/kernel/blocks/lgman.cpp:
  adopt to changed interface for Ndbd_mem_manager
storage/ndb/src/kernel/vm/Pool.cpp:
  Always use ZONE_LO for record pools
    as they use ptr.i == 19 bit page id + 13 bit page index
storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp:
  Add zones to Ndbd_mem_manager
  ZONE_LO = lower 16g
  ZONE_HI = rest
storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp:
  Add zones to Ndbd_mem_manager
  ZONE_LO = lower 16g
  ZONE_HI = rest
parent 25bddc4d
......@@ -918,7 +918,7 @@ Lgman::alloc_logbuffer_memory(Ptr<Logfile_group> ptr, Uint32 bytes)
{
Uint32 ptrI;
Uint32 cnt = pages > 64 ? 64 : pages;
m_ctx.m_mm.alloc(&ptrI, &cnt, 1);
m_ctx.m_mm.alloc_pages(RG_DISK_OPERATIONS, &ptrI, &cnt, 1);
if (cnt)
{
Buffer_idx range;
......@@ -1037,7 +1037,7 @@ Lgman::free_logbuffer_memory(Ptr<Logfile_group> ptr)
ndbrequire(map.next(it));
tmp[1] = *it.data;
m_ctx.m_mm.release(range.m_ptr_i, range.m_idx);
m_ctx.m_mm.release_pages(RG_DISK_OPERATIONS, range.m_ptr_i, range.m_idx);
map.next(it);
}
map.release();
......
......@@ -20,7 +20,8 @@
void*
Pool_context::alloc_page(Uint32 type_id, Uint32 *i)
{
return m_block->m_ctx.m_mm.alloc_page(type_id, i);
return m_block->m_ctx.m_mm.alloc_page(type_id, i,
Ndbd_mem_manager::NDB_ZONE_LO);
}
void
......
......@@ -20,6 +20,7 @@
#include <Bitmask.hpp>
#include <assert.h>
#include "Pool.hpp"
#include <Vector.hpp>
/**
* 13 -> 8192 words -> 32768 bytes
......@@ -59,16 +60,19 @@ public:
bool init(bool allow_alloc_less_than_requested = true);
void* get_memroot() const { return (void*)m_base_page;}
void alloc(Uint32* ret, Uint32 *pages, Uint32 min_requested);
void release(Uint32 start, Uint32 cnt);
void dump() const ;
void* alloc_page(Uint32 type, Uint32* i);
enum AllocZone
{
NDB_ZONE_LO = 0, // Only allocate with page_id < (1 << 13)
NDB_ZONE_ANY = 1 // Allocate with any page_id
};
void* alloc_page(Uint32 type, Uint32* i, enum AllocZone);
void release_page(Uint32 type, Uint32 i);
void* alloc_pages(Uint32 type, Uint32* i, Uint32 *cnt, Uint32 min = 1);
void release_pages(Uint32 type, Uint32 i, void*p, Uint32 cnt);
void alloc_pages(Uint32 type, Uint32* i, Uint32 *cnt, Uint32 min = 1);
void release_pages(Uint32 type, Uint32 i, Uint32 cnt);
/**
* Compute 2log of size
......@@ -80,25 +84,29 @@ public:
private:
void grow(Uint32 start, Uint32 cnt);
#define XX_RL_COUNT 3
#define XX_RL_COUNT 4
/**
* Return pointer to free page data on page
*/
static Free_page_data* get_free_page_data(Alloc_page*, Uint32 idx);
Bitmask<1> m_used_bitmap_pages;
Vector<Uint32> m_used_bitmap_pages;
Uint32 m_buddy_lists[16];
Uint32 m_buddy_lists[2][16];
Resource_limit m_resource_limit[XX_RL_COUNT]; // RG_COUNT in record_types.hpp
Alloc_page * m_base_page;
void release_impl(Uint32 start, Uint32 cnt);
void insert_free_list(Uint32 start, Uint32 cnt);
Uint32 remove_free_list(Uint32 start, Uint32 list);
void release_impl(Uint32 zone, Uint32 start, Uint32 cnt);
void insert_free_list(Uint32 zone, Uint32 start, Uint32 cnt);
Uint32 remove_free_list(Uint32 zone, Uint32 start, Uint32 list);
void set(Uint32 first, Uint32 last);
void clear(Uint32 first, Uint32 last);
void clear_and_set(Uint32 first, Uint32 last);
Uint32 check(Uint32 first, Uint32 last);
void alloc(AllocZone, Uint32* ret, Uint32 *pages, Uint32 min_requested);
void alloc_impl(Uint32 zone, Uint32* ret, Uint32 *pages, Uint32 min);
void release(Uint32 start, Uint32 cnt);
};
inline
......
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