1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include <string>
#include <map>
#include <optional>
#include <vector>
#include <seastar/core/future.hh>
#include "os/Transaction.h"
#include "crimson/common/smp_helpers.h"
#include "crimson/common/smp_helpers.h"
#include "crimson/osd/exceptions.h"
#include "include/buffer_fwd.h"
#include "include/uuid.h"
#include "osd/osd_types.h"
namespace ceph::os {
class Transaction;
}
namespace crimson::os {
class FuturizedCollection;
class FuturizedStore {
public:
class Shard {
public:
Shard() = default;
virtual ~Shard() = default;
// no copying
explicit Shard(const Shard& o) = delete;
const Shard& operator=(const Shard& o) = delete;
using CollectionRef = boost::intrusive_ptr<FuturizedCollection>;
using base_errorator = crimson::errorator<crimson::ct_error::input_output_error>;
using read_errorator = crimson::errorator<crimson::ct_error::enoent,
crimson::ct_error::input_output_error>;
virtual read_errorator::future<ceph::bufferlist> read(
CollectionRef c,
const ghobject_t& oid,
uint64_t offset,
size_t len,
uint32_t op_flags = 0) = 0;
virtual read_errorator::future<ceph::bufferlist> readv(
CollectionRef c,
const ghobject_t& oid,
interval_set<uint64_t>& m,
uint32_t op_flags = 0) = 0;
virtual base_errorator::future<bool> exists(
CollectionRef c,
const ghobject_t& oid) = 0;
using get_attr_errorator = crimson::errorator<
crimson::ct_error::enoent,
crimson::ct_error::enodata>;
virtual get_attr_errorator::future<ceph::bufferlist> get_attr(
CollectionRef c,
const ghobject_t& oid,
std::string_view name) const = 0;
using get_attrs_ertr = crimson::errorator<
crimson::ct_error::enoent>;
using attrs_t = std::map<std::string, ceph::bufferlist, std::less<>>;
virtual get_attrs_ertr::future<attrs_t> get_attrs(
CollectionRef c,
const ghobject_t& oid) = 0;
virtual seastar::future<struct stat> stat(
CollectionRef c,
const ghobject_t& oid) = 0;
using omap_values_t = attrs_t;
using omap_keys_t = std::set<std::string>;
virtual read_errorator::future<omap_values_t> omap_get_values(
CollectionRef c,
const ghobject_t& oid,
const omap_keys_t& keys) = 0;
using omap_values_paged_t = std::tuple<bool, omap_values_t>;
virtual read_errorator::future<omap_values_paged_t> omap_get_values(
CollectionRef c, ///< [in] collection
const ghobject_t &oid, ///< [in] oid
const std::optional<std::string> &start ///< [in] start, empty for begin
) = 0; ///< @return <done, values> values.empty() only if done
virtual get_attr_errorator::future<bufferlist> omap_get_header(
CollectionRef c,
const ghobject_t& oid) = 0;
virtual seastar::future<std::tuple<std::vector<ghobject_t>, ghobject_t>> list_objects(
CollectionRef c,
const ghobject_t& start,
const ghobject_t& end,
uint64_t limit) const = 0;
virtual seastar::future<CollectionRef> create_new_collection(const coll_t& cid) = 0;
virtual seastar::future<CollectionRef> open_collection(const coll_t& cid) = 0;
virtual seastar::future<> set_collection_opts(CollectionRef c,
const pool_opts_t& opts) = 0;
protected:
virtual seastar::future<> do_transaction_no_callbacks(
CollectionRef ch,
ceph::os::Transaction&& txn) = 0;
public:
seastar::future<> do_transaction(
CollectionRef ch,
ceph::os::Transaction&& txn) {
std::unique_ptr<Context> on_commit(
ceph::os::Transaction::collect_all_contexts(txn));
return do_transaction_no_callbacks(
std::move(ch), std::move(txn)
).then([on_commit=std::move(on_commit)]() mutable {
auto c = on_commit.release();
if (c) c->complete(0);
return seastar::now();
});
}
/**
* flush
*
* Flushes outstanding transactions on ch, returned future resolves
* after any previously submitted transactions on ch have committed.
*
* @param ch [in] collection on which to flush
*/
virtual seastar::future<> flush(CollectionRef ch) {
return do_transaction(ch, ceph::os::Transaction{});
}
// error injection
virtual seastar::future<> inject_data_error(const ghobject_t& o) {
return seastar::now();
}
virtual seastar::future<> inject_mdata_error(const ghobject_t& o) {
return seastar::now();
}
using fiemap_ret_t = std::map<uint64_t, uint64_t>;
virtual read_errorator::future<fiemap_ret_t> fiemap(
CollectionRef ch,
const ghobject_t& oid,
uint64_t off,
uint64_t len) = 0;
virtual unsigned get_max_attr_name_length() const = 0;
};
public:
static std::unique_ptr<FuturizedStore> create(const std::string& type,
const std::string& data,
const ConfigValues& values);
FuturizedStore()
: primary_core(seastar::this_shard_id())
{}
virtual ~FuturizedStore() = default;
// no copying
explicit FuturizedStore(const FuturizedStore& o) = delete;
const FuturizedStore& operator=(const FuturizedStore& o) = delete;
virtual seastar::future<> start() = 0;
virtual seastar::future<> stop() = 0;
using mount_ertr = crimson::errorator<crimson::stateful_ec>;
virtual mount_ertr::future<> mount() = 0;
virtual seastar::future<> umount() = 0;
using mkfs_ertr = crimson::errorator<crimson::stateful_ec>;
virtual mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) = 0;
virtual seastar::future<store_statfs_t> stat() const = 0;
virtual seastar::future<store_statfs_t> pool_statfs(int64_t pool_id) const = 0;
virtual seastar::future<> report_stats() { return seastar::now(); }
virtual uuid_d get_fsid() const = 0;
virtual seastar::future<> write_meta(const std::string& key,
const std::string& value) = 0;
// called on the shard and get this FuturizedStore::shard;
virtual Shard& get_sharded_store() = 0;
virtual seastar::future<std::tuple<int, std::string>> read_meta(
const std::string& key) = 0;
using coll_core_t = std::pair<coll_t, core_id_t>;
virtual seastar::future<std::vector<coll_core_t>> list_collections() = 0;
protected:
const core_id_t primary_core;
};
}
|