From: Sage Weil Date: Mon, 14 Apr 2014 15:56:18 +0000 (-0700) Subject: buffer: use Mutex instead of Spinlock for raw crcs X-Git-Tag: v0.80-rc1~16^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1696%2Fhead;p=ceph.git buffer: use Mutex instead of Spinlock for raw crcs Signed-off-by: Sage Weil --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 71f665de80b0..e7212f24a62a 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -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 #include @@ -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 > 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 &fromto, pair *crc) const { - Spinlock::Locker l(crc_lock); + Mutex::Locker l(crc_lock); map, pair >::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 &fromto, const pair &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(); } };