]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
min_min_alloc_size to accommodate changing min_alloc_size 11014/head
authorRamesh Chander <Ramesh.Chander@sandisk.com>
Fri, 9 Sep 2016 12:43:46 +0000 (05:43 -0700)
committerRamesh Chander <Ramesh.Chander@sandisk.com>
Tue, 13 Sep 2016 06:47:09 +0000 (23:47 -0700)
Signed-off-by: Ramesh Chander <Ramesh.Chander@sandisk.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index f09b22faeaba3096f1f05a110b2439b1cbe5801e..0ded9eb3532a4ede047df757a6f4985400d1eb88 100644 (file)
@@ -2748,7 +2748,7 @@ int BlueStore::_open_alloc()
   assert(bdev->get_size());
   alloc = Allocator::create(g_conf->bluestore_allocator,
                             bdev->get_size(),
-                            block_size);
+                            min_min_alloc_size);
   uint64_t num = 0, bytes = 0;
 
   // initialize from freelist
@@ -3569,6 +3569,8 @@ int BlueStore::mkfs()
   if (r < 0)
     goto out_close_db;
 
+  _save_min_min_alloc_size(min_alloc_size);
+
   r = _open_alloc();
   if (r < 0)
     goto out_close_fm;
@@ -5648,9 +5650,38 @@ ObjectMap::ObjectMapIterator BlueStore::get_omap_iterator(
   return ObjectMap::ObjectMapIterator(new OmapIteratorImpl(c, o, it));
 }
 
-
 // -----------------
 // write helpers
+void BlueStore::_save_min_min_alloc_size(uint64_t new_val)
+{
+  assert(new_val > 0);
+  if (new_val == min_min_alloc_size && min_min_alloc_size > 0) {
+    return;
+  }
+
+  if (new_val > min_min_alloc_size && min_min_alloc_size > 0) {
+    derr << "warning: bluestore_min_alloc_size "
+         << new_val << " > min_min_alloc_size " << min_min_alloc_size << ","
+         << " may impact performance." << dendl;
+    return;
+  }
+
+  if (new_val < min_min_alloc_size && min_min_alloc_size > 0) {
+    derr << "warning: bluestore_min_alloc_size value decreased from "
+         << min_min_alloc_size << " to " << new_val << "."
+         << " Decreased value could have performance impact." << dendl;
+  }
+
+
+  KeyValueDB::Transaction t = db->get_transaction();
+  {
+    bufferlist bl;
+    encode(new_val, bl);
+    t->set(PREFIX_SUPER, "min_min_alloc_size", bl);
+    db->submit_transaction_sync(t);
+  }
+  min_min_alloc_size = new_val;
+}
 
 int BlueStore::_open_super_meta()
 {
@@ -5696,6 +5727,21 @@ int BlueStore::_open_super_meta()
     }
   }
 
+  // Min min_alloc_size
+  {
+    bufferlist bl;
+    min_min_alloc_size = 0;
+    db->get(PREFIX_SUPER, "min_min_alloc_size", &bl);
+    bufferlist::iterator p = bl.begin();
+    try {
+      ::decode(min_min_alloc_size, p);
+    } catch (buffer::error& e) {
+    }
+
+    _save_min_min_alloc_size(min_alloc_size);
+    dout(10) << __func__ << " min_min_alloc_size " << min_min_alloc_size << dendl;
+  }
+
   // bluefs alloc
   {
     bluefs_extents.clear();
index eac753e766b99b29468758e4b05f18ac058c0d3b..9abd6849003e68b72f96b8025b7a33d86109437d 100644 (file)
@@ -1315,6 +1315,7 @@ private:
   size_t block_size_order; ///< bits to shift to get block size
 
   uint64_t min_alloc_size = 0; ///< minimum allocation unit (power of 2)
+  uint64_t min_min_alloc_size = 0; /// < minimum seen min_alloc_size
   size_t min_alloc_size_order = 0; ///< bits for min_alloc_size
 
   uint64_t max_alloc_size; ///< maximum allocation unit (power of 2)
@@ -1376,6 +1377,7 @@ private:
   int _check_or_set_bdev_label(string path, uint64_t size, string desc,
                               bool create);
 
+  void _save_min_min_alloc_size(uint64_t new_val);
   int _open_super_meta();
 
   int _reconcile_bluefs_freespace();