]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueFS: prevent _compact_log_async reentry 17562/head
authorSage Weil <sage@redhat.com>
Tue, 5 Sep 2017 19:01:02 +0000 (15:01 -0400)
committerAbhishek Lekshmanan <abhishek@suse.com>
Thu, 7 Sep 2017 13:00:32 +0000 (15:00 +0200)
_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 455cc6cea2e5e8bc1126b5047b6003fa583af1b5, which failed to implement
this properly.

Fixes: http://tracker.ceph.com/issues/21250
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 6bd9db304f906e9e4a07ca5ce07ffffdbc1678f0)

src/os/bluestore/BlueFS.cc

index 2a30e36e953d11ea6f58738ea4e6078278eab85b..1d39d76358c4859e02defeaa0e1dbb0742d0ff85 100644 (file)
@@ -1186,6 +1186,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;
@@ -1227,9 +1232,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);