]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: make sure racing flattens don't crash
authorJosh Durgin <josh.durgin@inktank.com>
Thu, 21 Feb 2013 19:26:45 +0000 (11:26 -0800)
committerJosh Durgin <josh.durgin@inktank.com>
Thu, 21 Feb 2013 19:26:49 +0000 (11:26 -0800)
The only way for a parent to disappear is a racing flatten completing,
or possibly in the future the image being forcibly removed. In either
case, continuing to flatten makes no sense, so stop early.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/librbd/internal.cc

index e1c65f0df40296f44302601547a64a55c8835423..d913b314edd4f9b61269348010285ea68850fcf0 100644 (file)
@@ -2017,6 +2017,12 @@ reprotect_and_return_err:
       assert(object_overlap <= object_size);
 
       RWLock::RLocker l(ictx->parent_lock);
+      // stop early if the parent went away - it just means
+      // another flatten finished first, so this one is useless.
+      if (!ictx->parent) {
+       r = 0;
+       goto err;
+      }
       if ((r = read(ictx->parent, objectx, buf, NULL)) < 0) {
        lderr(ictx->cct) << "reading from parent failed" << dendl;
        goto err;