From b5efdc6f1c9563357d7dfd33a8f379053592a215 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Wed, 12 May 2021 16:02:29 +0000 Subject: [PATCH] crimson/osd: unify the interruption handling between {Internal,}ClientRequest. Signed-off-by: Radoslaw Zarzynski --- .../osd/osd_operations/client_request.cc | 28 ++++--------------- .../osd_operations/client_request_common.cc | 24 ++++++++++++++++ .../osd_operations/client_request_common.h | 2 ++ .../osd_operations/internal_client_request.cc | 24 ++++------------ 4 files changed, 37 insertions(+), 41 deletions(-) diff --git a/src/crimson/osd/osd_operations/client_request.cc b/src/crimson/osd/osd_operations/client_request.cc index 426b7bbdf14f6..d178256e4d53a 100644 --- a/src/crimson/osd/osd_operations/client_request.cc +++ b/src/crimson/osd/osd_operations/client_request.cc @@ -122,28 +122,12 @@ seastar::future<> ClientRequest::start() sequencer.finish_op(get_id()); return seastar::stop_iteration::yes; }); - }, [this, pgref](std::exception_ptr eptr) mutable { - if (*eptr.__cxa_exception_type() == - typeid(::crimson::common::actingset_changed)) { - try { - std::rethrow_exception(eptr); - } catch(::crimson::common::actingset_changed& e) { - if (e.is_primary()) { - logger().debug("{} operation restart, acting set changed", *this); - sequencer.maybe_reset(get_id()); - return seastar::stop_iteration::no; - } else { - logger().debug("{} operation abort, up primary changed", *this); - sequencer.abort(); - return seastar::stop_iteration::yes; - } - } - } - assert(*eptr.__cxa_exception_type() == - typeid(crimson::common::system_shutdown_exception)); - crimson::get_logger(ceph_subsys_osd).debug( - "{} operation skipped, system shutdown", *this); - return seastar::stop_iteration::yes; + }, [this, pgref](std::exception_ptr eptr) { + if (should_abort_request(std::move(eptr))) { + return seastar::stop_iteration::yes; + } else { + return seastar::stop_iteration::no; + } }, pgref); }); }); diff --git a/src/crimson/osd/osd_operations/client_request_common.cc b/src/crimson/osd/osd_operations/client_request_common.cc index b39b2465a2d2b..37e12845b203d 100644 --- a/src/crimson/osd/osd_operations/client_request_common.cc +++ b/src/crimson/osd/osd_operations/client_request_common.cc @@ -33,4 +33,28 @@ CommonClientRequest::do_recover_missing( } } +bool CommonClientRequest::should_abort_request(std::exception_ptr eptr) +{ + if (*eptr.__cxa_exception_type() == + typeid(::crimson::common::actingset_changed)) { + try { + std::rethrow_exception(eptr); + } catch(::crimson::common::actingset_changed& e) { + if (e.is_primary()) { + logger().debug("{} operation restart, acting set changed", __func__); + return false; + } else { + logger().debug("{} operation abort, up primary changed", __func__); + return true; + } + } + } else { + assert(*eptr.__cxa_exception_type() == + typeid(crimson::common::system_shutdown_exception)); + crimson::get_logger(ceph_subsys_osd).debug( + "{} operation skipped, system shutdown", __func__); + return true; + } +} + } // namespace crimson::osd diff --git a/src/crimson/osd/osd_operations/client_request_common.h b/src/crimson/osd/osd_operations/client_request_common.h index bf826d847f730..d3b4c0b5218af 100644 --- a/src/crimson/osd/osd_operations/client_request_common.h +++ b/src/crimson/osd/osd_operations/client_request_common.h @@ -11,6 +11,8 @@ namespace crimson::osd { struct CommonClientRequest { static InterruptibleOperation::template interruptible_future<> do_recover_missing(Ref& pg, const hobject_t& soid); + + static bool should_abort_request(std::exception_ptr eptr); }; } // namespace crimson::osd diff --git a/src/crimson/osd/osd_operations/internal_client_request.cc b/src/crimson/osd/osd_operations/internal_client_request.cc index c2942fb505c37..9ea028f2e4dd5 100644 --- a/src/crimson/osd/osd_operations/internal_client_request.cc +++ b/src/crimson/osd/osd_operations/internal_client_request.cc @@ -97,26 +97,12 @@ seastar::future<> InternalClientRequest::start() }); }); }); - }, [this](std::exception_ptr eptr) mutable { - if (*eptr.__cxa_exception_type() == - typeid(::crimson::common::actingset_changed)) { - try { - std::rethrow_exception(eptr); - } catch(::crimson::common::actingset_changed& e) { - if (e.is_primary()) { - logger().debug("{} operation restart, acting set changed", *this); - return seastar::stop_iteration::no; - } else { - logger().debug("{} operation abort, up primary changed", *this); - return seastar::stop_iteration::yes; - } - } + }, [this](std::exception_ptr eptr) { + if (should_abort_request(std::move(eptr))) { + return seastar::stop_iteration::yes; + } else { + return seastar::stop_iteration::no; } - assert(*eptr.__cxa_exception_type() == - typeid(crimson::common::system_shutdown_exception)); - crimson::get_logger(ceph_subsys_osd).debug( - "{} operation skipped, system shutdown", *this); - return seastar::stop_iteration::yes; }, pg); }); }); -- 2.39.5