]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: fix rbd close race with rewatch
authorSong Shun <song.shun3@zte.com.cn>
Tue, 10 Apr 2018 05:41:18 +0000 (13:41 +0800)
committerJason Dillaman <dillaman@redhat.com>
Wed, 3 Oct 2018 13:50:54 +0000 (09:50 -0400)
  fix rbd close race with rewatch

Signed-off-by: Song Shun <song.shun3@zte.com.cn>
(cherry picked from commit 8b833a293eac54fd3d38f12660d856ecc310d805)

Conflicts:
src/librbd/Watcher.cc: trivial resolution

src/librbd/Watcher.cc
src/librbd/watcher/RewatchRequest.cc
src/test/librbd/watcher/test_mock_RewatchRequest.cc

index 6e31ad7c635929408ace2bd9a80c4a845b74ec12..9a72fc13a76b1a722cd8621c583b48ff262ca927 100644 (file)
@@ -263,7 +263,7 @@ void Watcher::rewatch() {
 }
 
 void Watcher::handle_rewatch(int r) {
-  ldout(m_cct, 10) "r=" << r << dendl;
+  ldout(m_cct, 10) << "r=" << r << dendl;
 
   bool watch_error = false;
   Context *unregister_watch_ctx = nullptr;
index fe236269793a95d1e9bc9b0978eac73a4e4d98e9..22d2bb8e567888312790f3ae6e4fb968cf8f7b08 100644 (file)
@@ -78,19 +78,10 @@ void RewatchRequest::rewatch() {
 void RewatchRequest::handle_rewatch(int r) {
   CephContext *cct = reinterpret_cast<CephContext *>(m_ioctx.cct());
   ldout(cct, 10) << "r=" << r << dendl;
-
-  if (r == -EBLACKLISTED) {
-    lderr(cct) << "client blacklisted" << dendl;
-    finish(r);
-    return;
-  } else if (r == -ENOENT) {
-    ldout(cct, 5) << "object deleted" << dendl;
-    finish(r);
-    return;
-  } else if (r < 0) {
+  if (r < 0) {
     lderr(cct) << "failed to watch object: " << cpp_strerror(r)
                << dendl;
-    rewatch();
+    finish(r);
     return;
   }
 
index 3b42b0e992491ac8ba857f7f6fa026d11af51656..e9e7d2fbe1dfea45bbf6ca11b43ff6fd699159d7 100644 (file)
@@ -176,7 +176,6 @@ TEST_F(TestMockWatcherRewatchRequest, WatchError) {
   InSequence seq;
   expect_aio_unwatch(mock_image_ctx, 0);
   expect_aio_watch(mock_image_ctx, -EINVAL);
-  expect_aio_watch(mock_image_ctx, 0);
 
   C_SaferCond ctx;
   MockRewatchRequest *req = MockRewatchRequest::create(mock_image_ctx.md_ctx,
@@ -189,7 +188,7 @@ TEST_F(TestMockWatcherRewatchRequest, WatchError) {
     RWLock::WLocker watch_locker(m_watch_lock);
     req->send();
   }
-  ASSERT_EQ(0, ctx.wait());
+  ASSERT_EQ(-EINVAL, ctx.wait());
 }
 
 } // namespace watcher