From fab17270c0f311c4e91a6a370a073124d892f9ee Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 28 May 2020 16:38:40 -0400 Subject: [PATCH] librbd: Watcher should not attempt to re-watch after detecting blacklisting Currently, the Watcher state machine will spin as fast as it can sending re-watch requests to the OSD and then retrying after it fails with the EBLACKLISTED error. Treat a blacklisting similarly to how removal of the object is treated: stop attempting to re-watch. Fixes: https://tracker.ceph.com/issues/45715 Signed-off-by: Jason Dillaman (cherry picked from commit 6be1d49c35be4c937664939947a52f33696b0d8f) --- src/librbd/Watcher.cc | 2 +- src/test/librbd/test_mock_Watcher.cc | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/librbd/Watcher.cc b/src/librbd/Watcher.cc index c02598983e70..9f866f25d9f5 100644 --- a/src/librbd/Watcher.cc +++ b/src/librbd/Watcher.cc @@ -324,7 +324,7 @@ void Watcher::handle_rewatch_callback(int r) { if (m_unregister_watch_ctx != nullptr) { m_watch_state = WATCH_STATE_IDLE; std::swap(unregister_watch_ctx, m_unregister_watch_ctx); - } else if (r == -ENOENT) { + } else if (r == -EBLACKLISTED || r == -ENOENT) { m_watch_state = WATCH_STATE_IDLE; } else if (r < 0 || m_watch_error) { watch_error = true; diff --git a/src/test/librbd/test_mock_Watcher.cc b/src/test/librbd/test_mock_Watcher.cc index 907f671e8771..529a56ab86f0 100644 --- a/src/test/librbd/test_mock_Watcher.cc +++ b/src/test/librbd/test_mock_Watcher.cc @@ -293,12 +293,6 @@ TEST_F(TestMockWatcher, ReregisterWatchBlacklist) { expect_aio_unwatch(mock_image_ctx, 0); expect_aio_watch(mock_image_ctx, -EBLACKLISTED); - C_SaferCond blacklist_ctx; - expect_aio_watch(mock_image_ctx, 0, [&blacklist_ctx]() { - blacklist_ctx.wait(); - }); - expect_aio_unwatch(mock_image_ctx, 0); - C_SaferCond register_ctx; mock_image_watcher.register_watch(®ister_ctx); ASSERT_TRUE(wait_for_watch(mock_image_ctx, 1)); @@ -309,17 +303,11 @@ TEST_F(TestMockWatcher, ReregisterWatchBlacklist) { // wait for recovery unwatch/watch ASSERT_TRUE(wait_for_watch(mock_image_ctx, 2)); - ASSERT_TRUE(mock_image_watcher.is_blacklisted()); - blacklist_ctx.complete(0); - - // wait for post-blacklist recovery watch - ASSERT_TRUE(wait_for_watch(mock_image_ctx, 1)); C_SaferCond unregister_ctx; mock_image_watcher.unregister_watch(&unregister_ctx); ASSERT_EQ(0, unregister_ctx.wait()); - ASSERT_FALSE(mock_image_watcher.is_blacklisted()); } TEST_F(TestMockWatcher, ReregisterUnwatchPendingUnregister) { -- 2.47.3