]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/io: ReadResult image-extent helper now takes a buffer offset
authorJason Dillaman <dillaman@redhat.com>
Wed, 4 Nov 2020 20:27:39 +0000 (15:27 -0500)
committerJason Dillaman <dillaman@redhat.com>
Mon, 16 Nov 2020 23:16:24 +0000 (18:16 -0500)
All existing users will continue to pass a buffer offset of zero, but
a future HTTP-based transfer class will need to potentially break up
multiple extents into individual HTTP requests and therefore will need
to adjust the offset.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/cache/WriteLogImageDispatch.cc
src/librbd/io/ReadResult.cc
src/librbd/io/ReadResult.h
src/librbd/migration/RawFormat.cc
src/test/librbd/io/test_mock_CopyupRequest.cc

index ce93d7ee83c53358e509b0c173bb707ef062ad9f..031e59287d9cd01de49503743378f435817cdb69 100644 (file)
@@ -71,7 +71,7 @@ bool WriteLogImageDispatch<I>::read(
   aio_comp->read_result.set_image_extents(image_extents);
 
   auto *req_comp = new io::ReadResult::C_ImageReadRequest(
-    aio_comp, image_extents);
+    aio_comp, 0, image_extents);
 
   m_image_cache->read(std::move(image_extents),
                       &req_comp->bl, op_flags,
index 21fa29fed5fc70d8daa44aa6770641307daad081..d8c03e1da38b1793d1379f7d8a5d6609be4bb24d 100644 (file)
@@ -142,8 +142,10 @@ struct ReadResult::AssembleResultVisitor : public boost::static_visitor<void> {
 };
 
 ReadResult::C_ImageReadRequest::C_ImageReadRequest(
-    AioCompletion *aio_completion, const Extents image_extents)
-  : aio_completion(aio_completion), image_extents(image_extents) {
+    AioCompletion *aio_completion, uint64_t buffer_offset,
+    const Extents image_extents)
+  : aio_completion(aio_completion), buffer_offset(buffer_offset),
+    image_extents(image_extents) {
   aio_completion->add_request();
 }
 
@@ -155,7 +157,7 @@ void ReadResult::C_ImageReadRequest::finish(int r) {
     striper::LightweightBufferExtents buffer_extents;
     size_t length = 0;
     for (auto &image_extent : image_extents) {
-      buffer_extents.emplace_back(length, image_extent.second);
+      buffer_extents.emplace_back(buffer_offset + length, image_extent.second);
       length += image_extent.second;
     }
     ceph_assert(length == bl.length());
index 69ced0c7b37601775bd02de586223c91f0be951d..1dfd15b69880a08a2f200ee9fd652aa9be6d1837 100644 (file)
@@ -27,10 +27,12 @@ class ReadResult {
 public:
   struct C_ImageReadRequest : public Context {
     AioCompletion *aio_completion;
+    uint64_t buffer_offset = 0;
     Extents image_extents;
     bufferlist bl;
 
     C_ImageReadRequest(AioCompletion *aio_completion,
+                       uint64_t buffer_offset,
                        const Extents image_extents);
 
     void finish(int r) override;
index 582cb664fd8f6881157321cb620fded07ae5986c..87f8b21c4199190387242f586f95f0401fa10689 100644 (file)
@@ -188,7 +188,7 @@ bool RawFormat<I>::read(
 
   aio_comp->set_request_count(1);
   auto ctx = new io::ReadResult::C_ImageReadRequest(aio_comp,
-                                                    image_extents);
+                                                    0, image_extents);
 
   // raw directly maps the image-extent IO down to a byte IO extent
   m_stream->read(std::move(image_extents), &ctx->bl, ctx);
index ee7a911c43e2caf6ddf7e2b0e9b0fb6d6ae8d823..3eab3bde557404daa303f101aac89491b952bd3b 100644 (file)
@@ -198,7 +198,7 @@ struct TestMockIoCopyupRequest : public TestMockFixture {
           aio_comp->read_result = std::move(req->read_result);
           aio_comp->read_result.set_image_extents(image_extents);
           aio_comp->set_request_count(1);
-          auto ctx = new ReadResult::C_ImageReadRequest(aio_comp,
+          auto ctx = new ReadResult::C_ImageReadRequest(aio_comp, 0,
                                                         image_extents);
           ctx->bl.append(data);
           mock_image_ctx.image_ctx->op_work_queue->queue(ctx, r);