From: Jonas Oreland Date: February 2 2012 11:04am Subject: bzr push into mysql-5.1-telco-7.0 branch (jonas.oreland:4844 to 4845) List-Archive: http://lists.mysql.com/commits/142928 Message-Id: <20120217084013.317C855C2B9@perch.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4845 Jonas Oreland 2012-02-02 ndb - 1) use NDB_ARRAY_SIZE to avoid repeating size of array 2) Set correct size of array which is dependant on NDBMT_BLOCK_INSTANCE_BITS. Not the actual max-block-instances in a particular version (for upgradability) modified: storage/ndb/include/kernel/ndb_limits.h storage/ndb/src/kernel/vm/SimulatedBlock.hpp storage/ndb/src/kernel/vm/mt.cpp 4844 jonas oreland 2012-02-01 ndb - fix overlapping memcpy causing error with new glibc (that performs memcpy backwards) modified: storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp === modified file 'storage/ndb/include/kernel/ndb_limits.h' --- a/storage/ndb/include/kernel/ndb_limits.h 2012-01-30 14:53:29 +0000 +++ b/storage/ndb/include/kernel/ndb_limits.h 2012-02-02 11:01:13 +0000 @@ -199,6 +199,7 @@ #define NDBMT_BLOCK_BITS 9 #define NDBMT_BLOCK_MASK ((1 << NDBMT_BLOCK_BITS) - 1) #define NDBMT_BLOCK_INSTANCE_BITS 7 +#define NDBMT_MAX_BLOCK_INSTANCES (1 << NDBMT_BLOCK_INSTANCE_BITS) #define NDB_DEFAULT_LOG_PARTS 4 === modified file 'storage/ndb/src/kernel/vm/SimulatedBlock.hpp' --- a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp 2012-01-04 11:13:53 +0000 +++ b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp 2012-02-02 11:01:13 +0000 @@ -635,10 +635,7 @@ private: * are real LQHs run by multiple threads. */ protected: - enum { MaxInstances = 3 + - MAX_NDBMT_TC_THREADS + - MAX_NDBMT_LQH_WORKERS + - MAX_NDBMT_RECEIVE_THREADS }; + enum { MaxInstances = NDBMT_MAX_BLOCK_INSTANCES }; private: SimulatedBlock** theInstanceList; // set in main, indexed by instance SimulatedBlock* theMainInstance; // set in all === modified file 'storage/ndb/src/kernel/vm/mt.cpp' --- a/storage/ndb/src/kernel/vm/mt.cpp 2012-01-31 16:36:20 +0000 +++ b/storage/ndb/src/kernel/vm/mt.cpp 2012-02-02 11:01:13 +0000 @@ -84,7 +84,6 @@ static const Uint32 MAX_SIGNALS_BEFORE_W MAX_NDBMT_LQH_THREADS + \ MAX_NDBMT_TC_THREADS + \ MAX_NDBMT_RECEIVE_THREADS) -#define MAX_BLOCK_INSTANCES (MAX_BLOCK_THREADS+1) /* If this is too small it crashes before first signal. */ #define MAX_INSTANCES_PER_THREAD (16 + 8 * MAX_NDBMT_LQH_THREADS) @@ -3242,14 +3241,14 @@ struct thr_map_entry { thr_map_entry() : thr_no(NULL_THR_NO) {} }; -static struct thr_map_entry thr_map[NO_OF_BLOCKS][MAX_BLOCK_INSTANCES]; +static struct thr_map_entry thr_map[NO_OF_BLOCKS][NDBMT_MAX_BLOCK_INSTANCES]; static inline Uint32 block2ThreadId(Uint32 block, Uint32 instance) { assert(block >= MIN_BLOCK_NO && block <= MAX_BLOCK_NO); Uint32 index = block - MIN_BLOCK_NO; - assert(instance < MAX_BLOCK_INSTANCES); + assert(instance < NDB_ARRAY_SIZE(thr_map[index])); const thr_map_entry& entry = thr_map[index][instance]; assert(entry.thr_no < num_threads); return entry.thr_no; @@ -3261,7 +3260,7 @@ add_thr_map(Uint32 main, Uint32 instance assert(main == blockToMain(main)); Uint32 index = main - MIN_BLOCK_NO; assert(index < NO_OF_BLOCKS); - assert(instance < MAX_BLOCK_INSTANCES); + assert(instance < NDB_ARRAY_SIZE(thr_map[index])); SimulatedBlock* b = globalData.getBlock(main, instance); require(b != 0); @@ -3419,14 +3418,14 @@ mt_finalize_thr_map() { Uint32 bno = b + MIN_BLOCK_NO; Uint32 cnt = 0; - while (cnt < MAX_BLOCK_INSTANCES && + while (cnt < NDB_ARRAY_SIZE(thr_map[b]) && thr_map[b][cnt].thr_no != thr_map_entry::NULL_THR_NO) cnt++; - if (cnt != MAX_BLOCK_INSTANCES) + if (cnt != NDB_ARRAY_SIZE(thr_map[b])) { SimulatedBlock * main = globalData.getBlock(bno, 0); - for (Uint32 i = cnt; i < MAX_BLOCK_INSTANCES; i++) + for (Uint32 i = cnt; i < NDB_ARRAY_SIZE(thr_map[b]); i++) { Uint32 dup = (cnt == 1) ? 0 : 1 + ((i - 1) % (cnt - 1)); if (thr_map[b][i].thr_no == thr_map_entry::NULL_THR_NO) @@ -4937,7 +4936,7 @@ mt_get_thread_references_for_blocks(cons */ assert(block == blockToMain(block)); Uint32 index = block - MIN_BLOCK_NO; - for (Uint32 instance = 0; instance < MAX_BLOCK_INSTANCES; instance++) + for (Uint32 instance = 0; instance < NDB_ARRAY_SIZE(thr_map[instance]); instance++) { Uint32 thr_no = thr_map[index][instance].thr_no; if (thr_no == thr_map_entry::NULL_THR_NO) No bundle (reason: useless for push emails).