Skip to content

Commit

Permalink
osd: Fix FileJournal wrap to get header out first
Browse files Browse the repository at this point in the history
Correct and restore assert that was removed

Cause by f46b1b4
Fixes: ceph#10883
Backport: dumpling, firefly, giant

Signed-off-by: David Zafman <[email protected]>
  • Loading branch information
dzafman committed Feb 19, 2015
1 parent a0ec53e commit 970bb49
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/os/FileJournal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,8 @@ int FileJournal::prepare_multi_write(bufferlist& bl, uint64_t& orig_ops, uint64_
}

dout(20) << "prepare_multi_write queue_pos now " << queue_pos << dendl;
//assert(write_pos + bl.length() == queue_pos);
assert((write_pos + bl.length() == queue_pos) ||
(write_pos + bl.length() - header.max_size + get_top() == queue_pos));
return 0;
}

Expand Down Expand Up @@ -1030,22 +1031,32 @@ void FileJournal::do_write(bufferlist& bl)
dout(10) << "do_write wrapping, first bit at " << pos << " len " << first.length()
<< " second bit len " << second.length() << " (orig len " << bl.length() << ")" << dendl;

if (write_bl(pos, first)) {
derr << "FileJournal::do_write: write_bl(pos=" << pos
<< ") failed" << dendl;
ceph_abort();
}
assert(pos == get_top());
//Save pos to write first piece second
off64_t first_pos = pos;
off64_t orig_pos;
pos = get_top();
// header too?
if (hbp.length()) {
// be sneaky: include the header in the second fragment
second.push_front(hbp);
pos = 0; // we included the header
}
// Write the second portion first possible with the header, so
// do_read_entry() won't even get a valid entry_header_t if there
// is a crash between the two writes.
orig_pos = pos;
if (write_bl(pos, second)) {
derr << "FileJournal::do_write: write_bl(pos=" << pos
derr << "FileJournal::do_write: write_bl(pos=" << orig_pos
<< ") failed" << dendl;
ceph_abort();
}
orig_pos = first_pos;
if (write_bl(first_pos, first)) {
derr << "FileJournal::do_write: write_bl(pos=" << orig_pos
<< ") failed" << dendl;
ceph_abort();
}
assert(first_pos == get_top());
} else {
// header too?
if (hbp.length()) {
Expand Down

0 comments on commit 970bb49

Please sign in to comment.