lock.Lock();
done = true;
- if (event_notify && ictx->event_socket.is_valid()) {
+ if (ictx && event_notify && ictx->event_socket.is_valid()) {
ictx->completed_reqs_lock.Lock();
ictx->completed_reqs.push_back(&m_xlist_item);
ictx->completed_reqs_lock.Unlock();
int n = --ref;
lock.Unlock();
if (!n) {
- if (event_notify) {
+ if (ictx && event_notify) {
ictx->completed_reqs_lock.Lock();
m_xlist_item.remove_myself();
ictx->completed_reqs_lock.Unlock();
}
}
- void enable_event_notify() {
+ void set_event_notify(bool s) {
Mutex::Locker l(lock);
- event_notify = true;
+ event_notify = s;
}
void *get_arg() {
#include "common/WorkQueue.h"
#include "librbd/AioImageRequestWQ.h"
+#include "librbd/AioCompletion.h"
#include "librbd/AsyncOperation.h"
#include "librbd/AsyncRequest.h"
#include "librbd/internal.h"
}
}
+ void ImageCtx::clear_pending_completions() {
+ Mutex::Locker l(completed_reqs_lock);
+ ldout(cct, 10) << "clear pending AioCompletion: count="
+ << completed_reqs.size() << dendl;
+
+ for (xlist<AioCompletion*>::iterator it = completed_reqs.begin();
+ !it.end(); ++it) {
+ ldout(cct, 10) << "clear pending AioCompletion: " << *it << dendl;
+ (*it)->set_event_notify(false);
+ }
+ completed_reqs.clear();
+ }
+
+
bool ImageCtx::_filter_metadata_confs(const string &prefix, map<string, bool> &configs,
map<string, bufferlist> &pairs, map<string, bufferlist> *res) {
size_t conf_prefix_len = prefix.size();
ictx->aio_work_queue->writes_empty());
ictx->cancel_async_requests();
+ ictx->clear_pending_completions();
ictx->flush_async_operations();
ictx->readahead.wait_for_pending();