]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: Add ictx check to avoid AIO_TYPE_NONE completion
authorHaomai Wang <haomaiwang@gmail.com>
Fri, 21 Aug 2015 06:54:56 +0000 (14:54 +0800)
committerHaomai Wang <haomai@xsky.com>
Tue, 1 Dec 2015 02:03:20 +0000 (10:03 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/librbd/AioCompletion.cc
src/librbd/AioCompletion.h
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/internal.cc
src/librbd/librbd.cc

index 9d25c0bd61fb5d96ca8dd7adb1d6d241cb90351b..2c58046a95474599868dd73319f25628de2b4054 100644 (file)
@@ -105,7 +105,7 @@ namespace librbd {
 
     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();
index 5094f64fc9f3280c32c65964d68ca7a9c8bf085c..975c916fe6e02439aac69ad9b797732ee894c77c 100644 (file)
@@ -132,7 +132,7 @@ namespace librbd {
       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();
@@ -155,9 +155,9 @@ namespace librbd {
       }
     }
 
-    void enable_event_notify() {
+    void set_event_notify(bool s) {
       Mutex::Locker l(lock);
-      event_notify = true;
+      event_notify = s;
     }
 
     void *get_arg() {
index 69fc596421fff68a13c25a388e7298b863d6a700..c42c6fd57ef5b60578197f43cbb2e20b48bc7c40 100644 (file)
@@ -11,6 +11,7 @@
 #include "common/WorkQueue.h"
 
 #include "librbd/AioImageRequestWQ.h"
+#include "librbd/AioCompletion.h"
 #include "librbd/AsyncOperation.h"
 #include "librbd/AsyncRequest.h"
 #include "librbd/internal.h"
@@ -873,6 +874,20 @@ struct C_InvalidateCache : public Context {
     }
   }
 
+  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();
index c0d4e5fe1f18f5c75ab51fbf4bb92e3fdea97827..fdebf8943eb6b34a5e9fb50bdee7d4a72186eade 100644 (file)
@@ -261,6 +261,7 @@ namespace librbd {
 
     void open_journal();
     int close_journal(bool force);
+    void clear_pending_completions();
   };
 }
 
index 543837a5b6828b4c3f0b37e198e6c053e33c7fe7..94f27ed1479656fad88d9a589689a63f9e9fe1d6 100644 (file)
@@ -2898,6 +2898,7 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type,
            ictx->aio_work_queue->writes_empty());
 
     ictx->cancel_async_requests();
+    ictx->clear_pending_completions();
     ictx->flush_async_operations();
     ictx->readahead.wait_for_pending();
 
index 0e450c73421792e67e6367ea01bb999c5b4657d7..53ed8b80bb668ce5d756d5b0f22830f42b22f46c 100644 (file)
@@ -283,7 +283,6 @@ namespace librbd {
                                                             complete_cb);
     pc = (void *)c;
     c->rbd_comp = this;
-    c->enable_event_notify();
   }
 
   bool RBD::AioCompletion::is_complete()