]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/osd/osd_operations/internal_client_request.cc
e71804d88ea718f58ff48cf0b1230ff55b376bf4
[ceph.git] / ceph / src / crimson / osd / osd_operations / internal_client_request.cc
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
8 namespace {
9 seastar::logger& logger() {
10 return crimson::get_logger(ceph_subsys_osd);
11 }
12 }
13
14 namespace crimson {
15 template <>
16 struct EventBackendRegistry<osd::InternalClientRequest> {
17 static std::tuple<> get_backends() {
18 return {};
19 }
20 };
21 }
22
23
24 namespace crimson::osd {
25
26 InternalClientRequest::InternalClientRequest(Ref<PG> pg)
27 : pg(std::move(pg))
28 {
29 assert(bool(this->pg));
30 assert(this->pg->is_primary());
31 }
32
33 InternalClientRequest::~InternalClientRequest()
34 {
35 logger().debug("{}: destroying", *this);
36 }
37
38 void InternalClientRequest::print(std::ostream &) const
39 {
40 }
41
42 void InternalClientRequest::dump_detail(Formatter *f) const
43 {
44 }
45
46 CommonPGPipeline& InternalClientRequest::pp()
47 {
48 return pg->request_pg_pipeline;
49 }
50
51 seastar::future<> InternalClientRequest::start()
52 {
53 track_event<StartEvent>();
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 {
58 return enter_stage<interruptor>(
59 pp().wait_for_active
60 ).then_interruptible([this] {
61 return with_blocking_event<PGActivationBlocker::BlockingEvent,
62 interruptor>([this] (auto&& trigger) {
63 return pg->wait_for_active_blocker.wait(std::move(trigger));
64 });
65 }).then_interruptible([this] {
66 return enter_stage<interruptor>(
67 pp().recover_missing);
68 }).then_interruptible([this] {
69 return do_recover_missing(pg, get_target_oid());
70 }).then_interruptible([this] {
71 return enter_stage<interruptor>(
72 pp().get_obc);
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) {
84 return enter_stage<interruptor>(pp().process).then_interruptible(
85 [obc=std::move(obc), &osd_ops, this] {
86 return pg->do_osd_ops(
87 std::move(obc),
88 osd_ops,
89 std::as_const(op_info),
90 get_do_osd_ops_params(),
91 [] {
92 return PG::do_osd_ops_iertr::now();
93 },
94 [] (const std::error_code& e) {
95 return PG::do_osd_ops_iertr::now();
96 }
97 ).safe_then_unpack_interruptible(
98 [](auto submitted, auto all_completed) {
99 return all_completed.handle_error_interruptible(
100 crimson::ct_error::eagain::handle([] {
101 return seastar::now();
102 }));
103 }, crimson::ct_error::eagain::handle([] {
104 return interruptor::now();
105 })
106 );
107 });
108 });
109 });
110 }).handle_error_interruptible(PG::load_obc_ertr::all_same_way([] {
111 return seastar::now();
112 })).then_interruptible([] {
113 return seastar::stop_iteration::yes;
114 });
115 }, [this](std::exception_ptr eptr) {
116 if (should_abort_request(*this, std::move(eptr))) {
117 return seastar::stop_iteration::yes;
118 } else {
119 return seastar::stop_iteration::no;
120 }
121 }, pg);
122 }).then([this] {
123 track_event<CompletionEvent>();
124 });
125 });
126 }
127
128 } // namespace crimson::osd
129