81
81
uint64_t last_committed_seq;
83
uint64_t full_commit_seq; // don't write, wait for this seq to commit
84
uint64_t full_restart_seq; // start writing again with this seq
84
* full states cycle at the beginnging of each commit epoch, when commit_start()
86
* FULL - we just filled up during this epoch.
87
* WAIT - we filled up last epoch; now we have to wait until everything during
88
* that epoch commits to the fs before we can start writing over it.
89
* NOTFULL - all good, journal away.
89
100
deque<pair<uint64_t, off64_t> > journalq; // track seq offsets, so we can trim later.
101
deque<pair<uint64_t,Context*> > completions; // queued, writing, waiting for commit.
91
// currently being journaled and awaiting callback.
92
// or, awaiting callback bc journal was full.
93
deque<uint64_t> writing_seq;
94
deque<Context*> writing_fin;
103
uint64_t writing_seq, journaled_seq;
104
bool plug_journal_completions;
96
106
// waiting to be journaled
97
107
struct write_item {
102
write_item(uint64_t s, bufferlist& b, int al, Context *f) :
103
seq(s), alignment(al), fin(f) {
111
write_item(uint64_t s, bufferlist& b, int al) :
112
seq(s), alignment(al) {
117
126
Cond commit_cond;
119
128
int _open(bool wr, bool create=false);
129
int _open_block_device();
130
void _check_disk_write_cache() const;
131
int _open_file(int64_t oldsize, blksize_t blksize, bool create);
120
132
void print_header();
121
133
int read_header();
122
134
bufferptr prepare_header();
124
136
void stop_writer();
125
137
void write_thread_entry();
139
void queue_completions_thru(uint64_t seq);
127
141
int check_for_full(uint64_t seq, off64_t pos, off64_t size);
128
142
int prepare_multi_write(bufferlist& bl, uint64_t& orig_ops, uint64_t& orig_bytee);
129
143
int prepare_single_write(bufferlist& bl, off64_t& queue_pos, uint64_t& orig_ops, uint64_t& orig_bytes);
155
169
writing(false), must_write_header(false),
156
170
write_pos(0), read_pos(0),
157
171
last_committed_seq(0),
158
full_commit_seq(0), full_restart_seq(0),
172
full_state(FULL_NOTFULL),
174
writing_seq(0), journaled_seq(0),
175
plug_journal_completions(false),
160
176
write_lock("FileJournal::write_lock"),
161
177
write_stop(false),
162
178
write_thread(this) { }
181
197
void submit_entry(uint64_t seq, bufferlist& bl, int alignment, Context *oncommit); // submit an item
182
199
void committed_thru(uint64_t seq);
200
bool should_commit_now() {
201
return full_state != FULL_NOTFULL;
185
204
void set_wait_on_full(bool b) { wait_on_full = b; }