Skip to content

Commit b6c7f69

Browse files
committed
librbd/migration: make FormatInterface::read() void again
Now that NativeFormat is handled via dispatch, FormatInterface::read() can be void again for consistency with FormatInterface::list_snaps(). Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 63159d6 commit b6c7f69

File tree

8 files changed

+33
-35
lines changed

8 files changed

+33
-35
lines changed

src/librbd/migration/FormatInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct FormatInterface {
3535
virtual void get_image_size(uint64_t snap_id, uint64_t* size,
3636
Context* on_finish) = 0;
3737

38-
virtual bool read(io::AioCompletion* aio_comp, uint64_t snap_id,
38+
virtual void read(io::AioCompletion* aio_comp, uint64_t snap_id,
3939
io::Extents&& image_extents, io::ReadResult&& read_result,
4040
int op_flags, int read_flags,
4141
const ZTracer::Trace &parent_trace) = 0;

src/librbd/migration/ImageDispatch.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ bool ImageDispatch<I>::read(
5050
}
5151

5252
*dispatch_result = io::DISPATCH_RESULT_COMPLETE;
53-
return m_format->read(aio_comp, io_context->get_read_snap(),
54-
std::move(image_extents), std::move(read_result),
55-
op_flags, read_flags, parent_trace);
53+
m_format->read(aio_comp, io_context->get_read_snap(),
54+
std::move(image_extents), std::move(read_result),
55+
op_flags, read_flags, parent_trace);
56+
return true;
5657
}
5758

5859
template <typename I>

src/librbd/migration/QCOWFormat.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ void QCOWFormat<I>::get_image_size(uint64_t snap_id, uint64_t* size,
14381438
}
14391439

14401440
template <typename I>
1441-
bool QCOWFormat<I>::read(
1441+
void QCOWFormat<I>::read(
14421442
io::AioCompletion* aio_comp, uint64_t snap_id, io::Extents&& image_extents,
14431443
io::ReadResult&& read_result, int op_flags, int read_flags,
14441444
const ZTracer::Trace &parent_trace) {
@@ -1453,7 +1453,7 @@ bool QCOWFormat<I>::read(
14531453
auto snapshot_it = m_snapshots.find(snap_id);
14541454
if (snapshot_it == m_snapshots.end()) {
14551455
aio_comp->fail(-ENOENT);
1456-
return true;
1456+
return;
14571457
}
14581458

14591459
auto& snapshot = snapshot_it->second;
@@ -1466,8 +1466,6 @@ bool QCOWFormat<I>::read(
14661466
auto read_request = new ReadRequest(this, aio_comp, l1_table,
14671467
std::move(image_extents));
14681468
read_request->send();
1469-
1470-
return true;
14711469
}
14721470

14731471
template <typename I>

src/librbd/migration/QCOWFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class QCOWFormat : public FormatInterface {
6767
void get_image_size(uint64_t snap_id, uint64_t* size,
6868
Context* on_finish) override;
6969

70-
bool read(io::AioCompletion* aio_comp, uint64_t snap_id,
70+
void read(io::AioCompletion* aio_comp, uint64_t snap_id,
7171
io::Extents&& image_extents, io::ReadResult&& read_result,
7272
int op_flags, int read_flags,
7373
const ZTracer::Trace &parent_trace) override;

src/librbd/migration/RawFormat.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void RawFormat<I>::get_image_size(uint64_t snap_id, uint64_t* size,
163163
}
164164

165165
template <typename I>
166-
bool RawFormat<I>::read(
166+
void RawFormat<I>::read(
167167
io::AioCompletion* aio_comp, uint64_t snap_id, io::Extents&& image_extents,
168168
io::ReadResult&& read_result, int op_flags, int read_flags,
169169
const ZTracer::Trace &parent_trace) {
@@ -174,13 +174,12 @@ bool RawFormat<I>::read(
174174
auto snapshot_it = m_snapshots.find(snap_id);
175175
if (snapshot_it == m_snapshots.end()) {
176176
aio_comp->fail(-ENOENT);
177-
return true;
177+
return;
178178
}
179179

180180
snapshot_it->second->read(aio_comp, std::move(image_extents),
181181
std::move(read_result), op_flags, read_flags,
182182
parent_trace);
183-
return true;
184183
}
185184

186185
template <typename I>

src/librbd/migration/RawFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class RawFormat : public FormatInterface {
4444
void get_image_size(uint64_t snap_id, uint64_t* size,
4545
Context* on_finish) override;
4646

47-
bool read(io::AioCompletion* aio_comp, uint64_t snap_id,
47+
void read(io::AioCompletion* aio_comp, uint64_t snap_id,
4848
io::Extents&& image_extents, io::ReadResult&& read_result,
4949
int op_flags, int read_flags,
5050
const ZTracer::Trace &parent_trace) override;

src/test/librbd/migration/test_mock_QCOWFormat.cc

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,8 @@ TEST_F(TestMockMigrationQCOWFormat, Read) {
835835
&ctx2, m_image_ctx, io::AIO_TYPE_READ);
836836
bufferlist bl;
837837
io::ReadResult read_result{&bl};
838-
ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
839-
std::move(read_result), 0, 0, {}));
838+
mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
839+
std::move(read_result), 0, 0, {});
840840
ASSERT_EQ(123, ctx2.wait());
841841
ASSERT_EQ(expect_bl, bl);
842842

@@ -870,8 +870,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadL1DNE) {
870870
&ctx2, m_image_ctx, io::AIO_TYPE_READ);
871871
bufferlist bl;
872872
io::ReadResult read_result{&bl};
873-
ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{234, 123}},
874-
std::move(read_result), 0, 0, {}));
873+
mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{234, 123}},
874+
std::move(read_result), 0, 0, {});
875875
ASSERT_EQ(123, ctx2.wait());
876876
bufferlist expect_bl;
877877
expect_bl.append_zero(123);
@@ -910,8 +910,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadL2DNE) {
910910
&ctx2, m_image_ctx, io::AIO_TYPE_READ);
911911
bufferlist bl;
912912
io::ReadResult read_result{&bl};
913-
ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{234, 123}},
914-
std::move(read_result), 0, 0, {}));
913+
mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{234, 123}},
914+
std::move(read_result), 0, 0, {});
915915
ASSERT_EQ(123, ctx2.wait());
916916
bufferlist expect_bl;
917917
expect_bl.append_zero(123);
@@ -950,8 +950,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadZero) {
950950
&ctx2, m_image_ctx, io::AIO_TYPE_READ);
951951
bufferlist bl;
952952
io::ReadResult read_result{&bl};
953-
ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
954-
std::move(read_result), 0, 0, {}));
953+
mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
954+
std::move(read_result), 0, 0, {});
955955
ASSERT_EQ(123, ctx2.wait());
956956
bufferlist expect_bl;
957957
expect_bl.append_zero(123);
@@ -1004,8 +1004,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadSnap) {
10041004
&ctx2, m_image_ctx, io::AIO_TYPE_READ);
10051005
bufferlist bl;
10061006
io::ReadResult read_result{&bl};
1007-
ASSERT_TRUE(mock_qcow_format.read(aio_comp, 1, {{65659, 123}},
1008-
std::move(read_result), 0, 0, {}));
1007+
mock_qcow_format.read(aio_comp, 1, {{65659, 123}},
1008+
std::move(read_result), 0, 0, {});
10091009
ASSERT_EQ(123, ctx2.wait());
10101010
ASSERT_EQ(expect_bl, bl);
10111011

@@ -1039,8 +1039,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadSnapDNE) {
10391039
&ctx2, m_image_ctx, io::AIO_TYPE_READ);
10401040
bufferlist bl;
10411041
io::ReadResult read_result{&bl};
1042-
ASSERT_TRUE(mock_qcow_format.read(aio_comp, 1, {{65659, 123}},
1043-
std::move(read_result), 0, 0, {}));
1042+
mock_qcow_format.read(aio_comp, 1, {{65659, 123}},
1043+
std::move(read_result), 0, 0, {});
10441044
ASSERT_EQ(-ENOENT, ctx2.wait());
10451045

10461046
C_SaferCond ctx3;
@@ -1090,8 +1090,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadClusterCacheHit) {
10901090
&ctx2, m_image_ctx, io::AIO_TYPE_READ);
10911091
bufferlist bl1;
10921092
io::ReadResult read_result1{&bl1};
1093-
ASSERT_TRUE(mock_qcow_format.read(aio_comp1, CEPH_NOSNAP, {{65659, 123}},
1094-
std::move(read_result1), 0, 0, {}));
1093+
mock_qcow_format.read(aio_comp1, CEPH_NOSNAP, {{65659, 123}},
1094+
std::move(read_result1), 0, 0, {});
10951095
ASSERT_EQ(123, ctx2.wait());
10961096
ASSERT_EQ(expect_bl1, bl1);
10971097

@@ -1100,8 +1100,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadClusterCacheHit) {
11001100
&ctx3, m_image_ctx, io::AIO_TYPE_READ);
11011101
bufferlist bl2;
11021102
io::ReadResult read_result2{&bl2};
1103-
ASSERT_TRUE(mock_qcow_format.read(aio_comp2, CEPH_NOSNAP, {{66016, 234}},
1104-
std::move(read_result2), 0, 0, {}));
1103+
mock_qcow_format.read(aio_comp2, CEPH_NOSNAP, {{66016, 234}},
1104+
std::move(read_result2), 0, 0, {});
11051105
ASSERT_EQ(234, ctx3.wait());
11061106
ASSERT_EQ(expect_bl2, bl2);
11071107

@@ -1142,8 +1142,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadClusterError) {
11421142
&ctx2, m_image_ctx, io::AIO_TYPE_READ);
11431143
bufferlist bl;
11441144
io::ReadResult read_result{&bl};
1145-
ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
1146-
std::move(read_result), 0, 0, {}));
1145+
mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
1146+
std::move(read_result), 0, 0, {});
11471147
ASSERT_EQ(-EIO, ctx2.wait());
11481148

11491149
C_SaferCond ctx3;
@@ -1179,8 +1179,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadL2TableError) {
11791179
&ctx2, m_image_ctx, io::AIO_TYPE_READ);
11801180
bufferlist bl;
11811181
io::ReadResult read_result{&bl};
1182-
ASSERT_TRUE(mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
1183-
std::move(read_result), 0, 0, {}));
1182+
mock_qcow_format.read(aio_comp, CEPH_NOSNAP, {{65659, 123}},
1183+
std::move(read_result), 0, 0, {});
11841184
ASSERT_EQ(-EIO, ctx2.wait());
11851185

11861186
C_SaferCond ctx3;

src/test/librbd/migration/test_mock_RawFormat.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ TEST_F(TestMockMigrationRawFormat, Read) {
336336
&ctx2, m_image_ctx, io::AIO_TYPE_READ);
337337
bufferlist bl;
338338
io::ReadResult read_result{&bl};
339-
ASSERT_TRUE(mock_raw_format.read(aio_comp, CEPH_NOSNAP, {{123, 123}},
340-
std::move(read_result), 0, 0, {}));
339+
mock_raw_format.read(aio_comp, CEPH_NOSNAP, {{123, 123}},
340+
std::move(read_result), 0, 0, {});
341341
ASSERT_EQ(123, ctx2.wait());
342342
ASSERT_EQ(expect_bl, bl);
343343

0 commit comments

Comments
 (0)