: m_image_ctx(image_ctx), m_state(STATE_UNINITIALIZED),
m_lock(util::unique_lock_name("librbd::ImageState::m_lock", this)),
m_last_refresh(0), m_refresh_seq(0),
- m_update_watchers(new ImageUpdateWatchers(image_ctx->cct)),
- m_skip_open_parent_image(false) {
+ m_update_watchers(new ImageUpdateWatchers(image_ctx->cct)) {
}
template <typename I>
}
template <typename I>
-int ImageState<I>::open(bool skip_open_parent) {
+int ImageState<I>::open(uint64_t flags) {
C_SaferCond ctx;
- open(skip_open_parent, &ctx);
+ open(flags, &ctx);
int r = ctx.wait();
if (r < 0) {
}
template <typename I>
-void ImageState<I>::open(bool skip_open_parent, Context *on_finish) {
+void ImageState<I>::open(uint64_t flags, Context *on_finish) {
CephContext *cct = m_image_ctx->cct;
ldout(cct, 20) << __func__ << dendl;
m_lock.Lock();
assert(m_state == STATE_UNINITIALIZED);
- m_skip_open_parent_image = skip_open_parent;
+ m_open_flags = flags;
Action action(ACTION_TYPE_OPEN);
action.refresh_seq = m_refresh_seq;
*m_image_ctx, create_context_callback<
ImageState<I>, &ImageState<I>::handle_open>(this));
image::OpenRequest<I> *req = image::OpenRequest<I>::create(
- m_image_ctx, m_skip_open_parent_image, ctx);
+ m_image_ctx, m_open_flags, ctx);
m_lock.Unlock();
req->send();
for (auto &id_it : info.second) {
ImageCtx *imctx = new ImageCtx("", id_it, NULL, ioctx, false);
- int r = imctx->state->open(false);
+ int r = imctx->state->open(0);
if (r < 0) {
lderr(cct) << "error opening image: "
<< cpp_strerror(r) << dendl;
// make sure parent snapshot exists
ImageCtx *p_imctx = new ImageCtx(p_name, "", p_snap_name, p_ioctx, true);
- int r = p_imctx->state->open(false);
+ int r = p_imctx->state->open(0);
if (r < 0) {
lderr(cct) << "error opening parent image: "
<< cpp_strerror(r) << dendl;
<< dstname << dendl;
ImageCtx *ictx = new ImageCtx(srcname, "", "", io_ctx, false);
- int r = ictx->state->open(false);
+ int r = ictx->state->open(0);
if (r < 0) {
lderr(cct) << "error opening source image: " << cpp_strerror(r) << dendl;
return r;
ImageCtx *ictx = new ImageCtx((image_id.empty() ? image_name : ""),
image_id, nullptr, io_ctx, false);
- r = ictx->state->open(true);
+ r = ictx->state->open(OPEN_FLAG_SKIP_OPEN_PARENT);
if (r == -ENOENT) {
return r;
} else if (r < 0) {
ImageCtx *dest = new librbd::ImageCtx(destname, "", NULL,
dest_md_ctx, false);
- r = dest->state->open(false);
+ r = dest->state->open(0);
if (r < 0) {
lderr(cct) << "failed to read newly created header" << dendl;
return r;
delete reinterpret_cast<librbd::ImageCtx*>(*ictxp);
*ictxp = nullptr;
- ictx->state->open(false, new C_OpenComplete(ictx, comp, ictxp));
+ ictx->state->open(0, new C_OpenComplete(ictx, comp, ictxp));
}
};
image.ctx = NULL;
}
- int r = ictx->state->open(false);
+ int r = ictx->state->open(0);
if (r < 0) {
tracepoint(librbd, open_image_exit, r);
return r;
image.ctx = nullptr;
}
- int r = ictx->state->open(false);
+ int r = ictx->state->open(0);
if (r < 0) {
tracepoint(librbd, open_image_by_id_exit, r);
return r;
reinterpret_cast<ImageCtx*>(image.ctx)->state->close(
new C_OpenAfterCloseComplete(ictx, get_aio_completion(c), &image.ctx));
} else {
- ictx->state->open(false, new C_OpenComplete(ictx, get_aio_completion(c),
- &image.ctx));
+ ictx->state->open(0, new C_OpenComplete(ictx, get_aio_completion(c),
+ &image.ctx));
}
tracepoint(librbd, aio_open_image_exit, 0);
return 0;
reinterpret_cast<ImageCtx*>(image.ctx)->state->close(
new C_OpenAfterCloseComplete(ictx, get_aio_completion(c), &image.ctx));
} else {
- ictx->state->open(false, new C_OpenComplete(ictx, get_aio_completion(c),
- &image.ctx));
+ ictx->state->open(0, new C_OpenComplete(ictx, get_aio_completion(c),
+ &image.ctx));
}
tracepoint(librbd, aio_open_image_by_id_exit, 0);
return 0;
image.ctx = NULL;
}
- int r = ictx->state->open(false);
+ int r = ictx->state->open(0);
if (r < 0) {
tracepoint(librbd, open_image_exit, r);
return r;
image.ctx = nullptr;
}
- int r = ictx->state->open(false);
+ int r = ictx->state->open(0);
if (r < 0) {
tracepoint(librbd, open_image_by_id_exit, r);
return r;
reinterpret_cast<ImageCtx*>(image.ctx)->state->close(
new C_OpenAfterCloseComplete(ictx, get_aio_completion(c), &image.ctx));
} else {
- ictx->state->open(false, new C_OpenComplete(ictx, get_aio_completion(c),
- &image.ctx));
+ ictx->state->open(0, new C_OpenComplete(ictx, get_aio_completion(c),
+ &image.ctx));
}
tracepoint(librbd, aio_open_image_exit, 0);
return 0;
reinterpret_cast<ImageCtx*>(image.ctx)->state->close(
new C_OpenAfterCloseComplete(ictx, get_aio_completion(c), &image.ctx));
} else {
- ictx->state->open(false, new C_OpenComplete(ictx, get_aio_completion(c),
- &image.ctx));
+ ictx->state->open(0, new C_OpenComplete(ictx, get_aio_completion(c),
+ &image.ctx));
}
tracepoint(librbd, aio_open_image_by_id_exit, 0);
return 0;
false);
tracepoint(librbd, open_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
- int r = ictx->state->open(false);
+ int r = ictx->state->open(0);
if (r >= 0) {
*image = (rbd_image_t)ictx;
}
tracepoint(librbd, open_image_enter, ictx, ictx->name.c_str(),
ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
- int r = ictx->state->open(false);
+ int r = ictx->state->open(0);
if (r < 0) {
delete ictx;
} else {
false);
librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
tracepoint(librbd, aio_open_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only, comp->pc);
- ictx->state->open(false, new C_OpenComplete(ictx, get_aio_completion(comp), image));
+ ictx->state->open(0, new C_OpenComplete(ictx, get_aio_completion(comp),
+ image));
tracepoint(librbd, aio_open_image_exit, 0);
return 0;
}
tracepoint(librbd, aio_open_image_enter, ictx, ictx->name.c_str(),
ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only,
comp->pc);
- ictx->state->open(false, new C_OpenComplete(ictx, get_aio_completion(comp), image));
+ ictx->state->open(0, new C_OpenComplete(ictx, get_aio_completion(comp),
+ image));
tracepoint(librbd, aio_open_image_exit, 0);
return 0;
}
true);
tracepoint(librbd, open_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
- int r = ictx->state->open(false);
+ int r = ictx->state->open(0);
if (r >= 0) {
*image = (rbd_image_t)ictx;
}
tracepoint(librbd, open_image_enter, ictx, ictx->name.c_str(),
ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
- int r = ictx->state->open(false);
+ int r = ictx->state->open(0);
if (r < 0) {
delete ictx;
} else {
true);
librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
tracepoint(librbd, aio_open_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only, comp->pc);
- ictx->state->open(false, new C_OpenComplete(ictx, get_aio_completion(comp),
- image));
+ ictx->state->open(0, new C_OpenComplete(ictx, get_aio_completion(comp),
+ image));
tracepoint(librbd, aio_open_image_exit, 0);
return 0;
}
librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
tracepoint(librbd, aio_open_image_enter, ictx, ictx->name.c_str(),
ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only, comp->pc);
- ictx->state->open(false, new C_OpenComplete(ictx, get_aio_completion(comp),
- image));
+ ictx->state->open(0, new C_OpenComplete(ictx, get_aio_completion(comp),
+ image));
tracepoint(librbd, aio_open_image_exit, 0);
return 0;
}