]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: object map ENOENT optimizations should complete asynchronously
authorJason Dillaman <dillaman@redhat.com>
Fri, 18 Dec 2015 20:12:23 +0000 (15:12 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 18 Dec 2015 20:14:06 +0000 (15:14 -0500)
This ensures a consistent lock ordering between the optimized path and
a librados callback. Remove the cache writebach handler's custom finisher
and re-use the op_work_queue.

Fixes: #14123
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/AioObjectRequest.cc
src/librbd/LibrbdWriteback.cc
src/librbd/LibrbdWriteback.h

index 67f9fe3c349d5942a17c05e202317accafe0cdf7..5b3d6165613747f6d04d67880f9870eda5bad1e4 100644 (file)
@@ -6,6 +6,7 @@
 #include "common/errno.h"
 #include "common/Mutex.h"
 #include "common/RWLock.h"
+#include "common/WorkQueue.h"
 
 #include "librbd/AioObjectRequest.h"
 #include "librbd/AioCompletion.h"
@@ -205,16 +206,16 @@ namespace librbd {
     ldout(m_ictx->cct, 20) << "send " << this << " " << m_oid << " "
                            << m_object_off << "~" << m_object_len << dendl;
 
-    // send read request to parent if the object doesn't exist locally
-    bool non_existent = false;
     {
       RWLock::RLocker snap_locker(m_ictx->snap_lock);
-      non_existent = (m_ictx->object_map != nullptr &&
-                      !m_ictx->object_map->object_may_exist(m_object_no));
-    }
-    if (non_existent) {
-      complete(-ENOENT);
-      return;
+
+      // send read request to parent if the object doesn't exist locally
+      if (m_ictx->object_map != nullptr &&
+          !m_ictx->object_map->object_may_exist(m_object_no)) {
+        m_ictx->op_work_queue->queue(util::create_context_callback<
+          AioObjectRequest>(this), -ENOENT);
+        return;
+      }
     }
 
     librados::ObjectReadOperation op;
index 85fc513f97852247227809861721f8e5e8b2d3bc..763860bc8632a6119db23d4ae86eb040f41b92e0 100644 (file)
@@ -5,8 +5,8 @@
 
 #include "common/ceph_context.h"
 #include "common/dout.h"
-#include "common/Finisher.h"
 #include "common/Mutex.h"
+#include "common/WorkQueue.h"
 #include "include/Context.h"
 #include "include/rados/librados.hpp"
 #include "include/rbd/librbd.hpp"
@@ -168,14 +168,7 @@ namespace librbd {
   };
 
   LibrbdWriteback::LibrbdWriteback(ImageCtx *ictx, Mutex& lock)
-    : m_finisher(new Finisher(ictx->cct)), m_tid(0), m_lock(lock), m_ictx(ictx)
-  {
-    m_finisher->start();
-  }
-
-  LibrbdWriteback::~LibrbdWriteback() {
-    m_finisher->stop();
-    delete m_finisher;
+    : m_tid(0), m_lock(lock), m_ictx(ictx) {
   }
 
   void LibrbdWriteback::read(const object_t& oid, uint64_t object_no,
@@ -192,7 +185,7 @@ namespace librbd {
       RWLock::RLocker snap_locker(m_ictx->snap_lock);
       if (m_ictx->object_map != nullptr &&
           !m_ictx->object_map->object_may_exist(object_no)) {
-       m_finisher->queue(req, -ENOENT);
+        m_ictx->op_work_queue->queue(req, -ENOENT);
        return;
       }
     }
index b7574ae5dd2d0fd58fcc469366c0b80c7719a670..11b46cf88615a07b651d7cfa6f3b1399ec557e7b 100644 (file)
@@ -11,7 +11,6 @@
 #include "osd/osd_types.h"
 #include "osdc/WritebackHandler.h"
 
-class Finisher;
 class Mutex;
 
 namespace librbd {
@@ -21,7 +20,6 @@ namespace librbd {
   class LibrbdWriteback : public WritebackHandler {
   public:
     LibrbdWriteback(ImageCtx *ictx, Mutex& lock);
-    virtual ~LibrbdWriteback();
 
     // Note that oloc, trunc_size, and trunc_seq are ignored
     virtual void read(const object_t& oid, uint64_t object_no,
@@ -61,7 +59,6 @@ namespace librbd {
   private:
     void complete_writes(const std::string& oid);
 
-    Finisher *m_finisher;
     ceph_tid_t m_tid;
     Mutex& m_lock;
     librbd::ImageCtx *m_ictx;