]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: better handling for duplicate flatten requests
authorJason Dillaman <dillaman@redhat.com>
Tue, 21 Apr 2015 16:59:33 +0000 (12:59 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 6 May 2015 15:51:37 +0000 (11:51 -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>
(cherry picked from commit ef7e210c3f747bc4c3c8768c7b6407cc91c5c319)

src/librbd/internal.cc

index 664927c0f21ba70ad6157f039ff81052e7c96a94..2c06a3ec29614660f04569d5d143a2e002bbdd9f 100644 (file)
@@ -2516,6 +2516,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,
@@ -2524,9 +2532,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)