summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Durgin <josh.durgin@inktank.com>2013-02-21 11:26:45 -0800
committerJosh Durgin <josh.durgin@inktank.com>2013-02-21 11:26:49 -0800
commita1ae8562877d1b902918e866a1699214090c40bd (patch)
treea6942b11ff6f9732326913a04eb1d01a8190f1b4
parent995ff0e3eaa560b242da8c019a2e11e735e854f7 (diff)
downloadceph-a1ae8562877d1b902918e866a1699214090c40bd.tar.gz
librbd: make sure racing flattens don't crash
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>
-rw-r--r--src/librbd/internal.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc
index e1c65f0df40..d913b314edd 100644
--- a/src/librbd/internal.cc
+++ b/src/librbd/internal.cc
@@ -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;