Skip to content

Commit

Permalink
os/bluestore/BlueFS: prevent _compact_log_async reentry
Browse files Browse the repository at this point in the history
_should_compact_log uses new_log != nullptr to tell whether compaction is
already in progress, but we don't set it until we are midway through the
process.  Set it at the top of the method to prevent reentry.

See 455cc6c, which failed to implement
this properly.

Fixes: http://tracker.ceph.com/issues/21250
Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed Sep 5, 2017
1 parent 683212a commit 6bd9db3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/os/bluestore/BlueFS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,11 @@ void BlueFS::_compact_log_async(std::unique_lock<std::mutex>& l)
assert(!new_log);
assert(!new_log_writer);

// create a new log [writer] so that we know compaction is in progress
// (see _should_compact_log)
new_log = new File;
new_log->fnode.ino = 0; // so that _flush_range won't try to log the fnode

// 1. allocate new log space and jump to it.
old_log_jump_to = log_file->fnode.get_allocated();
uint64_t need = old_log_jump_to + cct->_conf->bluefs_max_log_runway;
Expand Down Expand Up @@ -1228,9 +1233,7 @@ void BlueFS::_compact_log_async(std::unique_lock<std::mutex>& l)
dout(10) << __func__ << " new_log_jump_to 0x" << std::hex << new_log_jump_to
<< std::dec << dendl;

// create a new log [writer]
new_log = new File;
new_log->fnode.ino = 0; // so that _flush_range won't try to log the fnode
// allocate
int r = _allocate(BlueFS::BDEV_DB, new_log_jump_to,
&new_log->fnode.extents);
assert(r == 0);
Expand Down

0 comments on commit 6bd9db3

Please sign in to comment.