]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/osd/osdmap_gate.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / crimson / osd / osdmap_gate.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #pragma once
5
6 #include <functional>
7 #include <map>
8 #include <optional>
9
10 #include <seastar/core/future.hh>
11 #include <seastar/core/shared_future.hh>
12
13 #include "include/types.h"
14 #include "crimson/osd/osd_operation.h"
15
16 namespace ceph {
17 class Formatter;
18 }
19
20 namespace crimson::osd {
21
22 class ShardServices;
23
24 class OSDMapGate {
25 struct OSDMapBlocker : public Blocker {
26 const char * type_name;
27 epoch_t epoch;
28
29 OSDMapBlocker(std::pair<const char *, epoch_t> args)
30 : type_name(args.first), epoch(args.second) {}
31
32 OSDMapBlocker(const OSDMapBlocker &) = delete;
33 OSDMapBlocker(OSDMapBlocker &&) = delete;
34 OSDMapBlocker &operator=(const OSDMapBlocker &) = delete;
35 OSDMapBlocker &operator=(OSDMapBlocker &&) = delete;
36
37 seastar::shared_promise<epoch_t> promise;
38
39 void dump_detail(Formatter *f) const final;
40 private:
41 const char *get_type_name() const final {
42 return type_name;
43 }
44 };
45
46 // order the promises in ascending order of the waited osdmap epoch,
47 // so we can access all the waiters expecting a map whose epoch is less
48 // than or equal to a given epoch
49 using waiting_peering_t = std::map<epoch_t,
50 OSDMapBlocker>;
51 const char *blocker_type;
52 waiting_peering_t waiting_peering;
53 epoch_t current = 0;
54 std::optional<std::reference_wrapper<ShardServices>> shard_services;
55 bool stopping = false;
56 public:
57 OSDMapGate(
58 const char *blocker_type,
59 std::optional<std::reference_wrapper<ShardServices>> shard_services)
60 : blocker_type(blocker_type), shard_services(shard_services) {}
61
62 // wait for an osdmap whose epoch is greater or equal to given epoch
63 blocking_future<epoch_t> wait_for_map(epoch_t epoch);
64 void got_map(epoch_t epoch);
65 seastar::future<> stop();
66 };
67
68 }