]> 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>
Tue, 23 Apr 2013 18:33:17 +0000 (11:33 -0700)
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>
(cherry picked from commit a1ae8562877d1b902918e866a1699214090c40bd)

src/librbd/internal.cc

index c56106654a795217d1bd3cebaedad1606b47b5d6..ca6dbb7d4dfea83ba39eb8a4619e60e71b7def43 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;