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

ndb dd - bug#16913

  Use shared pool for tablespaces/datafiles in tsman
parent f867b02a
...@@ -83,9 +83,7 @@ Tsman::Tsman(Block_context& ctx, ...@@ -83,9 +83,7 @@ Tsman::Tsman(Block_context& ctx,
addRecSignal(GSN_GET_TABINFOREQ, &Tsman::execGET_TABINFOREQ); addRecSignal(GSN_GET_TABINFOREQ, &Tsman::execGET_TABINFOREQ);
m_tablespace_pool.setSize(10);
m_tablespace_hash.setSize(10); m_tablespace_hash.setSize(10);
m_file_pool.setSize(10);
m_file_hash.setSize(10); m_file_hash.setSize(10);
} }
...@@ -109,6 +107,12 @@ Tsman::execREAD_CONFIG_REQ(Signal* signal) ...@@ -109,6 +107,12 @@ Tsman::execREAD_CONFIG_REQ(Signal* signal)
m_ctx.m_config.getOwnConfigIterator(); m_ctx.m_config.getOwnConfigIterator();
ndbrequire(p != 0); ndbrequire(p != 0);
Pool_context pc;
pc.m_block = this;
m_file_pool.init(RT_TSMAN_FILE, pc);
m_tablespace_pool.init(RT_TSMAN_FILEGROUP, pc);
ReadConfigConf * conf = (ReadConfigConf*)signal->getDataPtrSend(); ReadConfigConf * conf = (ReadConfigConf*)signal->getDataPtrSend();
conf->senderRef = reference(); conf->senderRef = reference();
conf->senderData = senderData; conf->senderData = senderData;
...@@ -431,10 +435,10 @@ Tsman::execDROP_FILEGROUP_REQ(Signal* signal){ ...@@ -431,10 +435,10 @@ Tsman::execDROP_FILEGROUP_REQ(Signal* signal){
bool bool
Tsman::find_file_by_id(Ptr<Datafile>& ptr, Tsman::find_file_by_id(Ptr<Datafile>& ptr,
DLList<Datafile>::Head& head, Datafile_list::Head& head,
Uint32 id) Uint32 id)
{ {
LocalDLList<Datafile> list(m_file_pool, head); Local_datafile_list list(m_file_pool, head);
for(list.first(ptr); !ptr.isNull(); list.next(ptr)) for(list.first(ptr); !ptr.isNull(); list.next(ptr))
if(ptr.p->m_file_id == id) if(ptr.p->m_file_id == id)
return true; return true;
...@@ -522,7 +526,7 @@ Tsman::execCREATE_FILE_REQ(Signal* signal){ ...@@ -522,7 +526,7 @@ Tsman::execCREATE_FILE_REQ(Signal* signal){
} }
new (file_ptr.p) Datafile(req); new (file_ptr.p) Datafile(req);
LocalDLList<Datafile> tmp(m_file_pool, ptr.p->m_meta_files); Local_datafile_list tmp(m_file_pool, ptr.p->m_meta_files);
tmp.add(file_ptr); tmp.add(file_ptr);
file_ptr.p->m_state = Datafile::FS_CREATING; file_ptr.p->m_state = Datafile::FS_CREATING;
...@@ -649,7 +653,7 @@ Tsman::execFSCLOSECONF(Signal* signal) ...@@ -649,7 +653,7 @@ Tsman::execFSCLOSECONF(Signal* signal)
{ {
m_tablespace_pool.getPtr(lg_ptr, ptr.p->m_tablespace_ptr_i); m_tablespace_pool.getPtr(lg_ptr, ptr.p->m_tablespace_ptr_i);
LocalDLList<Datafile> list(m_file_pool, lg_ptr.p->m_meta_files); Local_datafile_list list(m_file_pool, lg_ptr.p->m_meta_files);
list.release(ptr); list.release(ptr);
} }
} }
...@@ -833,7 +837,7 @@ Tsman::create_file_ref(Signal* signal, ...@@ -833,7 +837,7 @@ Tsman::create_file_ref(Signal* signal,
sendSignal(ptr.p->m_create.m_senderRef, GSN_CREATE_FILE_REF, signal, sendSignal(ptr.p->m_create.m_senderRef, GSN_CREATE_FILE_REF, signal,
CreateFileImplRef::SignalLength, JBB); CreateFileImplRef::SignalLength, JBB);
LocalDLList<Datafile> meta(m_file_pool, lg_ptr.p->m_meta_files); Local_datafile_list meta(m_file_pool, lg_ptr.p->m_meta_files);
meta.release(ptr); meta.release(ptr);
} }
...@@ -1104,8 +1108,8 @@ Tsman::load_extent_page_callback(Signal* signal, ...@@ -1104,8 +1108,8 @@ Tsman::load_extent_page_callback(Signal* signal,
(getNodeState().getNodeRestartInProgress() && (getNodeState().getNodeRestartInProgress() &&
getNodeState().starting.restartType == NodeState::ST_INITIAL_NODE_RESTART)) getNodeState().starting.restartType == NodeState::ST_INITIAL_NODE_RESTART))
{ {
LocalDLList<Datafile> free(m_file_pool, ts_ptr.p->m_free_files); Local_datafile_list free(m_file_pool, ts_ptr.p->m_free_files);
LocalDLList<Datafile> meta(m_file_pool, ts_ptr.p->m_meta_files); Local_datafile_list meta(m_file_pool, ts_ptr.p->m_meta_files);
meta.remove(ptr); meta.remove(ptr);
free.add(ptr); free.add(ptr);
} }
...@@ -1144,7 +1148,7 @@ Tsman::scan_tablespace(Signal* signal, Uint32 ptrI) ...@@ -1144,7 +1148,7 @@ Tsman::scan_tablespace(Signal* signal, Uint32 ptrI)
Ptr<Datafile> file_ptr; Ptr<Datafile> file_ptr;
{ {
LocalDLList<Datafile> meta(m_file_pool, lg_ptr.p->m_meta_files); Local_datafile_list meta(m_file_pool, lg_ptr.p->m_meta_files);
meta.first(file_ptr); meta.first(file_ptr);
} }
...@@ -1249,18 +1253,18 @@ Tsman::scan_extent_headers(Signal* signal, Ptr<Datafile> ptr) ...@@ -1249,18 +1253,18 @@ Tsman::scan_extent_headers(Signal* signal, Ptr<Datafile> ptr)
} }
ptr.p->m_online.m_first_free_extent= firstFree; ptr.p->m_online.m_first_free_extent= firstFree;
LocalDLList<Datafile> meta(m_file_pool, lg_ptr.p->m_meta_files); Local_datafile_list meta(m_file_pool, lg_ptr.p->m_meta_files);
Ptr<Datafile> next = ptr; Ptr<Datafile> next = ptr;
meta.next(next); meta.next(next);
if(firstFree != RNIL) if(firstFree != RNIL)
{ {
LocalDLList<Datafile> free(m_file_pool, lg_ptr.p->m_free_files); Local_datafile_list free(m_file_pool, lg_ptr.p->m_free_files);
meta.remove(ptr); meta.remove(ptr);
free.add(ptr); free.add(ptr);
} }
else else
{ {
LocalDLList<Datafile> full(m_file_pool, lg_ptr.p->m_full_files); Local_datafile_list full(m_file_pool, lg_ptr.p->m_full_files);
meta.remove(ptr); meta.remove(ptr);
full.add(ptr); full.add(ptr);
} }
...@@ -1299,13 +1303,13 @@ Tsman::execDROP_FILE_REQ(Signal* signal) ...@@ -1299,13 +1303,13 @@ Tsman::execDROP_FILE_REQ(Signal* signal)
if (find_file_by_id(file_ptr, fg_ptr.p->m_full_files, req.file_id)) if (find_file_by_id(file_ptr, fg_ptr.p->m_full_files, req.file_id))
{ {
jam(); jam();
LocalDLList<Datafile> full(m_file_pool, fg_ptr.p->m_full_files); Local_datafile_list full(m_file_pool, fg_ptr.p->m_full_files);
full.remove(file_ptr); full.remove(file_ptr);
} }
else if(find_file_by_id(file_ptr, fg_ptr.p->m_free_files, req.file_id)) else if(find_file_by_id(file_ptr, fg_ptr.p->m_free_files, req.file_id))
{ {
jam(); jam();
LocalDLList<Datafile> free(m_file_pool, fg_ptr.p->m_free_files); Local_datafile_list free(m_file_pool, fg_ptr.p->m_free_files);
free.remove(file_ptr); free.remove(file_ptr);
} }
else else
...@@ -1314,7 +1318,7 @@ Tsman::execDROP_FILE_REQ(Signal* signal) ...@@ -1314,7 +1318,7 @@ Tsman::execDROP_FILE_REQ(Signal* signal)
break; break;
} }
LocalDLList<Datafile> meta(m_file_pool, fg_ptr.p->m_meta_files); Local_datafile_list meta(m_file_pool, fg_ptr.p->m_meta_files);
meta.add(file_ptr); meta.add(file_ptr);
if (file_ptr.p->m_online.m_used_extent_cnt || if (file_ptr.p->m_online.m_used_extent_cnt ||
...@@ -1338,16 +1342,16 @@ Tsman::execDROP_FILE_REQ(Signal* signal) ...@@ -1338,16 +1342,16 @@ Tsman::execDROP_FILE_REQ(Signal* signal)
case DropFileImplReq::Abort:{ case DropFileImplReq::Abort:{
ndbrequire(find_file_by_id(file_ptr, fg_ptr.p->m_meta_files, req.file_id)); ndbrequire(find_file_by_id(file_ptr, fg_ptr.p->m_meta_files, req.file_id));
file_ptr.p->m_state = Datafile::FS_ONLINE; file_ptr.p->m_state = Datafile::FS_ONLINE;
LocalDLList<Datafile> meta(m_file_pool, fg_ptr.p->m_meta_files); Local_datafile_list meta(m_file_pool, fg_ptr.p->m_meta_files);
meta.remove(file_ptr); meta.remove(file_ptr);
if (file_ptr.p->m_online.m_first_free_extent != RNIL) if (file_ptr.p->m_online.m_first_free_extent != RNIL)
{ {
LocalDLList<Datafile> free(m_file_pool, fg_ptr.p->m_free_files); Local_datafile_list free(m_file_pool, fg_ptr.p->m_free_files);
free.add(file_ptr); free.add(file_ptr);
} }
else else
{ {
LocalDLList<Datafile> full(m_file_pool, fg_ptr.p->m_full_files); Local_datafile_list full(m_file_pool, fg_ptr.p->m_full_files);
full.add(file_ptr); full.add(file_ptr);
} }
break; break;
...@@ -1407,7 +1411,7 @@ Tsman::execALLOC_EXTENT_REQ(Signal* signal) ...@@ -1407,7 +1411,7 @@ Tsman::execALLOC_EXTENT_REQ(Signal* signal)
ndbrequire(m_tablespace_hash.find(ts_ptr, req.request.tablespace_id)); ndbrequire(m_tablespace_hash.find(ts_ptr, req.request.tablespace_id));
Uint32 size = ts_ptr.p->m_extent_size; Uint32 size = ts_ptr.p->m_extent_size;
LocalDLList<Datafile> tmp(m_file_pool, ts_ptr.p->m_free_files); Local_datafile_list tmp(m_file_pool, ts_ptr.p->m_free_files);
if (tmp.first(file_ptr)) if (tmp.first(file_ptr))
{ {
...@@ -1456,7 +1460,7 @@ Tsman::execALLOC_EXTENT_REQ(Signal* signal) ...@@ -1456,7 +1460,7 @@ Tsman::execALLOC_EXTENT_REQ(Signal* signal)
if (next_free == RNIL) if (next_free == RNIL)
{ {
jam(); jam();
LocalDLList<Datafile> full(m_file_pool, ts_ptr.p->m_full_files); Local_datafile_list full(m_file_pool, ts_ptr.p->m_full_files);
tmp.remove(file_ptr); tmp.remove(file_ptr);
full.add(file_ptr); full.add(file_ptr);
} }
...@@ -1988,7 +1992,7 @@ Tsman::end_lcp(Signal* signal, Uint32 ptrI, Uint32 list, Uint32 filePtrI) ...@@ -1988,7 +1992,7 @@ Tsman::end_lcp(Signal* signal, Uint32 ptrI, Uint32 list, Uint32 filePtrI)
switch(list){ switch(list){
case 0: case 0:
{ {
LocalDLList<Datafile> tmp(m_file_pool, ptr.p->m_free_files); Local_datafile_list tmp(m_file_pool, ptr.p->m_free_files);
if(file.i == RNIL) if(file.i == RNIL)
{ {
if(!tmp.first(file)) if(!tmp.first(file))
...@@ -2005,7 +2009,7 @@ Tsman::end_lcp(Signal* signal, Uint32 ptrI, Uint32 list, Uint32 filePtrI) ...@@ -2005,7 +2009,7 @@ Tsman::end_lcp(Signal* signal, Uint32 ptrI, Uint32 list, Uint32 filePtrI)
} }
case 1: case 1:
{ {
LocalDLList<Datafile> tmp(m_file_pool, ptr.p->m_full_files); Local_datafile_list tmp(m_file_pool, ptr.p->m_full_files);
if(file.i == RNIL) if(file.i == RNIL)
{ {
if(!tmp.first(file)) if(!tmp.first(file))
...@@ -2046,8 +2050,8 @@ Tsman::end_lcp(Signal* signal, Uint32 ptrI, Uint32 list, Uint32 filePtrI) ...@@ -2046,8 +2050,8 @@ Tsman::end_lcp(Signal* signal, Uint32 ptrI, Uint32 list, Uint32 filePtrI)
file.p->m_online.m_lcp_free_extent_head = RNIL; file.p->m_online.m_lcp_free_extent_head = RNIL;
file.p->m_online.m_lcp_free_extent_tail = RNIL; file.p->m_online.m_lcp_free_extent_tail = RNIL;
LocalDLList<Datafile> free(m_file_pool, ptr.p->m_free_files); Local_datafile_list free(m_file_pool, ptr.p->m_free_files);
LocalDLList<Datafile> full(m_file_pool, ptr.p->m_full_files); Local_datafile_list full(m_file_pool, ptr.p->m_full_files);
full.remove(file); full.remove(file);
free.add(file); free.add(file);
} }
...@@ -2151,7 +2155,7 @@ void Tsman::execGET_TABINFOREQ(Signal* signal) ...@@ -2151,7 +2155,7 @@ void Tsman::execGET_TABINFOREQ(Signal* signal)
return; return;
} }
DLHashTable<Datafile>::Iterator iter; Datafile_hash::Iterator iter;
ndbrequire(m_file_hash.first(iter)); ndbrequire(m_file_hash.first(iter));
while(iter.curr.p->m_file_id != tableId && m_file_hash.next(iter)) while(iter.curr.p->m_file_id != tableId && m_file_hash.next(iter))
......
...@@ -84,6 +84,7 @@ public: ...@@ -84,6 +84,7 @@ public:
* - Part of local key * - Part of local key
* - Set by pgman * - Set by pgman
*/ */
Uint32 m_magic;
Uint32 m_file_no; Uint32 m_file_no;
Uint32 m_file_id; // Used when talking to DICT Uint32 m_file_id; // Used when talking to DICT
Uint32 m_fd; // NDBFS Uint32 m_fd; // NDBFS
...@@ -136,12 +137,18 @@ public: ...@@ -136,12 +137,18 @@ public:
return m_file_no == rec.m_file_no; return m_file_no == rec.m_file_no;
} }
}; };
typedef RecordPool<Datafile, RWPool> Datafile_pool;
typedef DLListImpl<Datafile_pool, Datafile> Datafile_list;
typedef LocalDLListImpl<Datafile_pool, Datafile> Local_datafile_list;
typedef DLHashTableImpl<Datafile_pool, Datafile> Datafile_hash;
struct Tablespace struct Tablespace
{ {
Tablespace(){} Tablespace(){}
Tablespace(Tsman*, Lgman*, const struct CreateFilegroupImplReq*); Tablespace(Tsman*, Lgman*, const struct CreateFilegroupImplReq*);
Uint32 m_magic;
union { union {
Uint32 key; Uint32 key;
Uint32 m_tablespace_id; Uint32 m_tablespace_id;
...@@ -157,11 +164,11 @@ public: ...@@ -157,11 +164,11 @@ public:
}; };
Uint32 m_extent_size; // In pages Uint32 m_extent_size; // In pages
DLList<Datafile>::Head m_free_files; // Files w/ free space Datafile_list::Head m_free_files; // Files w/ free space
Logfile_client m_logfile_client; Logfile_client m_logfile_client;
DLList<Datafile>::Head m_full_files; // Files wo/ free space Datafile_list::Head m_full_files; // Files wo/ free space
DLList<Datafile>::Head m_meta_files; // Files being created/dropped Datafile_list::Head m_meta_files; // Files being created/dropped
Uint32 nextHash; Uint32 nextHash;
Uint32 prevHash; Uint32 prevHash;
...@@ -179,14 +186,19 @@ public: ...@@ -179,14 +186,19 @@ public:
} }
}; };
typedef RecordPool<Tablespace, RWPool> Tablespace_pool;
typedef DLListImpl<Tablespace_pool, Tablespace> Tablespace_list;
typedef LocalDLListImpl<Tablespace_pool, Tablespace> Local_tablespace_list;
typedef KeyTableImpl<Tablespace_pool, Tablespace> Tablespace_hash;
private: private:
friend class Tablespace_client; friend class Tablespace_client;
ArrayPool<Datafile> m_file_pool; Datafile_pool m_file_pool;
ArrayPool<Tablespace> m_tablespace_pool; Tablespace_pool m_tablespace_pool;
DLHashTable<Datafile> m_file_hash; Datafile_hash m_file_hash;
DLList<Tablespace> m_tablespace_list; Tablespace_list m_tablespace_list;
KeyTable<Tablespace> m_tablespace_hash; Tablespace_hash m_tablespace_hash;
Page_cache_client m_page_cache_client; Page_cache_client m_page_cache_client;
Lgman * const m_lgman; Lgman * const m_lgman;
...@@ -209,7 +221,7 @@ private: ...@@ -209,7 +221,7 @@ private:
void scan_datafile(Signal*, Uint32, Uint32); void scan_datafile(Signal*, Uint32, Uint32);
void scan_extent_headers(Signal*, Ptr<Datafile>); void scan_extent_headers(Signal*, Ptr<Datafile>);
bool find_file_by_id(Ptr<Datafile>&, DLList<Datafile>::Head&, Uint32 id); bool find_file_by_id(Ptr<Datafile>&, Datafile_list::Head&, Uint32 id);
void create_file_abort(Signal* signal, Ptr<Datafile>); void create_file_abort(Signal* signal, Ptr<Datafile>);
void release_extent_pages(Signal* signal, Ptr<Datafile> ptr); void release_extent_pages(Signal* signal, Ptr<Datafile> ptr);
......
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