]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: Watcher should not attempt to re-watch after detecting blacklisting 35385/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 28 May 2020 20:38:40 +0000 (16:38 -0400)
committerNathan Cutler <ncutler@suse.com>
Thu, 4 Jun 2020 12:42:23 +0000 (14:42 +0200)
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 <dillaman@redhat.com>
(cherry picked from commit 6be1d49c35be4c937664939947a52f33696b0d8f)

src/librbd/Watcher.cc
src/test/librbd/test_mock_Watcher.cc

index c02598983e705174627f153710a8a5ef441a2279..9f866f25d9f579c600f8b7f1e1243e84967ec720 100644 (file)
@@ -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;
index 907f671e8771bf329e45c6a4d87abc8e913b1baf..529a56ab86f0d738404c5d853e956e8957e9ec29 100644 (file)
@@ -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(&register_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) {