From 7156addcdc1e1a3df80bd68def2705c011170997 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Fri, 7 Apr 2023 21:30:54 +0530 Subject: [PATCH] librbd: on notify_quiesce() show attempts in a better format notify_quiesce() currently shows number of attempts in descending order, this might be bit confusing to read. Example: on the very first attempt, 2023-04-04T19:45:56.096+0530 7ff8ba7fc640 10 librbd::ImageWatcher: 0x7ff898008b30 notify_quiesce: async_request_id=[4151,140705343226832,23] attempts=10 I initially misread the above means 10 attempts where done. This commit tries to pick the format that is used by ImageWatcher::handle_payload() and ImageWatcher::notify_async_progress() Fixes: https://tracker.ceph.com/issues/59379 Signed-off-by: Prasanna Kumar Kalever --- src/librbd/ImageWatcher.cc | 34 ++++++++++++++++------------------ src/librbd/ImageWatcher.h | 4 ++-- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 85049fac74f9a..86148d3124b90 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -393,37 +393,35 @@ void ImageWatcher::notify_quiesce(uint64_t *request_id, AsyncRequestId async_request_id(get_client_id(), *request_id); - auto attempts = m_image_ctx.config.template get_val( + auto total_attempts = m_image_ctx.config.template get_val( "rbd_quiesce_notification_attempts"); - notify_quiesce(async_request_id, attempts, prog_ctx, on_finish); + notify_quiesce(async_request_id, 1, total_attempts, prog_ctx, on_finish); } template void ImageWatcher::notify_quiesce(const AsyncRequestId &async_request_id, - size_t attempts, ProgressContext &prog_ctx, + size_t attempt, size_t total_attempts, + ProgressContext &prog_ctx, Context *on_finish) { + ceph_assert(attempt <= total_attempts); ldout(m_image_ctx.cct, 10) << this << " " << __func__ << ": async_request_id=" - << async_request_id << " attempts=" << attempts - << dendl; + << async_request_id << " attempts @ " + << attempt << "/" << total_attempts << dendl; - ceph_assert(attempts > 0); auto notify_response = new watcher::NotifyResponse(); auto on_notify = new LambdaContext( [notify_response=std::unique_ptr(notify_response), - this, async_request_id, &prog_ctx, on_finish, attempts=attempts-1](int r) { - auto total_attempts = m_image_ctx.config.template get_val( - "rbd_quiesce_notification_attempts"); - if (total_attempts < attempts) { - total_attempts = attempts; - } - prog_ctx.update_progress(total_attempts - attempts, total_attempts); - + this, async_request_id, attempt, total_attempts, &prog_ctx, + on_finish](int r) { + prog_ctx.update_progress(attempt, total_attempts); if (r == -ETIMEDOUT) { - ldout(m_image_ctx.cct, 10) << this << " " << __func__ << ": async_request_id=" - << async_request_id << " timed out" << dendl; - if (attempts > 0) { - notify_quiesce(async_request_id, attempts, prog_ctx, on_finish); + ldout(m_image_ctx.cct, 10) << this << " " << __func__ + << ": async_request_id=" << async_request_id + << " timed out" << dendl; + if (attempt < total_attempts) { + notify_quiesce(async_request_id, attempt + 1, total_attempts, + prog_ctx, on_finish); return; } } else if (r == 0) { diff --git a/src/librbd/ImageWatcher.h b/src/librbd/ImageWatcher.h index cda9a246e0eec..1281320110d67 100644 --- a/src/librbd/ImageWatcher.h +++ b/src/librbd/ImageWatcher.h @@ -241,8 +241,8 @@ private: void cancel_quiesce_requests(); void notify_quiesce(const watch_notify::AsyncRequestId &async_request_id, - size_t attempts, ProgressContext &prog_ctx, - Context *on_finish); + size_t attempt, size_t total_attempts, + ProgressContext &prog_ctx, Context *on_finish); bool handle_operation_request( const watch_notify::AsyncRequestId& async_request_id, -- 2.39.5