]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: potential race in RewatchRequest when resetting watch_handle
authorMykola Golub <mgolub@suse.com>
Tue, 13 Feb 2018 12:20:09 +0000 (14:20 +0200)
committerJason Dillaman <dillaman@redhat.com>
Wed, 3 Oct 2018 13:49:08 +0000 (09:49 -0400)
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit f5c02adfdbf5d9da0186fd494ee33c469445be83)

src/librbd/watcher/RewatchRequest.cc

index e103732e00e7030f5654b56a06798d71c6d27c5b..fe236269793a95d1e9bc9b0978eac73a4e4d98e9 100644 (file)
@@ -40,13 +40,14 @@ void RewatchRequest::unwatch() {
   CephContext *cct = reinterpret_cast<CephContext *>(m_ioctx.cct());
   ldout(cct, 10) << dendl;
 
+  uint64_t watch_handle = 0;
+  std::swap(*m_watch_handle, watch_handle);
+
   librados::AioCompletion *aio_comp = create_rados_callback<
                         RewatchRequest, &RewatchRequest::handle_unwatch>(this);
-  int r = m_ioctx.aio_unwatch(*m_watch_handle, aio_comp);
+  int r = m_ioctx.aio_unwatch(watch_handle, aio_comp);
   assert(r == 0);
   aio_comp->release();
-
-  *m_watch_handle = 0;
 }
 
 void RewatchRequest::handle_unwatch(int r) {