]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: git rid off legacy bluefs stuff
authorIgor Fedotov <ifedotov@suse.com>
Wed, 2 Oct 2019 14:21:48 +0000 (17:21 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Tue, 28 Jul 2020 15:37:39 +0000 (18:37 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/common/legacy_config_opts.h
src/common/options.cc
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/test/objectstore/store_test.cc

index 7e7b77ccfd6c3ef2f392505f41a51c5e63ed72c8..df8bd6d6cf5a80d701a6c1c9e7819d734d912a6f 100644 (file)
@@ -920,18 +920,9 @@ OPTION(bluefs_replay_recovery_disable_compact, OPT_BOOL)
 OPTION(bluestore_bluefs, OPT_BOOL)
 OPTION(bluestore_bluefs_env_mirror, OPT_BOOL) // mirror to normal Env for debug
 OPTION(bluestore_bluefs_min, OPT_U64) // 1gb
-OPTION(bluestore_bluefs_min_ratio, OPT_FLOAT)  // min fs free / total free
-OPTION(bluestore_bluefs_max_ratio, OPT_FLOAT)  // max fs free / total free
-OPTION(bluestore_bluefs_gift_ratio, OPT_FLOAT) // how much to add at a time
-OPTION(bluestore_bluefs_reclaim_ratio, OPT_FLOAT) // how much to reclaim at a time
-OPTION(bluestore_bluefs_balance_interval, OPT_FLOAT) // how often (sec) to balance free space between bluefs and bluestore
 // how often (sec) to dump allocator on allocation failure
 OPTION(bluestore_bluefs_alloc_failure_dump_interval, OPT_FLOAT)
 
-// Enforces db sync with legacy bluefs extents information on close.
-// Enables downgrades to pre-nautilus releases
-OPTION(bluestore_bluefs_db_compatibility, OPT_BOOL)
-
 // If you want to use spdk driver, you need to specify NVMe serial number here
 // with "spdk:" prefix.
 // Users can use 'lspci -vvv -d 8086:0953 | grep "Device Serial Number"' to
index d00414625f52a082644c5d76c08bccfd94828591..82f47e228c3bf9e06a0e08035cfe4cbddaddd309 100644 (file)
@@ -4073,41 +4073,11 @@ std::vector<Option> get_global_options() {
     .set_default(1_G)
     .set_description("minimum free space allocated to BlueFS"),
 
-    Option("bluestore_bluefs_max_free", Option::TYPE_SIZE, Option::LEVEL_ADVANCED)
-    .set_default(10_G)
-    .set_description("Maximum free space allocated to BlueFS"),
-
-    Option("bluestore_bluefs_min_ratio", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
-    .set_default(.02)
-    .set_description("Minimum fraction of free space devoted to BlueFS"),
-
-    Option("bluestore_bluefs_max_ratio", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
-    .set_default(.90)
-    .set_description("Maximum fraction of free storage devoted to BlueFS"),
-
-    Option("bluestore_bluefs_gift_ratio", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
-    .set_default(.02)
-    .set_description("Maximum fraction of free space to give to BlueFS at once"),
-
-    Option("bluestore_bluefs_reclaim_ratio", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
-    .set_default(.20)
-    .set_description("Maximum fraction of free space to reclaim from BlueFS at once"),
-
-    Option("bluestore_bluefs_balance_interval", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
-    .set_default(1)
-    .set_description("How frequently (in seconds) to balance free space between BlueFS and BlueStore"),
-
     Option("bluestore_bluefs_alloc_failure_dump_interval", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
     .set_default(0)
     .set_description("How frequently (in seconds) to dump allocator on"
       "BlueFS space allocation failure"),
 
-    Option("bluestore_bluefs_db_compatibility", Option::TYPE_BOOL, Option::LEVEL_DEV)
-    .set_default(true)
-    .set_description("Sync db with legacy bluefs extents info")
-    .set_long_description("Enforces db sync with legacy bluefs extents information on close."
-                          " Enables downgrades to pre-nautilus releases"),
-
     Option("bluestore_spdk_mem", Option::TYPE_SIZE, Option::LEVEL_DEV)
     .set_default(512)
     .set_description("Amount of dpdk memory size in MB")
index 44d2655bcdc4f835f51e02ddcd967f25166e9125..0e9d443cbcd110bdbf3c13970667abcb64e14888 100644 (file)
@@ -123,11 +123,6 @@ private:
          f->close_section();
        }
       }
-      size_t extra_space = 0;
-      if (bluefs->slow_dev_expander) {
-       extra_space = bluefs->slow_dev_expander->available_freespace(alloc_size);
-      }
-      f->dump_int("available_from_bluestore", extra_space);
       f->close_section();
     } else if (command == "bluefs stats") {
       std::stringstream ss;
@@ -203,10 +198,6 @@ void BlueFS::_init_logger()
 {
   PerfCountersBuilder b(cct, "bluefs",
                         l_bluefs_first, l_bluefs_last);
-  b.add_u64_counter(l_bluefs_gift_bytes, "gift_bytes",
-                   "Bytes gifted from BlueStore", NULL, 0, unit_t(UNIT_BYTES));
-  b.add_u64_counter(l_bluefs_reclaim_bytes, "reclaim_bytes",
-                   "Bytes reclaimed by BlueStore", NULL, 0, unit_t(UNIT_BYTES));
   b.add_u64(l_bluefs_db_total_bytes, "db_total_bytes",
            "Total bytes (main db device)",
            "b", PerfCountersBuilder::PRIO_USEFUL, unit_t(UNIT_BYTES));
@@ -376,64 +367,9 @@ void BlueFS::_add_block_extent(unsigned id, uint64_t offset, uint64_t length,
     alloc[id]->init_add_free(offset, length);
   }
 
-  if (logger)
-    logger->inc(l_bluefs_gift_bytes, length);
   dout(10) << __func__ << " done" << dendl;
 }
 
-int BlueFS::reclaim_blocks(unsigned id, uint64_t want,
-                          PExtentVector *extents)
-{
-  std::unique_lock l(lock);
-  dout(1) << __func__ << " bdev " << id
-          << " want 0x" << std::hex << want << std::dec << dendl;
-  ceph_assert(id < alloc.size());
-  ceph_assert(alloc[id]);
-  int64_t got = 0;
-
-  interval_set<uint64_t> granular;
-  while (want > 0 && !block_unused_too_granular[id].empty()) {
-    auto p = block_unused_too_granular[id].begin();
-    dout(20) << __func__ << " unused " << (int)id << ":"
-            << std::hex << p.get_start() << "~" << p.get_len() << dendl;
-    extents->push_back({p.get_start(), p.get_len()});
-    granular.insert(p.get_start(), p.get_len());
-    if (want >= p.get_len()) {
-      want -= p.get_len();
-    } else {
-      want = 0;
-    }
-    got += p.get_len();
-    block_unused_too_granular[id].erase(p);
-  }
-
-  if (want > 0) {
-    got += alloc[id]->allocate(want, alloc_size[id], 0, extents);
-    ceph_assert(got != 0);
-    if (got < 0) {
-      derr << __func__ << " failed to allocate space to return to bluestore"
-          << dendl;
-      alloc[id]->dump();
-      block_unused_too_granular[id].insert(granular);
-      return got;
-    }
-
-    for (auto& p : *extents) {
-      block_all[id].erase(p.offset, p.length);
-      log_t.op_alloc_rm(id, p.offset, p.length);
-    }
-
-    flush_bdev();
-    int r = _flush_and_sync_log(l);
-    ceph_assert(r == 0);
-  }
-
-  logger->inc(l_bluefs_reclaim_bytes, got);
-  dout(1) << __func__ << " bdev " << id << " want 0x" << std::hex << want
-         << " got " << *extents << dendl;
-  return 0;
-}
-
 void BlueFS::handle_discard(unsigned id, interval_set<uint64_t>& to_release)
 {
   dout(10) << __func__ << " bdev " << id << dendl;
@@ -488,14 +424,6 @@ void BlueFS::dump_block_extents(ostream& out)
         << " = 0x" << owned
         << " : using 0x" << owned - free
        << std::dec << "(" << byte_u_t(owned - free) << ")";
-    if (i == _get_slow_device_id()) {
-      ceph_assert(slow_dev_expander);
-      ceph_assert(alloc[i]);
-      free = slow_dev_expander->available_freespace(alloc_size[i]);
-      out << std::hex
-          << " : bluestore has 0x" << free
-          << std::dec << "(" << byte_u_t(free) << ") available";
-    }
     out << "\n";
   }
 }
@@ -3106,27 +3034,6 @@ const char* BlueFS::get_device_name(unsigned id)
   return names[id];
 }
 
-int BlueFS::_expand_slow_device(uint64_t need, PExtentVector& extents)
-{
-  int r = -ENOSPC;
-  if (slow_dev_expander) {
-    auto id = _get_slow_device_id();
-    auto min_alloc_size = alloc_size[id];
-    ceph_assert(id <= alloc.size() && alloc[id]);
-    auto min_need = round_up_to(need, min_alloc_size);
-    need = std::max(need,
-      slow_dev_expander->get_recommended_expansion_delta(
-        alloc[id]->get_free(), block_all[id].size()));
-
-    need = round_up_to(need, min_alloc_size);
-    dout(10) << __func__ << " expanding slow device by 0x"
-             << std::hex << need << std::dec
-            << dendl;
-    r = slow_dev_expander->allocate_freespace(min_need, need, extents);
-  }
-  return r;
-}
-
 int BlueFS::_allocate_without_fallback(uint8_t id, uint64_t len,
                      PExtentVector* extents)
 {
@@ -3195,35 +3102,8 @@ int BlueFS::_allocate(uint8_t id, uint64_t len,
     dout(1) << __func__ << " unable to allocate 0x" << std::hex << len
            << " on bdev " << (int)id << ", free 0x"
            << (alloc[id] ? alloc[id]->get_free() : (uint64_t)-1)
-           << "; fallback to slow device expander "
            << std::dec << dendl;
-    extents.clear();
-    if (_expand_slow_device(len, extents) == 0) {
-      id = _get_slow_device_id();
-      for (auto& e : extents) {
-       _add_block_extent(id, e.offset, e.length);
-      }
-      extents.clear();
-      auto* last_alloc = alloc[id];
-      ceph_assert(last_alloc);
-      // try again
-      alloc_len = last_alloc->allocate(round_up_to(len, alloc_size[id]),
-                                      alloc_size[id], hint, &extents);
-      if (alloc_len < 0 || alloc_len < (int64_t)len) {
-       if (alloc_len > 0) {
-         last_alloc->release(extents);
-       }
-       derr << __func__ << " failed to allocate 0x" << std::hex << len
-             << " on bdev " << (int)id
-             << ", free 0x" << last_alloc->get_free() << std::dec << dendl;
-        return -ENOSPC;
-      }
-    } else {
-      derr << __func__ << " failed to expand slow device to fit +0x"
-          << std::hex << len << std::dec
-          << dendl;
-      return -ENOSPC;
-    }
+    return -ENOSPC;
   } else {
     uint64_t total_allocated =
       block_all[id].size() - alloc[id]->get_free();
index 31ced7b913faabe3243096ecb6e071e7f98747dd..fe12df9fba3f80485fefbb9c04bebc52e147295b 100644 (file)
@@ -21,8 +21,6 @@ class Allocator;
 
 enum {
   l_bluefs_first = 732600,
-  l_bluefs_gift_bytes,
-  l_bluefs_reclaim_bytes,
   l_bluefs_db_total_bytes,
   l_bluefs_db_used_bytes,
   l_bluefs_wal_total_bytes,
@@ -55,25 +53,6 @@ enum {
   l_bluefs_last,
 };
 
-class BlueFSDeviceExpander {
-protected:
-  ~BlueFSDeviceExpander() {}
-public:
-  virtual uint64_t get_recommended_expansion_delta(uint64_t bluefs_free,
-    uint64_t bluefs_total) = 0;
-  virtual int allocate_freespace(
-    uint64_t min_size,
-    uint64_t size,
-    PExtentVector& extents) = 0;
-  /** Reports amount of space that can be transferred to BlueFS.
-   * This gives either current state, when alloc_size is currently used
-   * BlueFS's size, or simulation when alloc_size is different.
-   * @params
-   * alloc_size - allocation unit size to check
-   */
-  virtual uint64_t available_freespace(uint64_t alloc_size) = 0;
-};
-
 class BlueFSVolumeSelector {
 public:
   typedef std::vector<std::pair<std::string, uint64_t>> paths;
@@ -329,7 +308,6 @@ private:
 
   BlockDevice::aio_callback_t discard_cb[3]; //discard callbacks for each dev
 
-  BlueFSDeviceExpander* slow_dev_expander = nullptr;
   std::unique_ptr<BlueFSVolumeSelector> vselector;
 
   class SocketHook;
@@ -351,7 +329,6 @@ private:
     return bdev[BDEV_SLOW] ? BDEV_SLOW : BDEV_DB;
   }
   const char* get_device_name(unsigned id);
-  int _expand_slow_device(uint64_t min_size, PExtentVector& extents);
   int _allocate(uint8_t bdev, uint64_t len,
                bluefs_fnode_t* node);
   int _allocate_without_fallback(uint8_t id, uint64_t len,
@@ -525,9 +502,6 @@ public:
   /// test and compact log, if necessary
   void _maybe_compact_log(std::unique_lock<ceph::mutex>& l);
 
-  void set_slow_device_expander(BlueFSDeviceExpander* a) {
-    slow_dev_expander = a;
-  }
   void set_volume_selector(BlueFSVolumeSelector* s) {
     vselector.reset(s);
   }
@@ -553,10 +527,6 @@ public:
     ceph_assert(r == 0);
   }
 
-  /// reclaim block space
-  int reclaim_blocks(unsigned bdev, uint64_t want,
-                    PExtentVector *extents);
-
   // handler for discard event
   void handle_discard(unsigned dev, interval_set<uint64_t>& to_release);
 
index 32c2809a67ac05d510b13e6b7a66063b157cb445..b014f68b2dc21f91a08ce118f0143d9ef57e29e5 100644 (file)
@@ -4965,18 +4965,10 @@ int BlueStore::_open_fm(KeyValueDB::Transaction t, bool read_only)
 
     // allocate superblock reserved space.  note that we do not mark
     // bluefs space as allocated in the freelist; we instead rely on
-    // bluefs_extents.
+    // bluefs doing that itself.
     auto reserved = _get_ondisk_reserved();
     fm->allocate(0, reserved, t);
 
-    if (cct->_conf->bluestore_bluefs) {
-      ceph_assert(bluefs_extents.num_intervals() == 1);
-      interval_set<uint64_t>::iterator p = bluefs_extents.begin();
-      reserved = round_up_to(p.get_start() + p.get_len(), min_alloc_size);
-      dout(20) << __func__ << " reserved 0x" << std::hex << reserved << std::dec
-              << " for bluefs" << dendl;
-    }
-
     if (cct->_conf->bluestore_debug_prefill > 0) {
       uint64_t end = bdev->get_size() - reserved;
       dout(1) << __func__ << " pre-fragmenting freespace, using "
@@ -5077,21 +5069,6 @@ int BlueStore::_open_alloc()
   ceph_assert(alloc == NULL);
   ceph_assert(bdev->get_size());
 
-  if (bluefs) {
-    bluefs_extents.clear();
-    auto r = bluefs->get_block_extents(bluefs_layout.shared_bdev,
-                                       &bluefs_extents);
-    if (r < 0) {
-      lderr(cct) << __func__ << " failed to retrieve bluefs_extents: "
-                << cpp_strerror(r) << dendl;
-
-      return r;
-    }
-    dout(10) << __func__ << " bluefs extents 0x"
-             << std::hex << bluefs_extents << std::dec
-            << dendl;
-  }
-
   uint64_t alloc_size = min_alloc_size;
   if (bdev->is_smr()) {
     alloc_size = _piggyback_zoned_device_parameters_onto(alloc_size);
@@ -5150,11 +5127,6 @@ int BlueStore::_open_alloc()
   }
   fm->enumerate_reset();
 
-  // also mark bluefs space as allocated
-  for (auto e = bluefs_extents.begin(); e != bluefs_extents.end(); ++e) {
-    alloc->init_rm_free(e.get_start(), e.get_len());
-  }
-
   dout(1) << __func__ << " loaded " << byte_u_t(bytes)
     << " in " << num << " extents"
     << " available " << byte_u_t(alloc->get_free())
@@ -5172,7 +5144,6 @@ void BlueStore::_close_alloc()
   alloc->shutdown();
   delete alloc;
   alloc = NULL;
-  bluefs_extents.clear();
 }
 
 int BlueStore::_open_fsid(bool create)
@@ -5392,40 +5363,7 @@ int BlueStore::_minimal_open_bluefs(bool create)
          << cpp_strerror(r) << dendl;
     goto free_bluefs;
   }
-  if (create) {
-    // note: we always leave the first SUPER_RESERVED (8k) of the device unused
-    uint64_t start, initial;
-    if (bdev->is_smr()) {
-      // For now, we allocate all of the conventional region on HM-SMR drive to
-      // bluefs and assume that it never outgrows that region.
-      start = _get_ondisk_reserved();
-      initial = bdev->get_conventional_region_size() - start;
-    } else {
-      initial = bdev->get_size() * (cct->_conf->bluestore_bluefs_min_ratio +
-                                   cct->_conf->bluestore_bluefs_gift_ratio);
-      initial = std::max(initial, cct->_conf->bluestore_bluefs_min);
-      uint64_t alloc_size = cct->_conf->bluefs_shared_alloc_size;
-      if (alloc_size % min_alloc_size) {
-       derr << __func__ << " bluefs_shared_alloc_size 0x" << std::hex
-            << alloc_size << " is not a multiple of "
-            << "min_alloc_size 0x" << min_alloc_size << std::dec << dendl;
-       r = -EINVAL;
-       goto free_bluefs;
-      }
-      // align to bluefs's alloc_size
-      initial = p2roundup(initial, alloc_size);
-      // put bluefs in the middle of the device in case it is an HDD
-      start = p2align((bdev->get_size() - initial) / 2, alloc_size);
-      //avoiding superblock overwrite
-      start = std::max(alloc_size, start);
-      ceph_assert(start >=_get_ondisk_reserved());
-    }
-
-    bluefs->add_block_extent(bluefs_layout.shared_bdev, start, initial);
-    bluefs_extents.insert(start, initial);
-    ++out_of_sync_fm;
-  }
-
   bfn = path + "/block.wal";
   if (::stat(bfn.c_str(), &st) == 0) {
     r = bluefs->add_block_device(BlueFS::BDEV_WAL, bfn,
@@ -5626,23 +5564,7 @@ int BlueStore::_open_db_and_around(bool read_only)
 void BlueStore::_close_db_and_around(bool read_only)
 {
   if (bluefs) {
-    if (!read_only && out_of_sync_fm.fetch_and(0)) {
-      _sync_bluefs_and_fm();
-    }
     _close_db(read_only);
-    while(!read_only && out_of_sync_fm.fetch_and(0)) {
-      // if seen some allocations during close - repeat open_db, sync fm, close
-      dout(0) << __func__ << " syncing FreelistManager" << dendl;
-      int r = _open_db(false, false, false);
-      if (r < 0) {
-       derr << __func__
-             << " unable to open db, FreelistManager is probably out of sync"
-             << dendl;
-       break;
-      }
-      _sync_bluefs_and_fm();
-      _close_db(false);
-    }
     if (!_kv_only) {
       _close_alloc();
       _close_fm();
@@ -5654,30 +5576,6 @@ void BlueStore::_close_db_and_around(bool read_only)
   }
 }
 
-// updates legacy bluefs related recs in DB to a state valid for
-// downgrades from nautilus.
-void BlueStore::_sync_bluefs_and_fm()
-{
-  if (cct->_conf->bluestore_bluefs_db_compatibility) {
-    bufferlist bl;
-    encode(bluefs_extents, bl);
-    dout(20) << __func__ << " bluefs_extents at KV is now 0x"
-             << std::hex << bluefs_extents << std::dec
-            << dendl;
-    KeyValueDB::Transaction synct = db->get_transaction();
-    synct->set(PREFIX_SUPER, "bluefs_extents", bl);
-    synct->set(PREFIX_SUPER, "bluefs_extents_back", bl);
-
-    // Nice thing is that we don't need to update FreelistManager here.
-    // It always has corresponding bits set to 'Free' for both Nautilus+ and
-    // pre-Nautilis releases.
-    // So once we get an extent to bluefs_extents this means it's
-    // been free in allocator and hence it's free in FM too.
-
-    db->submit_transaction_sync(synct);
-  }
-}
-
 int BlueStore::open_db_environment(KeyValueDB **pdb)
 {
   string kv_dir_fn;
@@ -5803,7 +5701,6 @@ int BlueStore::_prepare_db_environment(bool create, bool read_only,
       // simplify the dir names, too, as "seen" by rocksdb
       fn = "db";
     }
-    bluefs->set_slow_device_expander(this);
     BlueFSVolumeSelector::paths paths;
     bluefs->get_vselector_paths(fn, paths);
 
@@ -5959,234 +5856,6 @@ void BlueStore::_dump_alloc_on_failure()
   }
 }
 
-
-int BlueStore::allocate_bluefs_freespace(
-  uint64_t min_size,
-  uint64_t size,
-  PExtentVector* extents_out)
-{
-  ceph_assert(min_size <= size);
-  if (size) {
-    // round up to alloc size
-    uint64_t alloc_size = bluefs->get_alloc_size(bluefs_layout.shared_bdev);
-    min_size = p2roundup(min_size, alloc_size);
-    size = p2roundup(size, alloc_size);
-
-    PExtentVector extents_local;
-    PExtentVector* extents = extents_out ? extents_out : &extents_local;
-
-
-    uint64_t gift;
-    uint64_t allocated = 0;
-    int64_t alloc_len;
-    auto need = size;
-    auto extent_count0 = extents->size();
-    do {
-      // hard cap to fit into 32 bits
-      gift = std::min<uint64_t>(size, 1ull << 30);
-      dout(10) << __func__ << " gifting " << gift
-              << " (" << byte_u_t(gift) << ")" << dendl;
-
-      alloc_len = alloc->allocate(gift, alloc_size, 0, 0, extents);
-      if (alloc_len > 0) {
-       allocated += alloc_len;
-       size -= alloc_len;
-      }
-
-      if (alloc_len < 0 || 
-          (alloc_len < (int64_t)gift && (min_size > allocated))) {
-       derr << __func__
-             << " failed to allocate on 0x" << std::hex << gift
-             << " min_size 0x" << min_size
-             << " > allocated total 0x" << allocated
-             << " bluefs_shared_alloc_size 0x" << alloc_size
-             << " allocated 0x" << (alloc_len < 0 ? 0 : alloc_len)
-             << " available 0x " << alloc->get_free()
-             << std::dec << dendl;
-
-       _dump_alloc_on_failure();
-       alloc->release(*extents);
-       extents->clear();
-       return -ENOSPC;
-      }
-    } while (size && alloc_len > 0);
-    _collect_allocation_stats(need, alloc_size, extents->size() - extent_count0);
-
-    for (auto& e : *extents) {
-      dout(5) << __func__ << " gifting " << e << " to bluefs" << dendl;
-      bluefs_extents.insert(e.offset, e.length);
-      ++out_of_sync_fm;
-      // apply to bluefs if not requested from outside
-      if (!extents_out) {
-        bluefs->add_block_extent(bluefs_layout.shared_bdev, e.offset, e.length);
-      }
-    }
-  }
-  return 0;
-}
-
-uint64_t BlueStore::available_freespace(uint64_t alloc_size) {
-  uint64_t total = 0;
-  auto iterated_allocation = [&](uint64_t off, uint64_t len) {
-    //only count in size that is alloc_size aligned
-    uint64_t dist_to_alignment;
-    uint64_t offset_in_block = off & (alloc_size - 1);
-    if (offset_in_block == 0)
-      dist_to_alignment = 0;
-    else
-      dist_to_alignment = alloc_size - offset_in_block;
-    if (dist_to_alignment >= len)
-      return;
-    len -= dist_to_alignment;
-    total += p2align(len, alloc_size);
-  };
-  alloc->dump(iterated_allocation);
-  return total;
-}
-
-int64_t BlueStore::_get_bluefs_size_delta(uint64_t bluefs_free, uint64_t bluefs_total)
-{
-  float bluefs_free_ratio = (float)bluefs_free / (float)bluefs_total;
-
-  uint64_t my_free = alloc->get_free();
-  uint64_t total = bdev->get_size();
-  float my_free_ratio = (float)my_free / (float)total;
-
-  uint64_t total_free = bluefs_free + my_free;
-
-  float bluefs_ratio = (float)bluefs_free / (float)total_free;
-
-  dout(10) << __func__
-          << " bluefs " << byte_u_t(bluefs_free)
-          << " free (" << bluefs_free_ratio
-          << ") bluestore " << byte_u_t(my_free)
-          << " free (" << my_free_ratio
-          << "), bluefs_ratio " << bluefs_ratio
-          << dendl;
-
-  uint64_t gift = 0;
-  uint64_t reclaim = 0;
-  if (bluefs_ratio < cct->_conf->bluestore_bluefs_min_ratio) {
-    gift = cct->_conf->bluestore_bluefs_gift_ratio * total_free;
-    if (gift >= my_free)
-      gift = my_free / 2;
-    dout(10) << __func__ << " bluefs_ratio " << bluefs_ratio
-            << " < min_ratio " << cct->_conf->bluestore_bluefs_min_ratio
-            << ", should gift " << byte_u_t(gift) << dendl;
-  } else if (bluefs_ratio > cct->_conf->bluestore_bluefs_max_ratio) {
-    reclaim = cct->_conf->bluestore_bluefs_reclaim_ratio * total_free;
-    if (bluefs_total - reclaim < cct->_conf->bluestore_bluefs_min)
-      reclaim = bluefs_total - cct->_conf->bluestore_bluefs_min;
-    if (reclaim >= bluefs_free)
-      reclaim = bluefs_free / 2;
-    dout(10) << __func__ << " bluefs_ratio " << bluefs_ratio
-            << " > max_ratio " << cct->_conf->bluestore_bluefs_max_ratio
-            << ", should reclaim " << byte_u_t(reclaim) << dendl;
-  }
-
-  // don't take over too much of the freespace
-  uint64_t free_cap = cct->_conf->bluestore_bluefs_max_ratio * total_free;
-  if (bluefs_total < cct->_conf->bluestore_bluefs_min &&
-      cct->_conf->bluestore_bluefs_min < free_cap) {
-    uint64_t g = cct->_conf->bluestore_bluefs_min - bluefs_total;
-    dout(10) << __func__ << " bluefs_total " << bluefs_total
-            << " < min " << cct->_conf->bluestore_bluefs_min
-            << ", should gift " << byte_u_t(g) << dendl;
-    if (g > gift)
-      gift = g;
-    reclaim = 0;
-  }
-  uint64_t min_free =
-    cct->_conf.get_val<Option::size_t>("bluestore_bluefs_min_free");
-  if (bluefs_free < min_free &&
-      min_free < free_cap) {
-    uint64_t g = min_free - bluefs_free;
-    dout(10) << __func__ << " bluefs_free " << bluefs_free
-            << " < min " << min_free
-            << ", should gift " << byte_u_t(g) << dendl;
-    if (g > gift)
-      gift = g;
-    reclaim = 0;
-  }
-  uint64_t max_free =
-    cct->_conf.get_val<Option::size_t>("bluestore_bluefs_max_free");
-  if (bluefs_free > max_free) {
-    dout(10) << __func__ << " bluefs_free " << bluefs_free
-             << " > max " << max_free
-             << ", stop gifting for now" << dendl;
-    gift = 0;
-  }
-  ceph_assert((int64_t)gift >= 0);
-  ceph_assert((int64_t)reclaim >= 0);
-  return gift > 0 ? (int64_t)gift : -(int64_t)reclaim;
-}
-
-int BlueStore::_balance_bluefs_freespace()
-{
-  int ret = 0;
-  ceph_assert(bluefs);
-
-  vector<pair<uint64_t,uint64_t>> bluefs_usage;  // <free, total> ...
-  bluefs->get_usage(&bluefs_usage);
-  ceph_assert(bluefs_usage.size() > bluefs_layout.shared_bdev);
-
-  bool clear_alert = true;
-  if (bluefs_layout.shared_bdev == BlueFS::BDEV_SLOW) {
-    auto& p = bluefs_usage[bluefs_layout.shared_bdev];
-    if (p.first != p.second) {
-      auto& db = bluefs_usage[BlueFS::BDEV_DB];
-      ostringstream ss;
-      ss << "spilled over " << byte_u_t(p.second - p.first)
-        << " metadata from 'db' device (" << byte_u_t(db.second - db.first)
-        << " used of " << byte_u_t(db.second) << ") to slow device";
-      _set_spillover_alert(ss.str());
-      clear_alert = false;
-    }
-  }
-  if (clear_alert) {
-    _clear_spillover_alert();
-  }
-
-  // fixme: look at primary bdev only for now
-  int64_t delta = _get_bluefs_size_delta(
-    bluefs_usage[bluefs_layout.shared_bdev].first,
-    bluefs_usage[bluefs_layout.shared_bdev].second);
-
-  // reclaim from bluefs?
-  if (delta < 0) {
-    // round up to alloc size
-    uint64_t alloc_size = bluefs->get_alloc_size(bluefs_layout.shared_bdev);
-    auto reclaim = p2roundup(uint64_t(-delta), alloc_size);
-
-    // hard cap to fit into 32 bits
-    reclaim = std::min<uint64_t>(reclaim, 1ull << 30);
-    dout(10) << __func__ << " reclaiming " << reclaim
-            << " (" << byte_u_t(reclaim) << ")" << dendl;
-
-    while (reclaim > 0) {
-      // NOTE: this will block and do IO.
-      PExtentVector extents;
-      int r = bluefs->reclaim_blocks(bluefs_layout.shared_bdev, reclaim,
-                                    &extents);
-      if (r < 0) {
-       derr << __func__ << " failed to reclaim space from bluefs"
-            << dendl;
-       break;
-      }
-      for (auto e : extents) {
-       ++out_of_sync_fm;
-       bluefs_extents.erase(e.offset, e.length);
-       bluefs_extents_reclaiming.insert(e.offset, e.length);
-       reclaim -= e.length;
-      }
-    }
-
-    ret = 1;
-  }
-
-  return ret;
-}
-
 int BlueStore::_open_collections()
 {
   dout(10) << __func__ << dendl;
@@ -6567,10 +6236,6 @@ int BlueStore::mkfs()
     }
   }
 
-  if (out_of_sync_fm.fetch_and(0)) {
-    _sync_bluefs_and_fm();
-  }
-
  out_close_fm:
   _close_fm();
  out_close_db:
@@ -6732,32 +6397,7 @@ int BlueStore::migrate_to_existing_bluefs_device(const set<int>& devs_source,
     used_space += bluefs->get_total(src_id) - bluefs->get_free(src_id);
   }
   uint64_t target_free = bluefs->get_free(id);
-  if (id == BlueFS::BDEV_SLOW && target_free < used_space) {
-    // will need to remount full BlueStore instance to allocate more space
-    _umount_for_bluefs();
-
-    r = mount();
-    ceph_assert(r == 0);
-    dout(1) << __func__
-            << " Allocating more space at slow device for BlueFS: +"
-           << used_space - target_free << " bytes" << dendl;
-    r = allocate_bluefs_freespace(
-      used_space - target_free,
-      used_space - target_free,
-      nullptr);
-
-    umount();
-    if (r != 0) {
-      derr << __func__
-          << " can't migrate, unable to allocate extra space: "
-          << used_space - target_free << " at target:" << id
-          << dendl;
-      return -ENOSPC;
-    }
-
-    r = _mount_for_bluefs();
-    ceph_assert(r == 0);
-  } else if (target_free < used_space) {
+  if (target_free < used_space) {
     derr << __func__
          << " can't migrate, free space at target: " << target_free
         << " is less than required space: " << used_space
@@ -8355,39 +7995,6 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
   }
 
   if (bluefs) {
-    if( cct->_conf->bluestore_bluefs_db_compatibility) {
-      interval_set<uint64_t> bluefs_extents_db;
-      bufferlist bl;
-      db->get(PREFIX_SUPER, "bluefs_extents", &bl);
-      auto p = bl.cbegin();
-      auto prev_errors = errors;
-      try {
-        decode(bluefs_extents_db, p);
-       bluefs_extents_db.union_of(bluefs_extents);
-       bluefs_extents_db.subtract(bluefs_extents);
-       if (!bluefs_extents_db.empty()) {
-         derr << "fsck error: bluefs_extents inconsistency, "
-              << "downgrade to previous releases might be broken."
-              << dendl;
-         ++errors;
-       }
-      }
-      catch (ceph::buffer::error& e) {
-       derr << "fsck error: failed to retrieve bluefs_extents from kv" << dendl;
-       ++errors;
-      }
-      if (errors != prev_errors && repair) {
-       repairer.fix_bluefs_extents(out_of_sync_fm);
-      }
-    }
-
-    for (auto e = bluefs_extents.begin(); e != bluefs_extents.end(); ++e) {
-      apply_for_bitset_range(
-        e.get_start(), e.get_len(), fm->get_alloc_size(), used_blocks,
-        [&](uint64_t pos, mempool_dynamic_bitset &bs) {
-          bs.set(pos);
-        });
-    }
     int r = bluefs->fsck();
     if (r < 0) {
       return r;
@@ -8869,16 +8476,6 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
 
     dout(1) << __func__ << " checking freelist vs allocated" << dendl;
     {
-      // remove bluefs_extents from used set since the freelist doesn't
-      // know they are allocated.
-      for (auto e = bluefs_extents.begin(); e != bluefs_extents.end(); ++e) {
-        apply_for_bitset_range(
-          e.get_start(), e.get_len(), fm->get_alloc_size(), used_blocks,
-          [&](uint64_t pos, mempool_dynamic_bitset &bs) {
-           bs.reset(pos);
-          }
-        );
-      }
       fm->enumerate_reset();
       uint64_t offset, length;
       while (fm->enumerate_next(db, &offset, &length)) {
@@ -12050,14 +11647,6 @@ void BlueStore::_kv_sync_thread()
       // transaction is ready for commit.
       throttle.release_kv_throttle(costs);
 
-      if (bluefs &&
-         after_flush - bluefs_last_balance >
-         ceph::make_timespan(cct->_conf->bluestore_bluefs_balance_interval)) {
-       bluefs_last_balance = after_flush;
-       int r = _balance_bluefs_freespace();
-       ceph_assert(r >= 0);
-      }
-
       // cleanup sync deferred keys
       for (auto b : deferred_stable) {
        for (auto& txc : b->txcs) {
@@ -12164,28 +11753,6 @@ void BlueStore::_kv_sync_thread()
          cct->_conf->bluestore_log_op_age);
       }
 
-      if (bluefs) {
-       if (!bluefs_extents_reclaiming.empty()) {
-         dout(0) << __func__ << " releasing old bluefs 0x" << std::hex
-                  << bluefs_extents_reclaiming << std::dec << dendl;
-         int r = 0;
-         if (cct->_conf->bdev_enable_discard && cct->_conf->bdev_async_discard) {
-           r = bdev->queue_discard(bluefs_extents_reclaiming);
-           if (r == 0) {
-             goto clear;
-           }
-         } else if (cct->_conf->bdev_enable_discard) {
-           for (auto p = bluefs_extents_reclaiming.begin(); p != bluefs_extents_reclaiming.end(); ++p) {
-             bdev->discard(p.get_start(), p.get_len());
-           }
-         }
-
-         alloc->release(bluefs_extents_reclaiming);
-clear:
-         bluefs_extents_reclaiming.clear();
-       }
-      }
-
       l.lock();
       // previously deferred "done" are now "stable" by virtue of this
       // commit cycle.
@@ -16099,16 +15666,6 @@ bool BlueStoreRepairer::fix_false_free(KeyValueDB *db,
   return true;
 }
 
-bool BlueStoreRepairer::fix_bluefs_extents(std::atomic<uint64_t>& out_of_sync_flag)
-{
-  // this is just a stub to count num of repairs properly,
-  // actual repair happens in BlueStore::_close_db_and_around()
-  // while doing _sync_bluefs_and_fm
-  ++out_of_sync_flag;
-  ++to_repair_cnt;
-  return true;
-}
-
 bool BlueStoreRepairer::preprocess_misreference(KeyValueDB *db)
 {
   if (misreferenced_extents.size()) {
index 2d05715e9b51c2d24c76a2fc96cd39f5d471220e..d2e356877c1326537aeb2843365e3f2de4407865 100644 (file)
@@ -147,7 +147,6 @@ enum {
 #define META_POOL_ID ((uint64_t)-1ull)
 
 class BlueStore : public ObjectStore,
-                 public BlueFSDeviceExpander,
                  public md_config_obs_t {
   // -----------------------------------------------------
   // types
@@ -2000,7 +1999,6 @@ public:
 private:
   BlueFS *bluefs = nullptr;
   bluefs_layout_t bluefs_layout;
-  ceph::mono_time bluefs_last_balance;
   utime_t next_dump_on_bluefs_alloc_failure;
 
   KeyValueDB *db = nullptr;
@@ -2031,9 +2029,6 @@ private:
   std::atomic<uint64_t> blobid_last = {0};
   std::atomic<uint64_t> blobid_max = {0};
 
-  interval_set<uint64_t> bluefs_extents;  ///< block extents owned by bluefs
-  interval_set<uint64_t> bluefs_extents_reclaiming; ///< currently reclaiming
-
   ceph::mutex deferred_lock = ceph::make_mutex("BlueStore::deferred_lock");
   ceph::mutex atomic_alloc_and_submit_lock =
       ceph::make_mutex("BlueStore::atomic_alloc_and_submit_lock");
@@ -2331,10 +2326,6 @@ private:
                              std::string* kv_dir, std::string* kv_backend);
   int _close_db_environment();
 
-  // updates legacy bluefs related recs in DB to a state valid for
-  // downgrades from nautilus.
-  void _sync_bluefs_and_fm();
-
   /*
    * @warning to_repair_db means that we open this db to repair it, will not
    * hold the rocksdb's file lock.
@@ -2391,9 +2382,6 @@ private:
 
   void _dump_alloc_on_failure();
 
-  int64_t _get_bluefs_size_delta(uint64_t bluefs_free, uint64_t bluefs_total);
-  int _balance_bluefs_freespace();
-
   CollectionRef _get_collection(const coll_t& cid);
   void _queue_reap_collection(CollectionRef& c);
   void _reap_collections();
@@ -2963,16 +2951,6 @@ public:
     return true;
   }
 
-  /*
-  Allocate space for BlueFS from slow device.
-  Either automatically applies allocated extents to underlying 
-  BlueFS (extents == nullptr) or just return them (non-null extents) provided
-  */
-  int allocate_bluefs_freespace(
-    uint64_t min_size,
-    uint64_t size,
-    PExtentVector* extents);
-
   inline void log_latency(const char* name,
     int idx,
     const ceph::timespan& lat,
@@ -3334,21 +3312,6 @@ private:
   std::array<std::tuple<uint64_t, uint64_t, uint64_t>, 5> alloc_stats_history =
   { std::make_tuple(0ul, 0ul, 0ul) };
 
-  std::atomic<uint64_t> out_of_sync_fm = {0};
-  // --------------------------------------------------------
-  // BlueFSDeviceExpander implementation
-  uint64_t get_recommended_expansion_delta(uint64_t bluefs_free,
-    uint64_t bluefs_total) override {
-    auto delta = _get_bluefs_size_delta(bluefs_free, bluefs_total);
-    return delta > 0 ? delta : 0;
-  }
-  int allocate_freespace(
-    uint64_t min_size,
-    uint64_t size,
-    PExtentVector& extents) override {
-    return allocate_bluefs_freespace(min_size, size, &extents);
-  };
-  uint64_t available_freespace(uint64_t alloc_size) override;
   inline bool _use_rotational_settings();
 
 public:
@@ -3608,7 +3571,6 @@ public:
   bool fix_false_free(KeyValueDB *db,
                      FreelistManager* fm,
                      uint64_t offset, uint64_t len);
-  bool fix_bluefs_extents(std::atomic<uint64_t>& out_of_sync_flag);
 
   void init(uint64_t total_space, uint64_t lres_tracking_unit_size);
 
index 4884232b925a549ccc5c376b1298c6c2df171cf8..52cdeb45ddaae0dfba3bfbb6d5d956660026c00b 100644 (file)
@@ -4728,41 +4728,6 @@ TEST_P(StoreTest, Synthetic) {
 }
 
 #if defined(WITH_BLUESTORE)
-TEST_P(StoreTestSpecificAUSize, BlueFSExtenderTest) {
-  if(string(GetParam()) != "bluestore")
-    return;
-
-  SetVal(g_conf(), "bluestore_block_db_size", "0");
-  SetVal(g_conf(), "bluestore_block_wal_size", "0");
-  SetVal(g_conf(), "bluestore_bluefs_min", "12582912");
-  SetVal(g_conf(), "bluestore_bluefs_min_free", "4194304");
-  SetVal(g_conf(), "bluestore_bluefs_gift_ratio", "0");
-  SetVal(g_conf(), "bluestore_bluefs_min_ratio", "0");
-  SetVal(g_conf(), "bluestore_bluefs_balance_interval", "100000");
-  SetVal(g_conf(), "bluestore_bluefs_db_compatibility", "false");
-
-  g_conf().apply_changes(nullptr);
-
-  StartDeferred(4096);
-
-  doSyntheticTest(10000, 400*1024, 40*1024, 0);
-
-  BlueStore* bstore = NULL;
-  EXPECT_NO_THROW(bstore = dynamic_cast<BlueStore*> (store.get()));
-
-  // verify downgrades are broken and repair that
-  bstore->umount();
-  ASSERT_EQ(bstore->fsck(false), 0);
-
-  SetVal(g_conf(), "bluestore_bluefs_db_compatibility", "true");
-  g_conf().apply_changes(nullptr);
-
-  ASSERT_EQ(bstore->fsck(false), 1);
-  ASSERT_EQ(bstore->repair(false), 0);
-  ASSERT_EQ(bstore->fsck(false), 0);
-  bstore->mount();
-}
-
 TEST_P(StoreTestSpecificAUSize, SyntheticMatrixSharding) {
   if (string(GetParam()) != "bluestore")
     return;
@@ -8402,30 +8367,6 @@ TEST_P(StoreTest, SpuriousReadErrorTest) {
   }
 }
 
-TEST_P(StoreTest, allocateBlueFSTest) {
-  if (string(GetParam()) != "bluestore")
-    return;
-
-  BlueStore* bstore = NULL;
-  EXPECT_NO_THROW(bstore = dynamic_cast<BlueStore*> (store.get()));
-
-  struct store_statfs_t statfs;
-  store->statfs(&statfs);
-
-  uint64_t to_alloc = g_conf().get_val<Option::size_t>("bluefs_alloc_size");
-
-  int r = bstore->allocate_bluefs_freespace(to_alloc, to_alloc, nullptr);
-  ASSERT_EQ(r, 0);
-  r = bstore->allocate_bluefs_freespace(statfs.total, statfs.total, nullptr);
-  ASSERT_EQ(r, -ENOSPC);
-  r = bstore->allocate_bluefs_freespace(to_alloc * 16, to_alloc * 16, nullptr);
-  ASSERT_EQ(r, 0);
-  store->umount();
-  ASSERT_EQ(store->fsck(false), 0); // do fsck explicitly
-  r = store->mount();
-  ASSERT_EQ(r, 0);
-}
-
 TEST_P(StoreTest, mergeRegionTest) {
   if (string(GetParam()) != "bluestore")
     return;