1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
7 #include <unordered_map>
13 #include <seastar/core/future.hh>
14 #include <seastar/core/future-util.hh>
16 #include "osd/osd_types.h"
17 #include "include/uuid.h"
19 #include "crimson/os/cyanstore/cyan_object.h"
20 #include "crimson/os/futurized_store.h"
26 namespace crimson::os
{
29 class CyanStore final
: public FuturizedStore
{
30 constexpr static unsigned MAX_KEYS_PER_OMAP_GET_CALL
= 32;
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;
39 class CyanOmapIterator final
: public OmapIterator
{
42 CyanOmapIterator(ObjectRef obj
) : obj(obj
) {
43 iter
= obj
->omap
.begin();
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
{
53 virtual ceph::buffer::list
value() {
56 virtual int status() const {
57 return iter
!= obj
->omap
.end() ? 0 : -1;
59 virtual ~CyanOmapIterator() {}
61 std::map
<std::string
, bufferlist
>::const_iterator iter
;
65 CyanStore(const std::string
& path
);
68 seastar::future
<> stop() final
{
69 return seastar::now();
71 mount_ertr::future
<> mount() final
;
72 seastar::future
<> umount() final
;
74 mkfs_ertr::future
<> mkfs(uuid_d new_osd_fsid
) final
;
75 seastar::future
<store_statfs_t
> stat() const final
;
76 seastar::future
<struct stat
> stat(
78 const ghobject_t
& oid
) final
;
80 read_errorator::future
<ceph::bufferlist
> read(
82 const ghobject_t
& oid
,
85 uint32_t op_flags
= 0) final
;
86 read_errorator::future
<ceph::bufferlist
> readv(
88 const ghobject_t
& oid
,
89 interval_set
<uint64_t>& m
,
90 uint32_t op_flags
= 0) final
;
92 get_attr_errorator::future
<ceph::bufferlist
> get_attr(
94 const ghobject_t
& oid
,
95 std::string_view name
) const final
;
96 get_attrs_ertr::future
<attrs_t
> get_attrs(
98 const ghobject_t
& oid
);
100 read_errorator::future
<omap_values_t
> omap_get_values(
102 const ghobject_t
& oid
,
103 const omap_keys_t
& keys
) final
;
105 /// Retrieves paged set of values > start (if present)
106 read_errorator::future
<std::tuple
<bool, omap_values_t
>> omap_get_values(
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
112 seastar::future
<std::tuple
<std::vector
<ghobject_t
>, ghobject_t
>> list_objects(
114 const ghobject_t
& start
,
115 const ghobject_t
& end
,
116 uint64_t limit
) const final
;
118 read_errorator::future
<ceph::bufferlist
> omap_get_header(
120 const ghobject_t
& oid
) final
;
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
;
126 seastar::future
<> do_transaction(CollectionRef ch
,
127 ceph::os::Transaction
&& txn
) final
;
129 seastar::future
<> write_meta(const std::string
& key
,
130 const std::string
& value
) final
;
131 seastar::future
<std::tuple
<int, std::string
>>
132 read_meta(const std::string
& key
) final
;
133 uuid_d
get_fsid() const final
;
134 unsigned get_max_attr_name_length() const final
;
136 seastar::future
<OmapIteratorRef
> get_omap_iterator(
138 const ghobject_t
& oid
);
140 seastar::future
<std::map
<uint64_t, uint64_t>> fiemap(CollectionRef c
,
141 const ghobject_t
& oid
,
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
);
151 int _zero(const coll_t
& cid
, const ghobject_t
& oid
,
152 uint64_t offset
, size_t len
);
155 const ghobject_t
& oid
);
156 int _omap_set_values(
158 const ghobject_t
& oid
,
159 std::map
<std::string
, ceph::bufferlist
> &&aset
);
160 int _omap_set_header(
162 const ghobject_t
& oid
,
163 const ceph::bufferlist
&header
);
166 const ghobject_t
& oid
,
167 const omap_keys_t
& aset
);
168 int _omap_rmkeyrange(
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
,
175 std::map
<std::string
,bufferlist
>&& aset
);
176 int _rm_attr(const coll_t
& cid
, const ghobject_t
& oid
,
177 std::string_view name
);
178 int _rm_attrs(const coll_t
& cid
, const ghobject_t
& oid
);
179 int _create_collection(const coll_t
& cid
, int bits
);
180 boost::intrusive_ptr
<Collection
> _get_collection(const coll_t
& cid
);