]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: moved snap_create header update notification to initiator 4498/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 7 Apr 2015 19:39:13 +0000 (15:39 -0400)
committerLoic Dachary <ldachary@redhat.com>
Wed, 29 Apr 2015 17:59:24 +0000 (19:59 +0200)
When handling a proxied snap_create operation, the client which
invoked the snap_create should send the header update notification
to avoid a possible race condition where snap_create completes but
the client doesn't see the new snapshot (since it didn't yet receive
the notification).

Fixes: #11342
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 6e20ed6834912ccd979d16e3f3b340c239e05288)

src/librbd/ImageWatcher.cc
src/librbd/ImageWatcher.h
src/librbd/internal.cc

index 142c2db84233df8693bcb4cd10bf49d415b033e6..fd400054766f676f9340ba88e263b50bb88e53a1 100644 (file)
@@ -389,11 +389,6 @@ void ImageWatcher::release_lock()
   unlock();
 }
 
-void ImageWatcher::finalize_header_update() {
-  librbd::notify_change(m_image_ctx.md_ctx, m_image_ctx.header_oid,
-                       &m_image_ctx);
-}
-
 void ImageWatcher::assert_header_locked(librados::ObjectWriteOperation *op) {
   rados::cls::lock::assert_locked(op, RBD_LOCK_NAME, LOCK_EXCLUSIVE,
                                   encode_lock_cookie(), WATCHER_LOCK_TAG);
@@ -898,16 +893,6 @@ void ImageWatcher::handle_payload(const SnapCreatePayload &payload,
     int r = librbd::snap_create(&m_image_ctx, payload.snap_name.c_str(), false);
 
     ::encode(ResponseMessage(r), *out);
-    if (r == 0) {
-      // increment now to avoid race due to the delayed notification
-      Mutex::Locker lictx(m_image_ctx.refresh_lock);
-      ++m_image_ctx.refresh_seq;
-
-      // cannot notify within a notificiation
-      FunctionContext *ctx = new FunctionContext(
-       boost::bind(&ImageWatcher::finalize_header_update, this));
-      m_task_finisher->queue(TASK_CODE_HEADER_UPDATE, ctx);
-    }
   }
 }
 
index 2ffe96569723aa9b27c21b4bc28fded053a6f343..d75e2fe22223fa8f26b919baf1ae1d07b3413afb 100644 (file)
@@ -74,7 +74,6 @@ namespace librbd {
       TASK_CODE_RELEASED_LOCK,
       TASK_CODE_RETRY_AIO_REQUESTS,
       TASK_CODE_CANCEL_ASYNC_REQUESTS,
-      TASK_CODE_HEADER_UPDATE,
       TASK_CODE_REREGISTER_WATCH,
       TASK_CODE_ASYNC_REQUEST,
       TASK_CODE_ASYNC_PROGRESS
@@ -212,7 +211,6 @@ namespace librbd {
     int lock();
     void release_lock();
     bool try_request_lock();
-    void finalize_header_update();
 
     void schedule_retry_aio_requests(bool use_timer);
     void retry_aio_requests();
index c356c79fe3b5efc1b372a60617df6be85f9cd24e..727ddb00e963b6f832cc17fc8c4d646d334f9555 100644 (file)
@@ -502,7 +502,8 @@ namespace librbd {
       }
 
       r = ictx->image_watcher->notify_snap_create(snap_name);
-      if (r == -EEXIST) {
+      if (r == 0 || r == -EEXIST) {
+        notify_change(ictx->md_ctx, ictx->header_oid, ictx);
         return 0;
       } else if (r != -ETIMEDOUT) {
        return r;