#At file:///home/jonas/src/telco-7.1/ based on revid:craig.russell@stripped
4198 Jonas Oreland 2011-05-17 [merge]
ndb - merge 70 to 71
added:
storage/ndb/src/kernel/vm/NdbSeqLock.hpp
modified:
storage/ndb/ndb_configure.m4
storage/ndb/src/common/portlib/NdbMutex.c
storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp
storage/ndb/src/kernel/vm/SimulatedBlock.cpp
storage/ndb/src/kernel/vm/SimulatedBlock.hpp
storage/ndb/src/kernel/vm/mt-asm.h
storage/ndb/src/kernel/vm/mt.cpp
storage/ndb/src/kernel/vm/mt.hpp
storage/ndb/src/ndbapi/Ndb.cpp
=== modified file 'storage/ndb/ndb_configure.m4'
--- a/storage/ndb/ndb_configure.m4 2011-04-28 23:14:15 +0000
+++ b/storage/ndb/ndb_configure.m4 2011-05-17 08:40:55 +0000
@@ -84,6 +84,9 @@ AC_DEFUN([NDB_CHECK_NDBMTD], [
AC_TRY_RUN(
[
#include "storage/ndb/src/kernel/vm/mt-asm.h"
+ #ifdef NDB_NO_ASM
+ #error "compiler/arch does not have asm needed for ndbmtd"
+ #endif
int main()
{
unsigned int a = 0;
=== modified file 'storage/ndb/src/common/portlib/NdbMutex.c'
--- a/storage/ndb/src/common/portlib/NdbMutex.c 2011-02-03 14:45:49 +0000
+++ b/storage/ndb/src/common/portlib/NdbMutex.c 2011-05-17 08:40:55 +0000
@@ -88,12 +88,14 @@ int NdbMutex_InitWithName(NdbMutex* pNdb
defined(HAVE_PTHREAD_MUTEXATTR_INIT) && \
defined(HAVE_PTHREAD_MUTEXATTR_SETTYPE)
- pthread_mutexattr_t t;
- pthread_mutexattr_init(&t);
- pthread_mutexattr_settype(&t, PTHREAD_MUTEX_ERRORCHECK);
- result = pthread_mutex_init(p, &t);
- assert(result == 0);
- pthread_mutexattr_destroy(&t);
+ {
+ pthread_mutexattr_t t;
+ pthread_mutexattr_init(&t);
+ pthread_mutexattr_settype(&t, PTHREAD_MUTEX_ERRORCHECK);
+ result = pthread_mutex_init(p, &t);
+ assert(result == 0);
+ pthread_mutexattr_destroy(&t);
+ }
#else
result = pthread_mutex_init(p, 0);
#endif
=== modified file 'storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp 2011-04-21 09:21:18 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp 2011-05-17 07:06:30 +0000
@@ -28,6 +28,7 @@
#include <signaldata/CopyGCIReq.hpp>
#include <blocks/mutexes.hpp>
#include <signaldata/LCP.hpp>
+#include <NdbSeqLock.hpp>
#ifdef DBDIH_C
@@ -441,7 +442,15 @@ public:
* TO LOCATE A FRAGMENT AND TO TRANSLATE A KEY OF A TUPLE TO THE FRAGMENT IT
* BELONGS
*/
- struct TabRecord {
+ struct TabRecord
+ {
+ /**
+ * rw-lock that protects multiple parallel DIGETNODES (readers) from
+ * updates to fragmenation changes (e.g CREATE_FRAGREQ)...
+ * search for DIH_TAB_WRITE_LOCK
+ */
+ NdbSeqLock m_lock;
+
/**
* State for copying table description into pages
*/
=== added file 'storage/ndb/src/kernel/vm/NdbSeqLock.hpp'
--- a/storage/ndb/src/kernel/vm/NdbSeqLock.hpp 1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/kernel/vm/NdbSeqLock.hpp 2011-05-17 07:06:30 +0000
@@ -0,0 +1,95 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef NDB_SEQLOCK_HPP
+#define NDB_SEQLOCK_HPP
+
+#include <ndb_types.h>
+#include "mt-asm.h"
+
+#if defined (NDB_HAVE_RMB) && defined(NDB_HAVE_WMB)
+struct NdbSeqLock
+{
+ NdbSeqLock() { m_seq = 0;}
+ volatile Uint32 m_seq;
+
+ void write_lock();
+ void write_unlock();
+
+ Uint32 read_lock();
+ bool read_unlock(Uint32 val) const;
+};
+
+inline
+void
+NdbSeqLock::write_lock()
+{
+ assert((m_seq & 1) == 0);
+ m_seq++;
+ wmb();
+}
+
+inline
+void
+NdbSeqLock::write_unlock()
+{
+ assert((m_seq & 1) == 1);
+ wmb();
+ m_seq++;
+}
+
+inline
+Uint32
+NdbSeqLock::read_lock()
+{
+loop:
+ Uint32 val = m_seq;
+ rmb();
+ if (unlikely(val & 1))
+ {
+#ifdef NDB_HAVE_CPU_PAUSE
+ cpu_pause();
+#endif
+ goto loop;
+ }
+ return val;
+}
+
+inline
+bool
+NdbSeqLock::read_unlock(Uint32 val) const
+{
+ rmb();
+ return val == m_seq;
+}
+#else /** ! rmb() or wmb() */
+/**
+ * Only for ndbd...
+ */
+
+struct NdbSeqLock
+{
+ NdbSeqLock() { }
+
+ void write_lock() {}
+ void write_unlock() {}
+
+ Uint32 read_lock() {}
+ bool read_unlock(Uint32 val) const { return true;}
+};
+
+#endif
+
+#endif
=== modified file 'storage/ndb/src/kernel/vm/SimulatedBlock.cpp'
--- a/storage/ndb/src/kernel/vm/SimulatedBlock.cpp 2011-02-01 23:27:25 +0000
+++ b/storage/ndb/src/kernel/vm/SimulatedBlock.cpp 2011-05-16 12:24:55 +0000
@@ -4397,3 +4397,13 @@ SimulatedBlock::ndbinfo_send_scan_conf(S
signal_length, JBB);
}
+#ifdef VM_TRACE
+void
+SimulatedBlock::assertOwnThread()
+{
+#ifdef NDBD_MULTITHREADED
+ mt_assert_own_thread(this);
+#endif
+}
+
+#endif
=== modified file 'storage/ndb/src/kernel/vm/SimulatedBlock.hpp'
--- a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp 2011-01-30 20:56:00 +0000
+++ b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp 2011-05-16 12:24:55 +0000
@@ -188,6 +188,15 @@ public:
static bool isNdbMtLqh() { return globalData.isNdbMtLqh; }
static Uint32 getLqhWorkers() { return globalData.ndbMtLqhWorkers; }
+ /**
+ * Assert that thread calling this function is "owner" of block instance
+ */
+#ifdef VM_TRACE
+ void assertOwnThread();
+#else
+ void assertOwnThread(){ }
+#endif
+
/*
* Instance key (1-4) is used only when sending a signal. Receiver
* maps it to actual instance (0, if receiver is not MT LQH).
=== modified file 'storage/ndb/src/kernel/vm/mt-asm.h'
--- a/storage/ndb/src/kernel/vm/mt-asm.h 2011-02-02 00:40:07 +0000
+++ b/storage/ndb/src/kernel/vm/mt-asm.h 2011-05-16 11:44:52 +0000
@@ -25,22 +25,31 @@
* GCC
*******************/
#if defined(__x86_64__) || defined (__i386__)
+
+#define NDB_HAVE_MB
+#define NDB_HAVE_RMB
+#define NDB_HAVE_WMB
+#define NDB_HAVE_READ_BARRIER_DEPENDS
+#define NDB_HAVE_XCNG
+#define NDB_HAVE_CPU_PAUSE
+
/* Memory barriers, these definitions are for x64_64. */
#define mb() asm volatile("mfence":::"memory")
/* According to Intel docs, it does not reorder loads. */
-/* #define rmb() asm volatile("lfence":::"memory") */
+/* #define rmb() asm volatile("lfence":::"memory") */
#define rmb() asm volatile("" ::: "memory")
#define wmb() asm volatile("" ::: "memory")
#define read_barrier_depends() do {} while(0)
-#define NDB_HAVE_XCNG
-static inline
+static
+inline
int
xcng(volatile unsigned * addr, int val)
{
asm volatile ("xchg %0, %1;" : "+r" (val) , "+m" (*addr));
return val;
}
+
static
inline
void
@@ -50,6 +59,12 @@ cpu_pause()
}
#elif defined(__sparc__)
+
+#define NDB_HAVE_MB
+#define NDB_HAVE_RMB
+#define NDB_HAVE_WMB
+#define NDB_HAVE_READ_BARRIER_DEPENDS
+
#define mb() asm volatile("membar #LoadLoad | #LoadStore | #StoreLoad | #StoreStore":::"memory")
#define rmb() asm volatile("membar #LoadLoad" ::: "memory")
#define wmb() asm volatile("membar #StoreStore" ::: "memory")
@@ -71,6 +86,7 @@ xcng(volatile unsigned * addr, int val)
}
#define cpu_pause()
#define NDB_HAVE_XCNG
+#define NDB_HAVE_CPU_PAUSE
#else
/* link error if used incorrectly (i.e wo/ having NDB_HAVE_XCNG) */
extern int xcng(volatile unsigned * addr, int val);
@@ -78,7 +94,7 @@ extern void cpu_pause();
#endif
#else
-#error "Unsupported architecture (gcc)"
+#define NDB_NO_ASM "Unsupported architecture (gcc)"
#endif
#elif defined(__sun)
@@ -91,20 +107,32 @@ extern void cpu_pause();
* i.e that it clobbers memory
*/
#if defined(__x86_64__)
+#define NDB_HAVE_MB
+#define NDB_HAVE_RMB
+#define NDB_HAVE_WMB
+#define NDB_HAVE_READ_BARRIER_DEPENDS
+
#define mb() asm ("mfence")
/* According to Intel docs, it does not reorder loads. */
/* #define rmb() asm ("lfence") */
#define rmb() asm ("")
#define wmb() asm ("")
#define read_barrier_depends() do {} while(0)
+
#elif defined(__sparc)
+#define NDB_HAVE_MB
+#define NDB_HAVE_RMB
+#define NDB_HAVE_WMB
+#define NDB_HAVE_READ_BARRIER_DEPENDS
+
#define mb() asm ("membar #LoadLoad | #LoadStore | #StoreLoad | #StoreStore")
#define rmb() asm ("membar #LoadLoad")
#define wmb() asm ("membar #StoreStore")
#define read_barrier_depends() do {} while(0)
#else
-#error "Unsupported architecture (sun studio)"
+#define NDB_NO_ASM "Unsupported architecture (sun studio)"
#endif
+
#if defined(__x86_64__) || defined(__sparc)
/**
* we should probably use assembler for x86 aswell...
@@ -116,6 +144,7 @@ extern void cpu_pause();
#ifdef HAVE_ATOMIC_SWAP_32
#define NDB_HAVE_XCNG
+#define NDB_HAVE_CPU_PAUSE
#if defined(__sparc)
static inline
int
@@ -154,6 +183,12 @@ extern void cpu_pause();
#endif
#endif
#elif defined (_MSC_VER)
+
+#define NDB_HAVE_MB
+#define NDB_HAVE_RMB
+#define NDB_HAVE_WMB
+#define NDB_HAVE_READ_BARRIER_DEPENDS
+
#include <windows.h>
#define mb() MemoryBarrier()
#define read_barrier_depends() do {} while(0)
@@ -171,6 +206,8 @@ extern void cpu_pause();
#endif
#define NDB_HAVE_XCNG
+#define NDB_HAVE_CPU_PAUSE
+
static inline
int
xcng(volatile unsigned * addr, int val)
@@ -186,7 +223,7 @@ cpu_pause()
YieldProcessor();
}
#else
-#error "Unsupported compiler"
+#define NDB_NO_ASM "Unsupported compiler"
#endif
#endif
=== modified file 'storage/ndb/src/kernel/vm/mt.cpp'
--- a/storage/ndb/src/kernel/vm/mt.cpp 2011-04-21 05:55:36 +0000
+++ b/storage/ndb/src/kernel/vm/mt.cpp 2011-05-17 08:40:55 +0000
@@ -4170,6 +4170,22 @@ mt_wakeup(class SimulatedBlock* block)
wakeup(&thrptr->m_waiter);
}
+#ifdef VM_TRACE
+void
+mt_assert_own_thread(SimulatedBlock* block)
+{
+ Uint32 thr_no = block->getThreadId();
+ thr_data *thrptr = g_thr_repository.m_thread + thr_no;
+
+ if (unlikely(pthread_equal(thrptr->m_thr_id, pthread_self()) == 0))
+ {
+ fprintf(stderr, "mt_assert_own_thread() - assertion-failure\n");
+ fflush(stderr);
+ abort();
+ }
+}
+#endif
+
/**
* Global data
*/
=== modified file 'storage/ndb/src/kernel/vm/mt.hpp'
--- a/storage/ndb/src/kernel/vm/mt.hpp 2011-02-02 00:40:07 +0000
+++ b/storage/ndb/src/kernel/vm/mt.hpp 2011-05-16 12:24:55 +0000
@@ -74,4 +74,11 @@ Uint32 mt_get_thread_references_for_bloc
*/
void mt_wakeup(class SimulatedBlock*);
+#ifdef VM_TRACE
+/**
+ * Assert that thread calling this function is "owner" of block instance
+ */
+void mt_assert_own_thread(class SimulatedBlock*);
+#endif
+
#endif
=== modified file 'storage/ndb/src/ndbapi/Ndb.cpp'
--- a/storage/ndb/src/ndbapi/Ndb.cpp 2011-04-27 10:48:16 +0000
+++ b/storage/ndb/src/ndbapi/Ndb.cpp 2011-05-17 07:23:31 +0000
@@ -201,6 +201,7 @@ Ndb::NDB_connect(Uint32 tNode, Uint32 in
tSignal->setData(theMyRef, 2); // Set my block reference
tSignal->setData(instance, 3); // Set requested instance
tNdbCon->Status(NdbTransaction::Connecting); // Set status to connecting
+ tNdbCon->theDBnode = tNode;
Uint32 nodeSequence;
tReturnCode= sendRecSignal(tNode, WAIT_TC_SEIZE, tSignal,
0, &nodeSequence);
No bundle (reason: revision is a merge).
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.1 branch (jonas:4198) | Jonas Oreland | 19 May |