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