]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: use Mutex instead of Spinlock for raw crcs 1696/head
authorSage Weil <sage@inktank.com>
Mon, 14 Apr 2014 15:56:18 +0000 (08:56 -0700)
committerSage Weil <sage@inktank.com>
Mon, 14 Apr 2014 15:56:18 +0000 (08:56 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/common/buffer.cc

index 71f665de80b0a78b8c0dbac184c2113385626f0f..e7212f24a62afe324721cc83fe7ebf587c7f4fa6 100644 (file)
@@ -22,7 +22,7 @@
 #include "include/atomic.h"
 #include "include/types.h"
 #include "include/compat.h"
-#include "include/Spinlock.h"
+#include "common/Mutex.h"
 
 #include <errno.h>
 #include <fstream>
@@ -123,12 +123,16 @@ static uint32_t simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZE
     unsigned len;
     atomic_t nref;
 
-    Spinlock crc_lock;
+    mutable Mutex crc_lock;
     map<pair<size_t, size_t>, pair<uint32_t, uint32_t> > crc_map;
 
-    raw(unsigned l) : data(NULL), len(l), nref(0)
+    raw(unsigned l)
+      : data(NULL), len(l), nref(0),
+       crc_lock("buffer::raw::crc_lock", false, false)
     { }
-    raw(char *c, unsigned l) : data(c), len(l), nref(0)
+    raw(char *c, unsigned l)
+      : data(c), len(l), nref(0),
+       crc_lock("buffer::raw::crc_lock", false, false)
     { }
     virtual ~raw() {};
 
@@ -159,7 +163,7 @@ static uint32_t simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZE
     }
     bool get_crc(const pair<size_t, size_t> &fromto,
                 pair<uint32_t, uint32_t> *crc) const {
-      Spinlock::Locker l(crc_lock);
+      Mutex::Locker l(crc_lock);
       map<pair<size_t, size_t>, pair<uint32_t, uint32_t> >::const_iterator i =
        crc_map.find(fromto);
       if (i == crc_map.end())
@@ -169,11 +173,11 @@ static uint32_t simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZE
     }
     void set_crc(const pair<size_t, size_t> &fromto,
                 const pair<uint32_t, uint32_t> &crc) {
-      Spinlock::Locker l(crc_lock);
+      Mutex::Locker l(crc_lock);
       crc_map[fromto] = crc;
     }
     void invalidate_crc() {
-      Spinlock::Locker l(crc_lock);
+      Mutex::Locker l(crc_lock);
       crc_map.clear();
     }
   };