Skip to content

Commit

Permalink
librbd: better handling for duplicate flatten requests
Browse files Browse the repository at this point in the history
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 ef7e210)
  • Loading branch information
Jason Dillaman committed May 6, 2015
1 parent ec0bd1d commit d21c0c0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/librbd/internal.cc
Expand Up @@ -2516,6 +2516,14 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type,
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,
Expand All @@ -2524,9 +2532,13 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type,
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)
Expand Down

0 comments on commit d21c0c0

Please sign in to comment.