mirror of
https://github.com/ceph/ceph
synced 2025-01-03 17:42:36 +00:00
rbd-mirror: only delete ImageCtx after open failure
The image is already closed -- it just needs to be destroyed in a thread context outside of librbd. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
parent
cb72ac120c
commit
18e849f01c
@ -83,7 +83,7 @@ struct CloseImageRequest<librbd::MockImageReplayerImageCtx> {
|
|||||||
Context *on_finish = nullptr;
|
Context *on_finish = nullptr;
|
||||||
|
|
||||||
static CloseImageRequest* create(librbd::MockImageReplayerImageCtx **image_ctx,
|
static CloseImageRequest* create(librbd::MockImageReplayerImageCtx **image_ctx,
|
||||||
ContextWQ *work_queue,
|
ContextWQ *work_queue, bool destroy_only,
|
||||||
Context *on_finish) {
|
Context *on_finish) {
|
||||||
assert(s_instance != nullptr);
|
assert(s_instance != nullptr);
|
||||||
s_instance->on_finish = on_finish;
|
s_instance->on_finish = on_finish;
|
||||||
|
@ -22,8 +22,9 @@ using librbd::util::create_context_callback;
|
|||||||
|
|
||||||
template <typename I>
|
template <typename I>
|
||||||
CloseImageRequest<I>::CloseImageRequest(I **image_ctx, ContextWQ *work_queue,
|
CloseImageRequest<I>::CloseImageRequest(I **image_ctx, ContextWQ *work_queue,
|
||||||
Context *on_finish)
|
bool destroy_only, Context *on_finish)
|
||||||
: m_image_ctx(image_ctx), m_work_queue(work_queue), m_on_finish(on_finish) {
|
: m_image_ctx(image_ctx), m_work_queue(work_queue),
|
||||||
|
m_destroy_only(destroy_only), m_on_finish(on_finish) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename I>
|
template <typename I>
|
||||||
@ -33,6 +34,11 @@ void CloseImageRequest<I>::send() {
|
|||||||
|
|
||||||
template <typename I>
|
template <typename I>
|
||||||
void CloseImageRequest<I>::close_image() {
|
void CloseImageRequest<I>::close_image() {
|
||||||
|
if (m_destroy_only) {
|
||||||
|
switch_thread_context();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dout(20) << dendl;
|
dout(20) << dendl;
|
||||||
|
|
||||||
Context *ctx = create_context_callback<
|
Context *ctx = create_context_callback<
|
||||||
|
@ -20,12 +20,13 @@ template <typename ImageCtxT = librbd::ImageCtx>
|
|||||||
class CloseImageRequest {
|
class CloseImageRequest {
|
||||||
public:
|
public:
|
||||||
static CloseImageRequest* create(ImageCtxT **image_ctx, ContextWQ *work_queue,
|
static CloseImageRequest* create(ImageCtxT **image_ctx, ContextWQ *work_queue,
|
||||||
Context *on_finish) {
|
bool destroy_only, Context *on_finish) {
|
||||||
return new CloseImageRequest(image_ctx, work_queue, on_finish);
|
return new CloseImageRequest(image_ctx, work_queue, destroy_only,
|
||||||
|
on_finish);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseImageRequest(ImageCtxT **image_ctx, ContextWQ *work_queue,
|
CloseImageRequest(ImageCtxT **image_ctx, ContextWQ *work_queue,
|
||||||
Context *on_finish);
|
bool destroy_only, Context *on_finish);
|
||||||
|
|
||||||
void send();
|
void send();
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ private:
|
|||||||
* <start>
|
* <start>
|
||||||
* |
|
* |
|
||||||
* v
|
* v
|
||||||
* CLOSE_IMAGE
|
* CLOSE_IMAGE (skip if not needed)
|
||||||
* |
|
* |
|
||||||
* v
|
* v
|
||||||
* SWITCH_CONTEXT
|
* SWITCH_CONTEXT
|
||||||
@ -48,6 +49,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
ImageCtxT **m_image_ctx;
|
ImageCtxT **m_image_ctx;
|
||||||
ContextWQ *m_work_queue;
|
ContextWQ *m_work_queue;
|
||||||
|
bool m_destroy_only;
|
||||||
Context *m_on_finish;
|
Context *m_on_finish;
|
||||||
|
|
||||||
void close_image();
|
void close_image();
|
||||||
|
@ -98,11 +98,11 @@ void OpenLocalImageRequest<I>::handle_open_image(int r) {
|
|||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
derr << "failed to open image '" << m_local_image_id << "': "
|
derr << "failed to open image '" << m_local_image_id << "': "
|
||||||
<< cpp_strerror(r) << dendl;
|
<< cpp_strerror(r) << dendl;
|
||||||
send_close_image(r);
|
send_close_image(true, r);
|
||||||
return;
|
return;
|
||||||
} else if ((*m_local_image_ctx)->exclusive_lock == nullptr) {
|
} else if ((*m_local_image_ctx)->exclusive_lock == nullptr) {
|
||||||
derr << "image does not support exclusive lock" << dendl;
|
derr << "image does not support exclusive lock" << dendl;
|
||||||
send_close_image(-EINVAL);
|
send_close_image(false, -EINVAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,12 +128,12 @@ void OpenLocalImageRequest<I>::handle_lock_image(int r) {
|
|||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
derr << "failed to lock image '" << m_local_image_id << "': "
|
derr << "failed to lock image '" << m_local_image_id << "': "
|
||||||
<< cpp_strerror(r) << dendl;
|
<< cpp_strerror(r) << dendl;
|
||||||
send_close_image(r);
|
send_close_image(false, r);
|
||||||
return;
|
return;
|
||||||
} else if ((*m_local_image_ctx)->exclusive_lock == nullptr ||
|
} else if ((*m_local_image_ctx)->exclusive_lock == nullptr ||
|
||||||
!(*m_local_image_ctx)->exclusive_lock->is_lock_owner()) {
|
!(*m_local_image_ctx)->exclusive_lock->is_lock_owner()) {
|
||||||
derr << "image is not locked" << dendl;
|
derr << "image is not locked" << dendl;
|
||||||
send_close_image(-EBUSY);
|
send_close_image(false, -EBUSY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ void OpenLocalImageRequest<I>::handle_lock_image(int r) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename I>
|
template <typename I>
|
||||||
void OpenLocalImageRequest<I>::send_close_image(int r) {
|
void OpenLocalImageRequest<I>::send_close_image(bool destroy_only, int r) {
|
||||||
dout(20) << dendl;
|
dout(20) << dendl;
|
||||||
|
|
||||||
if (m_ret_val == 0 && r < 0) {
|
if (m_ret_val == 0 && r < 0) {
|
||||||
@ -152,7 +152,7 @@ void OpenLocalImageRequest<I>::send_close_image(int r) {
|
|||||||
OpenLocalImageRequest<I>, &OpenLocalImageRequest<I>::handle_close_image>(
|
OpenLocalImageRequest<I>, &OpenLocalImageRequest<I>::handle_close_image>(
|
||||||
this);
|
this);
|
||||||
CloseImageRequest<I> *request = CloseImageRequest<I>::create(
|
CloseImageRequest<I> *request = CloseImageRequest<I>::create(
|
||||||
m_local_image_ctx, m_work_queue, ctx);
|
m_local_image_ctx, m_work_queue, destroy_only, ctx);
|
||||||
request->send();
|
request->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ private:
|
|||||||
void send_lock_image();
|
void send_lock_image();
|
||||||
void handle_lock_image(int r);
|
void handle_lock_image(int r);
|
||||||
|
|
||||||
void send_close_image(int r);
|
void send_close_image(bool destroy_only, int r);
|
||||||
void handle_close_image(int r);
|
void handle_close_image(int r);
|
||||||
|
|
||||||
void finish(int r);
|
void finish(int r);
|
||||||
|
Loading…
Reference in New Issue
Block a user