]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: better handling for duplicate flatten requests 4423/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 21 Apr 2015 16:59:33 +0000 (12:59 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 21 Apr 2015 17:02:29 +0000 (13:02 -0400)
A proxied flatten request could be replayed, resulting in a
-EINVAL error code being generated on the second attempt. Filter
out that error if it is known the parent did exist before the
op started.

Fixes: #11370
Backport: hammer
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/internal.cc

index ac219ad3a7c58af02d3293460e20ad0f48ce21fa..01d415dc542baf631511cbe5fdcacfcb0b6f2e11 100644 (file)
@@ -2628,6 +2628,14 @@ reprotect_and_return_err:
       return r;
     }
 
+    {
+      RWLock::RLocker parent_locker(ictx->parent_lock);
+      if (ictx->parent_md.spec.pool_id == -1) {
+       lderr(cct) << "image has no parent" << dendl;
+       return -EINVAL;
+      }
+    }
+
     uint64_t request_id = ictx->async_request_seq.inc();
     r = invoke_async_request(ictx, "flatten",
                              boost::bind(&async_flatten, ictx, _1,
@@ -2636,9 +2644,13 @@ reprotect_and_return_err:
                                          ictx->image_watcher, request_id,
                                          boost::ref(prog_ctx)));
 
+    if (r < 0 && r != -EINVAL) {
+      return r;
+    }
+
     notify_change(ictx->md_ctx, ictx->header_oid, ictx);
     ldout(cct, 20) << "flatten finished" << dendl;
-    return r;
+    return 0;
   }
 
   int async_flatten(ImageCtx *ictx, Context *ctx, ProgressContext &prog_ctx)