]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: filter out potential race with image rename 19855/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 20 Dec 2017 21:55:06 +0000 (16:55 -0500)
committerPrashant D <pdhange@redhat.com>
Tue, 9 Jan 2018 00:01:51 +0000 (19:01 -0500)
Fixes: http://tracker.ceph.com/issues/18435
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 001d2fc35c170f17e706aeae541fb86dac960319)

src/librbd/operation/RenameRequest.cc

index cfd54d1d860409b24be5fd3033dea8ba33915e68..75630915598fc00e9a918d5eaebcf42827923378 100644 (file)
@@ -74,8 +74,10 @@ bool RenameRequest<I>::should_complete(int r) {
     return true;
   }
 
-  if (m_state == STATE_REMOVE_SOURCE_HEADER) {
+  if (m_state == STATE_UPDATE_DIRECTORY) {
+    // update in-memory name before removing source header
     apply();
+  } else if (m_state == STATE_REMOVE_SOURCE_HEADER) {
     return true;
   }
 
@@ -102,7 +104,13 @@ int RenameRequest<I>::filter_state_return_code(int r) {
   I &image_ctx = this->m_image_ctx;
   CephContext *cct = image_ctx.cct;
 
-  if (m_state == STATE_REMOVE_SOURCE_HEADER && r < 0) {
+  if (m_state == STATE_READ_SOURCE_HEADER && r == -ENOENT) {
+    RWLock::RLocker snap_locker(image_ctx.snap_lock);
+    if (image_ctx.name == m_dest_name) {
+      // signal that replay raced with itself
+      return -EEXIST;
+    }
+  } else if (m_state == STATE_REMOVE_SOURCE_HEADER && r < 0) {
     if (r != -ENOENT) {
       lderr(cct) << "warning: couldn't remove old source object ("
                  << m_source_oid << ")" << dendl;