]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: fix wrong usage for BlueFS::_allocate.
authorJianpeng Ma <jianpeng.ma@intel.com>
Mon, 5 Mar 2018 16:54:14 +0000 (00:54 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Tue, 6 Mar 2018 08:11:17 +0000 (16:11 +0800)
In fact, function _allocate is atomic function which don't
allocate less than want space.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/os/bluestore/BlueFS.cc

index 7ac3fe7a095433982de8fe63049180233bae52a3..1e1d78cf7b92d78856648e1587f781e69239c933 100644 (file)
@@ -1259,19 +1259,15 @@ void BlueFS::_compact_log_sync()
   mempool::bluefs::vector<bluefs_extent_t> old_extents;
   uint64_t old_allocated = 0;
   log_file->fnode.swap_extents(old_extents, old_allocated);
-  while (log_file->fnode.get_allocated() < need) {
-    int r = _allocate(log_file->fnode.prefer_bdev,
-                     need - log_file->fnode.get_allocated(),
-                     &log_file->fnode);
-    assert(r == 0);
-  }
+  int r = _allocate(log_file->fnode.prefer_bdev, need, &log_file->fnode);
+  assert(r == 0);
 
   _close_writer(log_writer);
 
   log_file->fnode.size = bl.length();
   log_writer = _create_writer(log_file);
   log_writer->append(bl);
-  int r = _flush(log_writer, true);
+  r = _flush(log_writer, true);
   assert(r == 0);
 #ifdef HAVE_LIBAIO
   if (!cct->_conf->bluefs_sync_write) {
@@ -1341,15 +1337,11 @@ void BlueFS::_compact_log_async(std::unique_lock<std::mutex>& l)
 
   // 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;
   dout(10) << __func__ << " old_log_jump_to 0x" << std::hex << old_log_jump_to
-           << " need 0x" << need << std::dec << dendl;
-  while (log_file->fnode.get_allocated() < need) {
-    int r = _allocate(log_file->fnode.prefer_bdev,
-                     cct->_conf->bluefs_max_log_runway,
-                     &log_file->fnode);
-    assert(r == 0);
-  }
+           << " need 0x" << (old_log_jump_to + cct->_conf->bluefs_max_log_runway) << std::dec << dendl;
+  int r = _allocate(log_file->fnode.prefer_bdev,
+                   cct->_conf->bluefs_max_log_runway, &log_file->fnode);
+  assert(r == 0);
   dout(10) << __func__ << " log extents " << log_file->fnode.extents << dendl;
 
   // update the log file change and log a jump to the offset where we want to
@@ -1380,7 +1372,7 @@ void BlueFS::_compact_log_async(std::unique_lock<std::mutex>& l)
           << std::dec << dendl;
 
   // allocate
-  int r = _allocate(BlueFS::BDEV_DB, new_log_jump_to,
+  r = _allocate(BlueFS::BDEV_DB, new_log_jump_to,
                     &new_log->fnode);
   assert(r == 0);
   new_log_writer = _create_writer(new_log);