summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMykola Golub <to.my.trociny@gmail.com>2017-12-10 20:16:37 +0100
committerJason Dillaman <dillaman@redhat.com>2018-08-15 00:29:44 +0200
commit3d785798e185229856181d2e1f220560be08e82e (patch)
treea408e14bc427887173f30dfbe564a56dd249bff8 /src
parentcls/rbd: add assert_snapc_seq method (diff)
downloadceph-3d785798e185229856181d2e1f220560be08e82e.tar.xz
ceph-3d785798e185229856181d2e1f220560be08e82e.zip
librbd: add flags to open request
Signed-off-by: Mykola Golub <mgolub@suse.com>
Diffstat (limited to 'src')
-rw-r--r--src/librbd/ImageState.cc13
-rw-r--r--src/librbd/ImageState.h6
-rw-r--r--src/librbd/Types.h4
-rw-r--r--src/librbd/api/Mirror.cc4
-rw-r--r--src/librbd/image/CloneRequest.cc2
-rw-r--r--src/librbd/image/OpenRequest.cc5
-rw-r--r--src/librbd/image/OpenRequest.h6
-rw-r--r--src/librbd/image/RefreshParentRequest.cc2
-rw-r--r--src/librbd/internal.cc10
-rw-r--r--src/librbd/librbd.cc48
-rw-r--r--src/tools/rbd_mirror/image_deleter/SnapshotPurgeRequest.cc2
-rw-r--r--src/tools/rbd_mirror/image_replayer/OpenImageRequest.cc2
-rw-r--r--src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc2
13 files changed, 56 insertions, 50 deletions
diff --git a/src/librbd/ImageState.cc b/src/librbd/ImageState.cc
index c290e6b988d..12f7700bae0 100644
--- a/src/librbd/ImageState.cc
+++ b/src/librbd/ImageState.cc
@@ -234,8 +234,7 @@ ImageState<I>::ImageState(I *image_ctx)
: 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>
@@ -245,9 +244,9 @@ ImageState<I>::~ImageState() {
}
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) {
@@ -257,13 +256,13 @@ int ImageState<I>::open(bool skip_open_parent) {
}
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;
@@ -583,7 +582,7 @@ void ImageState<I>::send_open_unlock() {
*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();
diff --git a/src/librbd/ImageState.h b/src/librbd/ImageState.h
index d577f290d92..7f28d1eec71 100644
--- a/src/librbd/ImageState.h
+++ b/src/librbd/ImageState.h
@@ -26,8 +26,8 @@ public:
ImageState(ImageCtxT *image_ctx);
~ImageState();
- int open(bool skip_open_parent);
- void open(bool skip_open_parent, Context *on_finish);
+ int open(uint64_t flags);
+ void open(uint64_t flags, Context *on_finish);
int close();
void close(Context *on_finish);
@@ -110,7 +110,7 @@ private:
ImageUpdateWatchers *m_update_watchers;
- bool m_skip_open_parent_image;
+ uint64_t m_open_flags;
bool is_transition_state() const;
bool is_closed() const;
diff --git a/src/librbd/Types.h b/src/librbd/Types.h
index 809311adec2..9597b71880b 100644
--- a/src/librbd/Types.h
+++ b/src/librbd/Types.h
@@ -114,6 +114,10 @@ struct SnapInfo {
}
};
+enum {
+ OPEN_FLAG_SKIP_OPEN_PARENT = 1 << 0,
+};
+
} // namespace librbd
#endif // LIBRBD_TYPES_H
diff --git a/src/librbd/api/Mirror.cc b/src/librbd/api/Mirror.cc
index c1e545a39ea..3a2dff18cf6 100644
--- a/src/librbd/api/Mirror.cc
+++ b/src/librbd/api/Mirror.cc
@@ -596,7 +596,7 @@ int Mirror<I>::mode_set(librados::IoCtx& io_ctx,
if ((features & RBD_FEATURE_JOURNALING) != 0) {
I *img_ctx = I::create("", img_pair.second, nullptr, io_ctx, false);
- r = img_ctx->state->open(false);
+ r = img_ctx->state->open(0);
if (r < 0) {
lderr(cct) << "error opening image "<< img_pair.first << ": "
<< cpp_strerror(r) << dendl;
@@ -640,7 +640,7 @@ int Mirror<I>::mode_set(librados::IoCtx& io_ctx,
}
} else {
I *img_ctx = I::create("", img_id, nullptr, io_ctx, false);
- r = img_ctx->state->open(false);
+ r = img_ctx->state->open(0);
if (r < 0) {
lderr(cct) << "error opening image id "<< img_id << ": "
<< cpp_strerror(r) << dendl;
diff --git a/src/librbd/image/CloneRequest.cc b/src/librbd/image/CloneRequest.cc
index 44f3ac7d8aa..b784b9ab0c3 100644
--- a/src/librbd/image/CloneRequest.cc
+++ b/src/librbd/image/CloneRequest.cc
@@ -238,7 +238,7 @@ void CloneRequest<I>::send_open() {
using klass = CloneRequest<I>;
Context *ctx = create_context_callback<klass, &klass::handle_open>(this);
- m_imctx->state->open(true, ctx);
+ m_imctx->state->open(OPEN_FLAG_SKIP_OPEN_PARENT, ctx);
}
template <typename I>
diff --git a/src/librbd/image/OpenRequest.cc b/src/librbd/image/OpenRequest.cc
index ae187395eaa..33fa0335768 100644
--- a/src/librbd/image/OpenRequest.cc
+++ b/src/librbd/image/OpenRequest.cc
@@ -25,9 +25,10 @@ using util::create_context_callback;
using util::create_rados_callback;
template <typename I>
-OpenRequest<I>::OpenRequest(I *image_ctx, bool skip_open_parent,
+OpenRequest<I>::OpenRequest(I *image_ctx, uint64_t flags,
Context *on_finish)
- : m_image_ctx(image_ctx), m_skip_open_parent_image(skip_open_parent),
+ : m_image_ctx(image_ctx),
+ m_skip_open_parent_image(flags & OPEN_FLAG_SKIP_OPEN_PARENT),
m_on_finish(on_finish), m_error_result(0) {
}
diff --git a/src/librbd/image/OpenRequest.h b/src/librbd/image/OpenRequest.h
index 3b65f5455be..b3bc26a8d47 100644
--- a/src/librbd/image/OpenRequest.h
+++ b/src/librbd/image/OpenRequest.h
@@ -19,9 +19,9 @@ namespace image {
template <typename ImageCtxT = ImageCtx>
class OpenRequest {
public:
- static OpenRequest *create(ImageCtxT *image_ctx, bool skip_open_parent,
+ static OpenRequest *create(ImageCtxT *image_ctx, uint64_t flags,
Context *on_finish) {
- return new OpenRequest(image_ctx, skip_open_parent, on_finish);
+ return new OpenRequest(image_ctx, flags, on_finish);
}
void send();
@@ -75,7 +75,7 @@ private:
* @endverbatim
*/
- OpenRequest(ImageCtxT *image_ctx, bool skip_open_parent, Context *on_finish);
+ OpenRequest(ImageCtxT *image_ctx, uint64_t flags, Context *on_finish);
ImageCtxT *m_image_ctx;
bool m_skip_open_parent_image;
diff --git a/src/librbd/image/RefreshParentRequest.cc b/src/librbd/image/RefreshParentRequest.cc
index bc540913144..37bfc3c1017 100644
--- a/src/librbd/image/RefreshParentRequest.cc
+++ b/src/librbd/image/RefreshParentRequest.cc
@@ -125,7 +125,7 @@ void RefreshParentRequest<I>::send_open_parent() {
Context *ctx = create_async_context_callback(
m_child_image_ctx, create_context_callback<
klass, &klass::handle_open_parent, false>(this));
- OpenRequest<I> *req = OpenRequest<I>::create(m_parent_image_ctx, false, ctx);
+ OpenRequest<I> *req = OpenRequest<I>::create(m_parent_image_ctx, 0, ctx);
req->send();
}
diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc
index f7ca1e2478d..cb7cf88f2fb 100644
--- a/src/librbd/internal.cc
+++ b/src/librbd/internal.cc
@@ -597,7 +597,7 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2)
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;
@@ -958,7 +958,7 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2)
// 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;
@@ -1014,7 +1014,7 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2)
<< 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;
@@ -1392,7 +1392,7 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2)
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) {
@@ -1801,7 +1801,7 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2)
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;
diff --git a/src/librbd/librbd.cc b/src/librbd/librbd.cc
index b46ceb5002f..fee8f1d8f00 100644
--- a/src/librbd/librbd.cc
+++ b/src/librbd/librbd.cc
@@ -138,7 +138,7 @@ struct C_OpenAfterCloseComplete : public Context {
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));
}
};
@@ -305,7 +305,7 @@ namespace librbd {
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;
@@ -329,7 +329,7 @@ namespace librbd {
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;
@@ -351,8 +351,8 @@ namespace librbd {
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;
@@ -370,8 +370,8 @@ namespace librbd {
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;
@@ -389,7 +389,7 @@ namespace librbd {
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;
@@ -413,7 +413,7 @@ namespace librbd {
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;
@@ -435,8 +435,8 @@ namespace librbd {
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;
@@ -454,8 +454,8 @@ namespace librbd {
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;
@@ -2953,7 +2953,7 @@ extern "C" int rbd_open(rados_ioctx_t p, const char *name, rbd_image_t *image,
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;
}
@@ -2972,7 +2972,7 @@ extern "C" int rbd_open_by_id(rados_ioctx_t p, const char *id,
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 {
@@ -2993,7 +2993,8 @@ extern "C" int rbd_aio_open(rados_ioctx_t p, const char *name,
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;
}
@@ -3011,7 +3012,8 @@ extern "C" int rbd_aio_open_by_id(rados_ioctx_t p, const char *id,
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;
}
@@ -3026,7 +3028,7 @@ extern "C" int rbd_open_read_only(rados_ioctx_t p, const char *name,
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;
}
@@ -3045,7 +3047,7 @@ extern "C" int rbd_open_by_id_read_only(rados_ioctx_t p, const char *id,
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 {
@@ -3066,8 +3068,8 @@ extern "C" int rbd_aio_open_read_only(rados_ioctx_t p, const char *name,
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;
}
@@ -3085,8 +3087,8 @@ extern "C" int rbd_aio_open_by_id_read_only(rados_ioctx_t p, const char *id,
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;
}
diff --git a/src/tools/rbd_mirror/image_deleter/SnapshotPurgeRequest.cc b/src/tools/rbd_mirror/image_deleter/SnapshotPurgeRequest.cc
index d6aebeb56b3..4d1c3737d61 100644
--- a/src/tools/rbd_mirror/image_deleter/SnapshotPurgeRequest.cc
+++ b/src/tools/rbd_mirror/image_deleter/SnapshotPurgeRequest.cc
@@ -42,7 +42,7 @@ void SnapshotPurgeRequest<I>::open_image() {
Context *ctx = create_context_callback<
SnapshotPurgeRequest<I>, &SnapshotPurgeRequest<I>::handle_open_image>(
this);
- m_image_ctx->state->open(true, ctx);
+ m_image_ctx->state->open(librbd::OPEN_FLAG_SKIP_OPEN_PARENT, ctx);
}
template <typename I>
diff --git a/src/tools/rbd_mirror/image_replayer/OpenImageRequest.cc b/src/tools/rbd_mirror/image_replayer/OpenImageRequest.cc
index 54b95587f40..7f55745e124 100644
--- a/src/tools/rbd_mirror/image_replayer/OpenImageRequest.cc
+++ b/src/tools/rbd_mirror/image_replayer/OpenImageRequest.cc
@@ -43,7 +43,7 @@ void OpenImageRequest<I>::send_open_image() {
Context *ctx = create_context_callback<
OpenImageRequest<I>, &OpenImageRequest<I>::handle_open_image>(
this);
- (*m_image_ctx)->state->open(false, ctx);
+ (*m_image_ctx)->state->open(0, ctx);
}
template <typename I>
diff --git a/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc b/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc
index aca3f04b875..eabce81cb99 100644
--- a/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc
+++ b/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc
@@ -118,7 +118,7 @@ void OpenLocalImageRequest<I>::send_open_image() {
Context *ctx = create_context_callback<
OpenLocalImageRequest<I>, &OpenLocalImageRequest<I>::handle_open_image>(
this);
- (*m_local_image_ctx)->state->open(false, ctx);
+ (*m_local_image_ctx)->state->open(0, ctx);
}
template <typename I>