]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/migration: make FormatInterface::read() void again 58882/head
authorIlya Dryomov <idryomov@gmail.com>
Fri, 26 Jul 2024 14:54:31 +0000 (16:54 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 30 Jul 2024 21:05:51 +0000 (23:05 +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>
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 f5b90066c68882345697cc29d1ee18c2391baf8a..20cc3cb07e7eb79a74505a2514fc53feba625d2f 100644 (file)
@@ -50,9 +50,10 @@ bool ImageDispatch<I>::read(
   }
 
   *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
-  return m_format->read(aio_comp, io_context->get_read_snap(),
-                        std::move(image_extents), std::move(read_result),
-                        op_flags, read_flags, parent_trace);
+  m_format->read(aio_comp, io_context->get_read_snap(),
+                 std::move(image_extents), std::move(read_result),
+                 op_flags, read_flags, parent_trace);
+  return true;
 }
 
 template <typename I>
index 8ed00b155a3e600dd477db99fef48c17afff5ea9..ba5d7e4ee765d4d7d29d79237df8bfc10233010b 100644 (file)
@@ -1438,7 +1438,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) {
@@ -1453,7 +1453,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;
@@ -1466,8 +1466,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 3b355628cd2cb8327ea43ca1964ac3aeadf2c0e7..90164de208e0c7ba8c225fb480b46019f90b7542 100644 (file)
@@ -67,7 +67,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);