mirror of
https://github.com/ceph/ceph
synced 2024-12-18 01:16:55 +00:00
os/bluestore/BlueStore: avoid iterating to get ios/cost in _kv_sync_thread.
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
This commit is contained in:
parent
6435c4a252
commit
45113968b8
@ -7516,6 +7516,9 @@ void BlueStore::_txc_state_proc(TransContext *txc)
|
||||
kv_queue_unsubmitted.push_back(txc);
|
||||
++txc->osr->kv_committing_serially;
|
||||
}
|
||||
if (txc->had_ios)
|
||||
kv_ios++;
|
||||
kv_throttle_costs += txc->cost;
|
||||
}
|
||||
return;
|
||||
case TransContext::STATE_KV_SUBMITTED:
|
||||
@ -7962,6 +7965,8 @@ void BlueStore::_kv_sync_thread()
|
||||
} else {
|
||||
deque<TransContext*> kv_submitting;
|
||||
deque<DeferredBatch*> deferred_done, deferred_stable;
|
||||
uint64_t aios = 0, costs = 0;
|
||||
|
||||
dout(20) << __func__ << " committing " << kv_queue.size()
|
||||
<< " submitting " << kv_queue_unsubmitted.size()
|
||||
<< " deferred done " << deferred_done_queue.size()
|
||||
@ -7971,6 +7976,10 @@ void BlueStore::_kv_sync_thread()
|
||||
kv_submitting.swap(kv_queue_unsubmitted);
|
||||
deferred_done.swap(deferred_done_queue);
|
||||
deferred_stable.swap(deferred_stable_queue);
|
||||
aios = kv_ios;
|
||||
costs = kv_throttle_costs;
|
||||
kv_ios = 0;
|
||||
kv_throttle_costs = 0;
|
||||
utime_t start = ceph_clock_now();
|
||||
l.unlock();
|
||||
|
||||
@ -7979,22 +7988,13 @@ void BlueStore::_kv_sync_thread()
|
||||
dout(30) << __func__ << " deferred_done " << deferred_done << dendl;
|
||||
dout(30) << __func__ << " deferred_stable " << deferred_stable << dendl;
|
||||
|
||||
int num_aios = 0;
|
||||
uint64_t total_cost = 0;
|
||||
for (auto txc : kv_committing) {
|
||||
if (txc->had_ios) {
|
||||
++num_aios;
|
||||
}
|
||||
total_cost += txc->cost;
|
||||
}
|
||||
|
||||
bool force_flush = false;
|
||||
// if bluefs is sharing the same device as data (only), then we
|
||||
// can rely on the bluefs commit to flush the device and make
|
||||
// deferred aios stable. that means that if we do have done deferred
|
||||
// txcs AND we are not on a single device, we need to force a flush.
|
||||
if (bluefs_single_shared_device && bluefs) {
|
||||
if (num_aios) {
|
||||
if (aios) {
|
||||
force_flush = true;
|
||||
} else if (kv_committing.empty() && kv_submitting.empty() &&
|
||||
deferred_stable.empty()) {
|
||||
@ -8006,7 +8006,7 @@ void BlueStore::_kv_sync_thread()
|
||||
force_flush = true;
|
||||
|
||||
if (force_flush) {
|
||||
dout(20) << __func__ << " num_aios=" << num_aios
|
||||
dout(20) << __func__ << " num_aios=" << aios
|
||||
<< " force_flush=" << (int)force_flush
|
||||
<< ", flushing, deferred done->stable" << dendl;
|
||||
// flush/barrier on block device
|
||||
@ -8073,7 +8073,7 @@ void BlueStore::_kv_sync_thread()
|
||||
// iteration there will already be ops awake. otherwise, we
|
||||
// end up going to sleep, and then wake up when the very first
|
||||
// transaction is ready for commit.
|
||||
throttle_bytes.put(total_cost);
|
||||
throttle_bytes.put(costs);
|
||||
|
||||
PExtentVector bluefs_gift_extents;
|
||||
if (bluefs &&
|
||||
|
@ -1863,6 +1863,9 @@ private:
|
||||
|
||||
std::atomic<uint64_t> max_blob_size = {0}; ///< maximum blob size
|
||||
|
||||
uint64_t kv_ios = 0;
|
||||
uint64_t kv_throttle_costs = 0;
|
||||
|
||||
// cache trim control
|
||||
|
||||
// note that these update in a racy way, but we don't *really* care if
|
||||
|
Loading…
Reference in New Issue
Block a user