]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: remove unnecessary OpsLogFile::flush_mutex
authorCasey Bodley <cbodley@redhat.com>
Mon, 25 Apr 2022 17:40:19 +0000 (13:40 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 26 Apr 2022 16:30:49 +0000 (12:30 -0400)
this mutex was only held by one function, OpsLogFile::flush(). this
private member function is only ever called from the background thread,
so doesn't need to be protected by a mutex

as a further cleanup, i renamed 'cond' and 'mutex' now that we don't
need to differentiate between different locks

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 279d664f8b25d2eeafac0b5d60e532dbcf56218f)

src/rgw/rgw_log.cc
src/rgw/rgw_log.h

index a140c42a0944c7521f0c39001350e22c73d53b8e..4631697724cb1a9cc5c5f286bcf701ba551b2557 100644 (file)
@@ -350,9 +350,8 @@ OpsLogFile::OpsLogFile(CephContext* cct, std::string& path, uint64_t max_data_si
 
 void OpsLogFile::flush()
 {
-  std::scoped_lock flush_lock(flush_mutex);
   {
-    std::scoped_lock log_lock(log_mutex);
+    std::scoped_lock log_lock(mutex);
     assert(flush_buffer.empty());
     flush_buffer.swap(log_buffer);
     data_size = 0;
@@ -380,7 +379,7 @@ void OpsLogFile::flush()
 }
 
 void* OpsLogFile::entry() {
-  std::unique_lock lock(log_mutex);
+  std::unique_lock lock(mutex);
   while (!stopped) {
     if (!log_buffer.empty()) {
       lock.unlock();
@@ -388,7 +387,7 @@ void* OpsLogFile::entry() {
       lock.lock();
       continue;
     }
-    cond_flush.wait(lock);
+    cond.wait(lock);
   }
   flush();
   return NULL;
@@ -401,8 +400,8 @@ void OpsLogFile::start() {
 
 void OpsLogFile::stop() {
   {
-    std::unique_lock lock(log_mutex);
-    cond_flush.notify_one();
+    std::unique_lock lock(mutex);
+    cond.notify_one();
     stopped = true;
   }
   join();
@@ -418,14 +417,14 @@ OpsLogFile::~OpsLogFile()
 
 int OpsLogFile::log_json(struct req_state* s, bufferlist& bl)
 {
-  std::unique_lock lock(log_mutex);
+  std::unique_lock lock(mutex);
   if (data_size + bl.length() >= max_data_size) {
     ldout(s->cct, 0) << "ERROR: RGW ops log file buffer too full, dropping log for txn: " << s->trans_id << dendl;
     return -1;
   }
   log_buffer.push_back(bl);
   data_size += bl.length();
-  cond_flush.notify_all();
+  cond.notify_all();
   return 0;
 }
 
index 3495ef086290dd8e786694d5fd1ca3f37ff413c2..7bcb62b18579cb90791f8fa61cd1b877c114f467 100644 (file)
@@ -165,11 +165,10 @@ public:
 
 class OpsLogFile : public JsonOpsLogSink, public Thread, public DoutPrefixProvider {
   CephContext* cct;
-  ceph::mutex log_mutex = ceph::make_mutex("OpsLogFile_log");
-  ceph::mutex flush_mutex = ceph::make_mutex("OpsLogFile_flush");
+  ceph::mutex mutex = ceph::make_mutex("OpsLogFile");
   std::vector<bufferlist> log_buffer;
   std::vector<bufferlist> flush_buffer;
-  ceph::condition_variable cond_flush;
+  ceph::condition_variable cond;
   std::ofstream file;
   bool stopped;
   uint64_t data_size;