]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2014 Red Hat | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef CEPH_OSD_KSTORE_H | |
16 | #define CEPH_OSD_KSTORE_H | |
17 | ||
18 | #include "acconfig.h" | |
19 | ||
20 | #include <unistd.h> | |
21 | ||
22 | #include <atomic> | |
23 | #include <mutex> | |
24 | #include <condition_variable> | |
25 | ||
11fdf7f2 | 26 | #include "include/ceph_assert.h" |
7c673cae | 27 | #include "include/unordered_map.h" |
7c673cae | 28 | #include "common/Finisher.h" |
11fdf7f2 | 29 | #include "common/Throttle.h" |
7c673cae FG |
30 | #include "common/WorkQueue.h" |
31 | #include "os/ObjectStore.h" | |
32 | #include "common/perf_counters.h" | |
33 | #include "os/fs/FS.h" | |
34 | #include "kv/KeyValueDB.h" | |
35 | ||
36 | #include "kstore_types.h" | |
37 | ||
38 | #include "boost/intrusive/list.hpp" | |
39 | ||
40 | enum { | |
41 | l_kstore_first = 832430, | |
42 | l_kstore_state_prepare_lat, | |
43 | l_kstore_state_kv_queued_lat, | |
44 | l_kstore_state_kv_done_lat, | |
45 | l_kstore_state_finishing_lat, | |
46 | l_kstore_state_done_lat, | |
47 | l_kstore_last | |
48 | }; | |
49 | ||
50 | class KStore : public ObjectStore { | |
51 | // ----------------------------------------------------- | |
52 | // types | |
53 | public: | |
54 | ||
f67539c2 | 55 | struct TransContext; |
7c673cae FG |
56 | |
57 | /// an in-memory object | |
58 | struct Onode { | |
59 | CephContext* cct; | |
60 | std::atomic_int nref; ///< reference count | |
61 | ||
62 | ghobject_t oid; | |
f67539c2 | 63 | std::string key; ///< key under PREFIX_OBJ where we are stored |
7c673cae FG |
64 | boost::intrusive::list_member_hook<> lru_item; |
65 | ||
66 | kstore_onode_t onode; ///< metadata stored as value in kv store | |
67 | bool dirty; // ??? | |
68 | bool exists; | |
69 | ||
70 | std::mutex flush_lock; ///< protect flush_txns | |
71 | std::condition_variable flush_cond; ///< wait here for unapplied txns | |
f67539c2 | 72 | std::set<TransContext*> flush_txns; ///< committing txns |
7c673cae FG |
73 | |
74 | uint64_t tail_offset; | |
f67539c2 | 75 | ceph::buffer::list tail_bl; |
7c673cae | 76 | |
f67539c2 | 77 | std::map<uint64_t,ceph::buffer::list> pending_stripes; ///< unwritten stripes |
7c673cae | 78 | |
f67539c2 | 79 | Onode(CephContext* cct, const ghobject_t& o, const std::string& k) |
7c673cae FG |
80 | : cct(cct), |
81 | nref(0), | |
82 | oid(o), | |
83 | key(k), | |
84 | dirty(false), | |
85 | exists(false), | |
86 | tail_offset(0) { | |
87 | } | |
88 | ||
89 | void flush(); | |
90 | void get() { | |
91 | ++nref; | |
92 | } | |
93 | void put() { | |
94 | if (--nref == 0) | |
95 | delete this; | |
96 | } | |
97 | ||
98 | void clear_tail() { | |
99 | tail_offset = 0; | |
100 | tail_bl.clear(); | |
101 | } | |
102 | void clear_pending_stripes() { | |
103 | pending_stripes.clear(); | |
104 | } | |
105 | }; | |
106 | typedef boost::intrusive_ptr<Onode> OnodeRef; | |
107 | ||
108 | struct OnodeHashLRU { | |
109 | CephContext* cct; | |
110 | typedef boost::intrusive::list< | |
111 | Onode, | |
112 | boost::intrusive::member_hook< | |
113 | Onode, | |
114 | boost::intrusive::list_member_hook<>, | |
115 | &Onode::lru_item> > lru_list_t; | |
116 | ||
117 | std::mutex lock; | |
118 | ceph::unordered_map<ghobject_t,OnodeRef> onode_map; ///< forward lookups | |
119 | lru_list_t lru; ///< lru | |
120 | ||
121 | OnodeHashLRU(CephContext* cct) : cct(cct) {} | |
122 | ||
123 | void add(const ghobject_t& oid, OnodeRef o); | |
124 | void _touch(OnodeRef o); | |
125 | OnodeRef lookup(const ghobject_t& o); | |
126 | void rename(const ghobject_t& old_oid, const ghobject_t& new_oid); | |
127 | void clear(); | |
f67539c2 | 128 | bool get_next(const ghobject_t& after, std::pair<ghobject_t,OnodeRef> *next); |
7c673cae FG |
129 | int trim(int max=-1); |
130 | }; | |
131 | ||
11fdf7f2 TL |
132 | class OpSequencer; |
133 | typedef boost::intrusive_ptr<OpSequencer> OpSequencerRef; | |
134 | ||
7c673cae FG |
135 | struct Collection : public CollectionImpl { |
136 | KStore *store; | |
7c673cae | 137 | kstore_cnode_t cnode; |
9f95a23c TL |
138 | ceph::shared_mutex lock = |
139 | ceph::make_shared_mutex("KStore::Collection::lock", true, false); | |
7c673cae | 140 | |
11fdf7f2 TL |
141 | OpSequencerRef osr; |
142 | ||
7c673cae FG |
143 | // cache onodes on a per-collection basis to avoid lock |
144 | // contention. | |
145 | OnodeHashLRU onode_map; | |
146 | ||
147 | OnodeRef get_onode(const ghobject_t& oid, bool create); | |
148 | ||
7c673cae FG |
149 | bool contains(const ghobject_t& oid) { |
150 | if (cid.is_meta()) | |
151 | return oid.hobj.pool == -1; | |
152 | spg_t spgid; | |
153 | if (cid.is_pg(&spgid)) | |
154 | return | |
155 | spgid.pgid.contains(cnode.bits, oid) && | |
156 | oid.shard_id == spgid.shard; | |
157 | return false; | |
158 | } | |
159 | ||
11fdf7f2 TL |
160 | void flush() override; |
161 | bool flush_commit(Context *c) override; | |
162 | ||
9f95a23c TL |
163 | private: |
164 | FRIEND_MAKE_REF(Collection); | |
7c673cae FG |
165 | Collection(KStore *ns, coll_t c); |
166 | }; | |
9f95a23c | 167 | using CollectionRef = ceph::ref_t<Collection>; |
7c673cae FG |
168 | |
169 | class OmapIteratorImpl : public ObjectMap::ObjectMapIteratorImpl { | |
170 | CollectionRef c; | |
171 | OnodeRef o; | |
172 | KeyValueDB::Iterator it; | |
f67539c2 | 173 | std::string head, tail; |
7c673cae FG |
174 | public: |
175 | OmapIteratorImpl(CollectionRef c, OnodeRef o, KeyValueDB::Iterator it); | |
176 | int seek_to_first() override; | |
f67539c2 TL |
177 | int upper_bound(const std::string &after) override; |
178 | int lower_bound(const std::string &to) override; | |
7c673cae | 179 | bool valid() override; |
11fdf7f2 | 180 | int next() override; |
f67539c2 TL |
181 | std::string key() override; |
182 | ceph::buffer::list value() override; | |
7c673cae FG |
183 | int status() override { |
184 | return 0; | |
185 | } | |
186 | }; | |
187 | ||
7c673cae FG |
188 | struct TransContext { |
189 | typedef enum { | |
190 | STATE_PREPARE, | |
191 | STATE_AIO_WAIT, | |
192 | STATE_IO_DONE, | |
193 | STATE_KV_QUEUED, | |
194 | STATE_KV_COMMITTING, | |
195 | STATE_KV_DONE, | |
196 | STATE_FINISHING, | |
197 | STATE_DONE, | |
198 | } state_t; | |
199 | ||
200 | state_t state; | |
201 | ||
202 | const char *get_state_name() { | |
203 | switch (state) { | |
204 | case STATE_PREPARE: return "prepare"; | |
205 | case STATE_AIO_WAIT: return "aio_wait"; | |
206 | case STATE_IO_DONE: return "io_done"; | |
207 | case STATE_KV_QUEUED: return "kv_queued"; | |
208 | case STATE_KV_COMMITTING: return "kv_committing"; | |
209 | case STATE_KV_DONE: return "kv_done"; | |
210 | case STATE_FINISHING: return "finishing"; | |
211 | case STATE_DONE: return "done"; | |
212 | } | |
213 | return "???"; | |
214 | } | |
215 | ||
216 | void log_state_latency(PerfCounters *logger, int state) { | |
217 | utime_t lat, now = ceph_clock_now(); | |
218 | lat = now - start; | |
219 | logger->tinc(state, lat); | |
220 | start = now; | |
221 | } | |
222 | ||
11fdf7f2 | 223 | CollectionRef ch; |
7c673cae FG |
224 | OpSequencerRef osr; |
225 | boost::intrusive::list_member_hook<> sequencer_item; | |
226 | ||
227 | uint64_t ops, bytes; | |
228 | ||
f67539c2 | 229 | std::set<OnodeRef> onodes; ///< these onodes need to be updated/written |
7c673cae FG |
230 | KeyValueDB::Transaction t; ///< then we will commit this |
231 | Context *oncommit; ///< signal on commit | |
232 | Context *onreadable; ///< signal on readable | |
233 | Context *onreadable_sync; ///< signal on readable | |
f67539c2 TL |
234 | std::list<Context*> oncommits; ///< more commit completions |
235 | std::list<CollectionRef> removed_collections; ///< colls we removed | |
7c673cae FG |
236 | |
237 | CollectionRef first_collection; ///< first referenced collection | |
238 | utime_t start; | |
239 | explicit TransContext(OpSequencer *o) | |
240 | : state(STATE_PREPARE), | |
241 | osr(o), | |
242 | ops(0), | |
243 | bytes(0), | |
244 | oncommit(NULL), | |
245 | onreadable(NULL), | |
246 | onreadable_sync(NULL), | |
247 | start(ceph_clock_now()){ | |
248 | //cout << "txc new " << this << std::endl; | |
249 | } | |
250 | ~TransContext() { | |
251 | //cout << "txc del " << this << std::endl; | |
252 | } | |
253 | ||
254 | void write_onode(OnodeRef &o) { | |
255 | onodes.insert(o); | |
256 | } | |
257 | }; | |
258 | ||
11fdf7f2 | 259 | class OpSequencer : public RefCountedObject { |
7c673cae FG |
260 | public: |
261 | std::mutex qlock; | |
262 | std::condition_variable qcond; | |
263 | typedef boost::intrusive::list< | |
264 | TransContext, | |
265 | boost::intrusive::member_hook< | |
266 | TransContext, | |
267 | boost::intrusive::list_member_hook<>, | |
268 | &TransContext::sequencer_item> > q_list_t; | |
269 | q_list_t q; ///< transactions | |
270 | ||
11fdf7f2 TL |
271 | ~OpSequencer() { |
272 | ceph_assert(q.empty()); | |
7c673cae FG |
273 | } |
274 | ||
275 | void queue_new(TransContext *txc) { | |
276 | std::lock_guard<std::mutex> l(qlock); | |
277 | q.push_back(*txc); | |
278 | } | |
279 | ||
11fdf7f2 | 280 | void flush() { |
7c673cae FG |
281 | std::unique_lock<std::mutex> l(qlock); |
282 | while (!q.empty()) | |
283 | qcond.wait(l); | |
284 | } | |
285 | ||
11fdf7f2 | 286 | bool flush_commit(Context *c) { |
7c673cae FG |
287 | std::lock_guard<std::mutex> l(qlock); |
288 | if (q.empty()) { | |
289 | return true; | |
290 | } | |
291 | TransContext *txc = &q.back(); | |
292 | if (txc->state >= TransContext::STATE_KV_DONE) { | |
293 | return true; | |
294 | } | |
11fdf7f2 | 295 | ceph_assert(txc->state < TransContext::STATE_KV_DONE); |
7c673cae FG |
296 | txc->oncommits.push_back(c); |
297 | return false; | |
298 | } | |
299 | }; | |
300 | ||
301 | struct KVSyncThread : public Thread { | |
302 | KStore *store; | |
303 | explicit KVSyncThread(KStore *s) : store(s) {} | |
304 | void *entry() override { | |
305 | store->_kv_sync_thread(); | |
306 | return NULL; | |
307 | } | |
308 | }; | |
309 | ||
310 | // -------------------------------------------------------- | |
311 | // members | |
312 | private: | |
313 | KeyValueDB *db; | |
314 | uuid_d fsid; | |
f67539c2 | 315 | std::string basedir; |
7c673cae FG |
316 | int path_fd; ///< open handle to $path |
317 | int fsid_fd; ///< open handle (locked) to $path/fsid | |
318 | bool mounted; | |
319 | ||
9f95a23c TL |
320 | /// rwlock to protect coll_map |
321 | ceph::shared_mutex coll_lock = ceph::make_shared_mutex("KStore::coll_lock"); | |
7c673cae | 322 | ceph::unordered_map<coll_t, CollectionRef> coll_map; |
f67539c2 | 323 | std::map<coll_t,CollectionRef> new_coll_map; |
7c673cae FG |
324 | |
325 | std::mutex nid_lock; | |
326 | uint64_t nid_last; | |
327 | uint64_t nid_max; | |
328 | ||
329 | Throttle throttle_ops, throttle_bytes; ///< submit to commit | |
330 | ||
331 | Finisher finisher; | |
332 | ||
333 | KVSyncThread kv_sync_thread; | |
334 | std::mutex kv_lock; | |
335 | std::condition_variable kv_cond, kv_sync_cond; | |
336 | bool kv_stop; | |
f67539c2 | 337 | std::deque<TransContext*> kv_queue, kv_committing; |
7c673cae FG |
338 | |
339 | //Logger *logger; | |
340 | PerfCounters *logger; | |
341 | std::mutex reap_lock; | |
f67539c2 | 342 | std::list<CollectionRef> removed_collections; |
7c673cae FG |
343 | |
344 | ||
345 | // -------------------------------------------------------- | |
346 | // private methods | |
347 | ||
348 | void _init_logger(); | |
349 | void _shutdown_logger(); | |
350 | ||
351 | int _open_path(); | |
352 | void _close_path(); | |
353 | int _open_fsid(bool create); | |
354 | int _lock_fsid(); | |
355 | int _read_fsid(uuid_d *f); | |
356 | int _write_fsid(); | |
357 | void _close_fsid(); | |
358 | int _open_db(bool create); | |
359 | void _close_db(); | |
360 | int _open_collections(int *errors=0); | |
361 | void _close_collections(); | |
362 | ||
363 | int _open_super_meta(); | |
364 | ||
365 | CollectionRef _get_collection(coll_t cid); | |
366 | void _queue_reap_collection(CollectionRef& c); | |
367 | void _reap_collections(); | |
368 | ||
369 | void _assign_nid(TransContext *txc, OnodeRef o); | |
370 | ||
371 | void _dump_onode(OnodeRef o); | |
372 | ||
373 | TransContext *_txc_create(OpSequencer *osr); | |
374 | void _txc_release(TransContext *txc, uint64_t offset, uint64_t length); | |
375 | void _txc_add_transaction(TransContext *txc, Transaction *t); | |
376 | void _txc_finalize(OpSequencer *osr, TransContext *txc); | |
377 | void _txc_state_proc(TransContext *txc); | |
378 | void _txc_finish_kv(TransContext *txc); | |
379 | void _txc_finish(TransContext *txc); | |
380 | ||
381 | void _osr_reap_done(OpSequencer *osr); | |
382 | ||
383 | void _kv_sync_thread(); | |
384 | void _kv_stop() { | |
385 | { | |
386 | std::lock_guard<std::mutex> l(kv_lock); | |
387 | kv_stop = true; | |
388 | kv_cond.notify_all(); | |
389 | } | |
390 | kv_sync_thread.join(); | |
391 | kv_stop = false; | |
392 | } | |
393 | ||
f67539c2 | 394 | void _do_read_stripe(OnodeRef o, uint64_t offset, ceph::buffer::list *pbl, bool do_cache); |
7c673cae | 395 | void _do_write_stripe(TransContext *txc, OnodeRef o, |
f67539c2 | 396 | uint64_t offset, ceph::buffer::list& bl); |
7c673cae FG |
397 | void _do_remove_stripe(TransContext *txc, OnodeRef o, uint64_t offset); |
398 | ||
399 | int _collection_list( | |
400 | Collection *c, const ghobject_t& start, const ghobject_t& end, | |
f67539c2 | 401 | int max, std::vector<ghobject_t> *ls, ghobject_t *next); |
7c673cae FG |
402 | |
403 | public: | |
f67539c2 | 404 | KStore(CephContext *cct, const std::string& path); |
7c673cae FG |
405 | ~KStore() override; |
406 | ||
f67539c2 | 407 | std::string get_type() override { |
7c673cae FG |
408 | return "kstore"; |
409 | } | |
410 | ||
411 | bool needs_journal() override { return false; }; | |
412 | bool wants_journal() override { return false; }; | |
413 | bool allows_journal() override { return false; }; | |
414 | ||
f67539c2 | 415 | static int get_block_device_fsid(const std::string& path, uuid_d *fsid); |
7c673cae FG |
416 | |
417 | bool test_mount_in_use() override; | |
418 | ||
419 | int mount() override; | |
420 | int umount() override; | |
421 | void _sync(); | |
422 | ||
423 | int fsck(bool deep) override; | |
424 | ||
425 | ||
426 | int validate_hobject_key(const hobject_t &obj) const override { | |
427 | return 0; | |
428 | } | |
429 | unsigned get_max_attr_name_length() override { | |
430 | return 256; // arbitrary; there is no real limit internally | |
431 | } | |
432 | ||
433 | int mkfs() override; | |
434 | int mkjournal() override { | |
435 | return 0; | |
436 | } | |
f67539c2 | 437 | void dump_perf_counters(ceph::Formatter *f) override { |
7c673cae | 438 | f->open_object_section("perf_counters"); |
1e59de90 | 439 | logger->dump_formatted(f, false, false); |
7c673cae FG |
440 | f->close_section(); |
441 | } | |
f67539c2 | 442 | void get_db_statistics(ceph::Formatter *f) override { |
11fdf7f2 TL |
443 | db->get_statistics(f); |
444 | } | |
445 | int statfs(struct store_statfs_t *buf, | |
446 | osd_alert_list_t* alerts = nullptr) override; | |
9f95a23c TL |
447 | int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf, |
448 | bool *per_pool_omap) override; | |
11fdf7f2 TL |
449 | |
450 | CollectionHandle open_collection(const coll_t& c) override; | |
451 | CollectionHandle create_new_collection(const coll_t& c) override; | |
452 | void set_collection_commit_queue(const coll_t& cid, | |
453 | ContextQueue *commit_queue) override { | |
454 | } | |
7c673cae FG |
455 | |
456 | using ObjectStore::exists; | |
11fdf7f2 | 457 | bool exists(CollectionHandle& c, const ghobject_t& oid) override; |
7c673cae FG |
458 | using ObjectStore::stat; |
459 | int stat( | |
11fdf7f2 | 460 | CollectionHandle& c, |
7c673cae FG |
461 | const ghobject_t& oid, |
462 | struct stat *st, | |
463 | bool allow_eio = false) override; // struct stat? | |
464 | int set_collection_opts( | |
11fdf7f2 | 465 | CollectionHandle& c, |
7c673cae FG |
466 | const pool_opts_t& opts) override; |
467 | using ObjectStore::read; | |
468 | int read( | |
11fdf7f2 | 469 | CollectionHandle& c, |
7c673cae FG |
470 | const ghobject_t& oid, |
471 | uint64_t offset, | |
472 | size_t len, | |
f67539c2 | 473 | ceph::buffer::list& bl, |
224ce89b | 474 | uint32_t op_flags = 0) override; |
7c673cae FG |
475 | int _do_read( |
476 | OnodeRef o, | |
477 | uint64_t offset, | |
478 | size_t len, | |
f67539c2 | 479 | ceph::buffer::list& bl, |
9f95a23c | 480 | bool do_cache, |
7c673cae FG |
481 | uint32_t op_flags = 0); |
482 | ||
483 | using ObjectStore::fiemap; | |
f67539c2 TL |
484 | int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset, size_t len, std::map<uint64_t, uint64_t>& destmap) override; |
485 | int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset, size_t len, ceph::buffer::list& outbl) override; | |
7c673cae | 486 | using ObjectStore::getattr; |
f67539c2 | 487 | int getattr(CollectionHandle& c, const ghobject_t& oid, const char *name, ceph::buffer::ptr& value) override; |
7c673cae | 488 | using ObjectStore::getattrs; |
20effc67 TL |
489 | int getattrs(CollectionHandle& c, |
490 | const ghobject_t& oid, | |
491 | std::map<std::string,ceph::buffer::ptr,std::less<>>& aset) override; | |
7c673cae | 492 | |
f67539c2 | 493 | int list_collections(std::vector<coll_t>& ls) override; |
7c673cae | 494 | bool collection_exists(const coll_t& c) override; |
11fdf7f2 TL |
495 | int collection_empty(CollectionHandle& c, bool *empty) override; |
496 | int collection_bits(CollectionHandle& c) override; | |
7c673cae FG |
497 | int collection_list( |
498 | CollectionHandle &c, const ghobject_t& start, const ghobject_t& end, | |
499 | int max, | |
f67539c2 | 500 | std::vector<ghobject_t> *ls, ghobject_t *next) override; |
7c673cae FG |
501 | |
502 | using ObjectStore::omap_get; | |
503 | int omap_get( | |
11fdf7f2 | 504 | CollectionHandle& c, ///< [in] Collection containing oid |
7c673cae | 505 | const ghobject_t &oid, ///< [in] Object containing omap |
f67539c2 TL |
506 | ceph::buffer::list *header, ///< [out] omap header |
507 | std::map<std::string, ceph::buffer::list> *out /// < [out] Key to value std::map | |
7c673cae FG |
508 | ) override; |
509 | ||
510 | using ObjectStore::omap_get_header; | |
511 | /// Get omap header | |
512 | int omap_get_header( | |
11fdf7f2 | 513 | CollectionHandle& c, ///< [in] Collection containing oid |
7c673cae | 514 | const ghobject_t &oid, ///< [in] Object containing omap |
f67539c2 | 515 | ceph::buffer::list *header, ///< [out] omap header |
7c673cae FG |
516 | bool allow_eio = false ///< [in] don't assert on eio |
517 | ) override; | |
518 | ||
519 | using ObjectStore::omap_get_keys; | |
520 | /// Get keys defined on oid | |
521 | int omap_get_keys( | |
11fdf7f2 | 522 | CollectionHandle& c, ///< [in] Collection containing oid |
7c673cae | 523 | const ghobject_t &oid, ///< [in] Object containing omap |
f67539c2 | 524 | std::set<std::string> *keys ///< [out] Keys defined on oid |
7c673cae FG |
525 | ) override; |
526 | ||
527 | using ObjectStore::omap_get_values; | |
528 | /// Get key values | |
529 | int omap_get_values( | |
11fdf7f2 | 530 | CollectionHandle& c, ///< [in] Collection containing oid |
7c673cae | 531 | const ghobject_t &oid, ///< [in] Object containing omap |
f67539c2 TL |
532 | const std::set<std::string> &keys, ///< [in] Keys to get |
533 | std::map<std::string, ceph::buffer::list> *out ///< [out] Returned keys and values | |
7c673cae FG |
534 | ) override; |
535 | ||
536 | using ObjectStore::omap_check_keys; | |
537 | /// Filters keys into out which are defined on oid | |
538 | int omap_check_keys( | |
11fdf7f2 | 539 | CollectionHandle& c, ///< [in] Collection containing oid |
7c673cae | 540 | const ghobject_t &oid, ///< [in] Object containing omap |
f67539c2 TL |
541 | const std::set<std::string> &keys, ///< [in] Keys to check |
542 | std::set<std::string> *out ///< [out] Subset of keys defined on oid | |
7c673cae FG |
543 | ) override; |
544 | ||
545 | using ObjectStore::get_omap_iterator; | |
546 | ObjectMap::ObjectMapIterator get_omap_iterator( | |
11fdf7f2 | 547 | CollectionHandle& c, ///< [in] collection |
7c673cae FG |
548 | const ghobject_t &oid ///< [in] object |
549 | ) override; | |
550 | ||
551 | void set_fsid(uuid_d u) override { | |
552 | fsid = u; | |
553 | } | |
554 | uuid_d get_fsid() override { | |
555 | return fsid; | |
556 | } | |
557 | ||
558 | uint64_t estimate_objects_overhead(uint64_t num_objects) override { | |
559 | return num_objects * 300; //assuming per-object overhead is 300 bytes | |
560 | } | |
561 | ||
562 | objectstore_perf_stat_t get_cur_stats() override { | |
563 | return objectstore_perf_stat_t(); | |
564 | } | |
565 | const PerfCounters* get_perf_counters() const override { | |
566 | return logger; | |
567 | } | |
568 | ||
569 | ||
570 | int queue_transactions( | |
11fdf7f2 | 571 | CollectionHandle& ch, |
f67539c2 | 572 | std::vector<Transaction>& tls, |
7c673cae FG |
573 | TrackedOpRef op = TrackedOpRef(), |
574 | ThreadPool::TPHandle *handle = NULL) override; | |
575 | ||
224ce89b | 576 | void compact () override { |
11fdf7f2 | 577 | ceph_assert(db); |
224ce89b WB |
578 | db->compact(); |
579 | } | |
580 | ||
7c673cae FG |
581 | private: |
582 | // -------------------------------------------------------- | |
583 | // write ops | |
584 | ||
7c673cae FG |
585 | int _write(TransContext *txc, |
586 | CollectionRef& c, | |
587 | OnodeRef& o, | |
588 | uint64_t offset, size_t len, | |
f67539c2 | 589 | ceph::buffer::list& bl, |
7c673cae FG |
590 | uint32_t fadvise_flags); |
591 | int _do_write(TransContext *txc, | |
592 | OnodeRef o, | |
593 | uint64_t offset, uint64_t length, | |
f67539c2 | 594 | ceph::buffer::list& bl, |
7c673cae FG |
595 | uint32_t fadvise_flags); |
596 | int _touch(TransContext *txc, | |
597 | CollectionRef& c, | |
598 | OnodeRef& o); | |
599 | int _zero(TransContext *txc, | |
600 | CollectionRef& c, | |
601 | OnodeRef& o, | |
602 | uint64_t offset, size_t len); | |
603 | int _do_truncate(TransContext *txc, | |
604 | OnodeRef o, | |
605 | uint64_t offset); | |
606 | int _truncate(TransContext *txc, | |
607 | CollectionRef& c, | |
608 | OnodeRef& o, | |
609 | uint64_t offset); | |
610 | int _remove(TransContext *txc, | |
611 | CollectionRef& c, | |
612 | OnodeRef& o); | |
613 | int _do_remove(TransContext *txc, | |
614 | OnodeRef o); | |
615 | int _setattr(TransContext *txc, | |
616 | CollectionRef& c, | |
617 | OnodeRef& o, | |
f67539c2 TL |
618 | const std::string& name, |
619 | ceph::buffer::ptr& val); | |
7c673cae FG |
620 | int _setattrs(TransContext *txc, |
621 | CollectionRef& c, | |
622 | OnodeRef& o, | |
f67539c2 | 623 | const std::map<std::string,ceph::buffer::ptr>& aset); |
7c673cae FG |
624 | int _rmattr(TransContext *txc, |
625 | CollectionRef& c, | |
626 | OnodeRef& o, | |
f67539c2 | 627 | const std::string& name); |
7c673cae FG |
628 | int _rmattrs(TransContext *txc, |
629 | CollectionRef& c, | |
630 | OnodeRef& o); | |
631 | void _do_omap_clear(TransContext *txc, uint64_t id); | |
632 | int _omap_clear(TransContext *txc, | |
633 | CollectionRef& c, | |
634 | OnodeRef& o); | |
635 | int _omap_setkeys(TransContext *txc, | |
636 | CollectionRef& c, | |
637 | OnodeRef& o, | |
f67539c2 | 638 | ceph::buffer::list& bl); |
7c673cae FG |
639 | int _omap_setheader(TransContext *txc, |
640 | CollectionRef& c, | |
641 | OnodeRef& o, | |
f67539c2 | 642 | ceph::buffer::list& header); |
7c673cae FG |
643 | int _omap_rmkeys(TransContext *txc, |
644 | CollectionRef& c, | |
645 | OnodeRef& o, | |
f67539c2 | 646 | const ceph::buffer::list& bl); |
7c673cae FG |
647 | int _omap_rmkey_range(TransContext *txc, |
648 | CollectionRef& c, | |
649 | OnodeRef& o, | |
f67539c2 | 650 | const std::string& first, const std::string& last); |
7c673cae FG |
651 | int _setallochint(TransContext *txc, |
652 | CollectionRef& c, | |
653 | OnodeRef& o, | |
654 | uint64_t expected_object_size, | |
655 | uint64_t expected_write_size, | |
656 | uint32_t flags); | |
657 | int _clone(TransContext *txc, | |
658 | CollectionRef& c, | |
659 | OnodeRef& oldo, | |
660 | OnodeRef& newo); | |
661 | int _clone_range(TransContext *txc, | |
662 | CollectionRef& c, | |
663 | OnodeRef& oldo, | |
664 | OnodeRef& newo, | |
665 | uint64_t srcoff, uint64_t length, uint64_t dstoff); | |
666 | int _rename(TransContext *txc, | |
667 | CollectionRef& c, | |
668 | OnodeRef& oldo, | |
669 | OnodeRef& newo, | |
670 | const ghobject_t& new_oid); | |
671 | int _create_collection(TransContext *txc, coll_t cid, unsigned bits, | |
672 | CollectionRef *c); | |
673 | int _remove_collection(TransContext *txc, coll_t cid, CollectionRef *c); | |
674 | int _split_collection(TransContext *txc, | |
675 | CollectionRef& c, | |
676 | CollectionRef& d, | |
677 | unsigned bits, int rem); | |
11fdf7f2 TL |
678 | int _merge_collection(TransContext *txc, |
679 | CollectionRef *c, | |
680 | CollectionRef& d, | |
681 | unsigned bits); | |
7c673cae FG |
682 | |
683 | }; | |
684 | ||
7c673cae FG |
685 | static inline void intrusive_ptr_add_ref(KStore::Onode *o) { |
686 | o->get(); | |
687 | } | |
688 | static inline void intrusive_ptr_release(KStore::Onode *o) { | |
689 | o->put(); | |
690 | } | |
691 | ||
692 | static inline void intrusive_ptr_add_ref(KStore::OpSequencer *o) { | |
693 | o->get(); | |
694 | } | |
695 | static inline void intrusive_ptr_release(KStore::OpSequencer *o) { | |
696 | o->put(); | |
697 | } | |
698 | ||
699 | #endif |