]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: split is_asio_thread warnings into separate file/function
authorCasey Bodley <cbodley@redhat.com>
Thu, 20 Jun 2024 19:43:36 +0000 (15:43 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 2 Jul 2024 14:36:32 +0000 (10:36 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/CMakeLists.txt
src/rgw/driver/rados/rgw_tools.cc
src/rgw/driver/rados/rgw_tools.h
src/rgw/rgw_appmain.cc
src/rgw/rgw_asio_frontend.cc
src/rgw/rgw_asio_thread.cc [new file with mode: 0644]
src/rgw/rgw_asio_thread.h [new file with mode: 0644]
src/rgw/rgw_common.cc
src/rgw/rgw_http_client.cc

index f91fbaed4308b72a8ad132ee65c381b437319a1d..a8855acceee279ee593caf889ef282617cd261f7 100644 (file)
@@ -63,6 +63,7 @@ set(librgw_common_srcs
   rgw_acl_swift.cc
   rgw_aio.cc
   rgw_aio_throttle.cc
+  rgw_asio_thread.cc
   rgw_auth.cc
   rgw_auth_s3.cc
   rgw_arn.cc
index eec4a799115654a30ccc4a18fc44e9688eb6f83f..0af353b866f833b29fb34fd5205f4cd13738b1d6 100644 (file)
@@ -11,8 +11,8 @@
 #include "rgw_tools.h"
 #include "rgw_acl_s3.h"
 #include "rgw_aio_throttle.h"
+#include "rgw_asio_thread.h"
 #include "rgw_compression.h"
-#include "common/BackTrace.h"
 
 #define dout_subsys ceph_subsys_rgw
 
@@ -212,13 +212,7 @@ int rgw_rados_operate(const DoutPrefixProvider *dpp, librados::IoCtx& ioctx, con
     }
     return -ec.value();
   }
-  // work on asio threads should be asynchronous, so warn when they block
-  if (is_asio_thread) {
-    ldpp_dout(dpp, 20) << "WARNING: blocking librados call" << dendl;
-#ifdef _BACKTRACE_LOGGING
-    ldpp_dout(dpp, 20) << "BACKTRACE: " << __func__ << ": " << ClibBackTrace(0) << dendl;
-#endif
-  }
+  maybe_warn_about_blocking(dpp);
   return ioctx.operate(oid, op, nullptr, flags);
 }
 
@@ -232,12 +226,7 @@ int rgw_rados_operate(const DoutPrefixProvider *dpp, librados::IoCtx& ioctx, con
     librados::async_operate(yield, ioctx, oid, op, flags, trace_info, yield[ec]);
     return -ec.value();
   }
-  if (is_asio_thread) {
-    ldpp_dout(dpp, 20) << "WARNING: blocking librados call" << dendl;
-#ifdef _BACKTRACE_LOGGING
-    ldpp_dout(dpp, 20) << "BACKTRACE: " << __func__ << ": " << ClibBackTrace(0) << dendl;
-#endif
-  }
+  maybe_warn_about_blocking(dpp);
   return ioctx.operate(oid, op, flags, trace_info);
 }
 
@@ -255,12 +244,7 @@ int rgw_rados_notify(const DoutPrefixProvider *dpp, librados::IoCtx& ioctx, cons
     }
     return -ec.value();
   }
-  if (is_asio_thread) {
-    ldpp_dout(dpp, 20) << "WARNING: blocking librados call" << dendl;
-#ifdef _BACKTRACE_LOGGING
-    ldpp_dout(dpp, 20) << "BACKTRACE: " << __func__ << ": " << ClibBackTrace(0) << dendl;
-#endif
-  }
+  maybe_warn_about_blocking(dpp);
   return ioctx.notify2(oid, bl, timeout_ms, pbl);
 }
 
index aa365deb42aab9b9ee581a9cd6f4266eb9a45ded..257e513a9f7c16de539d27ed4bd2a39dafa7e85c 100644 (file)
@@ -90,10 +90,6 @@ const char *rgw_find_mime_by_ext(std::string& ext);
 void rgw_filter_attrset(std::map<std::string, bufferlist>& unfiltered_attrset, const std::string& check_prefix,
                         std::map<std::string, bufferlist> *attrset);
 
-/// indicates whether the current thread is in boost::asio::io_context::run(),
-/// used to log warnings if synchronous librados calls are made
-extern thread_local bool is_asio_thread;
-
 /// perform the rados operation, using the yield context when given
 int rgw_rados_operate(const DoutPrefixProvider *dpp, librados::IoCtx& ioctx, const std::string& oid,
                       librados::ObjectReadOperation *op, bufferlist* pbl,
index 9969811083eff00887469cf1901a02db06542ecd..8273ac1c96b043401fac7d602824931faab833a1 100644 (file)
@@ -26,6 +26,7 @@
 #include "include/str_list.h"
 #include "include/stringify.h"
 #include "rgw_main.h"
+#include "rgw_asio_thread.h"
 #include "rgw_common.h"
 #include "rgw_sal.h"
 #include "rgw_sal_config.h"
index ace3b7aff49e9a4d3424952946ceeb8ff4b8aa0f..788084c59ee8160b5a0728875ef3a9629eabb952 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "rgw_asio_client.h"
 #include "rgw_asio_frontend.h"
+#include "rgw_asio_thread.h"
 
 #ifdef WITH_RADOSGW_BEAST_OPENSSL
 #include <boost/asio/ssl.hpp>
diff --git a/src/rgw/rgw_asio_thread.cc b/src/rgw/rgw_asio_thread.cc
new file mode 100644 (file)
index 0000000..83a805f
--- /dev/null
@@ -0,0 +1,34 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab ft=cpp
+
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright contributors to the Ceph project
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#include "rgw_asio_thread.h"
+
+#include "common/BackTrace.h"
+#include "common/dout.h"
+
+thread_local bool is_asio_thread = false;
+
+void maybe_warn_about_blocking(const DoutPrefixProvider* dpp)
+{
+  // work on asio threads should be asynchronous, so warn when they block
+  if (!is_asio_thread) {
+    return;
+  }
+
+  ldpp_dout(dpp, 20) << "WARNING: blocking librados call" << dendl;
+#ifdef _BACKTRACE_LOGGING
+  ldpp_dout(dpp, 20) << "BACKTRACE: " << ClibBackTrace(0) << dendl;
+#endif
+}
diff --git a/src/rgw/rgw_asio_thread.h b/src/rgw/rgw_asio_thread.h
new file mode 100644 (file)
index 0000000..cafe071
--- /dev/null
@@ -0,0 +1,26 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab ft=cpp
+
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright contributors to the Ceph project
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#pragma once
+
+class DoutPrefixProvider;
+
+/// indicates whether the current thread is in boost::asio::io_context::run(),
+/// used to log warnings if synchronous librados calls are made
+extern thread_local bool is_asio_thread;
+
+/// call when an operation will block the calling thread due to an empty
+/// optional_yield. a warning is logged when is_asio_thread is true
+void maybe_warn_about_blocking(const DoutPrefixProvider* dpp);
index 4c9203093487e5fa2320cae33c2b60d584dcf7ef..987475bf390242665e226aa02f1fd265a9321356 100644 (file)
@@ -175,8 +175,6 @@ rgw_http_errors rgw_http_iam_errors({
 using namespace std;
 using namespace ceph::crypto;
 
-thread_local bool is_asio_thread = false;
-
 rgw_err::
 rgw_err()
 {
index 83a83626db48e7783036db6615754cbc3598dcd3..9f448bfc355a92af19ca4e2019a5acf46acab010 100644 (file)
@@ -9,6 +9,7 @@
 #include <curl/easy.h>
 #include <curl/multi.h>
 
+#include "rgw_asio_thread.h"
 #include "rgw_common.h"
 #include "rgw_http_client.h"
 #include "rgw_http_errors.h"
@@ -82,10 +83,8 @@ struct rgw_http_req_data : public RefCountedObject {
       async_wait(yield.get_executor(), l, yield[ec]);
       return -ec.value();
     }
-    // work on asio threads should be asynchronous, so warn when they block
-    if (is_asio_thread) {
-      dout(20) << "WARNING: blocking http request" << dendl;
-    }
+    maybe_warn_about_blocking(dpp);
+
     cond.wait(l, [this]{return done==true;});
     return ret;
   }