]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
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 <optional> | |
13 | #include <seastar/core/future.hh> | |
14 | #include <seastar/core/future-util.hh> | |
15 | ||
16 | #include "osd/osd_types.h" | |
17 | #include "include/uuid.h" | |
18 | ||
f67539c2 | 19 | #include "crimson/os/cyanstore/cyan_object.h" |
9f95a23c TL |
20 | #include "crimson/os/futurized_store.h" |
21 | ||
22 | namespace ceph::os { | |
23 | class Transaction; | |
24 | } | |
25 | ||
26 | namespace crimson::os { | |
27 | class Collection; | |
28 | ||
29 | class CyanStore final : public FuturizedStore { | |
30 | constexpr static unsigned MAX_KEYS_PER_OMAP_GET_CALL = 32; | |
31 | ||
32 | const std::string path; | |
33 | std::unordered_map<coll_t, boost::intrusive_ptr<Collection>> coll_map; | |
34 | std::map<coll_t, boost::intrusive_ptr<Collection>> new_coll_map; | |
35 | uint64_t used_bytes = 0; | |
36 | uuid_d osd_fsid; | |
37 | ||
38 | public: | |
f67539c2 TL |
39 | class CyanOmapIterator final : public OmapIterator { |
40 | public: | |
41 | CyanOmapIterator() {} | |
42 | CyanOmapIterator(ObjectRef obj) : obj(obj) { | |
43 | iter = obj->omap.begin(); | |
44 | } | |
45 | seastar::future<> seek_to_first() final; | |
46 | seastar::future<> upper_bound(const std::string &after) final; | |
47 | seastar::future<> lower_bound(const std::string &to) final; | |
48 | bool valid() const final; | |
49 | seastar::future<> next() final; | |
50 | std::string key() final { | |
51 | return iter->first; | |
52 | } | |
f67539c2 TL |
53 | virtual ceph::buffer::list value() { |
54 | return iter->second; | |
55 | } | |
56 | virtual int status() const { | |
57 | return iter != obj->omap.end() ? 0 : -1; | |
58 | } | |
59 | virtual ~CyanOmapIterator() {} | |
60 | private: | |
61 | std::map<std::string, bufferlist>::const_iterator iter; | |
62 | ObjectRef obj; | |
63 | }; | |
9f95a23c TL |
64 | |
65 | CyanStore(const std::string& path); | |
66 | ~CyanStore() final; | |
67 | ||
f67539c2 TL |
68 | seastar::future<> stop() final { |
69 | return seastar::now(); | |
70 | } | |
20effc67 | 71 | mount_ertr::future<> mount() final; |
9f95a23c TL |
72 | seastar::future<> umount() final; |
73 | ||
20effc67 | 74 | mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final; |
9f95a23c | 75 | seastar::future<store_statfs_t> stat() const final; |
f67539c2 TL |
76 | seastar::future<struct stat> stat( |
77 | CollectionRef c, | |
78 | const ghobject_t& oid) final; | |
9f95a23c TL |
79 | |
80 | read_errorator::future<ceph::bufferlist> read( | |
81 | CollectionRef c, | |
82 | const ghobject_t& oid, | |
83 | uint64_t offset, | |
84 | size_t len, | |
85 | uint32_t op_flags = 0) final; | |
f67539c2 TL |
86 | read_errorator::future<ceph::bufferlist> readv( |
87 | CollectionRef c, | |
88 | const ghobject_t& oid, | |
89 | interval_set<uint64_t>& m, | |
90 | uint32_t op_flags = 0) final; | |
91 | ||
20effc67 | 92 | get_attr_errorator::future<ceph::bufferlist> get_attr( |
9f95a23c TL |
93 | CollectionRef c, |
94 | const ghobject_t& oid, | |
95 | std::string_view name) const final; | |
96 | get_attrs_ertr::future<attrs_t> get_attrs( | |
97 | CollectionRef c, | |
98 | const ghobject_t& oid); | |
99 | ||
f67539c2 | 100 | read_errorator::future<omap_values_t> omap_get_values( |
9f95a23c TL |
101 | CollectionRef c, |
102 | const ghobject_t& oid, | |
103 | const omap_keys_t& keys) final; | |
104 | ||
9f95a23c | 105 | /// Retrieves paged set of values > start (if present) |
f67539c2 | 106 | read_errorator::future<std::tuple<bool, omap_values_t>> omap_get_values( |
9f95a23c TL |
107 | CollectionRef c, ///< [in] collection |
108 | const ghobject_t &oid, ///< [in] oid | |
109 | const std::optional<std::string> &start ///< [in] start, empty for begin | |
110 | ) final; ///< @return <done, values> values.empty() iff done | |
111 | ||
f67539c2 TL |
112 | seastar::future<std::tuple<std::vector<ghobject_t>, ghobject_t>> list_objects( |
113 | CollectionRef c, | |
114 | const ghobject_t& start, | |
115 | const ghobject_t& end, | |
116 | uint64_t limit) const final; | |
117 | ||
118 | read_errorator::future<ceph::bufferlist> omap_get_header( | |
119 | CollectionRef c, | |
120 | const ghobject_t& oid) final; | |
121 | ||
9f95a23c TL |
122 | seastar::future<CollectionRef> create_new_collection(const coll_t& cid) final; |
123 | seastar::future<CollectionRef> open_collection(const coll_t& cid) final; | |
124 | seastar::future<std::vector<coll_t>> list_collections() final; | |
125 | ||
126 | seastar::future<> do_transaction(CollectionRef ch, | |
127 | ceph::os::Transaction&& txn) final; | |
128 | ||
129 | seastar::future<> write_meta(const std::string& key, | |
130 | const std::string& value) final; | |
f67539c2 TL |
131 | seastar::future<std::tuple<int, std::string>> |
132 | read_meta(const std::string& key) final; | |
9f95a23c TL |
133 | uuid_d get_fsid() const final; |
134 | unsigned get_max_attr_name_length() const final; | |
135 | ||
f67539c2 TL |
136 | seastar::future<OmapIteratorRef> get_omap_iterator( |
137 | CollectionRef c, | |
138 | const ghobject_t& oid); | |
139 | ||
140 | seastar::future<std::map<uint64_t, uint64_t>> fiemap(CollectionRef c, | |
141 | const ghobject_t& oid, | |
142 | uint64_t off, | |
143 | uint64_t len); | |
144 | ||
9f95a23c TL |
145 | private: |
146 | int _remove(const coll_t& cid, const ghobject_t& oid); | |
147 | int _touch(const coll_t& cid, const ghobject_t& oid); | |
148 | int _write(const coll_t& cid, const ghobject_t& oid, | |
149 | uint64_t offset, size_t len, const ceph::bufferlist& bl, | |
150 | uint32_t fadvise_flags); | |
f67539c2 TL |
151 | int _zero(const coll_t& cid, const ghobject_t& oid, |
152 | uint64_t offset, size_t len); | |
153 | int _omap_clear( | |
154 | const coll_t& cid, | |
155 | const ghobject_t& oid); | |
9f95a23c TL |
156 | int _omap_set_values( |
157 | const coll_t& cid, | |
158 | const ghobject_t& oid, | |
159 | std::map<std::string, ceph::bufferlist> &&aset); | |
160 | int _omap_set_header( | |
161 | const coll_t& cid, | |
162 | const ghobject_t& oid, | |
163 | const ceph::bufferlist &header); | |
164 | int _omap_rmkeys( | |
165 | const coll_t& cid, | |
166 | const ghobject_t& oid, | |
167 | const omap_keys_t& aset); | |
168 | int _omap_rmkeyrange( | |
169 | const coll_t& cid, | |
170 | const ghobject_t& oid, | |
171 | const std::string &first, | |
172 | const std::string &last); | |
173 | int _truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size); | |
174 | int _setattrs(const coll_t& cid, const ghobject_t& oid, | |
20effc67 | 175 | std::map<std::string,bufferlist>&& aset); |
f67539c2 | 176 | int _rm_attr(const coll_t& cid, const ghobject_t& oid, |
20effc67 TL |
177 | std::string_view name); |
178 | int _rm_attrs(const coll_t& cid, const ghobject_t& oid); | |
9f95a23c TL |
179 | int _create_collection(const coll_t& cid, int bits); |
180 | boost::intrusive_ptr<Collection> _get_collection(const coll_t& cid); | |
181 | }; | |
182 | ||
183 | } |