From: Sage Weil Date: Mon, 17 Nov 2014 20:06:27 +0000 (-0800) Subject: osdc/Objecter: use RWLock for watch_lock X-Git-Tag: v0.91~85 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=26440fd72d9b3dca28d9665b85fe893849dfaff6;p=ceph.git osdc/Objecter: use RWLock for watch_lock This makes the linger_check fast path an RWLock read lock. Drop the unnecessary write lock on rwlock and drop the unused Cond. Signed-off-by: Sage Weil --- diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 856486cf8e9e..904e67a300fd 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -509,12 +509,11 @@ void Objecter::_linger_reconnect(LingerOp *info, int r) ldout(cct, 10) << __func__ << " " << info->linger_id << " = " << r << " (last_error " << info->last_error << ")" << dendl; if (r < 0) { - info->watch_lock.Lock(); + info->watch_lock.get_write(); info->last_error = r; - info->watch_cond.Signal(); if (info->watch_context) finisher->queue(new C_DoWatchError(info, r)); - info->watch_lock.Unlock(); + info->watch_lock.put_write(); } } @@ -566,7 +565,7 @@ void Objecter::_linger_ping(LingerOp *info, int r, utime_t sent, << " sent " << sent << " gen " << register_gen << " = " << r << " (last_error " << info->last_error << " register_gen " << info->register_gen << ")" << dendl; - info->watch_lock.Lock(); + info->watch_lock.get_write(); if (info->register_gen == register_gen) { if (r == 0) { info->watch_valid_thru = sent; @@ -575,17 +574,15 @@ void Objecter::_linger_ping(LingerOp *info, int r, utime_t sent, if (info->watch_context) finisher->queue(new C_DoWatchError(info, r)); } - info->watch_cond.SignalAll(); } else { ldout(cct, 20) << " ignoring old gen" << dendl; } - info->watch_lock.Unlock(); + info->watch_lock.put_write(); } int Objecter::linger_check(LingerOp *info) { - RWLock::WLocker wl(rwlock); - Mutex::Locker l(info->watch_lock); + RWLock::RLocker l(info->watch_lock); utime_t stamp = info->watch_valid_thru; if (!info->watch_pending_async.empty()) diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 942eefdd9dbe..b2249f928996 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1477,8 +1477,7 @@ public: bool is_watch; utime_t watch_valid_thru; ///< send time for last acked ping int last_error; ///< error from last failed ping|reconnect, if any - Mutex watch_lock; - Cond watch_cond; + RWLock watch_lock; // queue of pending async operations, with the timestamp of // when they were queued. @@ -1502,11 +1501,11 @@ public: epoch_t map_dne_bound; void queued_async() { - Mutex::Locker l(watch_lock); + RWLock::WLocker l(watch_lock); watch_pending_async.push_back(ceph_clock_now(NULL)); } void finished_async() { - Mutex::Locker l(watch_lock); + RWLock::WLocker l(watch_lock); assert(!watch_pending_async.empty()); watch_pending_async.pop_front(); }