]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: proper BlueFS shared allocator setup 30838/head
authorIgor Fedotov <ifedotov@suse.com>
Sat, 1 Aug 2020 08:43:44 +0000 (11:43 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Sat, 1 Aug 2020 08:43:44 +0000 (11:43 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index 9a3175b3241bf1d8300b2f72e5f0e5175ad0ce56..cf28b50b258327d0ac2128070a9e01ce98410bcc 100644 (file)
@@ -350,6 +350,7 @@ int BlueFS::add_block_device(unsigned id, const string& path, bool trim,
   if (_shared_bdev_alloc) {
     ceph_assert(shared_bdev_alloc == nullptr);
     alloc[id] = shared_bdev_alloc = _shared_bdev_alloc;
+    need_shared_alloc_init = true;
   }
   return 0;
 }
@@ -583,8 +584,7 @@ int BlueFS::mkfs(uuid_d osd_uuid, const bluefs_layout_t& layout)
   vselector.reset(nullptr);
   _stop_alloc();
   _shutdown_logger();
-
-  after_mkfs = true;
+  need_shared_alloc_init = false;
 
   dout(10) << __func__ << " success" << dendl;
   return 0;
@@ -698,15 +698,16 @@ int BlueFS::mount()
     dout(30) << __func__ << " noting alloc for " << p.second->fnode << dendl;
     for (auto& q : p.second->fnode.extents) {
       if (alloc[q.bdev] == shared_bdev_alloc) {
-        if (!after_mkfs) {
+        if (need_shared_alloc_init) {
           alloc[q.bdev]->init_rm_free(q.offset, q.length);
+          shared_bdev_used += q.length;
         }
-        shared_bdev_used += q.length;
       } else {
         alloc[q.bdev]->init_rm_free(q.offset, q.length);
       }
     }
   }
+  need_shared_alloc_init = false;
   dout(1) << __func__ << " shared_bdev_used = " << shared_bdev_used << dendl;
 
   // set up the log for future writes
@@ -717,8 +718,6 @@ int BlueFS::mount()
            << std::hex << log_writer->pos << std::dec
            << dendl;
 
-  after_mkfs = false;
-
   return 0;
 
  out:
@@ -1291,7 +1290,7 @@ int BlueFS::_replay(bool noop, bool to_stdout)
          if (!noop) {
            block_all[id].erase(offset, length);
            _adjust_granularity(id, &offset, &length, false);
-           if (length) {
+           if (length && alloc[id] != shared_bdev_alloc) {
              alloc[id]->init_rm_free(offset, length);
            }
             if (cct->_conf->bluefs_log_replay_check_allocations) {
index edbdd94e8891a031e1dc6950b559b3a0ef171857..1a4997663455b25a9f2c43770f0700aabb7b8318 100644 (file)
@@ -309,14 +309,14 @@ private:
   BlockDevice::aio_callback_t discard_cb[3]; //discard callbacks for each dev
 
   std::unique_ptr<BlueFSVolumeSelector> vselector;
+  bool need_shared_alloc_init = false;
   Allocator* shared_bdev_alloc = nullptr;
   std::atomic<uint64_t> shared_bdev_used = 0;
 
+
   class SocketHook;
   SocketHook* asok_hook = nullptr;
 
-  bool after_mkfs = false;
-
   void _init_logger();
   void _shutdown_logger();
   void _update_logger_stats();