]> git.proxmox.com Git - ceph.git/blame - ceph/src/os/filestore/Journal.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / os / filestore / Journal.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) 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"
9f95a23c 22#include "include/common_fwd.h"
7c673cae
FG
23#include "include/Context.h"
24#include "common/Finisher.h"
25#include "common/TrackedOp.h"
26#include "os/ObjectStore.h"
27#include "common/zipkin_trace.h"
28
7c673cae
FG
29
30class Journal {
31protected:
32 uuid_d fsid;
33 Finisher *finisher;
34public:
35 CephContext* cct;
36 PerfCounters *logger;
37protected:
9f95a23c 38 ceph::condition_variable *do_sync_cond;
7c673cae
FG
39 bool wait_on_full;
40
41public:
9f95a23c 42 Journal(CephContext* cct, uuid_d f, Finisher *fin, ceph::condition_variable *c=0) :
7c673cae
FG
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
f67539c2
TL
55 virtual void get_devices(std::set<std::string> *ls) {}
56 virtual void collect_metadata(std::map<std::string,std::string> *pm) {}
7c673cae
FG
57 /**
58 * reserve_throttle_and_backoff
59 *
60 * Implementation may throttle or backoff based on ops
61 * reserved here but not yet released using committed_thru.
62 */
63 virtual void reserve_throttle_and_backoff(uint64_t count) = 0;
64
f67539c2 65 virtual int dump(std::ostream& out) { return -EOPNOTSUPP; }
7c673cae
FG
66
67 void set_wait_on_full(bool b) { wait_on_full = b; }
68
69 // writes
70 virtual bool is_writeable() = 0;
71 virtual int make_writeable() = 0;
f67539c2 72 virtual void submit_entry(uint64_t seq, ceph::buffer::list& e, uint32_t orig_len,
7c673cae
FG
73 Context *oncommit,
74 TrackedOpRef osd_op = TrackedOpRef()) = 0;
75 virtual void commit_start(uint64_t seq) = 0;
76 virtual void committed_thru(uint64_t seq) = 0;
77
78 /// Read next journal entry - asserts on invalid journal
79 virtual bool read_entry(
f67539c2 80 ceph::buffer::list &bl, ///< [out] payload on successful read
7c673cae
FG
81 uint64_t &seq ///< [in,out] sequence number on last successful read
82 ) = 0; ///< @return true on successful read, false on journal end
83
84 virtual bool should_commit_now() = 0;
85
f67539c2 86 virtual int prepare_entry(std::vector<ObjectStore::Transaction>& tls, ceph::buffer::list* tbl) = 0;
7c673cae
FG
87
88 virtual off64_t get_journal_size_estimate() { return 0; }
89
90 // reads/recovery
91
92};
93
94#endif