OPTION(journal_dio, OPT_BOOL, true)
OPTION(journal_aio, OPT_BOOL, false)
OPTION(journal_block_align, OPT_BOOL, true)
+OPTION(journal_write_header_frequency, OPT_U64, 0)
OPTION(journal_max_write_bytes, OPT_INT, 10 << 20)
OPTION(journal_max_write_entries, OPT_INT, 100)
OPTION(journal_queue_max_ops, OPT_INT, 300)
bufferptr FileJournal::prepare_header()
{
bufferlist bl;
+ {
+ Mutex::Locker l(finisher_lock);
+ header.committed_up_to = journaled_seq;
+ }
::encode(header, bl);
bufferptr bp = buffer::create_page_aligned(get_top());
bp.zero();
return;
buffer::ptr hbp;
+ if (g_conf->journal_write_header_frequency &&
+ (((++journaled_since_start) %
+ g_conf->journal_write_header_frequency) == 0)) {
+ must_write_header = true;
+ }
+
if (must_write_header) {
must_write_header = false;
hbp = prepare_header();
#ifdef HAVE_LIBAIO
void FileJournal::do_aio_write(bufferlist& bl)
{
+
+ if (g_conf->journal_write_header_frequency &&
+ (((++journaled_since_start) %
+ g_conf->journal_write_header_frequency) == 0)) {
+ must_write_header = true;
+ }
+
// nothing to do?
if (bl.length() == 0 && !must_write_header)
return;
h = (entry_header_t *)hbl.c_str();
if (!h->check_magic(read_pos, header.get_fsid64())) {
+ if (header.committed_up_to && seq <= header.committed_up_to) {
+ derr << "ERROR: header claims we are committed up through "
+ << header.committed_up_to << " however, we have failed to read "
+ << "entry " << seq
+ << " journal is likely corrupt" << dendl;
+ assert(0 == "FileJournal::read_entry(): corrupt journal");
+ }
dout(2) << "read_entry " << read_pos << " : bad header magic, end of journal" << dendl;
return false;
}
__u32 alignment;
int64_t max_size; // max size of journal ring buffer
int64_t start; // offset of first entry
+ uint64_t committed_up_to; // committed up to
- header_t() : flags(0), block_size(0), alignment(0), max_size(0), start(0) {}
+ header_t() :
+ flags(0), block_size(0), alignment(0), max_size(0), start(0),
+ committed_up_to(0) {}
void clear() {
start = block_size;
}
void encode(bufferlist& bl) const {
- __u32 v = 2;
+ __u32 v = 3;
::encode(v, bl);
bufferlist em;
{
::encode(alignment, em);
::encode(max_size, em);
::encode(start, em);
+ ::encode(committed_up_to, em);
}
::encode(em, bl);
}
::decode(alignment, t);
::decode(max_size, t);
::decode(start, t);
+ if (v > 2)
+ ::decode(committed_up_to, t);
+ else
+ committed_up_to = 0;
}
} header;
#endif
uint64_t last_committed_seq;
+ uint64_t journaled_since_start;
/*
* full states cycle at the beginnging of each commit epoch, when commit_start()
aio_num(0), aio_bytes(0),
#endif
last_committed_seq(0),
+ journaled_since_start(0),
full_state(FULL_NOTFULL),
fd(-1),
writing_seq(0),