mirror of
https://github.com/ceph/ceph
synced 2025-03-30 23:40:09 +00:00
Merge pull request #36839 from dillaman/wip-46875
librbd: flush all incomplete in-flight IOs upon image close Reviewed-by: Mykola Golub <mgolub@suse.com>
This commit is contained in:
commit
912f6fab28
src/librbd
@ -90,6 +90,34 @@ void CloseRequest<I>::handle_shut_down_update_watchers(int r) {
|
||||
<< dendl;
|
||||
}
|
||||
|
||||
send_flush();
|
||||
}
|
||||
|
||||
template <typename I>
|
||||
void CloseRequest<I>::send_flush() {
|
||||
CephContext *cct = m_image_ctx->cct;
|
||||
ldout(cct, 10) << this << " " << __func__ << dendl;
|
||||
|
||||
std::shared_lock owner_locker{m_image_ctx->owner_lock};
|
||||
auto ctx = create_context_callback<
|
||||
CloseRequest<I>, &CloseRequest<I>::handle_flush>(this);
|
||||
auto aio_comp = io::AioCompletion::create_and_start(ctx, m_image_ctx,
|
||||
io::AIO_TYPE_FLUSH);
|
||||
auto req = io::ImageDispatchSpec<I>::create_flush(
|
||||
*m_image_ctx, io::IMAGE_DISPATCH_LAYER_API_START, aio_comp,
|
||||
io::FLUSH_SOURCE_INTERNAL, {});
|
||||
req->send();
|
||||
}
|
||||
|
||||
template <typename I>
|
||||
void CloseRequest<I>::handle_flush(int r) {
|
||||
CephContext *cct = m_image_ctx->cct;
|
||||
ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl;
|
||||
|
||||
if (r < 0) {
|
||||
lderr(cct) << "failed to flush IO: " << cpp_strerror(r) << dendl;
|
||||
}
|
||||
|
||||
send_shut_down_exclusive_lock();
|
||||
}
|
||||
|
||||
@ -108,7 +136,7 @@ void CloseRequest<I>::send_shut_down_exclusive_lock() {
|
||||
}
|
||||
|
||||
if (m_exclusive_lock == nullptr) {
|
||||
send_flush();
|
||||
send_unregister_image_watcher();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -148,33 +176,6 @@ void CloseRequest<I>::handle_shut_down_exclusive_lock(int r) {
|
||||
send_unregister_image_watcher();
|
||||
}
|
||||
|
||||
template <typename I>
|
||||
void CloseRequest<I>::send_flush() {
|
||||
CephContext *cct = m_image_ctx->cct;
|
||||
ldout(cct, 10) << this << " " << __func__ << dendl;
|
||||
|
||||
std::shared_lock owner_locker{m_image_ctx->owner_lock};
|
||||
auto ctx = create_context_callback<
|
||||
CloseRequest<I>, &CloseRequest<I>::handle_flush>(this);
|
||||
auto aio_comp = io::AioCompletion::create_and_start(ctx, m_image_ctx,
|
||||
io::AIO_TYPE_FLUSH);
|
||||
auto req = io::ImageDispatchSpec<I>::create_flush(
|
||||
*m_image_ctx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp,
|
||||
io::FLUSH_SOURCE_INTERNAL, {});
|
||||
req->send();
|
||||
}
|
||||
|
||||
template <typename I>
|
||||
void CloseRequest<I>::handle_flush(int r) {
|
||||
CephContext *cct = m_image_ctx->cct;
|
||||
ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl;
|
||||
|
||||
if (r < 0) {
|
||||
lderr(cct) << "failed to flush IO: " << cpp_strerror(r) << dendl;
|
||||
}
|
||||
send_unregister_image_watcher();
|
||||
}
|
||||
|
||||
template <typename I>
|
||||
void CloseRequest<I>::send_unregister_image_watcher() {
|
||||
if (m_image_ctx->image_watcher == nullptr) {
|
||||
|
@ -33,14 +33,15 @@ private:
|
||||
* BLOCK_IMAGE_WATCHER (skip if R/O)
|
||||
* |
|
||||
* v
|
||||
* SHUT_DOWN_UPDATE_WATCHERS . .
|
||||
* | . (exclusive lock disabled)
|
||||
* v v
|
||||
* SHUT_DOWN_EXCLUSIVE_LOCK FLUSH
|
||||
* | .
|
||||
* | . . . . . . . . . . .
|
||||
* | .
|
||||
* v v
|
||||
* SHUT_DOWN_UPDATE_WATCHERS
|
||||
* |
|
||||
* v
|
||||
* FLUSH
|
||||
* |
|
||||
* v (skip if disabled)
|
||||
* SHUT_DOWN_EXCLUSIVE_LOCK
|
||||
* |
|
||||
* v
|
||||
* UNREGISTER_IMAGE_WATCHER (skip if R/O)
|
||||
* |
|
||||
* v
|
||||
@ -82,12 +83,12 @@ private:
|
||||
void send_shut_down_update_watchers();
|
||||
void handle_shut_down_update_watchers(int r);
|
||||
|
||||
void send_shut_down_exclusive_lock();
|
||||
void handle_shut_down_exclusive_lock(int r);
|
||||
|
||||
void send_flush();
|
||||
void handle_flush(int r);
|
||||
|
||||
void send_shut_down_exclusive_lock();
|
||||
void handle_shut_down_exclusive_lock(int r);
|
||||
|
||||
void send_unregister_image_watcher();
|
||||
void handle_unregister_image_watcher(int r);
|
||||
|
||||
|
@ -107,10 +107,6 @@ bool QueueImageDispatch<I>::flush(
|
||||
auto cct = m_image_ctx->cct;
|
||||
ldout(cct, 20) << "tid=" << tid << dendl;
|
||||
|
||||
if (flush_source != FLUSH_SOURCE_USER) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*dispatch_result = DISPATCH_RESULT_CONTINUE;
|
||||
m_flush_tracker->flush(on_dispatched);
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user