List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:November 4 2010 3:09pm
Subject:bzr commit into mysql-5.1-telco-7.1 branch (jonas:3952)
View as plain text  
#At file:///home/jonas/src/telco-7.1/ based on revid:jonas@stripped

 3952 Jonas Oreland	2010-11-04 [merge]
      ndb - merge 70 to 71

    added:
      storage/ndb/src/ndbapi/trp_buffer.cpp
      storage/ndb/src/ndbapi/trp_buffer.hpp
    modified:
      storage/ndb/include/transporter/TransporterDefinitions.hpp
      storage/ndb/src/common/debugger/SignalLoggerManager.cpp
      storage/ndb/src/common/transporter/Packer.cpp
      storage/ndb/src/ndbapi/CMakeLists.txt
      storage/ndb/src/ndbapi/Makefile.am
      storage/ndb/src/ndbapi/NdbOperationExec.cpp
      storage/ndb/src/ndbapi/TransporterFacade.cpp
      storage/ndb/src/ndbapi/TransporterFacade.hpp
=== modified file 'storage/ndb/include/transporter/TransporterDefinitions.hpp'
--- a/storage/ndb/include/transporter/TransporterDefinitions.hpp	2010-11-04 07:12:01 +0000
+++ b/storage/ndb/include/transporter/TransporterDefinitions.hpp	2010-11-04 14:57:04 +0000
@@ -177,7 +177,7 @@ SegmentedSectionPtrPOD::assign(struct Se
 struct GenericSectionIterator {
   virtual ~GenericSectionIterator() {};
   virtual void reset()=0;
-  virtual Uint32* getNextWords(Uint32& sz)=0;
+  virtual const Uint32* getNextWords(Uint32& sz)=0;
 };
 
 struct GenericSectionPtr {

=== modified file 'storage/ndb/src/common/debugger/SignalLoggerManager.cpp'
--- a/storage/ndb/src/common/debugger/SignalLoggerManager.cpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/src/common/debugger/SignalLoggerManager.cpp	2010-11-04 14:57:04 +0000
@@ -641,7 +641,7 @@ SignalLoggerManager::printGenericSection
   Uint32 chunksz = 0;
   fprintf(output, " size=%u\n", (unsigned)len);
   while (pos < len) {
-    Uint32* data= ptr[i].sectionIter->getNextWords(chunksz);
+    const Uint32* data= ptr[i].sectionIter->getNextWords(chunksz);
     Uint32 i=0;
     while (i < chunksz)
       printDataWord(output, pos, data[i++]);

=== modified file 'storage/ndb/src/common/transporter/Packer.cpp'
--- a/storage/ndb/src/common/transporter/Packer.cpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/src/common/transporter/Packer.cpp	2010-11-04 14:57:04 +0000
@@ -410,7 +410,7 @@ importGeneric(Uint32 * & insertPtr, Gene
   while (remain > 0)
   {
     Uint32 len= 0;
-    Uint32* next= ptr.sectionIter->getNextWords(len);
+    const Uint32* next= ptr.sectionIter->getNextWords(len);
 
     assert(len <= remain);
     assert(next != NULL);

=== modified file 'storage/ndb/src/ndbapi/CMakeLists.txt'
--- a/storage/ndb/src/ndbapi/CMakeLists.txt	2010-10-13 06:15:20 +0000
+++ b/storage/ndb/src/ndbapi/CMakeLists.txt	2010-11-04 14:59:07 +0000
@@ -59,4 +59,5 @@ ADD_LIBRARY(ndbapi STATIC
             NdbInfoScanOperation.cpp
             ndb_internal.cpp
 	    trp_client.cpp
-            trp_node.cpp)
+            trp_node.cpp
+	    trp_buffer.cpp)

=== modified file 'storage/ndb/src/ndbapi/Makefile.am'
--- a/storage/ndb/src/ndbapi/Makefile.am	2010-10-13 06:15:20 +0000
+++ b/storage/ndb/src/ndbapi/Makefile.am	2010-11-04 14:59:07 +0000
@@ -63,7 +63,8 @@ libndbapi_la_SOURCES = \
 	NdbInfoScanOperation.cpp \
         ndb_internal.cpp \
 	trp_client.cpp \
-        trp_node.cpp
+        trp_node.cpp \
+	trp_buffer.cpp
 
 INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/mgmapi
 

=== modified file 'storage/ndb/src/ndbapi/NdbOperationExec.cpp'
--- a/storage/ndb/src/ndbapi/NdbOperationExec.cpp	2010-09-30 09:32:28 +0000
+++ b/storage/ndb/src/ndbapi/NdbOperationExec.cpp	2010-11-04 15:02:25 +0000
@@ -87,7 +87,7 @@ public :
     currentPos= firstDataPtr;
   }
 
-  Uint32* getNextWords(Uint32& sz)
+  const Uint32* getNextWords(Uint32& sz)
   {
     /* In first TCKEY/INDXREQ, data is at offset depending
      * on whether it's KEYINFO or ATTRINFO

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.cpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.cpp	2010-10-12 12:02:53 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp	2010-11-04 14:57:04 +0000
@@ -945,7 +945,7 @@ private :
   Uint32 rangeStart;                    /* Sub range start in underlying */
   Uint32 rangeLen;                      /* Sub range len in underlying */
   Uint32 rangeRemain;                   /* Remaining words in underlying */
-  Uint32* lastReadPtr;                  /* Ptr to last chunk obtained from
+  const Uint32* lastReadPtr;            /* Ptr to last chunk obtained from
                                          * underlying */
   Uint32 lastReadPtrLen;                /* Remaining words in last chunk
                                          * obtained from underlying */
@@ -1078,10 +1078,10 @@ public:
    * (GenericSectionIterator)
    * Get ptr and size of next contiguous words in subrange
    */
-  Uint32* getNextWords(Uint32& sz)
+  const Uint32* getNextWords(Uint32& sz)
   {
     assert(checkInvariants());
-    Uint32* currPtr= NULL;
+    const Uint32* currPtr= NULL;
 
     if (rangeRemain)
     {
@@ -1759,7 +1759,7 @@ SignalSender::sendSignal(Uint16 nodeId, 
   return ss;
 }
 
-Uint32*
+const Uint32*
 SignalSectionIterator::getNextWords(Uint32& sz)
 {
   if (likely(currentSignal != NULL))
@@ -1788,7 +1788,7 @@ verifyIteratorContents(GenericSectionIte
 
   while (pos < dataWords)
   {
-    Uint32* readPtr=NULL;
+    const Uint32* readPtr=NULL;
     Uint32 len= 0;
 
     readPtr= gsi.getNextWords(len);

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.hpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.hpp	2010-10-13 06:15:20 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp	2010-11-04 14:57:04 +0000
@@ -439,7 +439,7 @@ public :
     read= false;
   }
 
-  Uint32* getNextWords(Uint32& sz)
+  const Uint32* getNextWords(Uint32& sz)
   {
     if (likely(!read))
     {
@@ -483,7 +483,7 @@ public :
     currentSignal= firstSignal;
   }
 
-  Uint32* getNextWords(Uint32& sz);
+  const Uint32* getNextWords(Uint32& sz);
 };
 
 /*

=== added file 'storage/ndb/src/ndbapi/trp_buffer.cpp'
--- a/storage/ndb/src/ndbapi/trp_buffer.cpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/ndbapi/trp_buffer.cpp	2010-11-04 14:59:07 +0000
@@ -0,0 +1,88 @@
+/*
+   Copyright (c) 2010, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#include "trp_buffer.hpp"
+
+TFPool::TFPool()
+{
+  m_first_free = 0;
+  m_alloc_ptr = 0;
+}
+
+bool
+TFPool::init(Uint64 mem)
+{
+  unsigned char * ptr = (m_alloc_ptr = (unsigned char*)malloc(mem));
+  for (Uint64 i = 0; i + 32768 < mem; i += 32768)
+  {
+    TFPage * p = (TFPage*)(ptr + i);
+    p->m_size = 32768 - offsetof(TFPage, m_data);
+    p->init();
+    p->m_next = m_first_free;
+    m_first_free = p;
+  }
+  return true;
+}
+
+TFPool::~TFPool()
+{
+  if (m_alloc_ptr)
+    free (m_alloc_ptr);
+}
+
+void
+TFBuffer::validate() const
+{
+  if (m_bytes_in_buffer == 0)
+  {
+    assert(m_head == m_tail);
+    if (m_head)
+    {
+      assert(m_head->m_bytes < m_head->m_size);  // Full pages should be release
+      assert(m_head->m_bytes == m_head->m_start);
+    }
+    return;
+  }
+  else
+  {
+    assert(m_head != 0);
+    assert(m_tail != 0);
+  }
+  Uint32 sum = 0;
+  TFPage * p = m_head;
+  while (p)
+  {
+    assert(p->m_bytes <= p->m_size);
+    assert(p->m_start <= p->m_bytes);
+    assert((p->m_start & 3) == 0);
+    assert(p->m_bytes - p->m_start > 0);
+    assert(p->m_bytes - p->m_start <= (int)m_bytes_in_buffer);
+    assert(p->m_next != p);
+    if (p == m_tail)
+    {
+      assert(p->m_next == 0);
+    }
+    else
+    {
+      assert(p->m_next != 0);
+    }
+    sum += p->m_bytes - p->m_start;
+    p = p->m_next;
+  }
+  assert(sum == m_bytes_in_buffer);
+}
+

=== added file 'storage/ndb/src/ndbapi/trp_buffer.hpp'
--- a/storage/ndb/src/ndbapi/trp_buffer.hpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/ndbapi/trp_buffer.hpp	2010-11-04 14:59:07 +0000
@@ -0,0 +1,197 @@
+/*
+   Copyright (c) 2010, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#ifndef trp_buffer_hpp
+#define trp_buffer_hpp
+
+#include <ndb_global.h>
+
+struct TFPage
+{
+  inline Uint32 max_data_bytes() const {
+    return m_size;
+  }
+
+  inline Uint32 get_free_bytes() const {
+    return m_size - m_bytes;
+  }
+
+  inline bool is_full() const {
+    return m_bytes == m_size;
+  }
+
+  inline void init () {
+    m_bytes = 0;
+    m_start = 0;
+    m_ref_count = 0;
+  }
+
+  static TFPage* ptr(struct iovec p) {
+    UintPtr v = UintPtr(p.iov_base);
+    v -= offsetof(TFPage, m_data);
+    return (TFPage*)v;
+  }
+
+
+  /**
+   * Bytes on page
+   */
+  Uint16 m_bytes;
+
+  /**
+   * Start of unused data
+   */
+  Uint16 m_start;
+
+  /**
+   * size of page
+   */
+  Uint16 m_size;
+
+  /**
+   * ref-count
+   */
+  Uint16 m_ref_count;
+
+  /**
+   * Pointer to next page
+   */
+  struct TFPage * m_next;
+
+  /**
+   * The data...
+   */
+  char m_data[8];
+};
+
+/**
+ * TFSentinel is used to link pages wo/ having to care about
+ *   first page being null
+ */
+struct TFSentinel
+{
+  Uint64 data[sizeof(TFPage) / 8];
+
+  TFSentinel() {
+    for (Uint32 i = 0; i < NDB_ARRAY_SIZE(data); i++)
+      data[i] = 0;
+  }
+
+  TFPage* getPtr() { return new (&data[0]) TFPage;}
+};
+
+struct TFBuffer
+{
+  TFBuffer() { m_bytes_in_buffer = 0; m_head = m_tail = 0;}
+  Uint32 m_bytes_in_buffer;
+  struct TFPage * m_head;
+  struct TFPage * m_tail;
+
+  void validate() const;
+};
+
+struct TFBufferGuard
+{
+#ifdef VM_TRACE
+  const TFBuffer& buf;
+  TFBuffer m_save;
+  TFBufferGuard(const TFBuffer& _buf) : buf(_buf), m_save(_buf) {
+    buf.validate();
+  }
+  ~TFBufferGuard() {
+    buf.validate();
+  }
+#else
+  TFBufferGuard(const TFBuffer&) {}
+#endif
+};
+
+class TFPool
+{
+  unsigned char * m_alloc_ptr;
+  TFPage * m_first_free;
+public:
+  TFPool();
+  ~TFPool();
+
+  bool init(Uint64 total_memory);
+
+  TFPage* try_alloc(Uint32 N); // Return linked list of most N pages
+  Uint32 try_alloc(struct iovec tmp[], Uint32 cnt);
+
+  void release(TFPage* first, TFPage* last);
+  void release_list(TFPage*);
+};
+
+inline
+TFPage *
+TFPool::try_alloc(Uint32 n)
+{
+  TFPage * h = m_first_free;
+  if (h)
+  {
+    TFPage * p = h;
+    TFPage * prev = 0;
+    while (p != 0 && n != 0)
+    {
+      prev = p;
+      p = p->m_next;
+      n--;
+    }
+    prev->m_next = 0;
+    m_first_free = p;
+  }
+  return h;
+}
+
+inline
+Uint32
+TFPool::try_alloc(struct iovec tmp[], Uint32 cnt)
+{
+  TFPage * p = try_alloc(cnt);
+  Uint32 i = 0;
+  while (p)
+  {
+    p->init();
+    tmp[i].iov_base = p->m_data;
+    tmp[i].iov_len = p->m_size;
+
+    i++;
+    p = p->m_next;
+  }
+  return i;
+}
+
+inline
+void
+TFPool::release(TFPage* first, TFPage* last)
+{
+  last->m_next = m_first_free;
+  m_first_free = first;
+}
+
+inline
+void
+TFPool::release_list(TFPage* head)
+{
+  TFPage * tail = head;
+  while (tail->m_next != 0)
+    tail = tail->m_next;
+  release(head, tail);
+}
+
+#endif

No bundle (reason: revision is a merge).
Thread
bzr commit into mysql-5.1-telco-7.1 branch (jonas:3952) Jonas Oreland4 Nov