dout(2) << "open " << fn << " fsid " << fsid << " fs_op_seq " << fs_op_seq << dendl;
uint64_t next_seq = fs_op_seq + 1;
+ uint64_t seq = -1;
int err = _open(false);
if (err)
// read header?
err = read_header(&header);
if (err < 0)
- return err;
+ goto out;
// static zeroed buffer for alignment padding
delete [] zero_buf;
if (header.fsid != fsid) {
derr << "FileJournal::open: ondisk fsid " << header.fsid << " doesn't match expected " << fsid
<< ", invalid (someone else's?) journal" << dendl;
- return -EINVAL;
+ err = -EINVAL;
+ goto out;
}
if (header.max_size > max_size) {
dout(2) << "open journal size " << header.max_size << " > current " << max_size << dendl;
- return -EINVAL;
+ err = -EINVAL;
+ goto out;
}
if (header.block_size != block_size) {
dout(2) << "open journal block size " << header.block_size << " != current " << block_size << dendl;
- return -EINVAL;
+ err = -EINVAL;
+ goto out;
}
if (header.max_size % header.block_size) {
dout(2) << "open journal max size " << header.max_size
<< " not a multiple of block size " << header.block_size << dendl;
- return -EINVAL;
+ err = -EINVAL;
+ goto out;
}
if (header.alignment != block_size && directio) {
dout(0) << "open journal alignment " << header.alignment << " does not match block size "
<< block_size << " (required for direct_io journal mode)" << dendl;
- return -EINVAL;
+ err = -EINVAL;
+ goto out;
}
if ((header.alignment % CEPH_DIRECTIO_ALIGNMENT) && directio) {
dout(0) << "open journal alignment " << header.alignment
<< " is not multiple of minimum directio alignment "
<< CEPH_DIRECTIO_ALIGNMENT << " (required for direct_io journal mode)"
<< dendl;
- return -EINVAL;
+ err = -EINVAL;
+ goto out;
}
// looks like a valid header.
// find next entry
read_pos = header.start;
- uint64_t seq = header.start_seq;
-
- // last_committed_seq is 1 before the start of the journal or
- // 0 if the start is 0
- last_committed_seq = seq > 0 ? seq - 1 : seq;
- if (last_committed_seq < fs_op_seq) {
- dout(2) << "open advancing committed_seq " << last_committed_seq
- << " to fs op_seq " << fs_op_seq << dendl;
- last_committed_seq = fs_op_seq;
- }
+ seq = header.start_seq;
while (1) {
bufferlist bl;
}
return 0;
+out:
+ close();
+ return err;
}
void FileJournal::_close(int fd) const
}
print_header(header);
}
-
+
return -ENOSPC; // hrm, full on first op
}
if (eleft) {
aio_lock.Unlock();
iocb *piocb = &aio.iocb;
-
+
// 2^16 * 125us = ~8 seconds, so max sleep is ~16 seconds
int attempts = 16;
int delay = 125;
journaled_seq = seq;
return true;
}
+ } else {
+ derr << "do_read_entry(" << pos << "): " << ss.str() << dendl;
}
if (seq && seq < header.committed_up_to) {
}
}
- dout(25) << ss.str() << dendl;
dout(2) << "No further valid entries found, journal is most likely valid"
<< dendl;
return false;