]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: Lock -> lock, Unlock -> lock, TryLock -> try_lock 24107/head
authorSage Weil <sage@redhat.com>
Fri, 14 Sep 2018 16:26:25 +0000 (11:26 -0500)
committerSage Weil <sage@redhat.com>
Thu, 20 Sep 2018 13:11:36 +0000 (08:11 -0500)
Use the Lockable convention.

Signed-off-by: Sage Weil <sage@redhat.com>
12 files changed:
src/common/Cond.h
src/common/Finisher.cc
src/common/Finisher.h
src/common/OutputDataSocket.cc
src/common/QueueRing.h
src/common/Readahead.cc
src/common/Semaphore.h
src/common/Timer.cc
src/common/WorkQueue.cc
src/common/WorkQueue.h
src/common/dns_resolve.cc
src/common/obj_bencher.cc

index 0c7870051af697c5262f1e7a553899ba1cc4d7b4..383ff6ebef38b9266899250d6029304d619728ea 100644 (file)
@@ -156,12 +156,12 @@ public:
     *done = false;
   }
   void finish(int r) override {
-    lock->Lock();
+    lock->lock();
     if (rval)
       *rval = r;
     *done = true;
     cond->Signal();
-    lock->Unlock();
+    lock->unlock();
   }
 };
 
index 4d30fa665df77205831ef372f431c0b96e329aee..720477019dcec7b0f40d369340b6696eae9bf1ec 100644 (file)
@@ -16,19 +16,19 @@ void Finisher::start()
 void Finisher::stop()
 {
   ldout(cct, 10) << __func__ << dendl;
-  finisher_lock.Lock();
+  finisher_lock.lock();
   finisher_stop = true;
   // we don't have any new work to do, but we want the worker to wake up anyway
   // to process the stop condition.
   finisher_cond.Signal();
-  finisher_lock.Unlock();
+  finisher_lock.unlock();
   finisher_thread.join(); // wait until the worker exits completely
   ldout(cct, 10) << __func__ << " finish" << dendl;
 }
 
 void Finisher::wait_for_empty()
 {
-  finisher_lock.Lock();
+  finisher_lock.lock();
   while (!finisher_queue.empty() || finisher_running) {
     ldout(cct, 10) << "wait_for_empty waiting" << dendl;
     finisher_empty_wait = true;
@@ -36,12 +36,12 @@ void Finisher::wait_for_empty()
   }
   ldout(cct, 10) << "wait_for_empty empty" << dendl;
   finisher_empty_wait = false;
-  finisher_lock.Unlock();
+  finisher_lock.unlock();
 }
 
 void *Finisher::finisher_thread_entry()
 {
-  finisher_lock.Lock();
+  finisher_lock.lock();
   ldout(cct, 10) << "finisher_thread start" << dendl;
 
   utime_t start;
@@ -55,7 +55,7 @@ void *Finisher::finisher_thread_entry()
       vector<pair<Context*,int>> ls;
       ls.swap(finisher_queue);
       finisher_running = true;
-      finisher_lock.Unlock();
+      finisher_lock.unlock();
       ldout(cct, 10) << "finisher_thread doing " << ls << dendl;
 
       if (logger) {
@@ -74,7 +74,7 @@ void *Finisher::finisher_thread_entry()
        logger->tinc(l_finisher_complete_lat, ceph_clock_now() - start);
       }
 
-      finisher_lock.Lock();
+      finisher_lock.lock();
       finisher_running = false;
     }
     ldout(cct, 10) << "finisher_thread empty" << dendl;
@@ -92,7 +92,7 @@ void *Finisher::finisher_thread_entry()
 
   ldout(cct, 10) << "finisher_thread stop" << dendl;
   finisher_stop = false;
-  finisher_lock.Unlock();
+  finisher_lock.unlock();
   return 0;
 }
 
index 1d0a4a3f5cf226e8c5b2925bca9ab572a06611a2..15127ef6f9e9b6d2228b248e304588e48cd2602d 100644 (file)
@@ -63,18 +63,18 @@ class Finisher {
  public:
   /// Add a context to complete, optionally specifying a parameter for the complete function.
   void queue(Context *c, int r = 0) {
-    finisher_lock.Lock();
+    finisher_lock.lock();
     if (finisher_queue.empty()) {
       finisher_cond.Signal();
     }
     finisher_queue.push_back(make_pair(c, r));
     if (logger)
       logger->inc(l_finisher_queue_len);
-    finisher_lock.Unlock();
+    finisher_lock.unlock();
   }
 
   void queue(list<Context*>& ls) {
-    finisher_lock.Lock();
+    finisher_lock.lock();
     if (finisher_queue.empty()) {
       finisher_cond.Signal();
     }
@@ -83,11 +83,11 @@ class Finisher {
     }
     if (logger)
       logger->inc(l_finisher_queue_len, ls.size());
-    finisher_lock.Unlock();
+    finisher_lock.unlock();
     ls.clear();
   }
   void queue(deque<Context*>& ls) {
-    finisher_lock.Lock();
+    finisher_lock.lock();
     if (finisher_queue.empty()) {
       finisher_cond.Signal();
     }
@@ -96,11 +96,11 @@ class Finisher {
     }
     if (logger)
       logger->inc(l_finisher_queue_len, ls.size());
-    finisher_lock.Unlock();
+    finisher_lock.unlock();
     ls.clear();
   }
   void queue(vector<Context*>& ls) {
-    finisher_lock.Lock();
+    finisher_lock.lock();
     if (finisher_queue.empty()) {
       finisher_cond.Signal();
     }
@@ -109,7 +109,7 @@ class Finisher {
     }
     if (logger)
       logger->inc(l_finisher_queue_len, ls.size());
-    finisher_lock.Unlock();
+    finisher_lock.unlock();
     ls.clear();
   }
 
index c417107796ac38e2b94f660ec2dc9ba95b09dc19..9348c328609f34953fbdec0301d15a922012d5ea 100644 (file)
@@ -261,9 +261,9 @@ void OutputDataSocket::handle_connection(int fd)
 {
   bufferlist bl;
 
-  m_lock.Lock();
+  m_lock.lock();
   init_connection(bl);
-  m_lock.Unlock();
+  m_lock.unlock();
 
   if (bl.length()) {
     /* need to special case the connection init buffer output, as it needs
@@ -282,14 +282,14 @@ void OutputDataSocket::handle_connection(int fd)
     return;
 
   do {
-    m_lock.Lock();
+    m_lock.lock();
     cond.Wait(m_lock);
 
     if (going_down) {
-      m_lock.Unlock();
+      m_lock.unlock();
       break;
     }
-    m_lock.Unlock();
+    m_lock.unlock();
 
     ret = dump_data(fd);
   } while (ret >= 0);
@@ -297,11 +297,11 @@ void OutputDataSocket::handle_connection(int fd)
 
 int OutputDataSocket::dump_data(int fd)
 {
-  m_lock.Lock(); 
+  m_lock.lock();
   list<bufferlist> l = std::move(data);
   data.clear();
   data_size = 0;
-  m_lock.Unlock();
+  m_lock.unlock();
 
   for (list<bufferlist>::iterator iter = l.begin(); iter != l.end(); ++iter) {
     bufferlist& bl = *iter;
@@ -360,10 +360,10 @@ bool OutputDataSocket::init(const std::string &path)
 
 void OutputDataSocket::shutdown()
 {
-  m_lock.Lock();
+  m_lock.lock();
   going_down = true;
   cond.Signal();
-  m_lock.Unlock();
+  m_lock.unlock();
 
   if (m_shutdown_wr_fd < 0)
     return;
index 8be2365ee505b79f740035be18dc8d04c005a3db..4d6a43cbf95bb381fa1c3bb5037ec9d2ae576e55 100644 (file)
@@ -21,23 +21,23 @@ class QueueRing {
     }
 
     void enqueue(const T& entry) {
-      lock.Lock();
+      lock.lock();
       if (entries.empty()) {
         cond.Signal();
       }
       entries.push_back(entry);
-      lock.Unlock();
+      lock.unlock();
     }
 
     void dequeue(T *entry) {
-      lock.Lock();
+      lock.lock();
       if (entries.empty()) {
         cond.Wait(lock);
       };
       ceph_assert(!entries.empty());
       *entry = entries.front();
       entries.pop_front();
-      lock.Unlock();
+      lock.unlock();
     };
   };
 
index 5927c037fe3562bc7cc303b3a6d1d071c023e4f7..2db3950c54408414a1bd2d21e2ef649539605908 100644 (file)
@@ -24,28 +24,28 @@ Readahead::~Readahead() {
 }
 
 Readahead::extent_t Readahead::update(const vector<extent_t>& extents, uint64_t limit) {
-  m_lock.Lock();
+  m_lock.lock();
   for (vector<extent_t>::const_iterator p = extents.begin(); p != extents.end(); ++p) {
     _observe_read(p->first, p->second);
   }
   if (m_readahead_pos >= limit|| m_last_pos >= limit) {
-    m_lock.Unlock();
+    m_lock.unlock();
     return extent_t(0, 0);
   }
   pair<uint64_t, uint64_t> extent = _compute_readahead(limit);
-  m_lock.Unlock();
+  m_lock.unlock();
   return extent;
 }
 
 Readahead::extent_t Readahead::update(uint64_t offset, uint64_t length, uint64_t limit) {
-  m_lock.Lock();
+  m_lock.lock();
   _observe_read(offset, length);
   if (m_readahead_pos >= limit || m_last_pos >= limit) {
-    m_lock.Unlock();
+    m_lock.unlock();
     return extent_t(0, 0);
   }
   extent_t extent = _compute_readahead(limit);
-  m_lock.Unlock();
+  m_lock.unlock();
   return extent;
 }
 
@@ -122,25 +122,25 @@ Readahead::extent_t Readahead::_compute_readahead(uint64_t limit) {
 
 void Readahead::inc_pending(int count) {
   ceph_assert(count > 0);
-  m_pending_lock.Lock();
+  m_pending_lock.lock();
   m_pending += count;
-  m_pending_lock.Unlock();
+  m_pending_lock.unlock();
 }
 
 void Readahead::dec_pending(int count) {
   ceph_assert(count > 0);
-  m_pending_lock.Lock();
+  m_pending_lock.lock();
   ceph_assert(m_pending >= count);
   m_pending -= count;
   if (m_pending == 0) {
     std::list<Context *> pending_waiting(std::move(m_pending_waiting));
-    m_pending_lock.Unlock();
+    m_pending_lock.unlock();
 
     for (auto ctx : pending_waiting) {
       ctx->complete(0);
     }
   } else {
-    m_pending_lock.Unlock();
+    m_pending_lock.unlock();
   }
 }
 
@@ -151,20 +151,20 @@ void Readahead::wait_for_pending() {
 }
 
 void Readahead::wait_for_pending(Context *ctx) {
-  m_pending_lock.Lock();
+  m_pending_lock.lock();
   if (m_pending > 0) {
-    m_pending_lock.Unlock();
+    m_pending_lock.unlock();
     m_pending_waiting.push_back(ctx);
     return;
   }
-  m_pending_lock.Unlock();
+  m_pending_lock.unlock();
 
   ctx->complete(0);
 }
 void Readahead::set_trigger_requests(int trigger_requests) {
-  m_lock.Lock();
+  m_lock.lock();
   m_trigger_requests = trigger_requests;
-  m_lock.Unlock();
+  m_lock.unlock();
 }
 
 uint64_t Readahead::get_min_readahead_size(void) {
@@ -178,19 +178,19 @@ uint64_t Readahead::get_max_readahead_size(void) {
 }
 
 void Readahead::set_min_readahead_size(uint64_t min_readahead_size) {
-  m_lock.Lock();
+  m_lock.lock();
   m_readahead_min_bytes = min_readahead_size;
-  m_lock.Unlock();
+  m_lock.unlock();
 }
 
 void Readahead::set_max_readahead_size(uint64_t max_readahead_size) {
-  m_lock.Lock();
+  m_lock.lock();
   m_readahead_max_bytes = max_readahead_size;
-  m_lock.Unlock();
+  m_lock.unlock();
 }
 
 void Readahead::set_alignments(const vector<uint64_t> &alignments) {
-  m_lock.Lock();
+  m_lock.lock();
   m_alignments = alignments;
-  m_lock.Unlock();
+  m_lock.unlock();
 }
index 3a5ecdc95851ab33928355ebc4ea6283a1f883a2..80153a3c16f2ca058bd579d49943ea204c9acaef 100644 (file)
@@ -31,20 +31,20 @@ class Semaphore
 
   void Put()
   { 
-    m.Lock();
+    m.lock();
     count++;
     c.Signal();
-    m.Unlock();
+    m.unlock();
   }
 
   void Get() 
   { 
-    m.Lock();
+    m.lock();
     while(count <= 0) {
       c.Wait(m);
     }
     count--;
-    m.Unlock();
+    m.unlock();
   }
 };
 
index 46061eb84df7afdfdda6c054a265aa5128d571db..68a51f6388f4470efbe7d5a0382e35de7406c143 100644 (file)
@@ -65,9 +65,9 @@ void SafeTimer::shutdown()
     cancel_all_events();
     stopping = true;
     cond.Signal();
-    lock.Unlock();
+    lock.unlock();
     thread->join();
-    lock.Lock();
+    lock.lock();
     delete thread;
     thread = NULL;
   }
@@ -75,7 +75,7 @@ void SafeTimer::shutdown()
 
 void SafeTimer::timer_thread()
 {
-  lock.Lock();
+  lock.lock();
   ldout(cct,10) << "timer_thread starting" << dendl;
   while (!stopping) {
     utime_t now = ceph_clock_now();
@@ -93,10 +93,10 @@ void SafeTimer::timer_thread()
       ldout(cct,10) << "timer_thread executing " << callback << dendl;
       
       if (!safe_callbacks)
-       lock.Unlock();
+       lock.unlock();
       callback->complete(0);
       if (!safe_callbacks)
-       lock.Lock();
+       lock.lock();
     }
 
     // recheck stopping if we dropped the lock
@@ -111,7 +111,7 @@ void SafeTimer::timer_thread()
     ldout(cct,20) << "timer_thread awake" << dendl;
   }
   ldout(cct,10) << "timer_thread exiting" << dendl;
-  lock.Unlock();
+  lock.unlock();
 }
 
 Context* SafeTimer::add_event_after(double seconds, Context *callback)
index 6067bf53cb28c81be3f38a78e7c52bc91875a9e1..094d4e411de5517373d5aa99b338c1b5eb230928 100644 (file)
@@ -72,18 +72,18 @@ void ThreadPool::handle_conf_change(const ConfigProxy& conf,
     int v = atoi(buf);
     free(buf);
     if (v >= 0) {
-      _lock.Lock();
+      _lock.lock();
       _num_threads = v;
       start_threads();
       _cond.SignalAll();
-      _lock.Unlock();
+      _lock.unlock();
     }
   }
 }
 
 void ThreadPool::worker(WorkThread *wt)
 {
-  _lock.Lock();
+  _lock.lock();
   ldout(cct,10) << "worker start" << dendl;
   
   std::stringstream ss;
@@ -116,9 +116,9 @@ void ThreadPool::worker(WorkThread *wt)
                        << " (" << processing << " active)" << dendl;
          TPHandle tp_handle(cct, hb, wq->timeout_interval, wq->suicide_interval);
          tp_handle.reset_tp_timeout();
-         _lock.Unlock();
+         _lock.unlock();
          wq->_void_process(item, tp_handle);
-         _lock.Lock();
+         _lock.lock();
          wq->_void_process_finish(item);
          processing--;
          ldout(cct,15) << "worker wq " << wq->name << " done processing " << item
@@ -146,7 +146,7 @@ void ThreadPool::worker(WorkThread *wt)
 
   cct->get_heartbeat_map()->remove_worker(hb);
 
-  _lock.Unlock();
+  _lock.unlock();
 }
 
 void ThreadPool::start_threads()
@@ -186,9 +186,9 @@ void ThreadPool::start()
     cct->_conf.add_observer(this);
   }
 
-  _lock.Lock();
+  _lock.lock();
   start_threads();
-  _lock.Unlock();
+  _lock.unlock();
   ldout(cct,15) << "started" << dendl;
 }
 
@@ -201,11 +201,11 @@ void ThreadPool::stop(bool clear_after)
     cct->_conf.remove_observer(this);
   }
 
-  _lock.Lock();
+  _lock.lock();
   _stop = true;
   _cond.Signal();
   join_old_threads();
-  _lock.Unlock();
+  _lock.unlock();
   for (set<WorkThread*>::iterator p = _threads.begin();
        p != _threads.end();
        ++p) {
@@ -213,52 +213,52 @@ void ThreadPool::stop(bool clear_after)
     delete *p;
   }
   _threads.clear();
-  _lock.Lock();
+  _lock.lock();
   for (unsigned i=0; i<work_queues.size(); i++)
     work_queues[i]->_clear();
   _stop = false;
-  _lock.Unlock();    
+  _lock.unlock();
   ldout(cct,15) << "stopped" << dendl;
 }
 
 void ThreadPool::pause()
 {
   ldout(cct,10) << "pause" << dendl;
-  _lock.Lock();
+  _lock.lock();
   _pause++;
   while (processing)
     _wait_cond.Wait(_lock);
-  _lock.Unlock();
+  _lock.unlock();
   ldout(cct,15) << "paused" << dendl;
 }
 
 void ThreadPool::pause_new()
 {
   ldout(cct,10) << "pause_new" << dendl;
-  _lock.Lock();
+  _lock.lock();
   _pause++;
-  _lock.Unlock();
+  _lock.unlock();
 }
 
 void ThreadPool::unpause()
 {
   ldout(cct,10) << "unpause" << dendl;
-  _lock.Lock();
+  _lock.lock();
   ceph_assert(_pause > 0);
   _pause--;
   _cond.Signal();
-  _lock.Unlock();
+  _lock.unlock();
 }
 
 void ThreadPool::drain(WorkQueue_* wq)
 {
   ldout(cct,10) << "drain" << dendl;
-  _lock.Lock();
+  _lock.lock();
   _draining++;
   while (processing || (wq != NULL && !wq->_empty()))
     _wait_cond.Wait(_lock);
   _draining--;
-  _lock.Unlock();
+  _lock.unlock();
 }
 
 void ThreadPool::set_ioprio(int cls, int priority)
@@ -302,7 +302,7 @@ void ShardedThreadPool::shardedthreadpool_worker(uint32_t thread_index)
 
   while (!stop_threads) {
     if (pause_threads) {
-      shardedpool_lock.Lock();
+      shardedpool_lock.lock();
       ++num_paused;
       wait_cond.Signal();
       while (pause_threads) {
@@ -314,10 +314,10 @@ void ShardedThreadPool::shardedthreadpool_worker(uint32_t thread_index)
           cct->_conf->threadpool_empty_queue_max_wait, 0));
       }
       --num_paused;
-      shardedpool_lock.Unlock();
+      shardedpool_lock.unlock();
     }
     if (drain_threads) {
-      shardedpool_lock.Lock();
+      shardedpool_lock.lock();
       if (wq->is_shard_empty(thread_index)) {
         ++num_drained;
         wait_cond.Signal();
@@ -331,7 +331,7 @@ void ShardedThreadPool::shardedthreadpool_worker(uint32_t thread_index)
         }
         --num_drained;
       }
-      shardedpool_lock.Unlock();
+      shardedpool_lock.unlock();
     }
 
     cct->get_heartbeat_map()->reset_timeout(
@@ -365,9 +365,9 @@ void ShardedThreadPool::start()
 {
   ldout(cct,10) << "start" << dendl;
 
-  shardedpool_lock.Lock();
+  shardedpool_lock.lock();
   start_threads();
-  shardedpool_lock.Unlock();
+  shardedpool_lock.unlock();
   ldout(cct,15) << "started" << dendl;
 }
 
@@ -390,43 +390,43 @@ void ShardedThreadPool::stop()
 void ShardedThreadPool::pause()
 {
   ldout(cct,10) << "pause" << dendl;
-  shardedpool_lock.Lock();
+  shardedpool_lock.lock();
   pause_threads = true;
   ceph_assert(wq != NULL);
   wq->return_waiting_threads();
   while (num_threads != num_paused){
     wait_cond.Wait(shardedpool_lock);
   }
-  shardedpool_lock.Unlock();
+  shardedpool_lock.unlock();
   ldout(cct,10) << "paused" << dendl; 
 }
 
 void ShardedThreadPool::pause_new()
 {
   ldout(cct,10) << "pause_new" << dendl;
-  shardedpool_lock.Lock();
+  shardedpool_lock.lock();
   pause_threads = true;
   ceph_assert(wq != NULL);
   wq->return_waiting_threads();
-  shardedpool_lock.Unlock();
+  shardedpool_lock.unlock();
   ldout(cct,10) << "paused_new" << dendl;
 }
 
 void ShardedThreadPool::unpause()
 {
   ldout(cct,10) << "unpause" << dendl;
-  shardedpool_lock.Lock();
+  shardedpool_lock.lock();
   pause_threads = false;
   wq->stop_return_waiting_threads();
   shardedpool_cond.Signal();
-  shardedpool_lock.Unlock();
+  shardedpool_lock.unlock();
   ldout(cct,10) << "unpaused" << dendl;
 }
 
 void ShardedThreadPool::drain()
 {
   ldout(cct,10) << "drain" << dendl;
-  shardedpool_lock.Lock();
+  shardedpool_lock.lock();
   drain_threads = true;
   ceph_assert(wq != NULL);
   wq->return_waiting_threads();
@@ -436,7 +436,7 @@ void ShardedThreadPool::drain()
   drain_threads = false;
   wq->stop_return_waiting_threads();
   shardedpool_cond.Signal();
-  shardedpool_lock.Unlock();
+  shardedpool_lock.unlock();
   ldout(cct,10) << "drained" << dendl;
 }
 
index 5486e67b509e292b87e0850ed8407b06c04409bc..c30e493be0345d3a3c7aa954b0aefec442838a12 100644 (file)
@@ -138,21 +138,21 @@ public:
     }
 
     bool queue(T *item) {
-      pool->_lock.Lock();
+      pool->_lock.lock();
       bool r = _enqueue(item);
       pool->_cond.SignalOne();
-      pool->_lock.Unlock();
+      pool->_lock.unlock();
       return r;
     }
     void dequeue(T *item) {
-      pool->_lock.Lock();
+      pool->_lock.lock();
       _dequeue(item);
-      pool->_lock.Unlock();
+      pool->_lock.unlock();
     }
     void clear() {
-      pool->_lock.Lock();
+      pool->_lock.lock();
       _clear();
-      pool->_lock.Unlock();
+      pool->_lock.unlock();
     }
 
     void lock() {
@@ -201,25 +201,25 @@ public:
       return ((void*)1); // Not used
     }
     void _void_process(void *, TPHandle &handle) override {
-      _lock.Lock();
+      _lock.lock();
       ceph_assert(!to_process.empty());
       U u = to_process.front();
       to_process.pop_front();
-      _lock.Unlock();
+      _lock.unlock();
 
       _process(u, handle);
 
-      _lock.Lock();
+      _lock.lock();
       to_finish.push_back(u);
-      _lock.Unlock();
+      _lock.unlock();
     }
 
     void _void_process_finish(void *) override {
-      _lock.Lock();
+      _lock.lock();
       ceph_assert(!to_finish.empty());
       U u = to_finish.front();
       to_finish.pop_front();
-      _lock.Unlock();
+      _lock.unlock();
 
       _process_finish(u);
     }
@@ -299,21 +299,21 @@ public:
     }
     
     bool queue(T *item) {
-      pool->_lock.Lock();
+      pool->_lock.lock();
       bool r = _enqueue(item);
       pool->_cond.SignalOne();
-      pool->_lock.Unlock();
+      pool->_lock.unlock();
       return r;
     }
     void dequeue(T *item) {
-      pool->_lock.Lock();
+      pool->_lock.lock();
       _dequeue(item);
-      pool->_lock.Unlock();
+      pool->_lock.unlock();
     }
     void clear() {
-      pool->_lock.Lock();
+      pool->_lock.lock();
       _clear();
-      pool->_lock.Unlock();
+      pool->_lock.unlock();
     }
 
     Mutex &get_lock() {
@@ -488,11 +488,11 @@ public:
 
   /// take thread pool lock
   void lock() {
-    _lock.Lock();
+    _lock.lock();
   }
   /// release thread pool lock
   void unlock() {
-    _lock.Unlock();
+    _lock.unlock();
   }
 
   /// wait for a kick on this thread pool
index 05521d73a559b23c0615b568b475ccc5019362a9..6b4a16db68f47d757510ba677e9f04e9dd753b9b 100644 (file)
@@ -64,15 +64,15 @@ DNSResolver::~DNSResolver()
 #ifdef HAVE_RES_NQUERY
 int DNSResolver::get_state(CephContext *cct, res_state *ps)
 {
-  lock.Lock();
+  lock.lock();
   if (!states.empty()) {
     res_state s = states.front();
     states.pop_front();
-    lock.Unlock();
+    lock.unlock();
     *ps = s;
     return 0;
   }
-  lock.Unlock();
+  lock.unlock();
   struct __res_state *s = new struct __res_state;
   s->options = 0;
   if (res_ninit(s) < 0) {
index c70209dd2a967a14440d3e6f0e46e4b843d2eb31..47b9a7244921b4b1672286826395cc34675798b6 100644 (file)
@@ -98,7 +98,7 @@ void *ObjBencher::status_printer(void *_bencher) {
   double bandwidth;
   int iops = 0;
   mono_clock::duration ONE_SECOND = std::chrono::seconds(1);
-  bencher->lock.Lock();
+  bencher->lock.lock();
   if (formatter)
     formatter->open_array_section("datas");
   while(!data.done) {
@@ -229,7 +229,7 @@ void *ObjBencher::status_printer(void *_bencher) {
     std::chrono::duration<double> runtime = mono_clock::now() - data.start_time;
     data.idata.min_iops = data.idata.max_iops = data.finished / runtime.count();
   }
-  bencher->lock.Unlock();
+  bencher->lock.unlock();
   return NULL;
 }
 
@@ -267,7 +267,7 @@ int ObjBencher::aio_bench(
   }
 
   char* contentsChars = new char[op_size];
-  lock.Lock();
+  lock.lock();
   data.done = false;
   data.hints = hints;
   data.object_size = object_size;
@@ -280,7 +280,7 @@ int ObjBencher::aio_bench(
   data.avg_latency = 0;
   data.latency_diff_sum = 0;
   data.object_contents = contentsChars;
-  lock.Unlock();
+  lock.unlock();
 
   //fill in contentsChars deterministically so we can check returns
   sanitize_object_contents(&data, data.op_size);
@@ -342,9 +342,9 @@ struct lock_cond {
 
 void _aio_cb(void *cb, void *arg) {
   struct lock_cond *lc = (struct lock_cond *)arg;
-  lc->lock->Lock();
+  lc->lock->lock();
   lc->cond.Signal();
-  lc->lock->Unlock();
+  lc->lock->unlock();
 }
 
 int ObjBencher::fetch_bench_metadata(const std::string& metadata_file,
@@ -432,10 +432,10 @@ int ObjBencher::write_bench(int secondsToRun,
 
   pthread_create(&print_thread, NULL, ObjBencher::status_printer, (void *)this);
   ceph_pthread_setname(print_thread, "write_stat");
-  lock.Lock();
+  lock.lock();
   data.finished = 0;
   data.start_time = mono_clock::now();
-  lock.Unlock();
+  lock.unlock();
   for (int i = 0; i<concurrentios; ++i) {
     start_times[i] = mono_clock::now();
     r = create_completion(i, _aio_cb, (void *)&lc);
@@ -446,10 +446,10 @@ int ObjBencher::write_bench(int secondsToRun,
     if (r < 0) { //naughty, doesn't clean up heap
       goto ERR;
     }
-    lock.Lock();
+    lock.lock();
     ++data.started;
     ++data.in_flight;
-    lock.Unlock();
+    lock.unlock();
   }
 
   //keep on adding new writes as old ones complete until we've passed minimum time
@@ -460,7 +460,7 @@ int ObjBencher::write_bench(int secondsToRun,
 
   stopTime = data.start_time + std::chrono::seconds(secondsToRun);
   slot = 0;
-  lock.Lock();
+  lock.lock();
   while (secondsToRun && mono_clock::now() < stopTime) {
     bool found = false;
     while (1) {
@@ -479,7 +479,7 @@ int ObjBencher::write_bench(int secondsToRun,
         break;
       lc.cond.Wait(lock);
     }
-    lock.Unlock();
+    lock.unlock();
     //create new contents and name on the heap, and fill them
     newName = generate_object_name_fast(data.started / writes_per_object);
     newContents = contents[slot];
@@ -488,10 +488,10 @@ int ObjBencher::write_bench(int secondsToRun,
     newContents->invalidate_crc();
 
     completion_wait(slot);
-    lock.Lock();
+    lock.lock();
     r = completion_ret(slot);
     if (r != 0) {
-      lock.Unlock();
+      lock.unlock();
       goto ERR;
     }
     data.cur_latency = mono_clock::now() - start_times[slot];
@@ -505,7 +505,7 @@ int ObjBencher::write_bench(int secondsToRun,
     data.avg_latency = total_latency / data.finished;
     data.latency_diff_sum += delta * (data.cur_latency.count() - data.avg_latency);
     --data.in_flight;
-    lock.Unlock();
+    lock.unlock();
     release_completion(slot);
 
     //write new stuff to backend
@@ -519,7 +519,7 @@ int ObjBencher::write_bench(int secondsToRun,
       goto ERR;
     }
     name[slot] = newName;
-    lock.Lock();
+    lock.lock();
     ++data.started;
     ++data.in_flight;
     if (data.op_size) {
@@ -529,15 +529,15 @@ int ObjBencher::write_bench(int secondsToRun,
         break;
     }
   }
-  lock.Unlock();
+  lock.unlock();
 
   while (data.finished < data.started) {
     slot = data.finished % concurrentios;
     completion_wait(slot);
-    lock.Lock();
+    lock.lock();
     r = completion_ret(slot);
     if (r != 0) {
-      lock.Unlock();
+      lock.unlock();
       goto ERR;
     }
     data.cur_latency = mono_clock::now() - start_times[slot];
@@ -551,16 +551,16 @@ int ObjBencher::write_bench(int secondsToRun,
     data.avg_latency = total_latency / data.finished;
     data.latency_diff_sum += delta * (data.cur_latency.count() - data.avg_latency);
     --data.in_flight;
-    lock.Unlock();
+    lock.unlock();
     release_completion(slot);
     delete contents[slot];
     contents[slot] = 0;
   }
 
   timePassed = mono_clock::now() - data.start_time;
-  lock.Lock();
+  lock.lock();
   data.done = true;
-  lock.Unlock();
+  lock.unlock();
 
   pthread_join(print_thread, NULL);
 
@@ -641,9 +641,9 @@ int ObjBencher::write_bench(int secondsToRun,
   return 0;
 
  ERR:
-  lock.Lock();
+  lock.lock();
   data.done = 1;
-  lock.Unlock();
+  lock.unlock();
   pthread_join(print_thread, NULL);
   for (int i = 0; i < concurrentios; i++)
       if (contents[i])
@@ -684,10 +684,10 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
     contents[i] = new bufferlist();
   }
 
-  lock.Lock();
+  lock.lock();
   data.finished = 0;
   data.start_time = mono_clock::now();
-  lock.Unlock();
+  lock.unlock();
 
   pthread_t print_thread;
   pthread_create(&print_thread, NULL, status_printer, (void *)this);
@@ -705,10 +705,10 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
       cerr << "r = " << r << std::endl;
       goto ERR;
     }
-    lock.Lock();
+    lock.lock();
     ++data.started;
     ++data.in_flight;
-    lock.Unlock();
+    lock.unlock();
   }
 
   //keep on adding new reads as old ones complete
@@ -718,7 +718,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
   slot = 0;
   while ((seconds_to_run && mono_clock::now() < finish_time) &&
         num_objects > data.started) {
-    lock.Lock();
+    lock.lock();
     int old_slot = slot;
     bool found = false;
     while (1) {
@@ -758,13 +758,13 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
 
     newName = generate_object_name_fast(data.started / writes_per_object, pid);
     index[slot] = data.started;
-    lock.Unlock();
+    lock.unlock();
     completion_wait(slot);
-    lock.Lock();
+    lock.lock();
     r = completion_ret(slot);
     if (r < 0) {
       cerr << "read got " << r << std::endl;
-      lock.Unlock();
+      lock.unlock();
       goto ERR;
     }
     total_latency += data.cur_latency.count();
@@ -775,7 +775,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
     ++data.finished;
     data.avg_latency = total_latency / data.finished;
     --data.in_flight;
-    lock.Unlock();
+    lock.unlock();
     release_completion(slot);
 
     //start new read and check data if requested
@@ -786,10 +786,10 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
     if (r < 0) {
       goto ERR;
     }
-    lock.Lock();
+    lock.lock();
     ++data.started;
     ++data.in_flight;
-    lock.Unlock();
+    lock.unlock();
     name[slot] = newName;
   }
 
@@ -797,11 +797,11 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
   while (data.finished < data.started) {
     slot = data.finished % concurrentios;
     completion_wait(slot);
-    lock.Lock();
+    lock.lock();
     r = completion_ret(slot);
     if (r < 0) {
       cerr << "read got " << r << std::endl;
-      lock.Unlock();
+      lock.unlock();
       goto ERR;
     }
     data.cur_latency = mono_clock::now() - start_times[slot];
@@ -816,22 +816,22 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
     release_completion(slot);
     if (!no_verify) {
       snprintf(data.object_contents, data.op_size, "I'm the %16dth op!", index[slot]);
-      lock.Unlock();
+      lock.unlock();
       if ((contents[slot]->length() != data.op_size) || 
          (memcmp(data.object_contents, contents[slot]->c_str(), data.op_size) != 0)) {
         cerr << name[slot] << " is not correct!" << std::endl;
         ++errors;
       }
     } else {
-        lock.Unlock();
+        lock.unlock();
     }
     delete contents[slot];
   }
 
   timePassed = mono_clock::now() - data.start_time;
-  lock.Lock();
+  lock.lock();
   data.done = true;
-  lock.Unlock();
+  lock.unlock();
 
   pthread_join(print_thread, NULL);
 
@@ -879,9 +879,9 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
   return (errors > 0 ? -EIO : 0);
 
  ERR:
-  lock.Lock();
+  lock.lock();
   data.done = 1;
-  lock.Unlock();
+  lock.unlock();
   pthread_join(print_thread, NULL);
   return r;
 }
@@ -922,10 +922,10 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
     contents[i] = new bufferlist();
   }
 
-  lock.Lock();
+  lock.lock();
   data.finished = 0;
   data.start_time = mono_clock::now();
-  lock.Unlock();
+  lock.unlock();
 
   pthread_t print_thread;
   pthread_create(&print_thread, NULL, status_printer, (void *)this);
@@ -943,10 +943,10 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
       cerr << "r = " << r << std::endl;
       goto ERR;
     }
-    lock.Lock();
+    lock.lock();
     ++data.started;
     ++data.in_flight;
-    lock.Unlock();
+    lock.unlock();
   }
 
   //keep on adding new reads as old ones complete
@@ -956,7 +956,7 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
 
   slot = 0;
   while ((seconds_to_run && mono_clock::now() < finish_time)) {
-    lock.Lock();
+    lock.lock();
     int old_slot = slot;
     bool found = false;
     while (1) {
@@ -979,16 +979,16 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
     // calculate latency here, so memcmp doesn't inflate it
     data.cur_latency = mono_clock::now() - start_times[slot];
 
-    lock.Unlock();
+    lock.unlock();
 
     int current_index = index[slot];
     cur_contents = contents[slot];
     completion_wait(slot);
-    lock.Lock();
+    lock.lock();
     r = completion_ret(slot);
     if (r < 0) {
       cerr << "read got " << r << std::endl;
-      lock.Unlock();
+      lock.unlock();
       goto ERR;
     }
 
@@ -1000,7 +1000,7 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
     ++data.finished;
     data.avg_latency = total_latency / data.finished;
     --data.in_flight;
-    lock.Unlock();
+    lock.unlock();
     
     if (!no_verify) {
       snprintf(data.object_contents, data.op_size, "I'm the %16dth op!", current_index);
@@ -1027,10 +1027,10 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
     if (r < 0) {
       goto ERR;
     }
-    lock.Lock();
+    lock.lock();
     ++data.started;
     ++data.in_flight;
-    lock.Unlock();
+    lock.unlock();
     name[slot] = newName;
   }
 
@@ -1039,11 +1039,11 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
   while (data.finished < data.started) {
     slot = data.finished % concurrentios;
     completion_wait(slot);
-    lock.Lock();
+    lock.lock();
     r = completion_ret(slot);
     if (r < 0) {
       cerr << "read got " << r << std::endl;
-      lock.Unlock();
+      lock.unlock();
       goto ERR;
     }
     data.cur_latency = mono_clock::now() - start_times[slot];
@@ -1058,22 +1058,22 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
     release_completion(slot);
     if (!no_verify) {
       snprintf(data.object_contents, data.op_size, "I'm the %16dth op!", index[slot]);
-      lock.Unlock();
+      lock.unlock();
       if ((contents[slot]->length() != data.op_size) || 
           (memcmp(data.object_contents, contents[slot]->c_str(), data.op_size) != 0)) {
         cerr << name[slot] << " is not correct!" << std::endl;
         ++errors;
       }
     } else {
-        lock.Unlock();
+        lock.unlock();
     }
     delete contents[slot];
   }
 
   timePassed = mono_clock::now() - data.start_time;
-  lock.Lock();
+  lock.lock();
   data.done = true;
-  lock.Unlock();
+  lock.unlock();
 
   pthread_join(print_thread, NULL);
 
@@ -1120,9 +1120,9 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
   return (errors > 0 ? -EIO : 0);
 
  ERR:
-  lock.Lock();
+  lock.lock();
   data.done = 1;
-  lock.Unlock();
+  lock.unlock();
   pthread_join(print_thread, NULL);
   return r;
 }
@@ -1203,12 +1203,12 @@ int ObjBencher::clean_up(int num_objects, int prevPid, int concurrentios) {
   int r = 0;
   int slot = 0;
 
-  lock.Lock();
+  lock.lock();
   data.done = false;
   data.in_flight = 0;
   data.started = 0;
   data.finished = 0;
-  lock.Unlock();
+  lock.unlock();
 
   // don't start more completions than files
   if (num_objects == 0) {
@@ -1234,15 +1234,15 @@ int ObjBencher::clean_up(int num_objects, int prevPid, int concurrentios) {
       cerr << "r = " << r << std::endl;
       goto ERR;
     }
-    lock.Lock();
+    lock.lock();
     ++data.started;
     ++data.in_flight;
-    lock.Unlock();
+    lock.unlock();
   }
 
   //keep on adding new removes as old ones complete
   while (data.started < num_objects) {
-    lock.Lock();
+    lock.lock();
     int old_slot = slot;
     bool found = false;
     while (1) {
@@ -1261,19 +1261,19 @@ int ObjBencher::clean_up(int num_objects, int prevPid, int concurrentios) {
       }
       lc.cond.Wait(lock);
     }
-    lock.Unlock();
+    lock.unlock();
     newName = generate_object_name_fast(data.started, prevPid);
     completion_wait(slot);
-    lock.Lock();
+    lock.lock();
     r = completion_ret(slot);
     if (r != 0 && r != -ENOENT) { // file does not exist
       cerr << "remove got " << r << std::endl;
-      lock.Unlock();
+      lock.unlock();
       goto ERR;
     }
     ++data.finished;
     --data.in_flight;
-    lock.Unlock();
+    lock.unlock();
     release_completion(slot);
 
     //start new remove and check data if requested
@@ -1282,10 +1282,10 @@ int ObjBencher::clean_up(int num_objects, int prevPid, int concurrentios) {
     if (r < 0) {
       goto ERR;
     }
-    lock.Lock();
+    lock.lock();
     ++data.started;
     ++data.in_flight;
-    lock.Unlock();
+    lock.unlock();
     name[slot] = newName;
   }
 
@@ -1293,22 +1293,22 @@ int ObjBencher::clean_up(int num_objects, int prevPid, int concurrentios) {
   while (data.finished < data.started) {
     slot = data.finished % concurrentios;
     completion_wait(slot);
-    lock.Lock();
+    lock.lock();
     r = completion_ret(slot);
     if (r != 0 && r != -ENOENT) { // file does not exist
       cerr << "remove got " << r << std::endl;
-      lock.Unlock();
+      lock.unlock();
       goto ERR;
     }
     ++data.finished;
     --data.in_flight;
     release_completion(slot);
-    lock.Unlock();
+    lock.unlock();
   }
 
-  lock.Lock();
+  lock.lock();
   data.done = true;
-  lock.Unlock();
+  lock.unlock();
 
   completions_done();
 
@@ -1317,9 +1317,9 @@ int ObjBencher::clean_up(int num_objects, int prevPid, int concurrentios) {
   return 0;
 
  ERR:
-  lock.Lock();
+  lock.lock();
   data.done = 1;
-  lock.Unlock();
+  lock.unlock();
   return r;
 }
 
@@ -1369,12 +1369,12 @@ int ObjBencher::clean_up_slow(const std::string& prefix, int concurrentios) {
   std::list<Object> objects;
   bool objects_remain = true;
 
-  lock.Lock();
+  lock.lock();
   data.done = false;
   data.in_flight = 0;
   data.started = 0;
   data.finished = 0;
-  lock.Unlock();
+  lock.unlock();
 
   out(cout) << "Warning: using slow linear search" << std::endl;
 
@@ -1407,15 +1407,15 @@ int ObjBencher::clean_up_slow(const std::string& prefix, int concurrentios) {
       cerr << "r = " << r << std::endl;
       goto ERR;
     }
-    lock.Lock();
+    lock.lock();
     ++data.started;
     ++data.in_flight;
-    lock.Unlock();
+    lock.unlock();
   }
 
   //keep on adding new removes as old ones complete
   while (objects_remain) {
-    lock.Lock();
+    lock.lock();
     int old_slot = slot;
     bool found = false;
     while (1) {
@@ -1434,7 +1434,7 @@ int ObjBencher::clean_up_slow(const std::string& prefix, int concurrentios) {
       }
       lc.cond.Wait(lock);
     }
-    lock.Unlock();
+    lock.unlock();
 
     // get more objects if necessary
     if (objects.empty()) {
@@ -1450,16 +1450,16 @@ int ObjBencher::clean_up_slow(const std::string& prefix, int concurrentios) {
     objects.pop_front();
 
     completion_wait(slot);
-    lock.Lock();
+    lock.lock();
     r = completion_ret(slot);
     if (r != 0 && r != -ENOENT) { // file does not exist
       cerr << "remove got " << r << std::endl;
-      lock.Unlock();
+      lock.unlock();
       goto ERR;
     }
     ++data.finished;
     --data.in_flight;
-    lock.Unlock();
+    lock.unlock();
     release_completion(slot);
 
     //start new remove and check data if requested
@@ -1469,10 +1469,10 @@ int ObjBencher::clean_up_slow(const std::string& prefix, int concurrentios) {
     if (r < 0) {
       goto ERR;
     }
-    lock.Lock();
+    lock.lock();
     ++data.started;
     ++data.in_flight;
-    lock.Unlock();
+    lock.unlock();
     name[slot] = newName;
   }
 
@@ -1480,22 +1480,22 @@ int ObjBencher::clean_up_slow(const std::string& prefix, int concurrentios) {
   while (data.finished < data.started) {
     slot = data.finished % concurrentios;
     completion_wait(slot);
-    lock.Lock();
+    lock.lock();
     r = completion_ret(slot);
     if (r != 0 && r != -ENOENT) { // file does not exist
       cerr << "remove got " << r << std::endl;
-      lock.Unlock();
+      lock.unlock();
       goto ERR;
     }
     ++data.finished;
     --data.in_flight;
     release_completion(slot);
-    lock.Unlock();
+    lock.unlock();
   }
 
-  lock.Lock();
+  lock.lock();
   data.done = true;
-  lock.Unlock();
+  lock.unlock();
 
   completions_done();
 
@@ -1504,8 +1504,8 @@ int ObjBencher::clean_up_slow(const std::string& prefix, int concurrentios) {
   return 0;
 
  ERR:
-  lock.Lock();
+  lock.lock();
   data.done = 1;
-  lock.Unlock();
+  lock.unlock();
   return -EIO;
 }