From 6e20ed6834912ccd979d16e3f3b340c239e05288 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 7 Apr 2015 15:39:13 -0400 Subject: [PATCH] librbd: moved snap_create header update notification to initiator 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 --- src/librbd/ImageWatcher.cc | 15 --------------- src/librbd/ImageWatcher.h | 2 -- src/librbd/internal.cc | 3 ++- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index ab708521085a0..218f1a394e467 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -387,11 +387,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); @@ -896,16 +891,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); - } } } diff --git a/src/librbd/ImageWatcher.h b/src/librbd/ImageWatcher.h index 2ffe96569723a..d75e2fe22223f 100644 --- a/src/librbd/ImageWatcher.h +++ b/src/librbd/ImageWatcher.h @@ -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(); diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 64879a034fb1e..5e96476a58e52 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -531,7 +531,8 @@ int remove_object_map(ImageCtx *ictx) { } 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; -- 2.39.5