From 7d6c7bf7b28381ff568c46910bd92f60d4d95257 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Thu, 29 Jul 2021 20:05:09 +0200 Subject: [PATCH 1/8] Use XrdSysSemaphore directly, XrdSys::LinuxSemaphore has been removed as glibc version is used for RHEL7. --- Utilities/XrdAdaptor/src/XrdHostHandler.hh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Utilities/XrdAdaptor/src/XrdHostHandler.hh b/Utilities/XrdAdaptor/src/XrdHostHandler.hh index f9546a2437ef3..ae17c02177646 100644 --- a/Utilities/XrdAdaptor/src/XrdHostHandler.hh +++ b/Utilities/XrdAdaptor/src/XrdHostHandler.hh @@ -4,14 +4,6 @@ #include "XrdCl/XrdClXRootDResponses.hh" #include "FWCore/Utilities/interface/get_underlying_safe.h" -#if defined(__linux__) -#define HAVE_ATOMICS 1 -#include "XrdSys/XrdSysLinuxSemaphore.hh" -typedef XrdSys::LinuxSemaphore Semaphore; -#else -typedef XrdSysSemaphore Semaphore; -#endif - /** * The SyncResponseHandler from the XrdCl does not * preserve the hostinfo list, which we would like to @@ -53,7 +45,7 @@ private: edm::propagate_const> pStatus_; edm::propagate_const> pResponse_; edm::propagate_const> pHostList_; - Semaphore sem; + XrdSysSemaphore sem; }; #endif From dba2b6f1a7e42b7e89f60dfbbe3fa69784c3e147 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Fri, 30 Jul 2021 01:45:08 +0200 Subject: [PATCH 2/8] When opening an additional file for multi-source signal intention by appending triedrc=resel to opaque parameter list. --- Utilities/XrdAdaptor/src/XrdRequestManager.cc | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Utilities/XrdAdaptor/src/XrdRequestManager.cc b/Utilities/XrdAdaptor/src/XrdRequestManager.cc index 961d9787a0201..a25ba3c1d3e0c 100644 --- a/Utilities/XrdAdaptor/src/XrdRequestManager.cc +++ b/Utilities/XrdAdaptor/src/XrdRequestManager.cc @@ -552,30 +552,37 @@ std::future RequestManager::handle(std::shared_ptrExcludeID().substr(0, it->ExcludeID().find(':')), true); } for (const auto &it : m_inactiveSources) { - count++; - ss << it->ExcludeID().substr(0, it->ExcludeID().find(':')) << ","; + state.append_tried(it->ExcludeID().substr(0, it->ExcludeID().find(':'))); } } for (const auto &it : m_disabledExcludeStrings) { - count++; - ss << it.substr(0, it.find(':')) << ","; + state.append_tried(it.substr(0, it.find(':'))); } - if (count) { - std::string tmp_str = ss.str(); - return tmp_str.substr(0, tmp_str.size() - 1); + if (state.has_active) { + state.ss << "&triedrc=resel"; } - return ""; + + return state.ss.str(); } void XrdAdaptor::RequestManager::handleOpen(XrdCl::XRootDStatus &status, std::shared_ptr source) { @@ -1019,6 +1026,13 @@ void XrdAdaptor::RequestManager::OpenHandler::HandleResponseWithHosts(XrdCl::XRo ex.addContext("In XrdAdaptor::RequestManager::OpenHandler::HandleResponseWithHosts()"); manager->addConnections(ex); + // Brian, should we do something like this: + // if (status.status == XrdCl::errRedirectLimit) { + // // The following method does not exist (yet), would probaly need a multiplier for OPEN_DELAY. + // // Note that with XCache cluster one will never get multiple sources. + // manager->increaseMultiSourceInterval(); + // } + m_promise.set_exception(std::make_exception_ptr(ex)); } } From 242291840421164780fbfb8e8fc7111d9ffab804 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Fri, 30 Jul 2021 02:10:51 +0200 Subject: [PATCH 3/8] code-format --- Utilities/XrdAdaptor/src/XrdRequestManager.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Utilities/XrdAdaptor/src/XrdRequestManager.cc b/Utilities/XrdAdaptor/src/XrdRequestManager.cc index a25ba3c1d3e0c..3096f14132bce 100644 --- a/Utilities/XrdAdaptor/src/XrdRequestManager.cc +++ b/Utilities/XrdAdaptor/src/XrdRequestManager.cc @@ -555,9 +555,9 @@ std::string RequestManager::prepareOpaqueString() const { struct { std::stringstream ss; size_t count = 0; - bool has_active = false; + bool has_active = false; - void append_tried(const std::string& id, bool active = false) { + void append_tried(const std::string &id, bool active = false) { ss << (count ? "," : "tried=") << id; count++; if (active) { @@ -579,7 +579,7 @@ std::string RequestManager::prepareOpaqueString() const { state.append_tried(it.substr(0, it.find(':'))); } if (state.has_active) { - state.ss << "&triedrc=resel"; + state.ss << "&triedrc=resel"; } return state.ss.str(); From 162097951345a9a8547a7859f44c66d6580a8707 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Thu, 5 Aug 2021 10:04:53 +0200 Subject: [PATCH 4/8] In XrdStorageMaker::stagein() use synchronous call to XrdCl::FileSystem::Prepare() as result is expected right away and related XrdCl objects are allocated on the stack. --- Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc b/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc index f44a98cfe5add..31626f6b7b4f4 100644 --- a/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc +++ b/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc @@ -75,9 +75,11 @@ class XrdStorageMaker final : public StorageMaker { std::string fullpath(proto + ":" + path); XrdCl::URL url(fullpath); XrdCl::FileSystem fs(url); + XrdCl::Buffer *buffer = nullptr; std::vector fileList; fileList.push_back(url.GetPath()); - auto status = fs.Prepare(fileList, XrdCl::PrepareFlags::Stage, 0, &m_null_handler); + auto status = fs.Prepare(fileList, XrdCl::PrepareFlags::Stage, 0, buffer); + delete buffer; if (!status.IsOK()) { edm::LogWarning("StageInError") << "XrdCl::FileSystem::Prepare failed with error '" << status.ToStr() << "' (errNo = " << status.errNo << ")"; From db617bbbf183c30c11df91036106fb8da30e9f6d Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Thu, 5 Aug 2021 11:12:04 +0200 Subject: [PATCH 5/8] Remove unnecessary dependencies to specific XrdCl libs. --- Utilities/XrdAdaptor/BuildFile.xml | 2 -- Utilities/XrdAdaptor/plugins/BuildFile.xml | 1 - 2 files changed, 3 deletions(-) diff --git a/Utilities/XrdAdaptor/BuildFile.xml b/Utilities/XrdAdaptor/BuildFile.xml index 12c3053dadffc..5a0d3c4c56581 100644 --- a/Utilities/XrdAdaptor/BuildFile.xml +++ b/Utilities/XrdAdaptor/BuildFile.xml @@ -5,6 +5,4 @@ - - diff --git a/Utilities/XrdAdaptor/plugins/BuildFile.xml b/Utilities/XrdAdaptor/plugins/BuildFile.xml index a1ed79eeb7e85..d695d5b7a436f 100644 --- a/Utilities/XrdAdaptor/plugins/BuildFile.xml +++ b/Utilities/XrdAdaptor/plugins/BuildFile.xml @@ -1,7 +1,6 @@ - From b067e3d7f5df784b0ba54f92e45bfbc1734fc78e Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Thu, 19 Aug 2021 21:37:45 +0200 Subject: [PATCH 6/8] Revert back to async prepare call, store relevant objects as data members in the handler class. --- .../XrdAdaptor/plugins/XrdStorageMaker.cc | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc b/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc index 31626f6b7b4f4..d6dba8612b5f9 100644 --- a/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc +++ b/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc @@ -16,15 +16,41 @@ #include #include -class MakerResponseHandler : public XrdCl::ResponseHandler { +namespace { + +class PrepareHandler : public XrdCl::ResponseHandler { public: + PrepareHandler(const XrdCl::URL &url) : m_fs(url) { + m_fileList.push_back(url.GetPath()); + } + + void callAsyncPrepare() { + auto status = m_fs.Prepare(m_fileList, XrdCl::PrepareFlags::Stage, 0, this); + if (!status.IsOK()) { + LogDebug("StageInError") << "XrdCl::FileSystem::Prepare submit failed with error '" << status.ToStr() + << "' (errNo = " << status.errNo << ")"; + delete this; + } + } + void HandleResponse(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override { // Note: Prepare call has a response object. + if (!status->IsOK()) { + LogDebug("StageInError") << "XrdCl::FileSystem::Prepare failed with error '" << status->ToStr() + << "' (errNo = " << status->errNo << ")"; + } delete response; delete status; + delete this; } + +private: + XrdCl::FileSystem m_fs; + std::vector m_fileList; }; +} + class XrdStorageMaker final : public StorageMaker { public: static const unsigned int XRD_DEFAULT_TIMEOUT = 3 * 60; @@ -74,16 +100,9 @@ class XrdStorageMaker final : public StorageMaker { std::string fullpath(proto + ":" + path); XrdCl::URL url(fullpath); - XrdCl::FileSystem fs(url); - XrdCl::Buffer *buffer = nullptr; - std::vector fileList; - fileList.push_back(url.GetPath()); - auto status = fs.Prepare(fileList, XrdCl::PrepareFlags::Stage, 0, buffer); - delete buffer; - if (!status.IsOK()) { - edm::LogWarning("StageInError") << "XrdCl::FileSystem::Prepare failed with error '" << status.ToStr() - << "' (errNo = " << status.errNo << ")"; - } + + auto prep_handler = new PrepareHandler(url); + prep_handler->callAsyncPrepare(); } bool check(const std::string &proto, @@ -175,7 +194,6 @@ class XrdStorageMaker final : public StorageMaker { } private: - CMS_THREAD_SAFE mutable MakerResponseHandler m_null_handler; mutable std::mutex m_envMutex; mutable std::atomic m_lastDebugLevel; mutable std::atomic m_lastTimeout; From a2513feb426d9ee03624dda4f2f17ea2e4d63238 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Thu, 19 Aug 2021 21:52:39 +0200 Subject: [PATCH 7/8] Indentation of debug msgs. --- Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc b/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc index d6dba8612b5f9..7fc7edf7447a6 100644 --- a/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc +++ b/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc @@ -28,7 +28,7 @@ class PrepareHandler : public XrdCl::ResponseHandler { auto status = m_fs.Prepare(m_fileList, XrdCl::PrepareFlags::Stage, 0, this); if (!status.IsOK()) { LogDebug("StageInError") << "XrdCl::FileSystem::Prepare submit failed with error '" << status.ToStr() - << "' (errNo = " << status.errNo << ")"; + << "' (errNo = " << status.errNo << ")"; delete this; } } @@ -37,7 +37,7 @@ class PrepareHandler : public XrdCl::ResponseHandler { // Note: Prepare call has a response object. if (!status->IsOK()) { LogDebug("StageInError") << "XrdCl::FileSystem::Prepare failed with error '" << status->ToStr() - << "' (errNo = " << status->errNo << ")"; + << "' (errNo = " << status->errNo << ")"; } delete response; delete status; From 0be2a4991a8f6847f4a531e231813bfbcac31c7f Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Thu, 19 Aug 2021 22:05:14 +0200 Subject: [PATCH 8/8] clang format --- .../XrdAdaptor/plugins/XrdStorageMaker.cc | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc b/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc index 7fc7edf7447a6..e718d4dae3291 100644 --- a/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc +++ b/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc @@ -18,38 +18,36 @@ namespace { -class PrepareHandler : public XrdCl::ResponseHandler { -public: - PrepareHandler(const XrdCl::URL &url) : m_fs(url) { - m_fileList.push_back(url.GetPath()); - } - - void callAsyncPrepare() { - auto status = m_fs.Prepare(m_fileList, XrdCl::PrepareFlags::Stage, 0, this); - if (!status.IsOK()) { - LogDebug("StageInError") << "XrdCl::FileSystem::Prepare submit failed with error '" << status.ToStr() - << "' (errNo = " << status.errNo << ")"; - delete this; + class PrepareHandler : public XrdCl::ResponseHandler { + public: + PrepareHandler(const XrdCl::URL &url) : m_fs(url) { m_fileList.push_back(url.GetPath()); } + + void callAsyncPrepare() { + auto status = m_fs.Prepare(m_fileList, XrdCl::PrepareFlags::Stage, 0, this); + if (!status.IsOK()) { + LogDebug("StageInError") << "XrdCl::FileSystem::Prepare submit failed with error '" << status.ToStr() + << "' (errNo = " << status.errNo << ")"; + delete this; + } } - } - void HandleResponse(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override { - // Note: Prepare call has a response object. - if (!status->IsOK()) { - LogDebug("StageInError") << "XrdCl::FileSystem::Prepare failed with error '" << status->ToStr() - << "' (errNo = " << status->errNo << ")"; + void HandleResponse(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override { + // Note: Prepare call has a response object. + if (!status->IsOK()) { + LogDebug("StageInError") << "XrdCl::FileSystem::Prepare failed with error '" << status->ToStr() + << "' (errNo = " << status->errNo << ")"; + } + delete response; + delete status; + delete this; } - delete response; - delete status; - delete this; - } -private: - XrdCl::FileSystem m_fs; - std::vector m_fileList; -}; + private: + XrdCl::FileSystem m_fs; + std::vector m_fileList; + }; -} +} // namespace class XrdStorageMaker final : public StorageMaker { public: