mirror of
https://github.com/ceph/ceph
synced 2025-01-03 09:32:43 +00:00
Merge pull request #37880 from trociny/wip-rbd-finisher-cancel
librbd: relax requirements on finisher canceled callback Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
commit
54329691c0
@ -112,9 +112,11 @@ void ImageWatcher<I>::block_notifies(Context *on_finish) {
|
||||
template <typename I>
|
||||
void ImageWatcher<I>::schedule_async_progress(const AsyncRequestId &request,
|
||||
uint64_t offset, uint64_t total) {
|
||||
auto ctx = new LambdaContext(
|
||||
boost::bind(&ImageWatcher<I>::notify_async_progress, this, request, offset,
|
||||
total));
|
||||
auto ctx = new LambdaContext([this, request, offset, total](int r) {
|
||||
if (r != -ECANCELED) {
|
||||
notify_async_progress(request, offset, total);
|
||||
}
|
||||
});
|
||||
m_task_finisher->queue(Task(TASK_CODE_ASYNC_PROGRESS, request), ctx);
|
||||
}
|
||||
|
||||
@ -133,8 +135,11 @@ template <typename I>
|
||||
void ImageWatcher<I>::schedule_async_complete(const AsyncRequestId &request,
|
||||
int r) {
|
||||
m_async_op_tracker.start_op();
|
||||
auto ctx = new LambdaContext(
|
||||
boost::bind(&ImageWatcher<I>::notify_async_complete, this, request, r));
|
||||
auto ctx = new LambdaContext([this, request, ret_val=r](int r) {
|
||||
if (r != -ECANCELED) {
|
||||
notify_async_complete(request, ret_val);
|
||||
}
|
||||
});
|
||||
m_task_finisher->queue(ctx);
|
||||
}
|
||||
|
||||
@ -463,8 +468,11 @@ void ImageWatcher<I>::notify_metadata_remove(const std::string &key,
|
||||
|
||||
template <typename I>
|
||||
void ImageWatcher<I>::schedule_cancel_async_requests() {
|
||||
auto ctx = new LambdaContext(
|
||||
boost::bind(&ImageWatcher<I>::cancel_async_requests, this));
|
||||
auto ctx = new LambdaContext([this](int r) {
|
||||
if (r != -ECANCELED) {
|
||||
cancel_async_requests();
|
||||
}
|
||||
});
|
||||
m_task_finisher->queue(TASK_CODE_CANCEL_ASYNC_REQUESTS, ctx);
|
||||
}
|
||||
|
||||
|
@ -65,8 +65,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
it->second.first->complete(-ECANCELED);
|
||||
bool canceled = m_safe_timer->cancel_event(it->second.second);
|
||||
ceph_assert(canceled);
|
||||
m_safe_timer->cancel_event(it->second.second);
|
||||
m_task_contexts.erase(it);
|
||||
return true;
|
||||
}
|
||||
@ -75,8 +74,7 @@ public:
|
||||
std::lock_guard l{*m_lock};
|
||||
for (auto &[task, pair] : m_task_contexts) {
|
||||
pair.first->complete(-ECANCELED);
|
||||
bool canceled = m_safe_timer->cancel_event(pair.second);
|
||||
ceph_assert(canceled);
|
||||
m_safe_timer->cancel_event(pair.second);
|
||||
}
|
||||
m_task_contexts.clear();
|
||||
}
|
||||
@ -102,7 +100,9 @@ public:
|
||||
return false;
|
||||
}
|
||||
bool canceled = m_safe_timer->cancel_event(it->second.second);
|
||||
ceph_assert(canceled);
|
||||
if (!canceled) {
|
||||
return false;
|
||||
}
|
||||
auto timer_ctx = new C_Task(this, task);
|
||||
it->second.second = timer_ctx;
|
||||
m_safe_timer->add_event_after(seconds, timer_ctx);
|
||||
@ -117,12 +117,12 @@ public:
|
||||
std::lock_guard l{*m_lock};
|
||||
typename TaskContexts::iterator it = m_task_contexts.find(task);
|
||||
if (it != m_task_contexts.end()) {
|
||||
if (it->second.second != NULL) {
|
||||
ceph_assert(m_safe_timer->cancel_event(it->second.second));
|
||||
delete it->second.first;
|
||||
if (it->second.second != NULL &&
|
||||
m_safe_timer->cancel_event(it->second.second)) {
|
||||
it->second.first->complete(-ECANCELED);
|
||||
} else {
|
||||
// task already scheduled on the finisher
|
||||
delete ctx;
|
||||
ctx->complete(-ECANCELED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user