]> git.proxmox.com Git - ceph.git/blob - ceph/src/os/filestore/Journal.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / os / filestore / Journal.h
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) 2004-2006 Sage Weil <sage@newdream.net>
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
16 #ifndef CEPH_JOURNAL_H
17 #define CEPH_JOURNAL_H
18
19 #include <errno.h>
20
21 #include "include/buffer_fwd.h"
22 #include "include/Context.h"
23 #include "common/Finisher.h"
24 #include "common/TrackedOp.h"
25 #include "os/ObjectStore.h"
26 #include "common/zipkin_trace.h"
27
28 class PerfCounters;
29
30 class Journal {
31 protected:
32 uuid_d fsid;
33 Finisher *finisher;
34 public:
35 CephContext* cct;
36 PerfCounters *logger;
37 protected:
38 Cond *do_sync_cond;
39 bool wait_on_full;
40
41 public:
42 Journal(CephContext* cct, uuid_d f, Finisher *fin, Cond *c=0) :
43 fsid(f), finisher(fin), cct(cct), logger(NULL),
44 do_sync_cond(c),
45 wait_on_full(false) { }
46 virtual ~Journal() { }
47
48 virtual int check() = 0; ///< check if journal appears valid
49 virtual int create() = 0; ///< create a fresh journal
50 virtual int open(uint64_t fs_op_seq) = 0; ///< open an existing journal
51 virtual void close() = 0; ///< close an open journal
52
53 virtual void flush() = 0;
54
55 /**
56 * reserve_throttle_and_backoff
57 *
58 * Implementation may throttle or backoff based on ops
59 * reserved here but not yet released using committed_thru.
60 */
61 virtual void reserve_throttle_and_backoff(uint64_t count) = 0;
62
63 virtual int dump(ostream& out) { return -EOPNOTSUPP; }
64
65 void set_wait_on_full(bool b) { wait_on_full = b; }
66
67 // writes
68 virtual bool is_writeable() = 0;
69 virtual int make_writeable() = 0;
70 virtual void submit_entry(uint64_t seq, bufferlist& e, uint32_t orig_len,
71 Context *oncommit,
72 TrackedOpRef osd_op = TrackedOpRef()) = 0;
73 virtual void commit_start(uint64_t seq) = 0;
74 virtual void committed_thru(uint64_t seq) = 0;
75
76 /// Read next journal entry - asserts on invalid journal
77 virtual bool read_entry(
78 bufferlist &bl, ///< [out] payload on successful read
79 uint64_t &seq ///< [in,out] sequence number on last successful read
80 ) = 0; ///< @return true on successful read, false on journal end
81
82 virtual bool should_commit_now() = 0;
83
84 virtual int prepare_entry(vector<ObjectStore::Transaction>& tls, bufferlist* tbl) = 0;
85
86 virtual off64_t get_journal_size_estimate() { return 0; }
87
88 // reads/recovery
89
90 };
91
92 #endif