]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: Return read request early 34700/head
authorlixiaoy1 <xiaoyan.li@intel.com>
Thu, 23 Apr 2020 10:38:09 +0000 (06:38 -0400)
committerlixiaoy1 <xiaoyan.li@intel.com>
Mon, 27 Apr 2020 16:50:39 +0000 (12:50 -0400)
Finish read requests if the total length is 0.

Signed-off-by: Li, Xiaoyan <xiaoyan.li@intel.com>
src/librbd/io/ImageRequest.cc
src/librbd/io/ImageRequest.h

index 0f93c95da4c0533741906ab697b559353ffd9966..7b7e7e4f1594cde27a6eea7c007c90756b4e6f44 100644 (file)
@@ -263,6 +263,15 @@ int ImageRequest<I>::clip_request() {
   return 0;
 }
 
+template <typename I>
+uint64_t ImageRequest<I>::get_total_length() const {
+  uint64_t total_bytes = 0;
+  for (auto& image_extent : this->m_image_extents) {
+    total_bytes += image_extent.second;
+  }
+  return total_bytes;
+}
+
 template <typename I>
 void ImageRequest<I>::update_timestamp() {
   bool modify = (get_aio_type() != AIO_TYPE_READ);
@@ -342,6 +351,17 @@ int ImageReadRequest<I>::clip_request() {
   return 0;
 }
 
+template <typename I>
+bool ImageReadRequest<I>::finish_request_early() {
+  auto total_bytes = this->get_total_length();
+  if (total_bytes == 0) {
+    auto *aio_comp = this->m_aio_comp;
+    aio_comp->set_request_count(0);
+    return true;
+  }
+  return false;
+}
+
 template <typename I>
 void ImageReadRequest<I>::send_request() {
   I &image_ctx = this->m_image_ctx;
@@ -420,10 +440,7 @@ bool AbstractImageWriteRequest<I>::finish_request_early() {
       return true;
     }
   }
-  uint64_t total_bytes = 0;
-  for (auto& image_extent : this->m_image_extents) {
-    total_bytes += image_extent.second;
-  }
+  auto total_bytes = this->get_total_length();
   if (total_bytes == 0) {
     aio_comp->set_request_count(0);
     return true;
index e5a04597d3e7df46e3a05edebd03119950c636c1..ca2a74e35ee207221b0628091b8b46160341f3bf 100644 (file)
@@ -83,6 +83,8 @@ protected:
     m_trace.event("start");
   }
 
+  uint64_t get_total_length() const;
+
   virtual bool finish_request_early() {
     return false;
   }
@@ -106,6 +108,7 @@ public:
 
 protected:
   int clip_request() override;
+  bool finish_request_early() override;
 
   void send_request() override;
   void send_image_cache_request() override;