Skip to content

Commit

Permalink
Merge pull request ceph#6025 from ukernel/wip-13167
Browse files Browse the repository at this point in the history
journaler: detect unexpected holes in journal objects

Reviewed-by: Greg Farnum <[email protected]>
  • Loading branch information
gregsfortytwo committed Sep 29, 2015
2 parents 119336f + f4b55f4 commit a467db1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions src/osdc/Journaler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -803,11 +803,12 @@ void Journaler::_finish_prezero(int r, uint64_t start, uint64_t len)
class Journaler::C_Read : public Context {
Journaler *ls;
uint64_t offset;
uint64_t length;
public:
bufferlist bl;
C_Read(Journaler *l, uint64_t o) : ls(l), offset(o) {}
C_Read(Journaler *j, uint64_t o, uint64_t l) : ls(j), offset(o), length(l) {}
void finish(int r) {
ls->_finish_read(r, offset, bl);
ls->_finish_read(r, offset, length, bl);
}
};

Expand All @@ -822,23 +823,30 @@ class Journaler::C_RetryRead : public Context {
}
};

void Journaler::_finish_read(int r, uint64_t offset, bufferlist& bl)
void Journaler::_finish_read(int r, uint64_t offset, uint64_t length, bufferlist& bl)
{
Mutex::Locker l(lock);

if (r < 0) {
ldout(cct, 0) << "_finish_read got error " << r << dendl;
error = r;
} else {
ldout(cct, 10) << "_finish_read got " << offset << "~" << bl.length() << dendl;
if (bl.length() < length) {
ldout(cct, 0) << "_finish_read got less than expected (" << length << ")" << dendl;
error = -EINVAL;
}
}

if (error) {
if (on_readable) {
C_OnFinisher *f = on_readable;
on_readable = 0;
f->complete(r);
f->complete(error);
}
return;
}
assert(r>=0);

ldout(cct, 10) << "_finish_read got " << offset << "~" << bl.length() << dendl;
prefetch_buf[offset].swap(bl);

try {
Expand Down Expand Up @@ -940,7 +948,7 @@ void Journaler::_issue_read(uint64_t len)
uint64_t l = e - requested_pos;
if (l > len)
l = len;
C_Read *c = new C_Read(this, requested_pos);
C_Read *c = new C_Read(this, requested_pos, l);
filer.read(ino, &layout, CEPH_NOSNAP, requested_pos, l, &c->bl, 0, wrap_finisher(c), CEPH_OSD_OP_FLAG_FADVISE_DONTNEED);
requested_pos += l;
len -= l;
Expand Down
2 changes: 1 addition & 1 deletion src/osdc/Journaler.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class Journaler {
C_OnFinisher *on_write_error;
bool called_write_error;

void _finish_read(int r, uint64_t offset, bufferlist &bl); // read completion callback
void _finish_read(int r, uint64_t offset, uint64_t length, bufferlist &bl); // read completion callback
void _finish_retry_read(int r);
void _assimilate_prefetch();
void _issue_read(uint64_t len); // read some more
Expand Down

0 comments on commit a467db1

Please sign in to comment.