]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/migration: make FormatInterface::read() void again
authorIlya Dryomov <idryomov@gmail.com>
Fri, 26 Jul 2024 14:54:31 +0000 (16:54 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 11 Aug 2024 17:17:04 +0000 (19:17 +0200)
Now that NativeFormat is handled via dispatch, FormatInterface::read()
can be void again for consistency with FormatInterface::list_snaps().

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit b6c7f69b8044f9206aa982c2aba6466c49fd2bea)

Conflicts:
src/librbd/migration/ImageDispatch.cc [ commit 20aee5bbbcb5
  ("neorados: Make IOContext getters/setters less weird") not
  in reef ]

src/librbd/migration/FormatInterface.h
src/librbd/migration/ImageDispatch.cc
src/librbd/migration/QCOWFormat.cc
src/librbd/migration/QCOWFormat.h
src/librbd/migration/RawFormat.cc
src/librbd/migration/RawFormat.h
src/test/librbd/migration/test_mock_QCOWFormat.cc
src/test/librbd/migration/test_mock_RawFormat.cc

index d13521d1193da0369290b81e193b0814bff33ea1..27669dd51169a8c138b922aa80f147c842fa53e5 100644 (file)
@@ -35,7 +35,7 @@ struct FormatInterface {
   virtual void get_image_size(uint64_t snap_id, uint64_t* size,
                               Context* on_finish) = 0;
 
-  virtual bool read(io::AioCompletion* aio_comp, uint64_t snap_id,
+  virtual void read(io::AioCompletion* aio_comp, uint64_t snap_id,
                     io::Extents&& image_extents, io::ReadResult&& read_result,
                     int op_flags, int read_flags,
                     const ZTracer::Trace &parent_trace) = 0;
index d8c151fbd66302f3206284a66260237ed0882fef..e812f721c4f62758729ba74a87d23da5b4b1982f 100644 (file)
@@ -50,9 +50,10 @@ bool ImageDispatch<I>::read(
   }
 
   *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
-  return m_format->read(aio_comp, io_context->read_snap().value_or(CEPH_NOSNAP),
-                        std::move(image_extents), std::move(read_result),
-                        op_flags, read_flags, parent_trace);
+  m_format->read(aio_comp, io_context->read_snap().value_or(CEPH_NOSNAP),
+                 std::move(image_extents), std::move(read_result),
+                 op_flags, read_flags, parent_trace);
+  return true;
 }
 
 template <typename I>
index f05c35b9728b2ab99f7f4b52c1a703e0ea526592..dec7eb8f43856ece25fa5f32cae90e8d42f1430d 100644 (file)
@@ -1436,7 +1436,7 @@ void QCOWFormat<I>::get_image_size(uint64_t snap_id, uint64_t* size,
 }
 
 template <typename I>
-bool QCOWFormat<I>::read(
+void QCOWFormat<I>::read(
     io::AioCompletion* aio_comp, uint64_t snap_id, io::Extents&& image_extents,
     io::ReadResult&& read_result, int op_flags, int read_flags,
     const ZTracer::Trace &parent_trace) {
@@ -1451,7 +1451,7 @@ bool QCOWFormat<I>::read(
     auto snapshot_it = m_snapshots.find(snap_id);
     if (snapshot_it == m_snapshots.end()) {
       aio_comp->fail(-ENOENT);
-      return true;
+      return;
     }
 
     auto& snapshot = snapshot_it->second;
@@ -1464,8 +1464,6 @@ bool QCOWFormat<I>::read(
   auto read_request = new ReadRequest(this, aio_comp, l1_table,
                                       std::move(image_extents));
   read_request->send();
-
-  return true;
 }
 
 template <typename I>
index b365067165026565c1febb3106f1e08ecc2bd1c4..9219d7cc5676cd8b9a7c2fdacdd36268abf7dce4 100644 (file)
@@ -66,7 +66,7 @@ public:
   void get_image_size(uint64_t snap_id, uint64_t* size,
                       Context* on_finish) override;
 
-  bool read(io::AioCompletion* aio_comp, uint64_t snap_id,
+  void read(io::AioCompletion* aio_comp, uint64_t snap_id,
             io::Extents&& image_extents, io::ReadResult&& read_result,
             int op_flags, int read_flags,
             const ZTracer::Trace &parent_trace) override;
index 4d1f7158a03aa673a9aa798a757e01ccc02a5051..5feeb50e5e36bf243271dda300a92907fbaec91f 100644 (file)
@@ -163,7 +163,7 @@ void RawFormat<I>::get_image_size(uint64_t snap_id, uint64_t* size,
 }
 
 template <typename I>
-bool RawFormat<I>::read(
+void RawFormat<I>::read(
     io::AioCompletion* aio_comp, uint64_t snap_id, io::Extents&& image_extents,
     io::ReadResult&& read_result, int op_flags, int read_flags,
     const ZTracer::Trace &parent_trace) {
@@ -174,13 +174,12 @@ bool RawFormat<I>::read(
   auto snapshot_it = m_snapshots.find(snap_id);
   if (snapshot_it == m_snapshots.end()) {
     aio_comp->fail(-ENOENT);
-    return true;
+    return;
   }
 
   snapshot_it->second->read(aio_comp, std::move(image_extents),
                             std::move(read_result), op_flags, read_flags,
                             parent_trace);
-  return true;
 }
 
 template <typename I>
index a20c0814f746991ca601ee3d2a28577dadd5fea3..6c3fed6185791bf1e8a2dda33b3cec2dfcec3ee9 100644 (file)
@@ -44,7 +44,7 @@ public:
   void get_image_size(uint64_t snap_id, uint64_t* size,
                       Context* on_finish) override;
 
-  bool read(io::AioCompletion* aio_comp, uint64_t snap_id,
+  void read(io::AioCompletion* aio_comp, uint64_t snap_id,
             io::Extents&& image_extents, io::ReadResult&& read_result,
             int op_flags, int read_flags,
             const ZTracer::Trace &parent_trace) override;
index 6e7225d22430cbdafc08c9f23565812e202fad58..7d2b9c41050fbac0677840febfc49ab381bd9eb9 100644 (file)
@@ -835,8 +835,8 @@ TEST_F(TestMockMigrationQCOWFormat, Read) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl;
   io::ReadResult read_result{&bl};
-  ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
-                                    std::move(read_result), 0, 0, {}));
+  mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
+                        std::move(read_result), 0, 0, {});
   ASSERT_EQ(123, ctx2.wait());
   ASSERT_EQ(expect_bl, bl);
 
@@ -870,8 +870,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadL1DNE) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl;
   io::ReadResult read_result{&bl};
-  ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{234, 123}},
-                                    std::move(read_result), 0, 0, {}));
+  mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{234, 123}},
+                        std::move(read_result), 0, 0, {});
   ASSERT_EQ(123, ctx2.wait());
   bufferlist expect_bl;
   expect_bl.append_zero(123);
@@ -910,8 +910,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadL2DNE) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl;
   io::ReadResult read_result{&bl};
-  ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{234, 123}},
-                                    std::move(read_result), 0, 0, {}));
+  mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{234, 123}},
+                        std::move(read_result), 0, 0, {});
   ASSERT_EQ(123, ctx2.wait());
   bufferlist expect_bl;
   expect_bl.append_zero(123);
@@ -950,8 +950,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadZero) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl;
   io::ReadResult read_result{&bl};
-  ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
-                                    std::move(read_result), 0, 0, {}));
+  mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
+                        std::move(read_result), 0, 0, {});
   ASSERT_EQ(123, ctx2.wait());
   bufferlist expect_bl;
   expect_bl.append_zero(123);
@@ -1004,8 +1004,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadSnap) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl;
   io::ReadResult read_result{&bl};
-  ASSERT_TRUE(mock_qcow_format.read(aio_comp, 1, {{65659, 123}},
-                                    std::move(read_result), 0, 0, {}));
+  mock_qcow_format.read(aio_comp, 1, {{65659, 123}},
+                        std::move(read_result), 0, 0, {});
   ASSERT_EQ(123, ctx2.wait());
   ASSERT_EQ(expect_bl, bl);
 
@@ -1039,8 +1039,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadSnapDNE) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl;
   io::ReadResult read_result{&bl};
-  ASSERT_TRUE(mock_qcow_format.read(aio_comp, 1, {{65659, 123}},
-                                    std::move(read_result), 0, 0, {}));
+  mock_qcow_format.read(aio_comp, 1, {{65659, 123}},
+                        std::move(read_result), 0, 0, {});
   ASSERT_EQ(-ENOENT, ctx2.wait());
 
   C_SaferCond ctx3;
@@ -1090,8 +1090,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadClusterCacheHit) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl1;
   io::ReadResult read_result1{&bl1};
-  ASSERT_TRUE(mock_qcow_format.read(aio_comp1, CEPH_NOSNAP, {{65659, 123}},
-                                    std::move(read_result1), 0, 0, {}));
+  mock_qcow_format.read(aio_comp1, CEPH_NOSNAP, {{65659, 123}},
+                        std::move(read_result1), 0, 0, {});
   ASSERT_EQ(123, ctx2.wait());
   ASSERT_EQ(expect_bl1, bl1);
 
@@ -1100,8 +1100,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadClusterCacheHit) {
     &ctx3, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl2;
   io::ReadResult read_result2{&bl2};
-  ASSERT_TRUE(mock_qcow_format.read(aio_comp2, CEPH_NOSNAP, {{66016, 234}},
-                                    std::move(read_result2), 0, 0, {}));
+  mock_qcow_format.read(aio_comp2, CEPH_NOSNAP, {{66016, 234}},
+                        std::move(read_result2), 0, 0, {});
   ASSERT_EQ(234, ctx3.wait());
   ASSERT_EQ(expect_bl2, bl2);
 
@@ -1142,8 +1142,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadClusterError) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl;
   io::ReadResult read_result{&bl};
-  ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
-                                    std::move(read_result), 0, 0, {}));
+  mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
+                        std::move(read_result), 0, 0, {});
   ASSERT_EQ(-EIO, ctx2.wait());
 
   C_SaferCond ctx3;
@@ -1179,8 +1179,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadL2TableError) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl;
   io::ReadResult read_result{&bl};
-  ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
-                                    std::move(read_result), 0, 0, {}));
+  mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
+                        std::move(read_result), 0, 0, {});
   ASSERT_EQ(-EIO, ctx2.wait());
 
   C_SaferCond ctx3;
index 16627628b5564dc827b77b603c79f6e63ea413a8..761e205bd1ee397a283858546d09b13ed4fb55a8 100644 (file)
@@ -336,8 +336,8 @@ TEST_F(TestMockMigrationRawFormat, Read) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl;
   io::ReadResult read_result{&bl};
-  ASSERT_TRUE(mock_raw_format.read(aio_comp, CEPH_NOSNAP, {{123, 123}},
-                                   std::move(read_result), 0, 0, {}));
+  mock_raw_format.read(aio_comp, CEPH_NOSNAP, {{123, 123}},
+                       std::move(read_result), 0, 0, {});
   ASSERT_EQ(123, ctx2.wait());
   ASSERT_EQ(expect_bl, bl);