]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Objecter: use RWLock for watch_lock
authorSage Weil <sage@redhat.com>
Mon, 17 Nov 2014 20:06:27 +0000 (12:06 -0800)
committerSage Weil <sage@redhat.com>
Thu, 4 Dec 2014 18:34:05 +0000 (10:34 -0800)
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 <sage@redhat.com>
src/osdc/Objecter.cc
src/osdc/Objecter.h

index 856486cf8e9e95ff2e49f4fd0707225e42c86650..904e67a300fd8a6a753be597abafe23fb5db8702 100644 (file)
@@ -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())
index 942eefdd9dbebe5a1adedc25e2ceab0085b04d04..b2249f928996bd3706c9c80fc7d8c4701c5dd813 100644 (file)
@@ -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();
     }