]> git.proxmox.com Git - ceph.git/blame - ceph/src/crimson/osd/osd_operations/internal_client_request.cc
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / crimson / osd / osd_operations / internal_client_request.cc
CommitLineData
20effc67
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
2// vim: ts=8 sw=2 smarttab expandtab
3
4#include <seastar/core/future.hh>
5
6#include "crimson/osd/osd_operations/internal_client_request.h"
7
8namespace {
9 seastar::logger& logger() {
10 return crimson::get_logger(ceph_subsys_osd);
11 }
12}
13
1e59de90
TL
14namespace crimson {
15 template <>
16 struct EventBackendRegistry<osd::InternalClientRequest> {
17 static std::tuple<> get_backends() {
18 return {};
19 }
20 };
21}
22
23
20effc67
TL
24namespace crimson::osd {
25
26InternalClientRequest::InternalClientRequest(Ref<PG> pg)
27 : pg(std::move(pg))
28{
29 assert(bool(this->pg));
1e59de90 30 assert(this->pg->is_primary());
20effc67
TL
31}
32
33InternalClientRequest::~InternalClientRequest()
34{
35 logger().debug("{}: destroying", *this);
36}
37
38void InternalClientRequest::print(std::ostream &) const
39{
40}
41
42void InternalClientRequest::dump_detail(Formatter *f) const
43{
44}
45
aee94f69 46CommonPGPipeline& InternalClientRequest::client_pp()
20effc67 47{
1e59de90 48 return pg->request_pg_pipeline;
20effc67
TL
49}
50
51seastar::future<> InternalClientRequest::start()
52{
1e59de90 53 track_event<StartEvent>();
20effc67
TL
54 return crimson::common::handle_system_shutdown([this] {
55 return seastar::repeat([this] {
56 logger().debug("{}: in repeat", *this);
57 return interruptor::with_interruption([this]() mutable {
1e59de90 58 return enter_stage<interruptor>(
aee94f69 59 client_pp().wait_for_active
20effc67 60 ).then_interruptible([this] {
1e59de90
TL
61 return with_blocking_event<PGActivationBlocker::BlockingEvent,
62 interruptor>([this] (auto&& trigger) {
63 return pg->wait_for_active_blocker.wait(std::move(trigger));
64 });
20effc67 65 }).then_interruptible([this] {
1e59de90 66 return enter_stage<interruptor>(
aee94f69 67 client_pp().recover_missing);
1e59de90
TL
68 }).then_interruptible([this] {
69 return do_recover_missing(pg, get_target_oid());
70 }).then_interruptible([this] {
71 return enter_stage<interruptor>(
aee94f69 72 client_pp().get_obc);
1e59de90
TL
73 }).then_interruptible([this] () -> PG::load_obc_iertr::future<> {
74 logger().debug("{}: getting obc lock", *this);
75 return seastar::do_with(create_osd_ops(),
76 [this](auto& osd_ops) mutable {
77 logger().debug("InternalClientRequest: got {} OSDOps to execute",
78 std::size(osd_ops));
79 [[maybe_unused]] const int ret = op_info.set_from_op(
80 std::as_const(osd_ops), pg->get_pgid().pgid, *pg->get_osdmap());
81 assert(ret == 0);
82 return pg->with_locked_obc(get_target_oid(), op_info,
83 [&osd_ops, this](auto obc) {
aee94f69
TL
84 return enter_stage<interruptor>(client_pp().process
85 ).then_interruptible(
1e59de90
TL
86 [obc=std::move(obc), &osd_ops, this] {
87 return pg->do_osd_ops(
88 std::move(obc),
89 osd_ops,
90 std::as_const(op_info),
91 get_do_osd_ops_params(),
92 [] {
93 return PG::do_osd_ops_iertr::now();
94 },
95 [] (const std::error_code& e) {
96 return PG::do_osd_ops_iertr::now();
97 }
98 ).safe_then_unpack_interruptible(
99 [](auto submitted, auto all_completed) {
100 return all_completed.handle_error_interruptible(
101 crimson::ct_error::eagain::handle([] {
102 return seastar::now();
103 }));
104 }, crimson::ct_error::eagain::handle([] {
105 return interruptor::now();
106 })
107 );
20effc67 108 });
20effc67
TL
109 });
110 });
1e59de90
TL
111 }).handle_error_interruptible(PG::load_obc_ertr::all_same_way([] {
112 return seastar::now();
113 })).then_interruptible([] {
114 return seastar::stop_iteration::yes;
20effc67
TL
115 });
116 }, [this](std::exception_ptr eptr) {
117 if (should_abort_request(*this, std::move(eptr))) {
118 return seastar::stop_iteration::yes;
119 } else {
120 return seastar::stop_iteration::no;
121 }
122 }, pg);
1e59de90
TL
123 }).then([this] {
124 track_event<CompletionEvent>();
20effc67
TL
125 });
126 });
127}
128
129} // namespace crimson::osd
130