]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/async/rdma: simplify RDMAConnectedSocketImpl::read implementation
authorChangcheng Liu <changcheng.liu@aliyun.com>
Mon, 1 Jul 2019 06:09:51 +0000 (14:09 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Fri, 23 Aug 2019 02:45:22 +0000 (10:45 +0800)
After reading one chunk, the chunk could be pushed into buffer list if its
effecitve content size is not zero. In this case, it also means that the
caller has got the required read length. Then all the continuous chunk will
be pushed into buffer list since the effective content size is not zero.

Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/msg/async/rdma/RDMAConnectedSocketImpl.cc

index e8c7d4745b5bedd44dc41e9cb5b287eaf25227e4..327eaaa0b895fd502e895abd4a7f2852eff36560 100644 (file)
@@ -295,10 +295,8 @@ ssize_t RDMAConnectedSocketImpl::read(char* buf, size_t len)
     ibv_wc* response = &cqe[i];
     ceph_assert(response->status == IBV_WC_SUCCESS);
     Chunk* chunk = reinterpret_cast<Chunk *>(response->wr_id);
-    ldout(cct, 25) << __func__ << " chunk length: " << response->byte_len << " bytes." << chunk << dendl;
     chunk->prepare_read(response->byte_len);
-    worker->perf_logger->inc(l_msgr_rdma_rx_bytes, response->byte_len);
-    if (response->byte_len == 0) {
+    if (chunk->get_size() == 0) {
       chunk->clear();
       dispatcher->perf_logger->inc(l_msgr_rdma_rx_fin);
       if (connected) {
@@ -306,20 +304,20 @@ ssize_t RDMAConnectedSocketImpl::read(char* buf, size_t len)
         ldout(cct, 20) << __func__ << " got remote close msg..." << dendl;
       }
       dispatcher->post_chunk_to_pool(chunk);
+      continue;
+    }
+    ldout(cct, 25) << __func__ << " chunk " << chunk << " has bytes " << chunk->get_size() << dendl;
+    worker->perf_logger->inc(l_msgr_rdma_rx_bytes, response->byte_len);
+
+    read += chunk->read(buf + read, len - read);
+
+    if (chunk->get_size()) {
+      buffers.push_back(chunk);
+      ldout(cct, 25) << __func__ << " buffers add a chunk: " << chunk->get_offset() << ":" << chunk->get_bound() << dendl;
     } else {
-      if (read == (ssize_t)len) {
-        buffers.push_back(chunk);
-        ldout(cct, 25) << __func__ << " buffers add a chunk: " << response->byte_len << dendl;
-      } else if (read + response->byte_len > (ssize_t)len) {
-        read += chunk->read(buf+read, (ssize_t)len-read);
-        buffers.push_back(chunk);
-        ldout(cct, 25) << __func__ << " buffers add a chunk: " << chunk->get_offset() << ":" << chunk->get_bound() << dendl;
-      } else {
-        read += chunk->read(buf+read, response->byte_len);
-        chunk->clear();
-        dispatcher->post_chunk_to_pool(chunk);
-        update_post_backlog();
-      }
+      chunk->clear();
+      dispatcher->post_chunk_to_pool(chunk);
+      update_post_backlog();
     }
   }