diff options
author | Casey Bodley <cbodley@redhat.com> | 2024-06-20 21:43:36 +0200 |
---|---|---|
committer | Casey Bodley <cbodley@redhat.com> | 2024-07-02 16:36:32 +0200 |
commit | 94fbf6b2f16f64a4e8d8b348498148cdb9c30591 (patch) | |
tree | 773cac99fac7963811972dc53a2973167f0739af | |
parent | rgw: pass DoutPrefixProvider into RGWHTTPClient (diff) | |
download | ceph-94fbf6b2f16f64a4e8d8b348498148cdb9c30591.tar.xz ceph-94fbf6b2f16f64a4e8d8b348498148cdb9c30591.zip |
rgw: split is_asio_thread warnings into separate file/function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
-rw-r--r-- | src/rgw/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/rgw/driver/rados/rgw_tools.cc | 24 | ||||
-rw-r--r-- | src/rgw/driver/rados/rgw_tools.h | 4 | ||||
-rw-r--r-- | src/rgw/rgw_appmain.cc | 1 | ||||
-rw-r--r-- | src/rgw/rgw_asio_frontend.cc | 1 | ||||
-rw-r--r-- | src/rgw/rgw_asio_thread.cc | 34 | ||||
-rw-r--r-- | src/rgw/rgw_asio_thread.h | 26 | ||||
-rw-r--r-- | src/rgw/rgw_common.cc | 2 | ||||
-rw-r--r-- | src/rgw/rgw_http_client.cc | 7 |
9 files changed, 70 insertions, 30 deletions
diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index f91fbaed430..a8855acceee 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -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 diff --git a/src/rgw/driver/rados/rgw_tools.cc b/src/rgw/driver/rados/rgw_tools.cc index eec4a799115..0af353b866f 100644 --- a/src/rgw/driver/rados/rgw_tools.cc +++ b/src/rgw/driver/rados/rgw_tools.cc @@ -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); } diff --git a/src/rgw/driver/rados/rgw_tools.h b/src/rgw/driver/rados/rgw_tools.h index aa365deb42a..257e513a9f7 100644 --- a/src/rgw/driver/rados/rgw_tools.h +++ b/src/rgw/driver/rados/rgw_tools.h @@ -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, diff --git a/src/rgw/rgw_appmain.cc b/src/rgw/rgw_appmain.cc index 9969811083e..8273ac1c96b 100644 --- a/src/rgw/rgw_appmain.cc +++ b/src/rgw/rgw_appmain.cc @@ -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" diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index ace3b7aff49..788084c59ee 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -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 index 00000000000..83a805fb409 --- /dev/null +++ b/src/rgw/rgw_asio_thread.cc @@ -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 index 00000000000..cafe071fdc0 --- /dev/null +++ b/src/rgw/rgw_asio_thread.h @@ -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); diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 4c920309348..987475bf390 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -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() { diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index 83a83626db4..9f448bfc355 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -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; } |