From d0d162a55217837587ca992b8c4c1db32b03544f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 14 Apr 2014 08:56:18 -0700 Subject: [PATCH] buffer: use Mutex instead of Spinlock for raw crcs Signed-off-by: Sage Weil --- src/common/buffer.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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(); } }; -- 2.47.3