From: Mykola Golub Date: Wed, 23 Jan 2019 12:09:52 +0000 (+0200) Subject: rbd-mirror: guard access to image replayer perf counters X-Git-Tag: v14.1.0~252^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d0f99bfbf5bb2ad912fd76e500090357b6b7ee80;p=ceph.git rbd-mirror: guard access to image replayer perf counters It may be modified by reregister_admin_socket_hook. Signed-off-by: Mykola Golub --- diff --git a/src/tools/rbd_mirror/ImageReplayer.cc b/src/tools/rbd_mirror/ImageReplayer.cc index 058aaad094a..eb094ea6050 100644 --- a/src/tools/rbd_mirror/ImageReplayer.cc +++ b/src/tools/rbd_mirror/ImageReplayer.cc @@ -1254,21 +1254,26 @@ void ImageReplayer::handle_process_entry_safe(const ReplayEntry &replay_entry m_remote_journaler->committed(replay_entry); } - m_perf_counters->inc(l_rbd_mirror_replay); - m_perf_counters->inc(l_rbd_mirror_replay_bytes, - replay_entry.get_data().length()); - m_perf_counters->tinc(l_rbd_mirror_replay_latency, - ceph_clock_now() - replay_start_time); + auto bytes = replay_entry.get_data().length(); + auto latency = ceph_clock_now() - replay_start_time; if (g_perf_counters) { g_perf_counters->inc(l_rbd_mirror_replay); - g_perf_counters->inc(l_rbd_mirror_replay_bytes, - replay_entry.get_data().length()); - g_perf_counters->tinc(l_rbd_mirror_replay_latency, - ceph_clock_now() - replay_start_time); + g_perf_counters->inc(l_rbd_mirror_replay_bytes, bytes); + g_perf_counters->tinc(l_rbd_mirror_replay_latency, latency); } - m_event_replay_tracker.finish_op(); + auto ctx = new FunctionContext( + [this, bytes, latency](int r) { + Mutex::Locker locker(m_lock); + if (m_perf_counters) { + m_perf_counters->inc(l_rbd_mirror_replay); + m_perf_counters->inc(l_rbd_mirror_replay_bytes, bytes); + m_perf_counters->tinc(l_rbd_mirror_replay_latency, latency); + } + m_event_replay_tracker.finish_op(); + }); + m_threads->work_queue->queue(ctx, 0); } template