]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/os/seastore/journal.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / crimson / os / seastore / 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 #pragma once
5
6 #include <memory>
7
8 #include "crimson/os/seastore/ordering_handle.h"
9 #include "crimson/os/seastore/seastore_types.h"
10 #include "crimson/os/seastore/segment_seq_allocator.h"
11
12 namespace crimson::os::seastore {
13
14 namespace random_block_device {
15 class RBMDevice;
16 }
17
18 class SegmentManagerGroup;
19 class SegmentProvider;
20 class JournalTrimmer;
21
22 class Journal {
23 public:
24 virtual JournalTrimmer &get_trimmer() = 0;
25 /**
26 * initializes journal for mkfs writes -- must run prior to calls
27 * to submit_record.
28 */
29 using open_for_mkfs_ertr = crimson::errorator<
30 crimson::ct_error::input_output_error
31 >;
32 using open_for_mkfs_ret = open_for_mkfs_ertr::future<journal_seq_t>;
33 virtual open_for_mkfs_ret open_for_mkfs() = 0;
34
35 /**
36 * initializes journal for new writes -- must run prior to calls
37 * to submit_record. Should be called after replay if not a new
38 * Journal.
39 */
40 using open_for_mount_ertr = open_for_mkfs_ertr;
41 using open_for_mount_ret = open_for_mkfs_ret;
42 virtual open_for_mount_ret open_for_mount() = 0;
43
44 /// close journal
45 using close_ertr = crimson::errorator<
46 crimson::ct_error::input_output_error>;
47 virtual close_ertr::future<> close() = 0;
48
49 /**
50 * submit_record
51 *
52 * write record with the ordering handle
53 */
54 using submit_record_ertr = crimson::errorator<
55 crimson::ct_error::erange,
56 crimson::ct_error::input_output_error
57 >;
58 using submit_record_ret = submit_record_ertr::future<
59 record_locator_t
60 >;
61 virtual submit_record_ret submit_record(
62 record_t &&record,
63 OrderingHandle &handle
64 ) = 0;
65
66 /**
67 * flush
68 *
69 * Wait for all outstanding IOs on handle to commit.
70 * Note, flush() machinery must go through the same pipeline
71 * stages and locks as submit_record.
72 */
73 virtual seastar::future<> flush(OrderingHandle &handle) = 0;
74
75 /// sets write pipeline reference
76 virtual void set_write_pipeline(WritePipeline *_write_pipeline) = 0;
77
78 /**
79 * Read deltas and pass to delta_handler
80 *
81 * record_block_start (argument to delta_handler) is the start of the
82 * of the first block in the record
83 */
84 using replay_ertr = crimson::errorator<
85 crimson::ct_error::input_output_error,
86 crimson::ct_error::invarg,
87 crimson::ct_error::enoent,
88 crimson::ct_error::erange>;
89 using replay_ret = replay_ertr::future<>;
90 using delta_handler_t = std::function<
91 replay_ertr::future<bool>(
92 const record_locator_t&,
93 const delta_info_t&,
94 const journal_seq_t&, // dirty_tail
95 const journal_seq_t&, // alloc_tail
96 sea_time_point modify_time)>;
97 virtual replay_ret replay(
98 delta_handler_t &&delta_handler) = 0;
99
100 virtual seastar::future<> finish_commit(
101 transaction_type_t type) = 0;
102
103 virtual ~Journal() {}
104
105 virtual journal_type_t get_type() = 0;
106 };
107 using JournalRef = std::unique_ptr<Journal>;
108
109 namespace journal {
110
111 JournalRef make_segmented(
112 SegmentProvider &provider,
113 JournalTrimmer &trimmer);
114
115 JournalRef make_circularbounded(
116 JournalTrimmer &trimmer,
117 crimson::os::seastore::random_block_device::RBMDevice* device,
118 std::string path);
119
120 }
121
122 }