From: Jason Dillaman Date: Thu, 28 May 2020 20:38:40 +0000 (-0400) Subject: librbd: Watcher should not attempt to re-watch after detecting blacklisting X-Git-Tag: v16.1.0~2200^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F35301%2Fhead;p=ceph.git 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 --- diff --git a/src/librbd/Watcher.cc b/src/librbd/Watcher.cc index 0014cdf3d914..3d9a85f1d27c 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 704d7895b007..b36ec3e31f2a 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) {