C_SaferCond flush_ctx;
{
RWLock::RLocker owner_locker(ictx->owner_lock);
- auto aio_comp = io::AioCompletion::create(&flush_ctx, ictx,
- io::AIO_TYPE_FLUSH);
+ auto aio_comp = io::AioCompletion::create_and_start(&flush_ctx, ictx,
+ io::AIO_TYPE_FLUSH);
auto req = io::ImageDispatchSpec<I>::create_flush_request(
*ictx, aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
req->send();
RWLock::RLocker 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(ctx, m_image_ctx,
- io::AIO_TYPE_FLUSH);
+ auto aio_comp = io::AioCompletion::create_and_start(ctx, m_image_ctx,
+ io::AIO_TYPE_FLUSH);
auto req = io::ImageDispatchSpec<I>::create_flush_request(
*m_image_ctx, aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
req->send();
RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
auto ctx = create_context_callback<
RefreshRequest<I>, &RefreshRequest<I>::handle_flush_aio>(this);
- auto aio_comp = io::AioCompletion::create(
+ auto aio_comp = io::AioCompletion::create_and_start(
ctx, util::get_image_ctx(&m_image_ctx), io::AIO_TYPE_FLUSH);
auto req = io::ImageDispatchSpec<I>::create_flush_request(
m_image_ctx, aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
}
}
-void AioCompletion::start_op(bool ignore_type) {
+void AioCompletion::start_op() {
Mutex::Locker locker(lock);
ceph_assert(ictx != nullptr);
- ceph_assert(!async_op.started());
if (aio_type == AIO_TYPE_OPEN || aio_type == AIO_TYPE_CLOSE) {
// no need to track async open/close operations
return;
}
- if (state == AIO_STATE_PENDING &&
- (ignore_type || aio_type != AIO_TYPE_FLUSH)) {
- async_op.start_op(*ictx);
- }
+ ceph_assert(!async_op.started());
+ async_op.start_op(*ictx);
}
void AioCompletion::fail(int r)
return comp;
}
- template <typename T, void (T::*MF)(int) = &T::complete>
- static AioCompletion *create(T *obj, ImageCtx *image_ctx, aio_type_t type) {
- AioCompletion *comp = create<T, MF>(obj);
- comp->init_time(image_ctx, type);
- return comp;
- }
-
template <typename T, void (T::*MF)(int) = &T::complete>
static AioCompletion *create_and_start(T *obj, ImageCtx *image_ctx,
aio_type_t type) {
- AioCompletion *comp = create<T, MF>(obj, image_ctx, type);
+ AioCompletion *comp = create<T, MF>(obj);
+ comp->init_time(image_ctx, type);
comp->start_op();
return comp;
}
}
void init_time(ImageCtx *i, aio_type_t t);
- void start_op(bool ignore_type = false);
+ void start_op();
void fail(int r);
void complete();
void ImageRequest<I>::send() {
I &image_ctx = this->m_image_ctx;
ceph_assert(m_aio_comp->is_initialized(get_aio_type()));
- ceph_assert(m_aio_comp->is_started() ^ (get_aio_type() == AIO_TYPE_FLUSH));
+ ceph_assert(m_aio_comp->is_started());
CephContext *cct = image_ctx.cct;
AioCompletion *aio_comp = this->m_aio_comp;
}
// ensure all in-flight IOs are settled if non-user flush request
- aio_comp->start_op(true);
aio_comp->async_op.flush(ctx);
aio_comp->put();
template <typename I>
void flush_image(I& image_ctx, Context* on_finish) {
- auto aio_comp = librbd::io::AioCompletion::create(
+ auto aio_comp = librbd::io::AioCompletion::create_and_start(
on_finish, util::get_image_ctx(&image_ctx), librbd::io::AIO_TYPE_FLUSH);
auto req = librbd::io::ImageDispatchSpec<I>::create_flush_request(
image_ctx, aio_comp, librbd::io::FLUSH_SOURCE_INTERNAL, {});
queue(ImageDispatchSpec<I>::create_flush_request(
m_image_ctx, c, FLUSH_SOURCE_USER, trace));
} else {
+ c->start_op();
ImageRequest<I>::aio_flush(&m_image_ctx, c, FLUSH_SOURCE_USER, trace);
finish_in_flight_io();
}
RWLock::RLocker owner_locker(image_ctx.owner_lock);
auto ctx = create_context_callback<
ResizeRequest<I>, &ResizeRequest<I>::handle_flush_cache>(this);
- auto aio_comp = io::AioCompletion::create(
+ auto aio_comp = io::AioCompletion::create_and_start(
ctx, util::get_image_ctx(&image_ctx), io::AIO_TYPE_FLUSH);
auto req = io::ImageDispatchSpec<I>::create_flush_request(
image_ctx, aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
// user flush requests are ignored when journaling + cache are enabled
C_SaferCond flush_ctx;
- aio_comp = librbd::io::AioCompletion::create(
+ aio_comp = librbd::io::AioCompletion::create_and_start(
&flush_ctx, ictx, librbd::io::AIO_TYPE_FLUSH);
auto req = librbd::io::ImageDispatchSpec<>::create_flush_request(
*ictx, aio_comp, librbd::io::FLUSH_SOURCE_INTERNAL, {});
int flush(librbd::ImageCtx *image_ctx) {
C_SaferCond ctx;
- auto aio_comp = librbd::io::AioCompletion::create(
+ auto aio_comp = librbd::io::AioCompletion::create_and_start(
&ctx, image_ctx, librbd::io::AIO_TYPE_FLUSH);
auto req = librbd::io::ImageDispatchSpec<>::create_flush_request(
*image_ctx, aio_comp, librbd::io::FLUSH_SOURCE_INTERNAL, {});