]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: keep gen lambda context small
authorshangdehao1 <dehao.shang@intel.com>
Thu, 18 Apr 2019 23:18:48 +0000 (07:18 +0800)
committerJason Dillaman <dillaman@redhat.com>
Mon, 24 Jun 2019 21:35:40 +0000 (17:35 -0400)
move all codes of lambda context to handle_read_cache.

Signed-off-by: Dehao Shang <dehao.shang@intel.com>
src/librbd/cache/SharedReadOnlyObjectDispatch.cc
src/librbd/cache/SharedReadOnlyObjectDispatch.h

index c4b6ca6c5bf8504f86f20dca70caabc6f026d62f..499da1cbcb37618938a6daa2cf457ef70bb321db 100644 (file)
@@ -102,16 +102,8 @@ bool SharedReadOnlyObjectDispatch<I, C>::read(
                                      std::function<void(ObjectCacheRequest*)>>
    ([this, snap_id, read_data, dispatch_result, on_dispatched,
       oid, object_off, object_len](ObjectCacheRequest* ack) {
-    if (ack->type == RBDSC_READ_REPLY) {
-      std::string file_path = ((ObjectCacheReadReplyData*)ack)->cache_path;
-      ceph_assert(file_path != "");
-      handle_read_cache(file_path, object_off, object_len, read_data,
-                        dispatch_result, on_dispatched);
-    } else {
-      // go back to read rados
-      *dispatch_result = io::DISPATCH_RESULT_CONTINUE;
-      on_dispatched->complete(0);
-    }
+     handle_read_cache(ack, object_off, object_len, read_data,
+                       dispatch_result, on_dispatched);
   });
 
   if (m_cache_client && m_cache_client->is_session_work() && m_object_store) {
@@ -125,9 +117,20 @@ bool SharedReadOnlyObjectDispatch<I, C>::read(
 
 template <typename I, typename C>
 int SharedReadOnlyObjectDispatch<I, C>::handle_read_cache(
-    const std::string file_path, uint64_t read_off,
+    ObjectCacheRequest* ack, uint64_t read_off,
     uint64_t read_len, ceph::bufferlist* read_data,
     io::DispatchResult* dispatch_result, Context* on_dispatched) {
+  std::string file_path;
+  if (ack->type == RBDSC_READ_REPLY) {
+    file_path = ((ObjectCacheReadReplyData*)ack)->cache_path;
+    ceph_assert(file_path != "");
+  } else {
+    // go back to read rados
+    *dispatch_result = io::DISPATCH_RESULT_CONTINUE;
+    on_dispatched->complete(0);
+    return false;
+  }
+
   auto cct = m_image_ctx->cct;
   ldout(cct, 20) << dendl;
 
index 792f5fce6fc398fdb0a6f5c5f6a199170dcfb731..3c7e934f07bdabfd0bb8148e7b1be4aab90f33bd 100644 (file)
@@ -114,7 +114,7 @@ public:
 private:
 
   int handle_read_cache(
-      const std::string file_path, uint64_t read_off,
+      ObjectCacheRequest* ack, uint64_t read_off,
       uint64_t read_len, ceph::bufferlist* read_data,
       io::DispatchResult* dispatch_result,
       Context* on_dispatched);