]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/os/futurized_store.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / crimson / os / futurized_store.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 <string>
7 #include <unordered_map>
8 #include <map>
9 #include <typeinfo>
10 #include <vector>
11
12 #include <seastar/core/future.hh>
13
14 #include "crimson/osd/exceptions.h"
15 #include "include/buffer_fwd.h"
16 #include "include/uuid.h"
17 #include "osd/osd_types.h"
18
19 namespace ceph::os {
20 class Transaction;
21 }
22
23 namespace crimson::os {
24 class FuturizedCollection;
25
26 class FuturizedStore {
27
28 public:
29 static std::unique_ptr<FuturizedStore> create(const std::string& type,
30 const std::string& data,
31 const ConfigValues& values);
32 FuturizedStore() = default;
33 virtual ~FuturizedStore() = default;
34
35 // no copying
36 explicit FuturizedStore(const FuturizedStore& o) = delete;
37 const FuturizedStore& operator=(const FuturizedStore& o) = delete;
38
39 virtual seastar::future<> start() {
40 return seastar::now();
41 }
42 virtual seastar::future<> stop() = 0;
43 virtual seastar::future<> mount() = 0;
44 virtual seastar::future<> umount() = 0;
45
46 virtual seastar::future<> mkfs(uuid_d new_osd_fsid) = 0;
47 virtual seastar::future<store_statfs_t> stat() const = 0;
48
49 using CollectionRef = boost::intrusive_ptr<FuturizedCollection>;
50 using read_errorator = crimson::errorator<crimson::ct_error::enoent,
51 crimson::ct_error::input_output_error>;
52 virtual read_errorator::future<ceph::bufferlist> read(
53 CollectionRef c,
54 const ghobject_t& oid,
55 uint64_t offset,
56 size_t len,
57 uint32_t op_flags = 0) = 0;
58
59 using get_attr_errorator = crimson::errorator<
60 crimson::ct_error::enoent,
61 crimson::ct_error::enodata>;
62 virtual get_attr_errorator::future<ceph::bufferptr> get_attr(
63 CollectionRef c,
64 const ghobject_t& oid,
65 std::string_view name) const = 0;
66
67 using get_attrs_ertr = crimson::errorator<
68 crimson::ct_error::enoent>;
69 using attrs_t = std::map<std::string, ceph::bufferptr, std::less<>>;
70 virtual get_attrs_ertr::future<attrs_t> get_attrs(
71 CollectionRef c,
72 const ghobject_t& oid) = 0;
73
74 using omap_values_t = std::map<std::string, bufferlist, std::less<>>;
75 using omap_keys_t = std::set<std::string>;
76 virtual seastar::future<omap_values_t> omap_get_values(
77 CollectionRef c,
78 const ghobject_t& oid,
79 const omap_keys_t& keys) = 0;
80 virtual seastar::future<std::vector<ghobject_t>, ghobject_t> list_objects(
81 CollectionRef c,
82 const ghobject_t& start,
83 const ghobject_t& end,
84 uint64_t limit) const = 0;
85 virtual seastar::future<bool, omap_values_t> omap_get_values(
86 CollectionRef c, ///< [in] collection
87 const ghobject_t &oid, ///< [in] oid
88 const std::optional<std::string> &start ///< [in] start, empty for begin
89 ) = 0; ///< @return <done, values> values.empty() iff done
90
91 virtual seastar::future<CollectionRef> create_new_collection(const coll_t& cid) = 0;
92 virtual seastar::future<CollectionRef> open_collection(const coll_t& cid) = 0;
93 virtual seastar::future<std::vector<coll_t>> list_collections() = 0;
94
95 virtual seastar::future<> do_transaction(CollectionRef ch,
96 ceph::os::Transaction&& txn) = 0;
97
98 virtual seastar::future<> write_meta(const std::string& key,
99 const std::string& value) = 0;
100 virtual seastar::future<int, std::string> read_meta(const std::string& key) = 0;
101 virtual uuid_d get_fsid() const = 0;
102 virtual unsigned get_max_attr_name_length() const = 0;
103 };
104
105 }