]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: re-register watch on old format image rename
authorMykola Golub <mgolub@mirantis.com>
Wed, 15 Jun 2016 08:31:14 +0000 (11:31 +0300)
committerMykola Golub <mgolub@mirantis.com>
Wed, 15 Jun 2016 08:31:14 +0000 (11:31 +0300)
The watching object name is changed when renaming an old format image,
so unregister the watcher before the rename, and register back after,
to avoid "Transport endpoint is not connected" error.

Fixes: http://tracker.ceph.com/issues/16321
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/librbd/Operations.cc

index f19ebf2b891146a1575ae86f3e60137e000d8fe2..7769f97f983918bfe953284009ca0da307e134a6 100644 (file)
@@ -534,7 +534,18 @@ void Operations<I>::execute_rename(const char *dstname, Context *on_finish) {
                 << dendl;
 
   if (m_image_ctx.old_format) {
+    // unregister watch before and register back after rename
     on_finish = new C_NotifyUpdate<I>(m_image_ctx, on_finish);
+    on_finish = new FunctionContext([this, on_finish](int r) {
+       m_image_ctx.image_watcher->register_watch(on_finish);
+      });
+    on_finish = new FunctionContext([this, dstname, on_finish](int r) {
+       operation::RenameRequest<I> *req = new operation::RenameRequest<I>(
+         m_image_ctx, on_finish, dstname);
+       req->send();
+      });
+    m_image_ctx.image_watcher->unregister_watch(on_finish);
+    return;
   }
   operation::RenameRequest<I> *req = new operation::RenameRequest<I>(
     m_image_ctx, on_finish, dstname);