From: Ramesh Chander Date: Fri, 9 Sep 2016 12:43:46 +0000 (-0700) Subject: min_min_alloc_size to accommodate changing min_alloc_size X-Git-Tag: v11.0.1~246^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F11014%2Fhead;p=ceph.git min_min_alloc_size to accommodate changing min_alloc_size Signed-off-by: Ramesh Chander --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index f09b22faeaba..0ded9eb3532a 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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(); diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index eac753e766b9..9abd6849003e 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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();