From: Igor Fedotov Date: Mon, 10 Apr 2017 13:55:39 +0000 (+0000) Subject: os/bluestore: make dynamically loadable config parameters atomic X-Git-Tag: v12.0.3~324^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=736f39920784d136e7ee9cab8e42fdaa9f8242e6;p=ceph.git os/bluestore: make dynamically loadable config parameters atomic Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 95db56acced7..e9468af610d5 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7259,9 +7259,10 @@ void BlueStore::_txc_calc_cost(TransContext *txc) for (auto& p : txc->ioc.pending_aios) { ios += p.iov.size(); } - txc->cost = ios * throttle_cost_per_io + txc->bytes; + auto cost = throttle_cost_per_io.load(); + txc->cost = ios * cost + txc->bytes; dout(10) << __func__ << " " << txc << " cost " << txc->cost << " (" - << ios << " ios * " << throttle_cost_per_io << " + " << txc->bytes + << ios << " ios * " << cost << " + " << txc->bytes << " bytes)" << dendl; } @@ -9353,8 +9354,9 @@ int BlueStore::_do_alloc_write( AllocExtentVector extents; extents.reserve(4); // 4 should be (more than) enough for most allocations - int64_t got = alloc->allocate(final_length, min_alloc_size, max_alloc_size, - hint, &extents); + int64_t got = alloc->allocate(final_length, min_alloc_size, + max_alloc_size.load(), + hint, &extents); assert(got == (int64_t)final_length); need -= got; txc->statfs_delta.allocated() += got; @@ -9400,7 +9402,7 @@ int BlueStore::_do_alloc_write( // queue io if (!g_conf->bluestore_debug_omit_block_device_write) { - if (l->length() <= prefer_deferred_size) { + if (l->length() <= prefer_deferred_size.load()) { dout(20) << __func__ << " deferring small 0x" << std::hex << l->length() << std::dec << " write via deferred" << dendl; bluestore_deferred_op_t *op = _get_deferred_op(txc, o); @@ -9605,11 +9607,12 @@ int BlueStore::_do_write( CEPH_OSD_ALLOC_HINT_FLAG_APPEND_ONLY)) && (alloc_hints & CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_WRITE) == 0) { dout(20) << __func__ << " will prefer large blob and csum sizes" << dendl; + auto order = min_alloc_size_order.load(); if (o->onode.expected_write_size) { - wctx.csum_order = std::max(min_alloc_size_order, + wctx.csum_order = std::max(order, (size_t)ctzl(o->onode.expected_write_size)); } else { - wctx.csum_order = min_alloc_size_order; + wctx.csum_order = order; } if (wctx.compress) { diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 00e79b9902d3..77028ecdbadb 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1790,13 +1790,19 @@ private: size_t block_size_order = 0; ///< bits to shift to get block size uint64_t min_alloc_size = 0; ///< minimum allocation unit (power of 2) - size_t min_alloc_size_order = 0; ///< bits for min_alloc_size - uint64_t prefer_deferred_size = 0; ///< size threshold for forced deferred writes int deferred_batch_ops = 0; ///< deferred batch size - uint64_t max_alloc_size = 0; ///< maximum allocation unit (power of 2) + ///< bits for min_alloc_size + std::atomic min_alloc_size_order = {0}; + + ///< size threshold for forced deferred writes + std::atomic prefer_deferred_size = {0}; - uint64_t throttle_cost_per_io = 0; ///< approx cost per io, in bytes + ///< maximum allocation unit (power of 2) + std::atomic max_alloc_size = {0}; + + ///< approx cost per io, in bytes + std::atomic throttle_cost_per_io = {0}; std::atomic comp_mode = {Compressor::COMP_NONE}; ///< compression mode CompressorRef compressor;